summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegina König2021-07-01 10:09:27 +0200
committerRegina König2021-07-01 10:09:27 +0200
commit16ed1c92f3f6353461df4293dc7d6d7a48ea7b96 (patch)
treeb8eb49794caed8eb96fc313e7bb315edcd1f289c
parentCreate new subproject for allocation testing (diff)
downloadmemtest86-16ed1c92f3f6353461df4293dc7d6d7a48ea7b96.tar.gz
memtest86-16ed1c92f3f6353461df4293dc7d6d7a48ea7b96.tar.xz
memtest86-16ed1c92f3f6353461df4293dc7d6d7a48ea7b96.zip
Delete all unnecessary files
-rw-r--r--allocate_pages_test/README13
-rwxr-xr-xallocate_pages_test/build.sh191
-rw-r--r--allocate_pages_test/memtest86+/FAQ310
-rw-r--r--allocate_pages_test/memtest86+/bios/cpuid.h205
-rw-r--r--allocate_pages_test/memtest86+/bios/display.c76
-rw-r--r--allocate_pages_test/memtest86+/bios/dmi.c485
-rw-r--r--allocate_pages_test/memtest86+/bios/init.c1296
-rw-r--r--allocate_pages_test/memtest86+/bios/lib.c1223
-rw-r--r--allocate_pages_test/memtest86+/bios/linuxbios.c165
-rw-r--r--allocate_pages_test/memtest86+/bios/linuxbios_tables.h89
-rw-r--r--allocate_pages_test/memtest86+/bios/logger.c6
-rw-r--r--allocate_pages_test/memtest86+/bios/main_asm.h49
-rw-r--r--allocate_pages_test/memtest86+/bios/memory_tables.c277
-rw-r--r--allocate_pages_test/memtest86+/bios/rsdp.h13
-rw-r--r--allocate_pages_test/memtest86+/bios/stdin.h53
-rw-r--r--allocate_pages_test/memtest86+/bios/stdint.h60
-rw-r--r--allocate_pages_test/memtest86+/bios/test.c1549
-rw-r--r--allocate_pages_test/memtest86+/bios/test_cache.h20
-rw-r--r--allocate_pages_test/memtest86+/bios/vmem.c159
-rw-r--r--allocate_pages_test/memtest86+/bootsect.S383
-rw-r--r--allocate_pages_test/memtest86+/build.number1
-rw-r--r--allocate_pages_test/memtest86+/build_number.h9
-rw-r--r--allocate_pages_test/memtest86+/buildnumber.mak10
-rw-r--r--allocate_pages_test/memtest86+/changelog25
-rw-r--r--allocate_pages_test/memtest86+/head.S847
-rw-r--r--allocate_pages_test/memtest86+/mt86+_loaderbin784 -> 0 bytes
-rw-r--r--allocate_pages_test/memtest86+/mt86+_loader.asm231
-rwxr-xr-xallocate_pages_test/memtest86+/precomp.binbin153868 -> 0 bytes
-rw-r--r--allocate_pages_test/memtest86+/setup.S154
-rw-r--r--allocate_pages_test/memtest86+/version.number1
30 files changed, 0 insertions, 7900 deletions
diff --git a/allocate_pages_test/README b/allocate_pages_test/README
deleted file mode 100644
index d501aac..0000000
--- a/allocate_pages_test/README
+++ /dev/null
@@ -1,13 +0,0 @@
-README
-
-
-DEPENDENCIES
-
-
-
-HOW TO INSTALL
--- sudo make
-
-
-HOW TO RUN
--- sudo make run \ No newline at end of file
diff --git a/allocate_pages_test/build.sh b/allocate_pages_test/build.sh
deleted file mode 100755
index 4feccf2..0000000
--- a/allocate_pages_test/build.sh
+++ /dev/null
@@ -1,191 +0,0 @@
-#!/bin/bash
-
-MAIN_FILE="MemtestEfi"
-
-OBJECT_FILES=(AutoGen.obj OUTPUT/main.o OUTPUT/test.o OUTPUT/smp.o
- OUTPUT/config.o OUTPUT/screen_buffer.o OUTPUT/lib.o OUTPUT/init.o OUTPUT/controller.o
- OUTPUT/pci.o OUTPUT/spd.o OUTPUT/dmi.o OUTPUT/reloc.o OUTPUT/patn.o OUTPUT/linuxbios.o
- OUTPUT/error.o OUTPUT/vmem.o OUTPUT/cpuid.o OUTPUT/memsize.o OUTPUT/random.o OUTPUT/$MAIN_FILE.obj)
-
-STATIC_LIBRARY_FILES=(OUTPUT/$MAIN_FILE.lib libs/BaseLib.lib
- libs/BaseMemoryLib.lib libs/BasePcdLibNull.lib
- libs/BaseDebugPrintErrorLevelLib.lib libs/BasePrintLib.lib
- libs/UefiDebugLibStdErr.lib libs/UefiBootServicesTableLib.lib
- libs/UefiMemoryAllocationLib.lib libs/UefiRuntimeServicesTableLib.lib
- libs/UefiDevicePathLib.lib libs/UefiApplicationEntryPoint.lib libs/UefiLib.lib)
-
-INCLUDE_FILES=(main cpuid test smp config screen_buffer lib init controller pci
- spd dmi reloc patn linuxbios error vmem memsize random)
-
-ADDITIONAL_HEADER=(defs.h linuxbios_tables.h stdin.h io.h stdint.h stddef.h serial.h msr.h jedec_id.h elf.h)
-
-rm -f OUTPUT/*
-
-echo "######################## Create *.o files"
-for elem in ${ADDITIONAL_HEADER[@]}
- do
- cp memtest86+/${elem} OUTPUT/
- done
-
-for elem in ${INCLUDE_FILES[@]}
- do
- cp memtest86+/${elem}.* OUTPUT/
- done
-
-for elem in ${INCLUDE_FILES[@]}
- do
- gcc -c \
- -IInclude \
- -g \
- -fno-stack-protector \
- -fno-common \
- -fshort-wchar \
- -fno-builtin \
- -fno-strict-aliasing \
- -Wall \
- -Wno-array-bounds \
- -ffunction-sections \
- -fdata-sections \
- -include Include/AutoGen.h \
- -m64 \
- -maccumulate-outgoing-args \
- -mno-red-zone \
- -Wno-address \
- -mcmodel=small \
- -fpie \
- -fno-asynchronous-unwind-tables \
- -Wno-address \
- -flto \
- -DUSING_LTO \
- -Os \
- -D DISABLE_NEW_DEPRECATED_INTERFACES \
- "-DEFIAPI=__attribute__((ms_abi))" \
- -o OUTPUT/${elem}.o \
- OUTPUT/${elem}.c
-
- if [ $? -ne 0 ]; then exit 1; fi
- done
-
-
-# -Werror \
-
-if [ $? -ne 0 ]; then exit 1; fi
-echo "####################### Create obj file\n"
-#-S
-#-fverbose-asm
-# -m32 \
-
-#gcc -E -traditional memtest86+/head.S -o memtest86+/head.s
-#as --64 -o memtest86+/head.o memtest86+/head.s
-
-
-#gcc -E -traditional memtest86+/bootsect.S -o memtest86+/bootsect.s
-#as -o memtest86+/bootsect.o memtest86+/bootsect.s
-
-
-#gcc -E -traditional memtest86+/setup.S -o memtest86+/setup.s
-#as -o memtest86+/setup.o memtest86+/setup.s
-
-
-gcc -MMD -MF OUTPUT/$MAIN_FILE.obj.deps \
- -g \
- -fshort-wchar \
- -fno-builtin \
- -fno-strict-aliasing \
- -Wall \
- -Wno-array-bounds \
- -ffunction-sections \
- -fdata-sections \
- -include Include/AutoGen.h \
- -fno-common \
- -DSTRING_ARRAY_NAME=${MAIN_FILE}Strings \
- -m64 \
- -fno-stack-protector \
- "-DEFIAPI=__attribute__((ms_abi))" \
- -maccumulate-outgoing-args \
- -mno-red-zone \
- -Wno-address \
- -mcmodel=small \
- -fpie \
- -fno-asynchronous-unwind-tables \
- -Wno-address \
- -flto \
- -DUSING_LTO \
- -Os \
- -D DISABLE_NEW_DEPRECATED_INTERFACES \
- -c \
- -o OUTPUT/$MAIN_FILE.obj \
- -I . \
- -IInclude \
- -IOUTPUT \
- $MAIN_FILE.c
-
-
-if [ $? -ne 0 ]; then exit 1; fi
-echo "####################### Create $MAIN_FILE.lib"
-
-echo ${OBJECT_FILES[@]}
-
-
-gcc-ar crv OUTPUT/$MAIN_FILE.lib "${OBJECT_FILES[@]}"
-
-if [ $? -ne 0 ]; then exit 1; fi
-echo "####################### Create $MAIN_FILE.dll"
-
-echo ${STATIC_LIBRARY_FILES[@]}
-
-
-gcc -o OUTPUT/$MAIN_FILE.dll \
- -nostdlib \
- -Wl,-n,-q,--gc-sections \
- -Wl,--entry,_ModuleEntryPoint \
- -Wl,-Map,OUTPUT/$MAIN_FILE.map,--whole-archive \
- -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie \
- -Wl,--start-group,@static_library_files.lst,--end-group \
- -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 \
- -Wl,--script=Include/GccBase.lds \
- -z common-page-size=0x40 \
- -u _ModuleEntryPoint \
- -flto \
- -Os \
- -g \
- -fshort-wchar \
- -fno-builtin \
- -fno-strict-aliasing \
- -Wall \
- -Werror \
- -Wno-array-bounds \
- -ffunction-sections \
- -fdata-sections \
- -fno-common \
- -DSTRING_ARRAY_NAME=${MAIN_FILE}Strings \
- -m64 \
- -fno-stack-protector \
- "-DEFIAPI=__attribute__((ms_abi))" \
- -maccumulate-outgoing-args \
- -mno-red-zone \
- -Wno-address \
- -mcmodel=small \
- -fpie \
- -fno-asynchronous-unwind-tables \
- -Wno-address \
- -flto \
- -DUSING_LTO \
- -Os \
- -D DISABLE_NEW_DEPRECATED_INTERFACES \
- -include AutoGen.h \
- -I OUTPUT/ \
- -I Library/ \
- -Wno-error
-
-if [ $? -ne 0 ]; then exit 1; fi
-echo "####################### Objcopy strip unneeded"
-objcopy --strip-unneeded -R .eh_frame -v OUTPUT/$MAIN_FILE.dll OUTPUT/$MAIN_FILE.dll
-
-
-if [ $? -ne 0 ]; then exit 1; fi
-echo "####################### Run GenFW"
-
-./Include/GenFw -e UEFI_APPLICATION -o OUTPUT/start_$MAIN_FILE.efi OUTPUT/$MAIN_FILE.dll
-
-cp -v OUTPUT/start_$MAIN_FILE.efi ../test_code/hda-contents/
diff --git a/allocate_pages_test/memtest86+/FAQ b/allocate_pages_test/memtest86+/FAQ
deleted file mode 100644
index 3c2a01c..0000000
--- a/allocate_pages_test/memtest86+/FAQ
+++ /dev/null
@@ -1,310 +0,0 @@
-- What is memtest86+, what do I use it for?
-
- Memtest86+ is a utility designed to test whether your memory is in working
- order. It repeatedly writes an enormous amount of different patterns to all
- memory locations and reads them back again and verifies whether the result
- of the read is the same as what was written to memory.
-
- There can be a multitude of reasons for running memtest, but foremost of all
- is of course to test whether your memory modules might be bad. Whenever you
- suspect your modules to be bad because of system crashes, lockups or reboots
- it would be nice to know whether the modules are in working order.
- Memtest86+ is a utility which tries to answer that question for you.
-
- Another common use exists in the overclocking scene. When overclocking a
- system you are essentially pushing your system to the limits and at some
- point it will simply give way and break. Unfortunately there isn't a clear
- cut way of deciding whether a system is still working correctly. Because of
- the complexity of a computer a system which is pushed to the limits doesn't
- just break completely when it starts to fail, instead little errors start
- showing up in many different places in the system growing more frequent and
- widespread the more the system is pushed. Each one of these little errors
- can lead to a crash of your system but can also go unnoticed for days or
- weeks in a running system. The art so to speak of overclocking is thus to
- push the system as far as it can go without introducing any such errors. As
- memory is usually one of the first places these such errors start coming up
- a memory test is very useful.
-
-- How do I get it to run?
-
- There are several ways to use memtest, which are described below:
-
- + Run from floppydisk
-
- Memtest86+ is directly executable by any modern x86 compatible machine, by
- writing the bootable binary to a floppy disk one can boot from the disk to
- run memtest.
-
- Simply download the appropriate package, the Pre-Compiled Bootable Binary
- (.gz) package for Linux users and the Pre-Compiled package for Floppy (DOS
- - Win) for Windows users.
-
- For Windows, unzip the package into a directory like C:\memtest, insert a
- blank floppy into your a: disk drive and run the install.bat file. As the
- install prompts you, to use memtest directly, leave the disk in the drive
- and reboot your machine.
-
- For Linux, unpack the package into your home directory, insert a blank
- floppy into your floppy drive and execute 'dd if=~/memtest+-1.xx.bin.gz
- of=/dev/fd0 conv=osync' replacing 1.xx with the correct version number of
- the memtest86+ you downloaded. To run memtest immediately reboot your
- machine.
-
- Your machine should now boot from the disk, display the word Loading
- folowed by a series of periods and then show a screen much like the
- screenshots on the memtest86+ web page. The test is automatically started.
-
- If your machine simply boots back into Windows/Linux you will most likely
- have to configure your BIOS to attempt to boot from floppy disk on
- startup, refer to your computer's/mainboard's manual how to do this.
-
- When you are done testing simply remove the floppy and reset your
- computer, if ever you want to execure the test again simply reinsert the
- disk and reboot/start your computer.
-
- + Run from CD
-
- Memtest86+ is directly executable by any modern x86 compatible machine, by
- writing the iso to a CD one can boot from the CD to run memtest.
-
- Simply download the appropriate package, the Download - Pre-Compiled
- Bootable ISO (.gz) for Linux users and the Pre-Compiled Bootable ISO
- (.zip) for Windows users.
-
- For Windows, unzip the package into a directory like C:\memtest. You will
- now see a file called memtest86+-1.xx.iso in this directory. You will need
- to burn this file to a CD with a CD recording program. Do note however
- that you should not make a regular data CD on which you for instance write
- your text documents and holiday photographs. Instead the iso file is a so
- called image of a CD, it is a direct copy of a CD. Your CD recording
- program will most likely have a feature called burn image or something to
- that effect which you should use to burn the CD.
-
- For linux, unzip the package into your home directory. and execute
- 'cdrecord dev=<your burner> ~/memtest86+-1.xx.iso' where you replace <your
- burner> with the scsi address of your CD burner and replace 1.xx with the
- correct version number of the memtest86+ your downloaded.
-
- When the burning completed your drive will most likely have ejected the CD
- and you should have a bootable memtest86+ CD. To run the test directly
- reinsert the CD and reboot your machine.
-
- Your machine should now boot from the CD, display the word Loading folowed
- by a series of periods and then show a screen much like the screenshots on
- the memtest86+ web page. The test is automatically started.
-
- If your machine simply boots back into Windows/Linux you will most likely
- have to configure your BIOS to attempt to boot from CD-ROM drive on
- startup, refer to your computer's/mainboard's manual how to do this.
-
- When you are done testing simply remove the CD and reset your computer, if
- ever you want to execure the test again simply reinsert the CD and
- reboot/start your computer.
-
- + Run from USB Flash drive
-
- FIXME
-
- + Run from boot manager
-
- FIXME
-
-- How long does memtest86+ run? How do I stop it?
-
- Memtest86+ runs indefinately unless you stop it. It does however repeat the
- same tests over and over again. Memtest86+ contains a number of different
- tests which each take different approaches in trying to expose any errors in
- your memory. In the top right of your screen you can see the progress of
- each test in the lower of the two progress bars. The topmost progress bar
- shows the progress of a pass, each pass consists of all the tests in the
- memtest suite.
-
- Thus all tests are executed in one pass, so does that mean that no errors
- will show after the first pass if that pass didn't reveal any errors? Well
- no, there are several reasons why errors might only show up after a number
- of passes. Firstly as of this writing, the latest version of memtest also
- includes a test which uses random test patterns, each pass these patterns
- will of course be different. Secondly some types of errors simply don't show
- up until the system has been running for a while or are very critical on a
- certain timing condition, or other such conditions.
-
- To conclude, one successful pass of memtest will give you a pretty good idea
- that your memory is ok, only in rare cases will there be errors showing
- after the first pass. To be sure though simply have the test run overnight
- or even for a couple of days depending on the level of importance of the
- system.
-
-- How many errors are acceptable?
-
- No errors are acceptable. Even if there is just one error, something is
- amiss which can cause your system to crash. Of course what the cause of the
- errors is you will still have to determine.
-
-- What do I do when I get errors?
-
- Firstly, don't start drawing any conclusions. You only know that memtest86+
- is giving your errors, not what the cause is. Unfortunately it is not a
- straightforward exercise to decisively test the memory in an actual system.
- This is because a computer is not just built up of some memory, but also
- includes many other elements such as a memory controller, cache, a cache
- controller, algorithmic and logic units, etc, all of which contribute to the
- machine. If there are faults in any of these other parts of the computer you
- will likely also see errors showing up in memtest.
-
- So what to do? First verify that the BIOS settings of your machine are
- correctly configured. Look up the memory timing settings applicable to the
- brand and type of memory modules you have and check they match your BIOS
- settings, correct them if they don't and run memtest again
-
- Ok, you have all the settings correctly set and you're still getting errors.
- Well of course a very likely cause are the memory modules and the logical
- course of action is to look into them further.
-
- If you are well stocked, have a few other machines at your disposal, or just
- want to spend the cash for some new modules the best way to test if the
- cause are your memory modules is just to replace them and test again. If you
- are less fortunate though there is still something you can do.
-
- If you have more then one module in your system, test them one by one, if
- one is consistently giving errors and another is consistently showing no
- errors it's a pretty good bet that the module giving the errors is simply
- defective. To exclude the possibility that a defective slot is throwing your
- results, use the same slot to test each different module.
-
- If each module by itself shows no errors, but when you place two or more
- modules into the machine at the same time you do get errors, you are most
- likely stuck with a compatibility issue and unfortunately there isn't a
- whole lot you can do about it. Be sure to check your computer/motherboard
- manual to see if the setup you are trying is allowed, some boards require
- special restrictions in the sizes of modules, the order of modules, the
- placement of double sided and single sides modules and more of such things.
-
- If you have only one module in your system, or all modules are giving
- errors, there are only very few options left. The only thing you can do
- really is to try the module(s) in another slot. Finally simply try out
- different orders of the memory modules, although your manual might not
- mention anything on the matter sometimes there simply exist timing or other
- issues which can be resolved by changing the order of your modules. And of
- course test each slot by putting a single module into that slot and running
- memtest on it.
-
- In the end if you still have not been able to localize the problem you will
- have to find a replacement module to establish whether the problem lies in
- your modules. See if you can borrow a module from someone else.
-
- When you have replaced the memory by new memory and the errors still
- persist, first check if you can rule out any compatibility issues or timing
- issues. If you are sure the memory should work in the system the cause of
- the errors must obviously lie someplace else in the system.
-
- The only way to find out where, is by trial and error really. Simply start
- replacing and/or removing parts of your computer one by one, running memtest
- each time you changed anything, until the errors are resolved.
-
-- I'm getting errors in test #x, what doest that mean?
-
- Interpreting memtest results is as scientific an endeavour as testing
- whether a person is a witch by the methods used in Monty Python's Holy
- Grail. In short, don't even start, it's not going to get you anywhere. Just
- interpret any error as you should any other and use the methods descibed in
- the previous question to determine the cause.
-
-- I'm getting errors in test #5 and/or #8 and have read a lot about it.
-
- Yes there are just about enough discussions on the topic to fill a book, but
- it all boils down to the answer given above. The only thing that can be said
- is that many a times, when memory latencies are incorrectly set in the BIOS
- you will experience errors in test #5 and #8. (Though #8 does not exist
- anymore as of version 1.40 and might be reinstated as a different test in a
- later version.) This does however NOT mean that errors in these tests are
- always the cause of incorrect settings, your memory might just as well be
- defective.
-
-- I'm getting errors in memtest on one machine, but not when I put the same
- memory in another, what does that mean?
-
- It can mean one of two things:
- - The machine that is giving the errors is defective. Errors don't just
- orginate from the memory module itself, but can also be caused by
- defects in the cpu, chipset, motherboard, PSU and even by timing issues
- introduced by any other component in the machine.
- - The machine giving the errors is imposing stricter timing than the other
- which the memory module simply can't cope with. If the module should
- work with the machine according to its specifications then it most
- likely is defective.
-
-- Which memory is tested?
-
- As much as possible of the system memory is tested. Unfortunately memtest86+
- can usually not test all of the memory. The reason for this is that todays
- processors have become so complex that they require a small amount of memory
- to keep accounting data of the processor state. If memtest were to write
- over these areas the state of the processor becomes invalid and it's
- behaviour unpredictable. Alas it is also impossible to relocate these areas
- in the memory.
-
- This means that a small area of your memory can not be tested by memtest. If
- this part of the memory is defective you will know soon enough though as the
- processor, or parts of the processor simply won't work correctly if this
- part of your memory is defective. Do realise though that in very rare cases
- memtest will show no errors even though the module is defective, not because
- memtest can't detect the error, but because memtest can't test the area the
- error is located in.
-
-- When I select BIOS-ALL I get many errors / my machine crashes.
-
- This is normal. With todays computers this option should never be selected.
- See the previous question about the reason for the errors.
-
-- I want to use memtest on a multiboot CD, how do I do this?
-
- This is of course very dependent on which boot loader you use for your CD.
- Below is a description of how to set up a multiboot CD including memtest+
- with isolinux, if you have experience with any other bootloader(s) please
- consider writing a small description of using memtest with that bootloader
- for the FAQ.
-
- -isolinux
-
- For general instructions on how to make a bootable CD with isolinux see
- the syslinux website and the manual. What you need to do to get memtest
- working is as follows.
-
- Download the Pre-Compiled Bootable Binary, the .gz if you are working
- under linux, the .zip if you are working under windows. Unpack the file
- from the package and rename it to an 8.3 filename with an extension other
- than .bin, renaming to memtest. (without an extension) is a good choice.
-
- Put the file somewhere in your CD directory structure, for example in
- images/memtest and edit your config file to include the following:
-
- label memtest
- kernel /images/memtest
-
- If you want to boot memtest automatically insert or change a line at the
- top to:
-
- default memtest
-
- If you want to display a prompt from which you can start memtest add or
- change the lines at the top to: (Change the timeout to suit your needs)
-
- prompt 1
- timeout 200
-
-- If memtest86+ shows no errors does that mean my memory is not defective?
-
- Of course no answers are definitive, no matter how good memtest86+ will
- eventually become there is always the possibility that a particular type of
- error will go unnoticed. As long as you are having no problems with the
- system it will be pretty safe to say that the modules are good. If you are
- having problems with the system however you will just have to check by trial
- and error, ie swapping the modules for new ones and/or testing with modules
- of a different brand/type.
-
-- When I run install.bat it doesn't write anything to floppy.
-
- You most likely have unpacked the memtest+-2.xx.floppy.zip file into a
- folder with a long pathname and/or containing + and - signs. It seems
- rawrite doesn't like that. Just move the files you unpacked to a directory
- like c:\memtest and execure it from there.
diff --git a/allocate_pages_test/memtest86+/bios/cpuid.h b/allocate_pages_test/memtest86+/bios/cpuid.h
deleted file mode 100644
index 0feb56e..0000000
--- a/allocate_pages_test/memtest86+/bios/cpuid.h
+++ /dev/null
@@ -1,205 +0,0 @@
-
-
-#ifndef CPUID_H_
-#define CPUID_H_
-
-
-/*
- * cpuid.h --
- * contains the data structures required for CPUID
- * implementation.
- */
-
-#define CPUID_VENDOR_LENGTH 3 /* 3 GPRs hold vendor ID */
-#define CPUID_VENDOR_STR_LENGTH (CPUID_VENDOR_LENGTH * sizeof(uint32_t) + 1)
-#define CPUID_BRAND_LENGTH 12 /* 12 GPRs hold vendor ID */
-#define CPUID_BRAND_STR_LENGTH (CPUID_BRAND_LENGTH * sizeof(uint32_t) + 1)
-
-extern struct cpu_ident cpu_id;
-
-static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- /* ecx is often an input as well as an output. */
- asm volatile("\t"
- "push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx"
- : "=a" (*eax),
- "=D" (*ebx),
- "=c" (*ecx),
- "=d" (*edx)
- : "0" (*eax), "2" (*ecx));
-}
-
-static inline void cpuid(unsigned int op,
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- *eax = op;
- *ecx = 0;
- __cpuid(eax, ebx, ecx, edx);
-}
-
-/* Some CPUID calls want 'count' to be placed in ecx */
-static inline void cpuid_count(unsigned int op, int count,
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- *eax = op;
- *ecx = count;
- __cpuid(eax, ebx, ecx, edx);
-}
-
-/* Typedef for storing the Cache Information */
-typedef union {
- unsigned char ch[48];
- uint32_t uint[12];
- struct {
- uint32_t fill1:24; /* Bit 0 */
- uint32_t l1_i_sz:8;
- uint32_t fill2:24;
- uint32_t l1_d_sz:8;
- uint32_t fill3:16;
- uint32_t l2_sz:16;
- uint32_t fill4:18;
- uint32_t l3_sz:14;
- uint32_t fill5[8];
- } amd;
-} cpuid_cache_info_t;
-
-/* Typedef for storing the CPUID Vendor String */
-typedef union {
- /* Note: the extra byte in the char array is for '\0'. */
- char char_array[CPUID_VENDOR_STR_LENGTH];
- uint32_t uint32_array[CPUID_VENDOR_LENGTH];
-} cpuid_vendor_string_t;
-
-/* Typedef for storing the CPUID Brand String */
-typedef union {
- /* Note: the extra byte in the char array is for '\0'. */
- char char_array[CPUID_BRAND_STR_LENGTH];
- uint32_t uint32_array[CPUID_BRAND_LENGTH];
-} cpuid_brand_string_t;
-
-/* Typedef for storing CPUID Version */
-typedef union {
- uint32_t flat;
- struct {
- uint32_t stepping:4; /* Bit 0 */
- uint32_t model:4;
- uint32_t family:4;
- uint32_t processorType:2;
- uint32_t reserved1514:2;
- uint32_t extendedModel:4;
- uint32_t extendedFamily:8;
- uint32_t reserved3128:4; /* Bit 31 */
- } bits;
-} cpuid_version_t;
-
-/* Typedef for storing CPUID Processor Information */
-typedef union {
- uint32_t flat;
- struct {
- uint32_t brandIndex:8; /* Bit 0 */
- uint32_t cflushLineSize:8;
- uint32_t logicalProcessorCount:8;
- uint32_t apicID:8; /* Bit 31 */
- } bits;
-} cpuid_proc_info_t;
-
-/* Typedef for storing CPUID Feature flags */
-typedef union {
- uint32_t flat;
- struct {
- uint32_t :1;
- } bits;
-} cpuid_custom_features;
-
-/* Typedef for storing CPUID Feature flags */
-typedef union {
- uint32_t uint32_array[3];
- struct {
- uint32_t fpu:1; /* EDX feature flags, bit 0 */
- uint32_t vme:1;
- uint32_t de:1;
- uint32_t pse:1;
- uint32_t rdtsc:1;
- uint32_t msr:1;
- uint32_t pae:1;
- uint32_t mce:1;
- uint32_t cx8:1;
- uint32_t apic:1;
- uint32_t bit10:1;
- uint32_t sep:1;
- uint32_t mtrr:1;
- uint32_t pge:1;
- uint32_t mca:1;
- uint32_t cmov:1;
- uint32_t pat:1;
- uint32_t pse36:1;
- uint32_t psn:1;
- uint32_t cflush:1;
- uint32_t bit20:1;
- uint32_t ds:1;
- uint32_t acpi:1;
- uint32_t mmx:1;
- uint32_t fxsr:1;
- uint32_t sse:1;
- uint32_t sse2:1;
- uint32_t ss:1;
- uint32_t htt:1;
- uint32_t tm:1;
- uint32_t bit30:1;
- uint32_t pbe:1; /* EDX feature flags, bit 31 */
- uint32_t sse3:1; /* ECX feature flags, bit 0 */
- uint32_t mulq:1;
- uint32_t bit2:1;
- uint32_t mon:1;
- uint32_t dscpl:1;
- uint32_t vmx:1;
- uint32_t smx:1;
- uint32_t eist:1;
- uint32_t tm2:1;
- uint32_t bits_9_31:23;
- uint32_t bits0_28:29; /* EDX extended feature flags, bit 0 */
- uint32_t lm:1; /* Long Mode */
- uint32_t bits_30_31:2; /* EDX extended feature flags, bit 32 */
- } bits;
-} cpuid_feature_flags_t;
-
-/* An overall structure to cache all of the CPUID information */
-struct cpu_ident {
- uint32_t max_cpuid;
- uint32_t max_xcpuid;
- uint32_t dts_pmp;
- cpuid_version_t vers;
- cpuid_proc_info_t info;
- cpuid_feature_flags_t fid;
- cpuid_vendor_string_t vend_id;
- cpuid_brand_string_t brand_id;
- cpuid_cache_info_t cache_info;
- cpuid_custom_features custom;
-};
-
-struct cpuid4_eax {
- uint32_t ctype:5;
- uint32_t level:3;
- uint32_t is_self_initializing:1;
- uint32_t is_fully_associative:1;
- uint32_t reserved:4;
- uint32_t num_threads_sharing:12;
- uint32_t num_cores_on_die:6;
-};
-
-struct cpuid4_ebx {
- uint32_t coherency_line_size:12;
- uint32_t physical_line_partition:10;
- uint32_t ways_of_associativity:10;
-};
-
-struct cpuid4_ecx {
- uint32_t number_of_sets:32;
-};
-
-void get_cpuid();
-
-#endif // CPUID_H_
diff --git a/allocate_pages_test/memtest86+/bios/display.c b/allocate_pages_test/memtest86+/bios/display.c
deleted file mode 100644
index 32ee3aa..0000000
--- a/allocate_pages_test/memtest86+/bios/display.c
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "test.h"
-#include "bios/logger.h" // TODO must be implemented
-#include "smp.h"
-#include "cpuid.h"
-
-
-extern volatile short btflag;
-extern struct barrier_s *barr;
-
-/*
- * Print characters on screen
- */
-void cprint(int y, int x, const char *text)
-{
- register int i;
- char *dptr;
-
- dptr = (char *)(uintptr_t)(SCREEN_ADR + (160*y) + (2*x));
- for (i=0; text[i]; i++) {
- *dptr = text[i];
- dptr += 2;
- }
- tty_print_line(y, x, text);
-}
-
-void clear_screen()
-{
- int i;
- char *pp;
-
- /* Clear screen & set background to blue */
- for(i=0, pp=(char *)(SCREEN_ADR); i<80*25; i++) {
- *pp++ = ' ';
- *pp++ = 0x17;
- }
-
- if (btflag) {
- cprint(1, 0, "Boot Trace Enabled");
- cprint(1, 0, "Press any key to advance to next trace point");
- cprint(9, 1,"CPU Line Message Param #1 Param #2 CPU Line Message Param #1 Param #2");
- cprint(10,1,"--- ---- ----------- -------- -------- --- ---- ----------- -------- --------");
- }
-
-}
-
-
-/* Boot trace function */
-short tidx = 25;
-void btrace(int me, int line, char *msg, int wait, long v1, long v2)
-{
- int y, x;
-
- /* Is tracing turned on? */
- if (btflag == 0) return;
-
- spin_lock(&barr->mutex);
- y = tidx%13;
- x = tidx/13*40;
- cplace(y+11, x+1, ' ');
- if (++tidx > 25) {
- tidx = 0;
- }
- y = tidx%13;
- x = tidx/13*40;
-
- cplace(y+11, x+1, '>');
- dprint(y+11, x+2, me, 2, 0);
- dprint(y+11, x+5, line, 4, 0);
- cprint(y+11, x+10, msg);
- hprint(y+11, x+22, v1);
- hprint(y+11, x+31, v2);
- if (wait) {
- wait_keyup();
- }
- spin_unlock(&barr->mutex);
-}
diff --git a/allocate_pages_test/memtest86+/bios/dmi.c b/allocate_pages_test/memtest86+/bios/dmi.c
deleted file mode 100644
index 688d067..0000000
--- a/allocate_pages_test/memtest86+/bios/dmi.c
+++ /dev/null
@@ -1,485 +0,0 @@
-/* dmi.c using the DMI from SMBIOS to read information about the hardware's
- * memory devices capabilities and where they are mapped into the address space
- *
- * Copyright (c) Joachim Deguara, AMD 2006
- *
- * Release under the GPL version 2
- * ----------------------------------------------------
- * Memtest86+ V4.00 - Added compliance with SMBIOS Spec V2.6.1
- */
-
-#include "Uefi.h"
-#include "Library/UefiLib.h"
-
-extern EFI_SYSTEM_TABLE *gST;
-
-#include "test.h"
-#include "stdint.h"
-
-#include "logger.h"
-
-#define round_up(x,y) (((x) + (y) - 1) & ~((y)-1))
-#define round_down(x,y) ((x) & ~((y)-1))
-
-extern short logflag;
-extern short log_mem_ctrl;
-
-struct dmi_eps {
- uint8_t anchor[4];
- int8_t checksum;
- uint8_t length;
- uint8_t majorversion;
- uint8_t minorversion;
- uint16_t maxstructsize;
- uint8_t revision;
- uint8_t pad[5];
- uint8_t intanchor[5];
- int8_t intchecksum;
- uint16_t tablelength;
- uint32_t tableaddress;
- uint16_t numstructs;
- uint8_t SMBIOSrev;
-} __attribute__((packed));
-
-struct tstruct_header{
- uint8_t type;
- uint8_t length;
- uint16_t handle;
-} __attribute__((packed));
-
-struct system_map {
- struct tstruct_header header;
- uint8_t manufacturer;
- uint8_t productname;
- uint8_t version;
- uint8_t serialnumber;
- uint8_t uuidbytes[16];
- uint8_t wut;
-} __attribute__((packed));
-
-struct cpu_map {
- struct tstruct_header header;
- uint8_t cpu_socket;
- uint8_t cpu_type;
- uint8_t cpu_family;
- uint8_t cpu_manufacturer;
- uint32_t cpu_id;
- uint8_t cpu_version;
- uint8_t cpu_voltage;
- uint16_t ext_clock;
- uint16_t max_speed;
- uint16_t cur_speed;
- uint8_t cpu_status;
- uint8_t cpu_upgrade;
- uint16_t l1_handle;
- uint16_t l2_handle;
- uint16_t l3_handle;
- uint8_t cpu_serial;
- uint8_t cpu_asset_tag;
- uint8_t cpu_part_number;
- uint8_t core_count;
- uint8_t core_enabled;
- uint8_t thread_count;
- uint16_t cpu_specs;
- uint16_t cpu_family_2;
-} __attribute__((packed));
-
-struct mem_dev {
- struct tstruct_header header;
- uint16_t pma_handle;
- uint16_t err_handle;
- uint16_t tot_width;
- uint16_t dat_width;
- uint16_t size;
- uint8_t form;
- uint8_t set;
- uint8_t dev_locator;
- uint8_t bank_locator;
- uint8_t type;
- uint16_t typedetail;
- uint16_t speed;
- uint8_t manufacturer;
- uint8_t serialnum;
- uint8_t asset;
- uint8_t partnum;
- uint8_t attributes;
- uint8_t ext_size;
- uint8_t conf_ram_speed;
- uint8_t min_voltage;
- uint8_t max_votage;
- uint8_t conf_voltage;
-} __attribute__((packed));
-
-struct md_map{
- struct tstruct_header header;
- uint32_t start;
- uint32_t end;
- uint16_t md_handle;
- uint16_t mama_handle;
- uint8_t row_pos;
- uint8_t interl_pos;
- uint8_t interl_depth;
-} __attribute__((packed));
-
-struct pma{
- struct tstruct_header header;
- uint8_t location;
- uint8_t use;
- uint8_t ecc;
- uint32_t capacity;
- uint16_t errhandle;
- uint16_t numdevs;
-} __attribute__((packed));
-
-static char *form_factors[] = {
- "?",
- "Other", "Unknown", "SIMM", "SIP", "Chip", "DIP", "ZIP",
- "Proprietary Card", "DIMM", "TSOP", "Row of chips", "RIMM",
- "SODIMM", "SRIMM", "FB-DIMM", "Die"
-};
-
-
-static char *memory_types[] = {
- "?",
- "Other", "????", "DRAM", "EDRAM", "VRAM", "SRAM", "RAM",
- "ROM", "FLASH", "EEPROM", "FEPROM", "EPROM", "CDRAM", "3DRAM",
- "SDRAM", "SGRAM", "RDRAM", "DDR", "DDR2", "DDR2 FB", "RSVD",
- "RSVD","RSVD","DDR3","FBD2", "DDR4", "LPDDR", "LPDDR2", "LPDDR3",
- "LPDDR4", "LNVD", "HBM", "HBM2", "DDR5", "LPDDR5"
-};
-
-
-struct mem_dev * mem_devs[MAX_DMI_MEMDEVS];
-int mem_devs_count=0;
-struct md_map * md_maps[MAX_DMI_MEMDEVS];
-struct system_map * dmi_system_info;
-struct cpu_map * dmi_cpu_info;
-int md_maps_count=0;
-int dmi_err_cnts[MAX_DMI_MEMDEVS];
-short dmi_initialized=0;
-
-char * get_tstruct_string(struct tstruct_header *header, int n){
- if(n<1)
- return 0;
- char * a = (char *)header + header->length;
- n--;
- do{
- if (!*a)
- n--;
- if (!n && *a)
- return a;
- a++;
- }while (!(*a==0 && *(a-1)==0));
- return 0;
-}
-
-int open_dmi(void) {
-
-}
-
-/*int open_dmi(void){
- char *dmi, *dmi_search_start, *dmi_start;
- int found=0;
- struct dmi_eps *eps;
- char *table_start;
- int tstruct_count=0;
- dmi_search_start = (char *)DMI_SEARCH_START;
-
- //find anchor
- for(dmi = dmi_search_start; dmi < dmi_search_start + 0xf0000; dmi +=16){
- if( *dmi == '_' &&
- *(dmi+1) == 'S' &&
- *(dmi+2) == 'M' &&
- *(dmi+3) == '_'){
- found =1;
- break;
- }
- }
- if (!found) {
- print_log("open_dmi(): dmi not found", 25);
- return -1;
- }
- dmi_start=dmi;
- eps=(struct dmi_eps *)dmi;
-
- //check checksum
- int8_t checksum=0;
- for (; dmi < dmi_start + eps->length; dmi++)
- checksum += *dmi;
- if (checksum){
- return -1;
- }
-
- //we need at least revision 2.1 of SMBIOS
- if ( eps->majorversion < 2 &&
- eps->minorversion < 1){
- return -1;
- }
-
- table_start=(char *)(uintptr_t)eps->tableaddress;
- dmi=table_start;
-//look at all structs
- while(dmi < table_start + eps->tablelength){
- struct tstruct_header *header = (struct tstruct_header *)dmi;
-
- if (header->type == 17)
- mem_devs[mem_devs_count++] = (struct mem_dev *)dmi;
-
- // Mem Dev Map
- if (header->type == 20)
- md_maps[md_maps_count++] = (struct md_map *)dmi;
-
- // MB_SPEC
- if (header->type == 2)
- {
- dmi_system_info = (struct system_map *)dmi;
- }
-
- // CPU_SPEC
- if (header->type == 4)
- {
- dmi_cpu_info = (struct cpu_map *)dmi;
- }
-
- dmi+=header->length;
-
- while( ! (*dmi == 0 && *(dmi+1) == 0 ) )
- dmi++;
- dmi+=2;
-
- if (++tstruct_count > eps->numstructs)
- return -1;
- }
- return 0;
-}*/
-
-void init_dmi(void){
-
- if (logflag) print_log("init_dmi() started", 18);
-
- int i;
- for(i=0; i < MAX_DMI_MEMDEVS; i++)
- dmi_err_cnts[i]=0;
- open_dmi();
- dmi_initialized=1;
-}
-
-void print_dmi_startup_info(void)
-{
-
- if (logflag) print_log("print_dmi_startup_info() started", 32);
-
- char *string1;
- char *string2;
- char *string3;
- int dmicol = 78;
- int slength;
- int sl1, sl2, sl3;
-
- if(!dmi_initialized) { init_dmi(); }
-
- string1 = get_tstruct_string(&dmi_system_info->header,dmi_system_info->manufacturer);
- sl1 = mt86_strlen(string1);
- string2 = get_tstruct_string(&dmi_system_info->header,dmi_system_info->productname);
- sl2 = mt86_strlen(string2);
- string3 = get_tstruct_string(&dmi_cpu_info->header,dmi_cpu_info->cpu_socket);
- sl3 = mt86_strlen(string3);
-
- if (logflag && log_mem_ctrl) {
- char log[61] = "print_dmi_startup_info(): manufacturer = ";
- int length = 41;
- string_to_charr(string1, log, &length);
- print_log(log, length);
- }
-
- if (logflag && log_mem_ctrl) {
- char log[16] = "sl1 = ";
- int length = 6;
- int_to_charr(sl1, log, &length);
- print_log(log, length);
- }
-
- if (logflag && log_mem_ctrl) {
- char log[60] = "print_dmi_startup_info(): productname = ";
- int length = 40;
- string_to_charr(string2, log, &length);
- print_log(log, length);
- }
-
- if (logflag && log_mem_ctrl) {
- char log[59] = "print_dmi_startup_info(): cpu_socket = ";
- int length = 39;
- string_to_charr(string3, log, &length);
- print_log(log, length);
- }
-
- slength = sl1 + sl2;
- if(sl3 > 2) { slength += sl3 + 4; } else { slength++; }
-
- if(sl1 && sl2)
- {
- //dmicol -= slength; // right align
- dmicol = 39 - slength/2; // center align
- cprint(LINE_DMI, dmicol, string1);
- dmicol += sl1 + 1;
- cprint(LINE_DMI, dmicol, string2);
- dmicol += sl2 + 1;
-
- if(sl3 > 2){
- cprint(LINE_DMI, dmicol, "(");
- dmicol++;
- cprint(LINE_DMI, dmicol, string3);
- dmicol += sl3;
- cprint(LINE_DMI, dmicol, ")");
- }
- }
-}
-
-void print_dmi_info(void){
- int i,j,page;
- char * string=0;
-
- if(!dmi_initialized)
- init_dmi();
-
- if (mem_devs_count == 0){
- cprint(POP2_Y+1, POP2_X+2, "No valid DMI Memory Devices info found");
- while (get_key() == 0);
- return;
- }
-
- for(page=1; page <= 1 + (mem_devs_count-1)/8; page++){
- pop2clear();
- cprint(POP2_Y+1, POP2_X+2, "DMI Memory Device Info (page ");
- itoa(string,page);
- cprint(POP2_Y+1, POP2_X+32, string);
- cprint(POP2_Y+1, POP2_X+33, "/");
- itoa(string,1 + (mem_devs_count-1)/8);
- cprint(POP2_Y+1, POP2_X+34, string);
- cprint(POP2_Y+1, POP2_X+35, ")");
-
- cprint(POP2_Y+3, POP2_X+4, "Location Size(MB) Speed(MHz) Type Form");
- cprint(POP2_Y+4, POP2_X+4, "--------------------------------------------------------------");
-
- for(i=8*(page-1); i<mem_devs_count && i<8*page; i++){
- int size_in_mb;
- int yof;
-
- yof = POP2_Y+5+2*(i-8*(page-1));
- cprint(yof, POP2_X+4, get_tstruct_string(&(mem_devs[i]->header), mem_devs[i]->dev_locator));
-
- if (mem_devs[i]->size == 0){
- cprint(yof, POP2_X+4+18, "Empty");
- }else if (mem_devs[i]->size == 0xFFFF){
- cprint(yof, POP2_X+4+18, "Unknown");
- }else if (mem_devs[i]->size == 0x7FFF){
- // SMBIOS 2.7+
- size_in_mb = mem_devs[i]->ext_size;
- itoa(string, size_in_mb);
- cprint(yof, POP2_X+4+18, string);
- }else{
- size_in_mb = 0xFFFF & mem_devs[i]->size;
- if (mem_devs[i]->size & 0x8000)
- size_in_mb <<= 10;
- itoa(string, size_in_mb);
- cprint(yof, POP2_X+4+18, string);
- }
-
- //this is the only field that needs to be SMBIOS 2.3+
- if ( mem_devs[i]->speed &&
- mem_devs[i]->header.length > 21){
- itoa(string, mem_devs[i]->speed);
- cprint(yof, POP2_X+4+27, string);
- }else{
- cprint(yof, POP2_X+4+27, "Unknown");
- }
- cprint(yof, POP2_X+4+37, memory_types[mem_devs[i]->type]);
- cprint(yof, POP2_X+4+44, form_factors[mem_devs[i]->form]);
-
- //print mappings
- int mapped=0,of=0;
- cprint(yof+1, POP2_X+6,"mapped to: ");
- for(j=0; j<md_maps_count; j++)
- {
- if (mem_devs[i]->header.handle != md_maps[j]->md_handle)
- continue;
- if (mapped++){
- cprint(yof+1, POP2_X+17+of, ",");
- of++;
- }
- hprint3(yof+1, POP2_X+17+of, md_maps[j]->start>>22, 4);
- of += 4;
- hprint3(yof+1, POP2_X+17+of, md_maps[j]->start<<10, 8);
- of += 8;
- cprint(yof+1, POP2_X+17+of, "-");
- of++;
- hprint3(yof+1, POP2_X+17+of, md_maps[j]->end>>22, 4);
- of += 4;
- hprint3(yof+1, POP2_X+17+of, ((md_maps[j]->end+1)<<10) - 1, 8);
- of += 8;
- if(md_maps[j]->end == 0) { hprint3(yof+1, POP2_X+17+of-8,0,8); }
- }
- if (!mapped)
- {
- cprint(yof+1, POP2_X+17, "No mapping (Interleaved Device)");
- }
-
- }
-
- wait_keyup();
- while (get_key() == 0);
- }
-}
-
-//return 1 if the list of bad memory devices changes, 0 otherwise, -1 if no mapped
-int add_dmi_err(ulong adr){
- int i,j,found=-1;
-
- if(!dmi_initialized)
- init_dmi();
-
- for(i=0; i < md_maps_count; i++){
- if ( adr < (md_maps[i]->start<<10) ||
- adr > (md_maps[i]->end<<10) )
- continue;
-
- //matching map found, now check find corresponding dev
- for(j=0; j < mem_devs_count; j++){
- if (mem_devs[j]->header.handle != md_maps[i]->md_handle)
- continue;
- if (dmi_err_cnts[j]){
- found=0;
- }else{
- found = dmi_err_cnts[j] = 1;
- }
- }
- }
-
- return found;
-}
-
-void print_dmi_err(void){
- int i,count,of;
- char *string;
-
- scroll();
-
- cprint(vv->msg_line, 0,"Bad Memory Devices: ");
- of=20;
- for ( i=count=0; i < MAX_DMI_MEMDEVS; i++){
- if (!dmi_err_cnts[i])
- continue;
- struct mem_dev *md = mem_devs[i];
- if(count++){
- cprint(vv->msg_line, of, ", ");
- of+=2;
- }
- string=get_tstruct_string((struct tstruct_header *)md,md->dev_locator);
- if (mt86_strlen(string) + of > 80){
- scroll();
- of=7;
- }
- cprint(vv->msg_line, of, string);
- of += mt86_strlen(string);
- }
-}
diff --git a/allocate_pages_test/memtest86+/bios/init.c b/allocate_pages_test/memtest86+/bios/init.c
deleted file mode 100644
index 1cb3b97..0000000
--- a/allocate_pages_test/memtest86+/bios/init.c
+++ /dev/null
@@ -1,1296 +0,0 @@
-/*
- * MemTest86+ V5 Specific code (GPL V2.0)
- * By Samuel DEMEULEMEESTER, sdemeule@memtest.org
- * http://www.canardpc.com - http://www.memtest.org
- * ------------------------------------------------
- * init.c - MemTest-86 Version 3.6
- *
- * Released under version 2 of the Gnu Public License.
- * By Chris Brady
- */
-
-
-#include "stdin.h"
-#include "stddef.h"
-#include "test.h"
-#include "defs.h"
-#include "config.h"
-#include "cpuid.h"
-#include "smp.h"
-#include "io.h"
-#include "spd.h"
-#include "pci.h"
-#include "controller.h"
-
-extern struct tseq tseq[];
-extern short memsz_mode;
-extern int num_cpus;
-extern int act_cpus;
-extern int found_cpus;
-unsigned long imc_type = 0;
-extern int maxcpus;
-extern char cpu_mask[];
-extern void initialise_cpus();
-
-/* Here we store all of the cpuid data */
-extern struct cpu_ident cpu_id;
-
-int l1_cache=0, l2_cache=0, l3_cache=0;
-int tsc_invariable = 0;
-ulong extclock;
-
-ulong memspeed(ulong src, ulong len, int iter);
-static void cpu_type(void);
-static int cpuspeed(void);
-static void get_cache_size();
-static void cpu_cache_speed();
-void get_cpuid();
-int beepmode;
-extern short dmi_initialized;
-extern int dmi_err_cnts[MAX_DMI_MEMDEVS];
-
-/* Failsafe function */
-/* msec: number of ms to wait - scs: scancode expected to stop */
-/* bits: 0 = extended detection - 1: SMP - 2: Temp Check */
-/* 3: MP SMP - 4-7: RSVD */
-void failsafe(int msec, int scs)
-{
- int i;
- ulong sh, sl, l, h, t;
- unsigned char c;
- volatile char *pp;
-
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<40; i++, pp+=2) {
- *pp = 0x1E;
- }
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<3; i++, pp+=2) {
- *pp = 0x9E;
- }
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(55*2)+1); i<3; i++, pp+=2) {
- *pp = 0x9E;
- }
-
- cprint(18, 18, "==> Press F1 to enter Fail-Safe Mode <==");
-
- if(vv->fail_safe & 2)
- {
- cprint(19, 15, "==> Press F2 to force Multi-Threading (SMP) <==");
- }
-
- /* save the starting time */
- asm __volatile__
- ("rdtsc":"=a" (sl),"=d" (sh));
-
- /* loop for n seconds */
- while (1) {
- asm __volatile__(
- "rdtsc":"=a" (l),"=d" (h));
- asm __volatile__ (
- "subl %2,%0\n\t"
- "sbbl %3,%1"
- :"=a" (l), "=d" (h)
- :"g" (sl), "g" (sh),
- "0" (l), "1" (h));
-
- t = h * ((unsigned)0xffffffff / vv->clks_msec);
- t += (l / vv->clks_msec);
-
- /* Is the time up? */
- if (t >= msec) { break; }
-
- /* Is expected Scan code pressed? */
- c = get_key();
- c &= 0x7f;
-
- /* F1 */
- if(c == scs) { vv->fail_safe |= 1; break; }
-
- /* F2 */
- if(c == scs+1)
- {
- vv->fail_safe ^= 2;
- break;
-
- }
-
- /* F3 */
- if(c == scs+2)
- {
- if(vv->fail_safe & 2) { vv->fail_safe ^= 2; }
- vv->fail_safe |= 8;
- break;
- }
- }
-
- cprint(18, 18, " ");
- cprint(19, 15, " ");
-
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<40; i++, pp+=2) {
- *pp = 0x17;
- }
-}
-
-static void display_init(void)
-{
- int i;
- volatile char *pp;
-
- /* Set HW cursor out of screen boundaries */
- __outb(0x0F, 0x03D4);
- __outb(0xFF, 0x03D5);
-
- __outb(0x0E, 0x03D4);
- __outb(0xFF, 0x03D5);
-
-
- serial_echo_init();
- serial_echo_print("INE_SCROLL;24r"); /* Set scroll area row 7-23 */
- serial_echo_print(""); /* Clear Screen */
- serial_echo_print("");
- serial_echo_print("");
- serial_echo_print("");
-
- /* Clear screen & set background to blue */
- for(i=0, pp=(char *)(SCREEN_ADR); i<80*24; i++) {
- *pp++ = ' ';
- *pp++ = 0x17;
- }
-
- /* Make the name background green */
- for(i=0, pp=(char *)(SCREEN_ADR+1); i<TITLE_WIDTH; i++, pp+=2) {
- *pp = 0x20;
- }
- cprint(0, 0, " Memtest86 5.31b ");
-
- /* Set Blinking "+" */
- for(i=0, pp=(char *)(SCREEN_ADR+1); i<2; i++, pp+=30) {
- *pp = 0xA4;
- }
- cprint(0, 15, "+");
-
- /* Do reverse video for the bottom display line */
- for(i=0, pp=(char *)(SCREEN_ADR+1+(24 * 160)); i<80; i++, pp+=2) {
- *pp = 0x71;
- }
-
- serial_echo_print("");
-}
-
-/*
- * Initialize test, setup screen and find out how much memory there is.
- */
-void init(void)
-{
- int i;
-
- outb(0x8, 0x3f2); /* Kill Floppy Motor */
-
- /* Turn on cache */
- set_cache(1);
-
- /* Setup the display */
- display_init();
-
- cprint(5, 60, "| Time: 0:00:00");
- cprint(1, COL_MID,"Pass %");
- cprint(2, COL_MID,"Test %");
- cprint(3, COL_MID,"Test #");
- cprint(4, COL_MID,"Testing: ");
- cprint(5, COL_MID,"Pattern: ");
- cprint(1, 0, "CLK: (32b Mode)");
- cprint(2, 0, "L1 Cache: Unknown ");
- cprint(3, 0, "L2 Cache: Unknown ");
- cprint(4, 0, "L3 Cache: None ");
- cprint(5, 0, "Memory : ");
- cprint(6, 0, "------------------------------------------------------------------------------");
- cprint(7, 0, "Core#:");
- cprint(8, 0, "State:");
- cprint(9, 0, "Cores: Active / Total (Run: All) | Pass: 0 Errors: 0 ");
- cprint(10, 0, "------------------------------------------------------------------------------");
-
- /*
- for(i=0, pp=(char *)(SCREEN_ADR+(5*160)+(53*2)+1); i<20; i++, pp+=2) {
- *pp = 0x92;
- }
-
- for(i=0, pp=(char *)(SCREEN_ADR+0*160+1); i<80; i++, pp+=2) {
- *pp = 0x47;
- }
- */
-
- cprint(7, 39, "| Chipset : Unknown");
- cprint(8, 39, "| Memory Type : Unknown");
-
- for(i=0; i < 6; i++) {
- cprint(i, COL_MID-2, "| ");
- }
-
- footer();
-
- aprint(5, 10, vv->test_pages);
-
- vv->pass = 0;
- vv->msg_line = 0;
- vv->ecount = 0;
- vv->ecc_ecount = 0;
- vv->testsel = -1;
- vv->msg_line = LINE_SCROLL-1;
- vv->scroll_start = vv->msg_line * 160;
- vv->erri.low_addr.page = 0x7fffffff;
- vv->erri.low_addr.offset = 0xfff;
- vv->erri.high_addr.page = 0;
- vv->erri.high_addr.offset = 0;
- vv->erri.min_bits = 32;
- vv->erri.max_bits = 0;
- vv->erri.min_bits = 32;
- vv->erri.max_bits = 0;
- vv->erri.maxl = 0;
- vv->erri.cor_err = 0;
- vv->erri.ebits = 0;
- vv->erri.hdr_flag = 0;
- vv->erri.tbits = 0;
- for (i=0; tseq[i].msg != NULL; i++) {
- tseq[i].errors = 0;
- }
- if (dmi_initialized) {
- for (i=0; i < MAX_DMI_MEMDEVS; i++){
- if (dmi_err_cnts[i] > 0) {
- dmi_err_cnts[i] = 0;
- }
- }
- }
-
- /* setup beep mode */
- beepmode = BEEP_MODE;
-
- /* Get the cpu and cache information */
- get_cpuid();
-
- /* setup pci */
- pci_init();
-
- get_cache_size();
-
- cpu_type();
-
- cpu_cache_speed();
-
- /* Check fail safe */
- failsafe(5000, 0x3B);
-
- /* Initalize SMP */
- initialise_cpus();
-
- for (i = 0; i <num_cpus; i++) {
- dprint(7, i+7, i%10, 1, 0);
- cprint(8, i+7, "S");
- }
-
- dprint(9, 19, num_cpus, 2, 0);
-
- if((vv->fail_safe & 3) == 2)
- {
- cprint(LINE_CPU,9, "(SMP: Disabled)");
- cprint(LINE_RAM,9, "Running...");
- }
- // dprint(10, 5, found_cpus, 2, 0);
-
- /* Find Memory Specs */
- if(vv->fail_safe & 1)
- {
- cprint(LINE_CPU, COL_SPEC, " **** FAIL SAFE **** FAIL SAFE **** ");
- cprint(LINE_RAM, COL_SPEC, " No detection, same reliability ");
- } else {
- find_controller();
- get_spd_spec();
- if(num_cpus <= 16 && !(vv->fail_safe & 4)) { coretemp(); }
- }
-
- if(vv->check_temp > 0 && !(vv->fail_safe & 4))
- {
- cprint(LINE_CPU, 26, "| CPU Temp");
- cprint(LINE_CPU+1, 26, "| øC");
- }
-
- beep(600);
- beep(1000);
-
- /* Record the start time */
- asm __volatile__ ("rdtsc":"=a" (vv->startl),"=d" (vv->starth));
- vv->snapl = vv->startl;
- vv->snaph = vv->starth;
- if (l1_cache == 0) { l1_cache = 64; }
- if (l2_cache == 0) { l1_cache = 512; }
- vv->printmode=PRINTMODE_ADDRESSES;
- vv->numpatn=0;
-}
-
-/* Get cache sizes for most AMD and Intel CPUs, exceptions for old CPUs are
- * handled in CPU detection */
-void get_cache_size()
-{
- int i, j, n, size;
- unsigned int v[4];
- unsigned char *dp = (unsigned char *)v;
- struct cpuid4_eax *eax = (struct cpuid4_eax *)&v[0];
- struct cpuid4_ebx *ebx = (struct cpuid4_ebx *)&v[1];
- struct cpuid4_ecx *ecx = (struct cpuid4_ecx *)&v[2];
-
- switch(cpu_id.vend_id.char_array[0]) {
- /* AMD Processors */
- case 'A':
- //l1_cache = cpu_id.cache_info.amd.l1_i_sz;
- l1_cache = cpu_id.cache_info.amd.l1_d_sz;
- l2_cache = cpu_id.cache_info.amd.l2_sz;
- l3_cache = cpu_id.cache_info.amd.l3_sz;
- l3_cache *= 512;
- break;
- case 'G':
- /* Intel Processors */
- l1_cache = 0;
- l2_cache = 0;
- l3_cache = 0;
-
- /* Use CPUID(4) if it is available */
- if (cpu_id.max_cpuid > 3) {
-
- /* figure out how many cache leaves */
- n = -1;
- do
- {
- ++n;
- /* Do cpuid(4) loop to find out num_cache_leaves */
- cpuid_count(4, n, &v[0], &v[1], &v[2], &v[3]);
- } while ((eax->ctype) != 0);
-
- /* loop through all of the leaves */
- for (i=0; i<n; i++)
- {
- cpuid_count(4, i, &v[0], &v[1], &v[2], &v[3]);
-
- /* Check for a valid cache type */
- if (eax->ctype == 1 || eax->ctype == 3)
- {
-
- /* Compute the cache size */
- size = (ecx->number_of_sets + 1) *
- (ebx->coherency_line_size + 1) *
- (ebx->physical_line_partition + 1) *
- (ebx->ways_of_associativity + 1);
- size /= 1024;
-
- switch (eax->level)
- {
- case 1:
- l1_cache += size;
- break;
- case 2:
- l2_cache += size;
- break;
- case 3:
- l3_cache += size;
- break;
- }
- }
- }
- return;
- }
-
- /* No CPUID(4) so we use the older CPUID(2) method */
- /* Get number of times to iterate */
- cpuid(2, &v[0], &v[1], &v[2], &v[3]);
- n = v[0] & 0xff;
- for (i=0 ; i<n ; i++) {
- cpuid(2, &v[0], &v[1], &v[2], &v[3]);
-
- /* If bit 31 is set, this is an unknown format */
- for (j=0 ; j<3 ; j++) {
- if (v[j] & (1 << 31)) {
- v[j] = 0;
- }
- }
-
- /* Byte 0 is level count, not a descriptor */
- for (j = 1 ; j < 16 ; j++) {
- switch(dp[j]) {
- case 0x6:
- case 0xa:
- case 0x66:
- l1_cache += 8;
- break;
- case 0x8:
- case 0xc:
- case 0xd:
- case 0x60:
- case 0x67:
- l1_cache += 16;
- break;
- case 0xe:
- l1_cache += 24;
- break;
- case 0x9:
- case 0x2c:
- case 0x30:
- case 0x68:
- l1_cache += 32;
- break;
- case 0x39:
- case 0x3b:
- case 0x41:
- case 0x79:
- l2_cache += 128;
- break;
- case 0x3a:
- l2_cache += 192;
- break;
- case 0x21:
- case 0x3c:
- case 0x3f:
- case 0x42:
- case 0x7a:
- case 0x82:
- l2_cache += 256;
- break;
- case 0x3d:
- l2_cache += 384;
- break;
- case 0x3e:
- case 0x43:
- case 0x7b:
- case 0x7f:
- case 0x80:
- case 0x83:
- case 0x86:
- l2_cache += 512;
- break;
- case 0x44:
- case 0x78:
- case 0x7c:
- case 0x84:
- case 0x87:
- l2_cache += 1024;
- break;
- case 0x45:
- case 0x7d:
- case 0x85:
- l2_cache += 2048;
- break;
- case 0x48:
- l2_cache += 3072;
- break;
- case 0x4e:
- l2_cache += 6144;
- break;
- case 0x23:
- case 0xd0:
- l3_cache += 512;
- break;
- case 0xd1:
- case 0xd6:
- l3_cache += 1024;
- break;
- case 0x25:
- case 0xd2:
- case 0xd7:
- case 0xdc:
- case 0xe2:
- l3_cache += 2048;
- break;
- case 0x29:
- case 0x46:
- case 0x49:
- case 0xd8:
- case 0xdd:
- case 0xe3:
- l3_cache += 4096;
- break;
- case 0x4a:
- l3_cache += 6144;
- break;
- case 0x47:
- case 0x4b:
- case 0xde:
- case 0xe4:
- l3_cache += 8192;
- break;
- case 0x4c:
- case 0xea:
- l3_cache += 12288;
- break;
- case 0x4d:
- l3_cache += 16384;
- break;
- case 0xeb:
- l3_cache += 18432;
- break;
- case 0xec:
- l3_cache += 24576;
- break;
- } /* end switch */
- } /* end for 1-16 */
- } /* end for 0 - n */
- }
-}
-
-/*
- * Find IMC type and set global variables accordingly
- */
-void detect_imc(void)
-{
- // Check AMD IMC
- if(cpu_id.vend_id.char_array[0] == 'A' && cpu_id.vers.bits.family == 0xF)
- {
- switch(cpu_id.vers.bits.extendedFamily)
- {
- case 0x0:
- imc_type = 0x0100; // Old K8
- break;
- case 0x1:
- case 0x2:
- imc_type = 0x0101; // K10 (Family 10h & 11h)
- break;
- case 0x3:
- imc_type = 0x0102; // A-Series APU (Family 12h)
- break;
- case 0x5:
- imc_type = 0x0103; // C- / E- / Z- Series APU (Family 14h)
- break;
- case 0x6:
- imc_type = 0x0104; // FX Series (Family 15h)
- break;
- case 0x7:
- imc_type = 0x0105; // Kabini & related (Family 16h)
- break;
- }
- return;
- }
-
- // Check Intel IMC
- if(cpu_id.vend_id.char_array[0] == 'G' && cpu_id.vers.bits.family == 6 && cpu_id.vers.bits.extendedModel)
- {
- switch(cpu_id.vers.bits.model)
- {
- case 0x5:
- if(cpu_id.vers.bits.extendedModel == 2) { imc_type = 0x0003; } // Core i3/i5 1st Gen 45 nm (NHM)
- if(cpu_id.vers.bits.extendedModel == 3) { vv->fail_safe |= 4; } // Atom Clover Trail
- if(cpu_id.vers.bits.extendedModel == 4) { imc_type = 0x0007; } // HSW-ULT
- break;
- case 0x6:
- if(cpu_id.vers.bits.extendedModel == 3) {
- imc_type = 0x0009; // Atom Cedar Trail
- vv->fail_safe |= 4; // Disable Core temp
- }
- break;
- case 0xA:
- switch(cpu_id.vers.bits.extendedModel)
- {
- case 0x1:
- imc_type = 0x0001; // Core i7 1st Gen 45 nm (NHME)
- break;
- case 0x2:
- imc_type = 0x0004; // Core 2nd Gen (SNB)
- break;
- case 0x3:
- imc_type = 0x0006; // Core 3nd Gen (IVB)
- break;
- }
- break;
- case 0xC:
- switch(cpu_id.vers.bits.extendedModel)
- {
- case 0x1:
- if(cpu_id.vers.bits.stepping > 9) { imc_type = 0x0008; } // Atom PineView
- vv->fail_safe |= 4; // Disable Core temp
- break;
- case 0x2:
- imc_type = 0x0002; // Core i7 1st Gen 32 nm (WMR)
- break;
- case 0x3:
- imc_type = 0x0007; // Core 4nd Gen (HSW)
- break;
- }
- break;
- case 0xD:
- imc_type = 0x0005; // SNB-E
- break;
- case 0xE:
- imc_type = 0x0001; // Core i7 1st Gen 45 nm (NHM)
- break;
- }
-
- if(imc_type) { tsc_invariable = 1; }
- return;
- }
-}
-
-void smp_default_mode(void)
-{
- int i, result;
- char *cpupsn = cpu_id.brand_id.char_array;
- char *disabledcpu[] = { "Opteron", "Xeon", "EPYC", "Genuine Intel" };
-
- for(i = 0; i < 3; i++)
- {
- result = mt86_strstr(cpupsn , disabledcpu[i]);
- if(result != -1) { vv->fail_safe |= 0b10; }
- }
-
- // For 5.01 release, SMP disabled by defualt by config.h toggle
- if(CONSERVATIVE_SMP) { vv->fail_safe |= 0b10; }
-
-}
-
-/*
- * Find CPU type
- */
-void cpu_type(void)
-{
- /* If we can get a brand string use it, and we are done */
- if (cpu_id.max_xcpuid >= 0x80000004) {
- cprint(0, COL_MID, cpu_id.brand_id.char_array);
- //If we have a brand string, maybe we have an IMC. Check that.
- detect_imc();
- smp_default_mode();
- return;
- }
-
- /* The brand string is not available so we need to figure out
- * CPU what we have */
- switch(cpu_id.vend_id.char_array[0]) {
- /* AMD Processors */
- case 'A':
- switch(cpu_id.vers.bits.family) {
- case 4:
- switch(cpu_id.vers.bits.model) {
- case 3:
- cprint(0, COL_MID, "AMD 486DX2");
- break;
- case 7:
- cprint(0, COL_MID, "AMD 486DX2-WB");
- break;
- case 8:
- cprint(0, COL_MID, "AMD 486DX4");
- break;
- case 9:
- cprint(0, COL_MID, "AMD 486DX4-WB");
- break;
- case 14:
- cprint(0, COL_MID, "AMD 5x86-WT");
- break;
- case 15:
- cprint(0, COL_MID, "AMD 5x86-WB");
- break;
- }
- /* Since we can't get CPU speed or cache info return */
- return;
- case 5:
- switch(cpu_id.vers.bits.model) {
- case 0:
- case 1:
- case 2:
- case 3:
- cprint(0, COL_MID, "AMD K5");
- l1_cache = 8;
- break;
- case 6:
- case 7:
- cprint(0, COL_MID, "AMD K6");
- break;
- case 8:
- cprint(0, COL_MID, "AMD K6-2");
- break;
- case 9:
- cprint(0, COL_MID, "AMD K6-III");
- break;
- case 13:
- cprint(0, COL_MID, "AMD K6-III+");
- break;
- }
- break;
- case 6:
-
- switch(cpu_id.vers.bits.model) {
- case 1:
- cprint(0, COL_MID, "AMD Athlon (0.25)");
- break;
- case 2:
- case 4:
- cprint(0, COL_MID, "AMD Athlon (0.18)");
- break;
- case 6:
- if (l2_cache == 64) {
- cprint(0, COL_MID, "AMD Duron (0.18)");
- } else {
- cprint(0, COL_MID, "Athlon XP (0.18)");
- }
- break;
- case 8:
- case 10:
- if (l2_cache == 64) {
- cprint(0, COL_MID, "AMD Duron (0.13)");
- } else {
- cprint(0, COL_MID, "Athlon XP (0.13)");
- }
- break;
- case 3:
- case 7:
- cprint(0, COL_MID, "AMD Duron");
- /* Duron stepping 0 CPUID for L2 is broken */
- /* (AMD errata T13)*/
- if (cpu_id.vers.bits.stepping == 0) { /* stepping 0 */
- /* Hard code the right L2 size */
- l2_cache = 64;
- } else {
- }
- break;
- }
- break;
-
- /* All AMD family values >= 10 have the Brand ID
- * feature so we don't need to find the CPU type */
- }
- break;
-
- /* Intel or Transmeta Processors */
- case 'G':
- if ( cpu_id.vend_id.char_array[7] == 'T' ) { /* GenuineTMx86 */
- if (cpu_id.vers.bits.family == 5) {
- cprint(0, COL_MID, "TM 5x00");
- } else if (cpu_id.vers.bits.family == 15) {
- cprint(0, COL_MID, "TM 8x00");
- }
- l1_cache = cpu_id.cache_info.ch[3] + cpu_id.cache_info.ch[7];
- l2_cache = (cpu_id.cache_info.ch[11]*256) + cpu_id.cache_info.ch[10];
- } else { /* GenuineIntel */
- if (cpu_id.vers.bits.family == 4) {
- switch(cpu_id.vers.bits.model) {
- case 0:
- case 1:
- cprint(0, COL_MID, "Intel 486DX");
- break;
- case 2:
- cprint(0, COL_MID, "Intel 486SX");
- break;
- case 3:
- cprint(0, COL_MID, "Intel 486DX2");
- break;
- case 4:
- cprint(0, COL_MID, "Intel 486SL");
- break;
- case 5:
- cprint(0, COL_MID, "Intel 486SX2");
- break;
- case 7:
- cprint(0, COL_MID, "Intel 486DX2-WB");
- break;
- case 8:
- cprint(0, COL_MID, "Intel 486DX4");
- break;
- case 9:
- cprint(0, COL_MID, "Intel 486DX4-WB");
- break;
- }
- /* Since we can't get CPU speed or cache info return */
- return;
- }
-
-
- switch(cpu_id.vers.bits.family) {
- case 5:
- switch(cpu_id.vers.bits.model) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 7:
- cprint(0, COL_MID, "Pentium");
- if (l1_cache == 0) {
- l1_cache = 8;
- }
- break;
- case 4:
- case 8:
- cprint(0, COL_MID, "Pentium-MMX");
- if (l1_cache == 0) {
- l1_cache = 16;
- }
- break;
- }
- break;
- case 6:
- switch(cpu_id.vers.bits.model) {
- case 0:
- case 1:
- cprint(0, COL_MID, "Pentium Pro");
- break;
- case 3:
- case 4:
- cprint(0, COL_MID, "Pentium II");
- break;
- case 5:
- if (l2_cache == 0) {
- cprint(0, COL_MID, "Celeron");
- } else {
- cprint(0, COL_MID, "Pentium II");
- }
- break;
- case 6:
- if (l2_cache == 128) {
- cprint(0, COL_MID, "Celeron");
- } else {
- cprint(0, COL_MID, "Pentium II");
- }
- }
- break;
- case 7:
- case 8:
- case 11:
- if (l2_cache == 128) {
- cprint(0, COL_MID, "Celeron");
- } else {
- cprint(0, COL_MID, "Pentium III");
- }
- break;
- case 9:
- if (l2_cache == 512) {
- cprint(0, COL_MID, "Celeron M (0.13)");
- } else {
- cprint(0, COL_MID, "Pentium M (0.13)");
- }
- break;
- case 10:
- cprint(0, COL_MID, "Pentium III Xeon");
- break;
- case 12:
- l1_cache = 24;
- cprint(0, COL_MID, "Atom (0.045)");
- break;
- case 13:
- if (l2_cache == 1024) {
- cprint(0, COL_MID, "Celeron M (0.09)");
- } else {
- cprint(0, COL_MID, "Pentium M (0.09)");
- }
- break;
- case 14:
- cprint(0, COL_MID, "Intel Core");
- break;
- case 15:
- if (l2_cache == 1024) {
- cprint(0, COL_MID, "Pentium E");
- } else {
- cprint(0, COL_MID, "Intel Core 2");
- }
- break;
- }
- break;
- case 15:
- switch(cpu_id.vers.bits.model) {
- case 0:
- case 1:
- case 2:
- if (l2_cache == 128) {
- cprint(0, COL_MID, "Celeron");
- } else {
- cprint(0, COL_MID, "Pentium 4");
- }
- break;
- case 3:
- case 4:
- if (l2_cache == 256) {
- cprint(0, COL_MID, "Celeron (0.09)");
- } else {
- cprint(0, COL_MID, "Pentium 4 (0.09)");
- }
- break;
- case 6:
- cprint(0, COL_MID, "Pentium D (65nm)");
- break;
- default:
- cprint(0, COL_MID, "Unknown Intel");
- break;
- break;
- }
-
- }
- break;
-
- /* VIA/Cyrix/Centaur Processors with CPUID */
- case 'C':
- if ( cpu_id.vend_id.char_array[1] == 'e' ) { /* CentaurHauls */
- l1_cache = cpu_id.cache_info.ch[3] + cpu_id.cache_info.ch[7];
- l2_cache = cpu_id.cache_info.ch[11];
- switch(cpu_id.vers.bits.family){
- case 5:
- cprint(0, COL_MID, "Centaur 5x86");
- break;
- case 6: // VIA C3
- switch(cpu_id.vers.bits.model){
- default:
- if (cpu_id.vers.bits.stepping < 8) {
- cprint(0, COL_MID, "VIA C3 Samuel2");
- } else {
- cprint(0, COL_MID, "VIA C3 Eden");
- }
- break;
- case 10:
- cprint(0, COL_MID, "VIA C7 (C5J)");
- l1_cache = 64;
- l2_cache = 128;
- break;
- case 13:
- cprint(0, COL_MID, "VIA C7 (C5R)");
- l1_cache = 64;
- l2_cache = 128;
- break;
- case 15:
- cprint(0, COL_MID, "VIA Isaiah (CN)");
- l1_cache = 64;
- l2_cache = 128;
- break;
- }
- }
- } else { /* CyrixInstead */
- switch(cpu_id.vers.bits.family) {
- case 5:
- switch(cpu_id.vers.bits.model) {
- case 0:
- cprint(0, COL_MID, "Cyrix 6x86MX/MII");
- break;
- case 4:
- cprint(0, COL_MID, "Cyrix GXm");
- break;
- }
- return;
-
- case 6: // VIA C3
- switch(cpu_id.vers.bits.model) {
- case 6:
- cprint(0, COL_MID, "Cyrix III");
- break;
- case 7:
- if (cpu_id.vers.bits.stepping < 8) {
- cprint(0, COL_MID, "VIA C3 Samuel2");
- } else {
- cprint(0, COL_MID, "VIA C3 Ezra-T");
- }
- break;
- case 8:
- cprint(0, COL_MID, "VIA C3 Ezra-T");
- break;
- case 9:
- cprint(0, COL_MID, "VIA C3 Nehemiah");
- break;
- }
- // L1 = L2 = 64 KB from Cyrix III to Nehemiah
- l1_cache = 64;
- l2_cache = 64;
- break;
- }
- }
- break;
- /* Unknown processor */
- default:
- /* Make a guess at the family */
- switch(cpu_id.vers.bits.family) {
- case 5:
- cprint(0, COL_MID, "586");
- case 6:
- cprint(0, COL_MID, "686");
- default:
- cprint(0, COL_MID, "Unidentified Processor");
- }
- }
-}
-
-#define STEST_ADDR 0x100000 /* Measure memory speed starting at 1MB */
-
-/* Measure and display CPU and cache sizes and speeds */
-void cpu_cache_speed()
-{
- int i, off = 4;
- ulong speed;
-
-
- /* Print CPU speed */
- if ((speed = cpuspeed()) > 0) {
- if (speed < 999499) {
- speed += 50; /* for rounding */
- cprint(1, off, " . MHz");
- dprint(1, off+1, speed/1000, 3, 1);
- dprint(1, off+5, (speed/100)%10, 1, 0);
- } else {
- speed += 500; /* for rounding */
- cprint(1, off, " MHz");
- dprint(1, off, speed/1000, 5, 0);
- }
- extclock = speed;
- }
-
- /* Print out L1 cache info */
- /* To measure L1 cache speed we use a block size that is 1/4th */
- /* of the total L1 cache size since half of it is for instructions */
- if (l1_cache) {
- cprint(2, 0, "L1 Cache: K ");
- dprint(2, 11, l1_cache, 3, 0);
- if ((speed=memspeed(STEST_ADDR, (l1_cache/2)*1024, 200))) {
- cprint(2, 16, " MB/s");
- dprint(2, 16, speed, 6, 0);
- }
- }
-
- /* Print out L2 cache info */
- /* We measure the L2 cache speed by using a block size that is */
- /* the size of the L1 cache. We have to fudge if the L1 */
- /* cache is bigger than the L2 */
- if (l2_cache) {
- cprint(3, 0, "L2 Cache: K ");
- dprint(3, 10, l2_cache, 4, 0);
-
- if (l2_cache < l1_cache) {
- i = l1_cache / 4 + l2_cache / 4;
- } else {
- i = l1_cache;
- }
- if ((speed=memspeed(STEST_ADDR, i*1024, 200))) {
- cprint(3, 16, " MB/s");
- dprint(3, 16, speed, 6, 0);
- }
- }
- /* Print out L3 cache info */
- /* We measure the L3 cache speed by using a block size that is */
- /* 2X the size of the L2 cache. */
-
- if (l3_cache)
- {
- cprint(4, 0, "L3 Cache: K ");
- aprint(4, 10, l3_cache/4);
- //dprint(4, 10, l3_cache, 4, 0);
-
- i = l2_cache*2;
-
- if ((speed=memspeed(STEST_ADDR, i*1024, 150))) {
- cprint(4, 16, " MB/s");
- dprint(4, 16, speed, 6, 0);
- }
- }
-}
-
-/* Measure and display memory speed, multitasked using all CPUs */
-ulong spd[MAX_CPUS];
-void get_mem_speed(int me, int ncpus)
-{
- int i;
- ulong speed=0;
-
- /* Determine memory speed. To find the memory speed we use
- * A block size that is the sum of all the L1, L2 & L3 caches
- * in all cpus * 6 */
- i = (l3_cache + l2_cache + l1_cache) * 4;
-
- /* Make sure that we have enough memory to do the test */
- /* If not use all we have */
- if ((1 + (i * 2)) > (vv->plim_upper << 2)) {
- i = ((vv->plim_upper <<2) - 1) / 2;
- }
-
- speed = memspeed(STEST_ADDR, i * 1024, 100);
- cprint(5, 16, " MB/s");
- dprint(5, 16, speed, 6, 0);
-
-}
-
-/* #define TICKS 5 * 11832 (count = 6376)*/
-/* #define TICKS (65536 - 12752) */
-#define TICKS 59659 /* 50 ms */
-
-/* Returns CPU clock in khz */
-ulong stlow, sthigh;
-static int cpuspeed(void)
-{
- int loops;
- ulong end_low, end_high;
-
- if (cpu_id.fid.bits.rdtsc == 0 ) {
- return(-1);
- }
-
- /* Setup timer */
- outb((inb(0x61) & ~0x02) | 0x01, 0x61);
- outb(0xb0, 0x43);
- outb(TICKS & 0xff, 0x42);
- outb(TICKS >> 8, 0x42);
-
- asm __volatile__ ("rdtsc":"=a" (stlow),"=d" (sthigh));
-
- loops = 0;
- do {
- loops++;
- } while ((inb(0x61) & 0x20) == 0);
-
- asm __volatile__ (
- "rdtsc\n\t" \
- "subl stlow,%%eax\n\t" \
- "sbbl sthigh,%%edx\n\t" \
- :"=a" (end_low), "=d" (end_high)
- );
-
- /* Make sure we have a credible result */
- if (loops < 4 || end_low < 50000) {
- return(-1);
- }
- vv->clks_msec = end_low/50;
-
- if (tsc_invariable) end_low = correct_tsc(end_low);
-
- return(vv->clks_msec);
-}
-
-/* Measure cache speed by copying a block of memory. */
-/* Returned value is kbytes/second */
-ulong memspeed(ulong src, ulong len, int iter)
-{
- int i;
- ulong dst, wlen;
- ulong st_low, st_high;
- ulong end_low, end_high;
- ulong cal_low, cal_high;
-
- if (cpu_id.fid.bits.rdtsc == 0 ) {
- return(-1);
- }
- if (len == 0) return(-2);
-
- dst = src + len;
- wlen = len / 4; /* Length is bytes */
-
- /* Calibrate the overhead with a zero word copy */
- asm __volatile__ ("rdtsc":"=a" (st_low),"=d" (st_high));
- for (i=0; i<iter; i++) {
- asm __volatile__ (
- "movl %0,%%esi\n\t" \
- "movl %1,%%edi\n\t" \
- "movl %2,%%ecx\n\t" \
- "cld\n\t" \
- "rep\n\t" \
- "movsl\n\t" \
- :: "g" (src), "g" (dst), "g" (0)
- : "esi", "edi", "ecx"
- );
- }
- asm __volatile__ ("rdtsc":"=a" (cal_low),"=d" (cal_high));
-
- /* Compute the overhead time */
- asm __volatile__ (
- "subl %2,%0\n\t"
- "sbbl %3,%1"
- :"=a" (cal_low), "=d" (cal_high)
- :"g" (st_low), "g" (st_high),
- "0" (cal_low), "1" (cal_high)
- );
-
-
- /* Now measure the speed */
- /* Do the first copy to prime the cache */
- asm __volatile__ (
- "movl %0,%%esi\n\t" \
- "movl %1,%%edi\n\t" \
- "movl %2,%%ecx\n\t" \
- "cld\n\t" \
- "rep\n\t" \
- "movsl\n\t" \
- :: "g" (src), "g" (dst), "g" (wlen)
- : "esi", "edi", "ecx"
- );
- asm __volatile__ ("rdtsc":"=a" (st_low),"=d" (st_high));
- for (i=0; i<iter; i++) {
- asm __volatile__ (
- "movl %0,%%esi\n\t" \
- "movl %1,%%edi\n\t" \
- "movl %2,%%ecx\n\t" \
- "cld\n\t" \
- "rep\n\t" \
- "movsl\n\t" \
- :: "g" (src), "g" (dst), "g" (wlen)
- : "esi", "edi", "ecx"
- );
- }
- asm __volatile__ ("rdtsc":"=a" (end_low),"=d" (end_high));
-
- /* Compute the elapsed time */
- asm __volatile__ (
- "subl %2,%0\n\t"
- "sbbl %3,%1"
- :"=a" (end_low), "=d" (end_high)
- :"g" (st_low), "g" (st_high),
- "0" (end_low), "1" (end_high)
- );
- /* Subtract the overhead time */
- asm __volatile__ (
- "subl %2,%0\n\t"
- "sbbl %3,%1"
- :"=a" (end_low), "=d" (end_high)
- :"g" (cal_low), "g" (cal_high),
- "0" (end_low), "1" (end_high)
- );
-
- /* Make sure that the result fits in 32 bits */
- //hprint(11,40,end_high);
- if (end_high) {
- return(-3);
- }
- end_low /= 2;
-
- /* Convert to clocks/KB */
- end_low /= len;
- end_low *= 1024;
- end_low /= iter;
- if (end_low == 0) {
- return(-4);
- }
-
- /* Convert to kbytes/sec */
-
- if (tsc_invariable) end_low = correct_tsc(end_low);
-
- return((vv->clks_msec)/end_low);
-}
-
-#define rdmsr(msr,val1,val2) \
- __asm__ __volatile__("rdmsr" \
- : "=a" (val1), "=d" (val2) \
- : "c" (msr))
-
-
-ulong correct_tsc(ulong el_org)
-{
- float coef_now, coef_max;
- int msr_lo, msr_hi, is_xe;
-
- rdmsr(0x198, msr_lo, msr_hi);
- is_xe = (msr_lo >> 31) & 0x1;
-
- if(is_xe){
- rdmsr(0x198, msr_lo, msr_hi);
- coef_max = ((msr_hi >> 8) & 0x1F);
- if ((msr_hi >> 14) & 0x1) { coef_max = coef_max + 0.5f; }
- } else {
- rdmsr(0x17, msr_lo, msr_hi);
- coef_max = ((msr_lo >> 8) & 0x1F);
- if ((msr_lo >> 14) & 0x1) { coef_max = coef_max + 0.5f; }
- }
-
- if(cpu_id.fid.bits.eist) {
- rdmsr(0x198, msr_lo, msr_hi);
- coef_now = ((msr_lo >> 8) & 0x1F);
- if ((msr_lo >> 14) & 0x1) { coef_now = coef_now + 0.5f; }
- } else {
- rdmsr(0x2A, msr_lo, msr_hi);
- coef_now = (msr_lo >> 22) & 0x1F;
- }
- if(coef_max && coef_now) {
- el_org = (ulong)(el_org * coef_now / coef_max);
- }
- return el_org;
-}
-
diff --git a/allocate_pages_test/memtest86+/bios/lib.c b/allocate_pages_test/memtest86+/bios/lib.c
deleted file mode 100644
index c313be7..0000000
--- a/allocate_pages_test/memtest86+/bios/lib.c
+++ /dev/null
@@ -1,1223 +0,0 @@
-/* lib.c - MemTest-86 Version 3.4
- *
- * Released under version 2 of the Gnu Public License.
- * By Chris Brady
- */
-#include "io.h"
-#include "serial.h"
-#include "test.h"
-#include "config.h"
-#include "screen_buffer.h"
-#include "stdint.h"
-#include "cpuid.h"
-#include "smp.h"
-
-#include "logger.h"
-
-
-int slock = 0, lsr = 0;
-short serial_cons = SERIAL_CONSOLE_DEFAULT;
-
-#if SERIAL_TTY != 0 && SERIAL_TTY != 1
-#error Bad SERIAL_TTY. Only ttyS0 and ttyS1 are supported.
-#endif
-
-short serial_tty = SERIAL_TTY;
-const short serial_base_ports[] = {0x3f8, 0x2f8};
-
-#if ((115200%SERIAL_BAUD_RATE) != 0)
-#error Bad default baud rate
-#endif
-
-extern short logflag;
-
-int serial_baud_rate = SERIAL_BAUD_RATE;
-unsigned char serial_parity = 0;
-unsigned char serial_bits = 8;
-
-struct ascii_map_str {
- int ascii;
- int keycode;
-};
-
-void reboot(void)
-{
-
- /* tell the BIOS to do a cold start */
- *((unsigned short *)0x472) = 0x0;
-
- while(1)
- {
- outb(0xFE, 0x64);
- outb(0x02, 0xcf9); /* reset that doesn't rely on the keyboard controller */
- outb(0x04, 0xcf9);
- outb(0x0E, 0xcf9);
- }
-}
-
-int mt86_strlen(char * string){
- int i=0;
- while(*string++){i++;};
- return i;
-}
-
-int mt86_strstr(char *haystack, char * needle)
-{
- int i=0,j=0;
- int here=0;
- while(1){
- if(needle[i]==haystack[j])
- {
- if(here==0)
- here=j;
- i++;j++;
- if(i>=mt86_strlen(needle))
- {
- return here;
- }
- if(j>=mt86_strlen(haystack))
- {
- return -1;
- }
- } else {
- j++;i=0;here=0;
- }
- }
-}
-
-int mt86_memcmp(const void *s1, const void *s2, ulong count)
-{
- const unsigned char *src1 = s1, *src2 = s2;
- int i;
- for(i = 0; i < count; i++) {
- if (src1[i] != src2[i]) {
- return (int)src1[i] - (int)src2[i];
- }
- }
- return 0;
-}
-
-int mt86_strncmp(const char *s1, const char *s2, ulong n) {
- signed char res = 0;
- while (n) {
- res = *s1 - *s2;
- if (res != 0)
- return res;
- if (*s1 == '\0')
- return 0;
- ++s1, ++s2;
- --n;
- }
- return res;
-}
-
-void *mt86_memmove(void *dest, const void *src, ulong n)
-{
- long i;
- char *d = (char *)dest, *s = (char *)src;
-
- /* If src == dest do nothing */
- if (dest < src) {
- for(i = 0; i < n; i++) {
- d[i] = s[i];
- }
- }
- else if (dest > src) {
- for(i = n -1; i >= 0; i--) {
- d[i] = s[i];
- }
- }
- return dest;
-}
-
-char toupper(char c)
-{
- if (c >= 'a' && c <= 'z')
- return c + 'A' -'a';
- else
- return c;
-}
-
-int mt86_isdigit(char c)
-{
- return c >= '0' && c <= '9';
-}
-
-int isxdigit(char c)
-{
- return mt86_isdigit(c) || (toupper(c) >= 'A' && toupper(c) <= 'F'); }
-
-unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) {
- unsigned long result = 0, value;
-
- if (!base) {
- base = 10;
- if (*cp == '0') {
- base = 8;
- cp++;
- if (toupper(*cp) == 'X' && isxdigit(cp[1])) {
- cp++;
- base = 16;
- }
- }
- } else if (base == 16) {
- if (cp[0] == '0' && toupper(cp[1]) == 'X')
- cp += 2;
- }
- while (isxdigit(*cp) &&
- (value = mt86_isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) {
- result = result*base + value;
- cp++;
- }
- if (endp)
- *endp = (char *)cp;
- return result;
-}
-
-/*
- * Scroll the error message area of the screen as needed
- * Starts at line LINE_SCROLL and ends at line 23
- */
-void scroll(void)
-{
- int i, j;
- char *s, tmp;
-
- /* Only scroll if at the bottom of the screen */
- if (vv->msg_line < 23) {
- vv->msg_line++;
- } else {
- /* If scroll lock is on, loop till it is cleared */
- while (slock) {
- check_input();
- }
- for (i=LINE_SCROLL; i<23; i++) {
- s = (char *)(uintptr_t)(SCREEN_ADR + ((i+1) * 160));
- for (j=0; j<160; j+=2, s+=2) {
- *(s-160) = *s;
- tmp = get_scrn_buf(i+1, j/2);
- set_scrn_buf(i, j/2, tmp);
- }
- }
- /* Clear the newly opened line */
- s = (char *)(SCREEN_ADR + (23 * 160));
- for (j=0; j<80; j++) {
- *s = ' ';
- set_scrn_buf(23, j, ' ');
- s += 2;
- }
- tty_print_region(LINE_SCROLL, 0, 23, 79);
- }
-}
-
-/*
- * Clear scroll region
- */
-void clear_scroll(void)
-{
- int i;
- char *s;
-
- s = (char*)(SCREEN_ADR+LINE_HEADER*160);
- for(i=0; i<80*(24-LINE_HEADER); i++) {
- *s++ = ' ';
- *s++ = 0x17;
- }
-}
-
-/*
- * Place a single character on screen
- */
-void cplace(int y, int x, const char c)
-{
- char *dptr;
-
- dptr = (char *)(uintptr_t)(SCREEN_ADR + (160*y) + (2*x));
- *dptr = c;
-}
-
-
-void itoa(char s[], int n)
-{
- int i, sign;
-
- if((sign = n) < 0)
- n = -n;
- i=0;
- do {
- s[i++] = n % 10 + '0';
- } while ((n /= 10) > 0);
- if(sign < 0)
- s[i++] = '-';
- s[i] = '\0';
- reverse(s);
-}
-
-void reverse(char s[])
-{
- int c, i, j;
- for(j = 0; s[j] != 0; j++)
- ;
-
- for(i=0, j = j - 1; i < j; i++, j--) {
- c = s[i];
- s[i] = s[j];
- s[j] = c;
- }
-}
-void memcpy (void *dst, void *src, int len)
-{
- char *s = (char*)src;
- char *d = (char*)dst;
- int i;
-
- if (len <= 0) {
- return;
- }
- for (i = 0 ; i < len; i++) {
- *d++ = *s++;
- }
-}
-
-/*
- * Print a people friendly address
- */
-void aprint(int y, int x, ulong page)
-{
- /* page is in multiples of 4K */
- if ((page << 2) < 9999) {
- dprint(y, x, page << 2, 4, 0);
- cprint(y, x+4, "K");
- }
- else if ((page >>8) < 9999) {
- dprint(y, x, (page + (1 << 7)) >> 8, 4, 0);
- cprint(y, x+4, "M");
- }
- else if ((page >>18) < 9999) {
- dprint(y, x, (page + (1 << 17)) >> 18, 4, 0);
- cprint(y, x+4, "G");
- }
- else {
- dprint(y, x, (page + (1 << 27)) >> 28, 4, 0);
- cprint(y, x+4, "T");
- }
-}
-
-/*
- * Print a decimal number on screen
- */
-void dprint(int y, int x, ulong val, int len, int right)
-{
- ulong j, k;
- int i, flag=0;
- char buf[18];
-
- if (val > 999999999 || len > 9) {
- return;
- }
- for(i=0, j=1; i<len-1; i++) {
- j *= 10;
- }
- if (!right) {
- for (i=0; j>0; j/=10) {
- k = val/j;
- if (k > 9) {
- j *= 100;
- continue;
- }
- if (flag || k || j == 1) {
- buf[i++] = k + '0';
- flag++;
- } else {
- buf[i++] = ' ';
- }
- val -= k * j;
- }
- } else {
- for(i=0; i<len; j/=10) {
- if (j) {
- k = val/j;
- if (k > 9) {
- j *= 100;
- len++;
- continue;
- }
- if (k == 0 && flag == 0) {
- continue;
- }
- buf[i++] = k + '0';
- val -= k * j;
- } else {
- if (flag == 0 && i < len-1) {
- buf[i++] = '0';
- } else {
- buf[i++] = ' ';
- }
- }
- flag++;
- }
- }
- buf[i] = 0;
- cprint(y,x,buf);
-}
-
-/*
- * Print a hex number on screen at least digits long
- */
-void hprint2(int y,int x, unsigned long val, int digits)
-{
- unsigned long j;
- int i, idx, flag = 0;
- char buf[18];
-
- for (i=0, idx=0; i<8; i++) {
- j = val >> (28 - (4 * i));
- j &= 0xf;
- if (j < 10) {
- if (flag || j || i == 7) {
- buf[idx++] = j + '0';
- flag++;
- } else {
- buf[idx++] = '0';
- }
- } else {
- buf[idx++] = j + 'a' - 10;
- flag++;
- }
- }
- if (digits > 8) {
- digits = 8;
- }
- if (flag > digits) {
- digits = flag;
- }
- buf[idx] = 0;
- cprint(y,x,buf + (idx - digits));
-}
-
-/*
- * Print a hex number on screen exactly digits long
- */
-void hprint3(int y,int x, unsigned long val, int digits)
-{
- unsigned long j;
- int i, idx, flag = 0;
- char buf[18];
-
- for (i=0, idx=0; i<digits; i++) {
- j = 0xf & val;
- val /= 16;
-
- if (j < 10) {
- if (flag || j || i == 7) {
- buf[digits - ++idx] = j + '0';
- flag++;
- } else {
- buf[digits - ++idx] = '0';
- }
- } else {
- buf[digits - ++idx] = j + 'a' - 10;
- flag++;
- }
- }
- buf[idx] = 0;
- cprint(y,x,buf);
-}
-
-/*
- * Print a hex number on screen
- */
-void hprint(int y, int x, unsigned long val)
-{
- return hprint2(y, x, val, 8);
-}
-
-/*
- * Print an address in 0000m0000k0000 notation
- */
-void xprint(int y,int x, ulong val)
-{
- ulong j;
-
- j = (val & 0xffc00000) >> 20;
- dprint(y, x, j, 4, 0);
- cprint(y, x+4, "m");
- j = (val & 0xffc00) >> 10;
- dprint(y, x+5, j, 4, 0);
- cprint(y, x+9, "k");
- j = val & 0x3ff;
- dprint(y, x+10, j, 4, 0);
-}
-
-char *codes[] = {
- " Divide",
- " Debug",
- " NMI",
- " Brkpnt",
- "Overflow",
- " Bound",
- " Inv_Op",
- " No_Math",
- "Double_Fault",
- "Seg_Over",
- " Inv_TSS",
- " Seg_NP",
- "Stack_Fault",
- "Gen_Prot",
- "Page_Fault",
- " Resvd",
- " FPE",
- "Alignment",
- " Mch_Chk",
- "SIMD FPE"
-};
-
-struct eregs {
- ulong ss;
- ulong ds;
- ulong esp;
- ulong ebp;
- ulong esi;
- ulong edi;
- ulong edx;
- ulong ecx;
- ulong ebx;
- ulong eax;
- ulong vect;
- ulong code;
- ulong eip;
- ulong cs;
- ulong eflag;
-};
-
-/* Handle an interrupt */
-void inter(struct eregs *trap_regs)
-{
- int i, line;
- unsigned char *pp;
- ulong address = 0;
- int my_cpu_num = smp_my_cpu_num();
-
- /* Get the page fault address */
- if (trap_regs->vect == 14) {
- __asm__("movl %%cr2,%0":"=r" (address));
- }
-#ifdef PARITY_MEM
-
- /* Check for a parity error */
- if (trap_regs->vect == 2) {
- parity_err(trap_regs->edi, trap_regs->esi);
- return;
- }
-#endif
-
- /* clear scrolling region */
- pp=(unsigned char *)(SCREEN_ADR+(2*80*(LINE_SCROLL-2)));
- for(i=0; i<2*80*(24-LINE_SCROLL-2); i++, pp+=2) {
- *pp = ' ';
- }
- line = LINE_SCROLL-2;
-
- cprint(line, 0, "Unexpected Interrupt - Halting CPU");
- dprint(line, COL_MID + 4, my_cpu_num, 2, 1);
- cprint(line+2, 0, " Type: ");
- if (trap_regs->vect <= 19) {
- cprint(line+2, 7, codes[trap_regs->vect]);
- } else {
- hprint(line+2, 7, trap_regs->vect);
- }
- cprint(line+3, 0, " PC: ");
- hprint(line+3, 7, trap_regs->eip);
- cprint(line+4, 0, " CS: ");
- hprint(line+4, 7, trap_regs->cs);
- cprint(line+5, 0, "Eflag: ");
- hprint(line+5, 7, trap_regs->eflag);
- cprint(line+6, 0, " Code: ");
- hprint(line+6, 7, trap_regs->code);
- cprint(line+7, 0, " DS: ");
- hprint(line+7, 7, trap_regs->ds);
- cprint(line+8, 0, " SS: ");
- hprint(line+8, 7, trap_regs->ss);
- if (trap_regs->vect == 14) {
- /* Page fault address */
- cprint(line+7, 0, " Addr: ");
- hprint(line+7, 7, address);
- }
-
- cprint(line+2, 20, "eax: ");
- hprint(line+2, 25, trap_regs->eax);
- cprint(line+3, 20, "ebx: ");
- hprint(line+3, 25, trap_regs->ebx);
- cprint(line+4, 20, "ecx: ");
- hprint(line+4, 25, trap_regs->ecx);
- cprint(line+5, 20, "edx: ");
- hprint(line+5, 25, trap_regs->edx);
- cprint(line+6, 20, "edi: ");
- hprint(line+6, 25, trap_regs->edi);
- cprint(line+7, 20, "esi: ");
- hprint(line+7, 25, trap_regs->esi);
- cprint(line+8, 20, "ebp: ");
- hprint(line+8, 25, trap_regs->ebp);
- cprint(line+9, 20, "esp: ");
- hprint(line+9, 25, trap_regs->esp);
-
- cprint(line+1, 38, "Stack:");
- for (i=0; i<10; i++) {
- hprint(line+2+i, 38, trap_regs->esp+(4*i));
- hprint(line+2+i, 47, *(ulong*)(trap_regs->esp+(4*i)));
- hprint(line+2+i, 57, trap_regs->esp+(4*(i+10)));
- hprint(line+2+i, 66, *(ulong*)(trap_regs->esp+(4*(i+10))));
- }
-
- cprint(line+11, 0, "CS:EIP: ");
- pp = (unsigned char *)trap_regs->eip;
- for(i = 0; i < 9; i++) {
- hprint2(line+11, 8+(3*i), pp[i], 2);
- }
-
- while(1) {
- check_input();
- }
-}
-
-void set_cache(int val)
-{
- switch(val) {
- case 0:
- cache_off();
- break;
- case 1:
- cache_on();
- break;
- }
-}
-
-int get_key() {
-
- if (logflag) {
- char log[] = "get_key() started.";
- print_log(log, sizeof(log) - 1);
- }
-
- int c;
-
- c = inb(0x64);
- if ((c & 1) == 0) {
- if (serial_cons) {
- int comstat;
- comstat = serial_echo_inb(UART_LSR);
- if (comstat & UART_LSR_DR) {
- c = serial_echo_inb(UART_RX);
- /* Pressing '.' has same effect as 'c'
- on a keyboard.
- Oct 056 Dec 46 Hex 2E Ascii .
- */
- return (ascii_to_keycode(c));
- }
- }
- return(0);
- }
- c = inb(0x60);
- return((c));
-}
-
-void check_input(void)
-{
- unsigned char c;
-
- if ((c = get_key())) {
- switch(c & 0x7f) {
- case 1:
- /* "ESC" key was pressed, bail out. */
- cprint(LINE_RANGE, COL_MID+23, "Halting... ");
- reboot();
- break;
- case 46:
- /* c - Configure */
- get_config();
- break;
- case 28:
- /* CR - clear scroll lock */
- slock = 0;
- footer();
- break;
- case 57:
- /* SP - set scroll lock */
- slock = 1;
- footer();
- break;
- case 0x26:
- /* ^L/L - redraw the display */
- tty_print_screen();
- break;
- }
- }
-}
-
-void footer()
-{
- cprint(24, 0, "(ESC)exit (c)configuration (SP)scroll_lock (CR)scroll_unlock");
- if (slock) {
- cprint(24, 74, "Locked");
- } else {
- cprint(24, 74, " ");
- }
-}
-
-ulong getval(int x, int y, int result_shift)
-{
- unsigned long val;
- int done;
- int c;
- int i, n;
- int base;
- int shift;
- char buf[16];
-
- for(i = 0; i < sizeof(buf)/sizeof(buf[0]); i++ ) {
- buf[i] = ' ';
- }
- buf[sizeof(buf)/sizeof(buf[0]) -1] = '\0';
-
- wait_keyup();
- done = 0;
- n = 0;
- base = 10;
- while(!done) {
- /* Read a new character and process it */
- c = get_key();
- switch(c) {
- case 0x26: /* ^L/L - redraw the display */
- tty_print_screen();
- break;
- case 0x1c: /* CR */
- /* If something has been entered we are done */
- if(n) done = 1;
- break;
- case 0x19: /* p */ buf[n] = 'p'; break;
- case 0x22: /* g */ buf[n] = 'g'; break;
- case 0x32: /* m */ buf[n] = 'm'; break;
- case 0x25: /* k */ buf[n] = 'k'; break;
- case 0x2d: /* x */
- /* Only allow 'x' after an initial 0 */
- if (n == 1 && (buf[0] == '0')) {
- buf[n] = 'x';
- }
- break;
- case 0x0e: /* BS */
- if (n > 0) {
- n -= 1;
- buf[n] = ' ';
- }
- break;
- /* Don't allow entering a number not in our current base */
- case 0x0B: if (base >= 1) buf[n] = '0'; break;
- case 0x02: if (base >= 2) buf[n] = '1'; break;
- case 0x03: if (base >= 3) buf[n] = '2'; break;
- case 0x04: if (base >= 4) buf[n] = '3'; break;
- case 0x05: if (base >= 5) buf[n] = '4'; break;
- case 0x06: if (base >= 6) buf[n] = '5'; break;
- case 0x07: if (base >= 7) buf[n] = '6'; break;
- case 0x08: if (base >= 8) buf[n] = '7'; break;
- case 0x09: if (base >= 9) buf[n] = '8'; break;
- case 0x0A: if (base >= 10) buf[n] = '9'; break;
- case 0x1e: if (base >= 11) buf[n] = 'a'; break;
- case 0x30: if (base >= 12) buf[n] = 'b'; break;
- case 0x2e: if (base >= 13) buf[n] = 'c'; break;
- case 0x20: if (base >= 14) buf[n] = 'd'; break;
- case 0x12: if (base >= 15) buf[n] = 'e'; break;
- case 0x21: if (base >= 16) buf[n] = 'f'; break;
- default:
- break;
- }
- /* Don't allow anything to be entered after a suffix */
- if (n > 0 && (
- (buf[n-1] == 'p') || (buf[n-1] == 'g') ||
- (buf[n-1] == 'm') || (buf[n-1] == 'k'))) {
- buf[n] = ' ';
- }
- /* If we have entered a character increment n */
- if (buf[n] != ' ') {
- n++;
- }
- buf[n] = ' ';
- /* Print the current number */
- cprint(x, y, buf);
-
- /* Find the base we are entering numbers in */
- base = 10;
- if ((buf[0] == '0') && (buf[1] == 'x')) {
- base = 16;
- }
- else if (buf[0] == '0') {
- base = 8;
- }
- }
- /* Compute our current shift */
- shift = 0;
- switch(buf[n-1]) {
- case 'g': /* gig */ shift = 30; break;
- case 'm': /* meg */ shift = 20; break;
- case 'p': /* page */ shift = 12; break;
- case 'k': /* kilo */ shift = 10; break;
- }
- shift -= result_shift;
-
- /* Compute our current value */
- val = simple_strtoul(buf, 0, base);
- if (shift > 0) {
- if (shift >= 32) {
- val = 0xffffffff;
- } else {
- val <<= shift;
- }
- } else {
- if (-shift >= 32) {
- val = 0;
- }
- else {
- val >>= -shift;
- }
- }
- return val;
-}
-
-void ttyprint(int y, int x, const char *p)
-{
- static char sx[3];
- static char sy[3];
-
- sx[0]='\0';
- sy[0]='\0';
- x++; y++;
- itoa(sx, x);
- itoa(sy, y);
- serial_echo_print("[");
- serial_echo_print(sy);
- serial_echo_print(";");
- serial_echo_print(sx);
- serial_echo_print("H");
- serial_echo_print(p);
-}
-
-void serial_echo_init(void)
-{
- int comstat, serial_div;
- unsigned char lcr;
-
- /* read the Divisor Latch */
- comstat = serial_echo_inb(UART_LCR);
- serial_echo_outb(comstat | UART_LCR_DLAB, UART_LCR);
- /*hi =*/ serial_echo_inb(UART_DLM);
- /*lo =*/ serial_echo_inb(UART_DLL);
- serial_echo_outb(comstat, UART_LCR);
-
- /* now do hardwired init */
- lcr = serial_parity | (serial_bits - 5);
- serial_echo_outb(lcr, UART_LCR); /* No parity, 8 data bits, 1 stop */
- serial_div = 115200 / serial_baud_rate;
- serial_echo_outb(0x80|lcr, UART_LCR); /* Access divisor latch */
- serial_echo_outb(serial_div & 0xff, UART_DLL); /* baud rate divisor */
- serial_echo_outb((serial_div >> 8) & 0xff, UART_DLM);
- serial_echo_outb(lcr, UART_LCR); /* Done with divisor */
-
- /* Prior to disabling interrupts, read the LSR and RBR
- * registers */
- comstat = serial_echo_inb(UART_LSR); /* COM? LSR */
- comstat = serial_echo_inb(UART_RX); /* COM? RBR */
- serial_echo_outb(0x00, UART_IER); /* Disable all interrupts */
-
- clear_screen_buf();
-
- return;
-}
-
-/*
- * Get_number of digits
- */
-int getnum(ulong val)
-{
- int len = 0;
- int i = 1;
-
- while(i <= val)
- {
- len++;
- i *= 10;
- }
-
- return len;
-
-}
-
-
-void serial_echo_print(const char *p)
-{
- if (!serial_cons) {
- return;
- }
- /* Now, do each character */
- while (*p) {
- WAIT_FOR_XMITR;
-
- /* Send the character out. */
- serial_echo_outb(*p, UART_TX);
- if(*p==10) {
- WAIT_FOR_XMITR;
- serial_echo_outb(13, UART_TX);
- }
- p++;
- }
-}
-
-/* Except for multi-character key sequences this mapping
- * table is complete. So it should not need to be updated
- * when new keys are searched for. However the key handling
- * should really be turned around and only in get_key should
- * we worry about the exact keycode that was pressed. Everywhere
- * else we should switch on the character...
- */
-struct ascii_map_str ser_map[] =
- /*ascii keycode ascii keycode*/
- {
- /* Special cases come first so I can leave
- * their ``normal'' mapping in the table,
- * without it being activated.
- */
- { 27, 0x01}, /* ^[/ESC -> ESC */
- { 127, 0x0e}, /* DEL -> BS */
- { 8, 0x0e}, /* ^H/BS -> BS */
- { 10, 0x1c}, /* ^L/NL -> CR */
- { 13, 0x1c}, /* ^M/CR -> CR */
- { 9, 0x0f}, /* ^I/TAB -> TAB */
- { 19, 0x39}, /* ^S -> SP */
- { 17, 28}, /* ^Q -> CR */
-
- { ' ', 0x39}, /* SP -> SP */
- { 'a', 0x1e},
- { 'A', 0x1e},
- { 1, 0x1e}, /* ^A -> A */
- { 'b', 0x30},
- { 'B', 0x30},
- { 2, 0x30}, /* ^B -> B */
- { 'c', 0x2e},
- { 'C', 0x2e},
- { 3, 0x2e}, /* ^C -> C */
- { 'd', 0x20},
- { 'D', 0x20},
- { 4, 0x20}, /* ^D -> D */
- { 'e', 0x12},
- { 'E', 0x12},
- { 5, 0x12}, /* ^E -> E */
- { 'f', 0x21},
- { 'F', 0x21},
- { 6, 0x21}, /* ^F -> F */
- { 'g', 0x22},
- { 'G', 0x22},
- { 7, 0x22}, /* ^G -> G */
- { 'h', 0x23},
- { 'H', 0x23},
- { 8, 0x23}, /* ^H -> H */
- { 'i', 0x17},
- { 'I', 0x17},
- { 9, 0x17}, /* ^I -> I */
- { 'j', 0x24},
- { 'J', 0x24},
- { 10, 0x24}, /* ^J -> J */
- { 'k', 0x25},
- { 'K', 0x25},
- { 11, 0x25}, /* ^K -> K */
- { 'l', 0x26},
- { 'L', 0x26},
- { 12, 0x26}, /* ^L -> L */
- { 'm', 0x32},
- { 'M', 0x32},
- { 13, 0x32}, /* ^M -> M */
- { 'n', 0x31},
- { 'N', 0x31},
- { 14, 0x31}, /* ^N -> N */
- { 'o', 0x18},
- { 'O', 0x18},
- { 15, 0x18}, /* ^O -> O */
- { 'p', 0x19},
- { 'P', 0x19},
- { 16, 0x19}, /* ^P -> P */
- { 'q', 0x10},
- { 'Q', 0x10},
- { 17, 0x10}, /* ^Q -> Q */
- { 'r', 0x13},
- { 'R', 0x13},
- { 18, 0x13}, /* ^R -> R */
- { 's', 0x1f},
- { 'S', 0x1f},
- { 19, 0x1f}, /* ^S -> S */
- { 't', 0x14},
- { 'T', 0x14},
- { 20, 0x14}, /* ^T -> T */
- { 'u', 0x16},
- { 'U', 0x16},
- { 21, 0x16}, /* ^U -> U */
- { 'v', 0x2f},
- { 'V', 0x2f},
- { 22, 0x2f}, /* ^V -> V */
- { 'w', 0x11},
- { 'W', 0x11},
- { 23, 0x11}, /* ^W -> W */
- { 'x', 0x2d},
- { 'X', 0x2d},
- { 24, 0x2d}, /* ^X -> X */
- { 'y', 0x15},
- { 'Y', 0x15},
- { 25, 0x15}, /* ^Y -> Y */
- { 'z', 0x2c},
- { 'Z', 0x2c},
- { 26, 0x2c}, /* ^Z -> Z */
- { '-', 0x0c},
- { '_', 0x0c},
- { 31, 0x0c}, /* ^_ -> _ */
- { '=', 0x0c},
- { '+', 0x0c},
- { '[', 0x1a},
- { '{', 0x1a},
- { 27, 0x1a}, /* ^[ -> [ */
- { ']', 0x1b},
- { '}', 0x1b},
- { 29, 0x1b}, /* ^] -> ] */
- { ';', 0x27},
- { ':', 0x27},
- { '\'', 0x28},
- { '"', 0x28},
- { '`', 0x29},
- { '~', 0x29},
- { '\\', 0x2b},
- { '|', 0x2b},
- { 28, 0x2b}, /* ^\ -> \ */
- { ',', 0x33},
- { '<', 0x33},
- { '.', 0x34},
- { '>', 0x34},
- { '/', 0x35},
- { '?', 0x35},
- { '1', 0x02},
- { '!', 0x02},
- { '2', 0x03},
- { '@', 0x03},
- { '3', 0x04},
- { '#', 0x04},
- { '4', 0x05},
- { '$', 0x05},
- { '5', 0x06},
- { '%', 0x06},
- { '6', 0x07},
- { '^', 0x07},
- { 30, 0x07}, /* ^^ -> 6 */
- { '7', 0x08},
- { '&', 0x08},
- { '8', 0x09},
- { '*', 0x09},
- { '9', 0x0a},
- { '(', 0x0a},
- { '0', 0x0b},
- { ')', 0x0b},
- { 0, 0}
- };
-
-/*
- * Given an ascii character, return the keycode
- *
- * Uses ser_map definition above.
- *
- * It would be more efficient to use an array of 255 characters
- * and directly index into it.
- */
-int ascii_to_keycode (int in)
-{
- struct ascii_map_str *p;
- for (p = ser_map; p->ascii; p++) {
- if (in ==p->ascii)
- return p->keycode;
- }
- return 0;
-}
-
-/*
- * Call this when you want to wait for the user to lift the
- * finger off of a key. It is a noop if you are using a
- * serial console.
- */
-void wait_keyup( void ) {
- /* Check to see if someone lifted the keyboard key */
- while (1) {
- if ((get_key() & 0x80) != 0) {
- return;
- }
- /* Trying to simulate waiting for a key release with
- * the serial port is to nasty to let live.
- * In particular some menus don't even display until
- * you release the key that caused to to get there.
- * With the serial port this results in double pressing
- * or something worse for just about every key.
- */
- if (serial_cons) {
- return;
- }
- }
-}
-
-/*
- * Handles "console=<param>" command line option
- *
- * Examples of accepted params:
- * ttyS0
- * ttyS1
- * ttyS0,115200
- * ttyS0,9600e8
- */
-void serial_console_setup(char *param)
-{
- char *option, *end;
- unsigned long tty;
- unsigned long baud_rate;
- unsigned char parity, bits;
-
- if (mt86_strncmp(param, "ttyS", 4)) {
- print_log("4", 2);
- return; /* not a serial port */
- }
-
- param += 4;
-
- tty = simple_strtoul(param, &option, 10);
-
- if (option == param) {
- print_log("4", 2);
- return; /* there were no digits */
- }
-
- if (tty > 1) {
- print_log("4", 2);
- return; /* only ttyS0 and ttyS1 supported */
- }
-
- if (*option == '\0' || *option == ' ') {
- print_log("4", 2);
- goto save_tty; /* no options given, just ttyS? */
- }
-
- if (*option != ',') {
- print_log("4", 2);
- return; /* missing the comma separator */
- }
-
- /* baud rate must follow */
- option++;
- baud_rate = simple_strtoul(option, &end, 10);
-
- if (end == option){
- print_log("4", 2);
- return; /* no baudrate after comma */
- }
-
- if (baud_rate == 0 || (115200 % baud_rate) != 0) {
- print_log("4", 2);
- return; /* wrong baud rate */
- }
-
- if (*end == '\0' || *end == ' ') {
- print_log("4", 2);
- goto save_baud_rate; /* no more options given */
- }
-
- switch (toupper(*end)) {
- case 'N':
- parity = 0;
- break;
- case 'O':
- parity = UART_LCR_PARITY;
- break;
- case 'E':
- parity = UART_LCR_PARITY | UART_LCR_EPAR;
- break;
- default:
- /* Unknown parity */
- print_log("4", 2);
- return;
- }
-
- end++;
- if (*end == '\0' || *end == ' ') {
- print_log("4", 2);
- goto save_parity;
- }
-
- /* word length (bits) */
- if (*end < '7' || *end > '8') {
- print_log("4", 2);
- return; /* invalid number of bits */
- }
-
- bits = *end - '0';
-
- end++;
-
- if (*end != '\0' || *end != ' ') {
- print_log("4", 2);
- return; /* garbage at the end */
- }
-
- serial_bits = bits;
- save_parity:
- serial_parity = parity;
- print_log("3", 2);
- save_baud_rate:
- serial_baud_rate = (int) baud_rate;
- print_log("3", 2);
- save_tty:
- serial_tty = (short) tty;
- serial_cons = 1;
- print_log("3", 2);
-}
-
-/* Get a comma seperated list of numbers */
-void get_list(int x, int y, int len, char *buf)
-{
- int c, n = 0;
-
- len--;
- wait_keyup();
- while(1) {
- /* Read a new character and process it */
- c = get_key();
- switch(c) {
- case 0x1c: /* CR */
- /* If something has been entered we are done */
- if(n) {
- buf[n] = 0;
- return;
- }
- break;
- case 0x0e: /* BS */
- if (n > 0) {
- n -= 1;
- buf[n] = ' ';
- }
- break;
- case 0x0B: buf[n++] = '0'; break;
- case 0x02: buf[n++] = '1'; break;
- case 0x03: buf[n++] = '2'; break;
- case 0x04: buf[n++] = '3'; break;
- case 0x05: buf[n++] = '4'; break;
- case 0x06: buf[n++] = '5'; break;
- case 0x07: buf[n++] = '6'; break;
- case 0x08: buf[n++] = '7'; break;
- case 0x09: buf[n++] = '8'; break;
- case 0x0a: buf[n++] = '9'; break;
- case 0x33: buf[n++] = ','; break;
- }
- cprint(x, y, buf);
- if (n >= len) {
- buf[n] = 0;
- return;
- }
- }
-}
diff --git a/allocate_pages_test/memtest86+/bios/linuxbios.c b/allocate_pages_test/memtest86+/bios/linuxbios.c
deleted file mode 100644
index 4804b31..0000000
--- a/allocate_pages_test/memtest86+/bios/linuxbios.c
+++ /dev/null
@@ -1,165 +0,0 @@
-#include "linuxbios_tables.h"
-#include "test.h"
-
-static unsigned long ip_compute_csum(void *addr, unsigned long length)
-{
- uint16_t *ptr;
- unsigned long sum;
- unsigned long len;
- unsigned long laddr;
- /* compute an ip style checksum */
- laddr = (unsigned long )addr;
- sum = 0;
- if (laddr & 1) {
- uint16_t buffer;
- unsigned char *ptr;
- /* copy the first byte into a 2 byte buffer.
- * This way automatically handles the endian question
- * of which byte (low or high) the last byte goes in.
- */
- buffer = 0;
- ptr = addr;
- mt86_memmove(&buffer, ptr, 1);
- sum += buffer;
- if (sum > 0xFFFF)
- sum -= 0xFFFF;
- length -= 1;
- addr = ptr +1;
-
- }
- len = length >> 1;
- ptr = addr;
- while (len--) {
- sum += *(ptr++);
- if (sum > 0xFFFF)
- sum -= 0xFFFF;
- }
- addr = ptr;
- if (length & 1) {
- uint16_t buffer;
- unsigned char *ptr;
- /* copy the last byte into a 2 byte buffer.
- * This way automatically handles the endian question
- * of which byte (low or high) the last byte goes in.
- */
- buffer = 0;
- ptr = addr;
- mt86_memmove(&buffer, ptr, 1);
- sum += buffer;
- if (sum > 0xFFFF)
- sum -= 0xFFFF;
- }
- return (~sum) & 0xFFFF;
-
-}
-
-#define for_each_lbrec(head, rec) \
- for(rec = (struct lb_record *)(((char *)head) + sizeof(*head)); \
- (((char *)rec) < (((char *)head) + sizeof(*head) + head->table_bytes)) && \
- (rec->size >= 1) && \
- ((((char *)rec) + rec->size) <= (((char *)head) + sizeof(*head) + head->table_bytes)); \
- rec = (struct lb_record *)(((char *)rec) + rec->size))
-
-
-static int count_lb_records(struct lb_header *head)
-{
- struct lb_record *rec;
- int count;
- count = 0;
- for_each_lbrec(head, rec) {
- count++;
- }
- return count;
-}
-
-static struct lb_header * __find_lb_table(unsigned long start, unsigned long end)
-{
- unsigned long addr;
- /* For now be stupid.... */
- for(addr = start; addr < end; addr += 16) {
- struct lb_header *head = (struct lb_header *)addr;
- struct lb_record *recs = (struct lb_record *)(addr + sizeof(*head));
- if (mt86_memcmp(head->signature, "LBIO", 4) != 0)
- continue;
- if (head->header_bytes != sizeof(*head))
- continue;
- if (ip_compute_csum((unsigned char *)head, sizeof(*head)) != 0)
- continue;
- if (ip_compute_csum((unsigned char *)recs, head->table_bytes)
- != head->table_checksum)
- continue;
- if (count_lb_records(head) != head->table_entries)
- continue;
- return head;
- };
- return 0;
-}
-
-static struct lb_header * find_lb_table(void)
-{
- struct lb_header *head;
- head = 0;
- if (!head) {
- /* First try at address 0 */
- head = __find_lb_table(0x00000, 0x1000);
- }
- if (!head) {
- /* Then try at address 0xf0000 */
- head = __find_lb_table(0xf0000, 0x100000);
- }
- return head;
-}
-
-int query_linuxbios(void)
-{
- struct lb_header *head;
- struct lb_record *rec;
- struct lb_memory *mem;
- struct lb_forward *forward;
- int i, entries;
-
- head = find_lb_table();
- if (!head) {
- return 0;
- }
-
- /* coreboot also can forward the table to the high tables area. */
- rec = (struct lb_record *)(((char *)head) + sizeof(*head));
- if (rec->tag == LB_TAG_FORWARD) {
- forward = (struct lb_forward *)rec;
- head = (struct lb_header *)(unsigned long)(forward->forward);
- if (!head) { return 0; }
- }
-
- mem = 0;
- for_each_lbrec(head, rec) {
- if (rec->tag == LB_TAG_MEMORY) {
- mem = (struct lb_memory *)rec;
- break;
- }
- }
- if (!mem) {
- return 1;
- }
- entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
- if (entries == 0)
- return 1;
- mem_info.e820_nr = 0;
- for(i = 0; i < entries; i++) {
- unsigned long long start;
- unsigned long long size;
- unsigned long type;
- if (i >= E820MAX) {
- break;
- }
- start = mem->map[i].start;
- size = mem->map[i].size;
- type = (mem->map[i].type == LB_MEM_RAM)?E820_RAM: E820_RESERVED;
- mem_info.e820[mem_info.e820_nr].addr = start;
- mem_info.e820[mem_info.e820_nr].size = size;
- mem_info.e820[mem_info.e820_nr].type = type;
- mem_info.e820_nr++;
- }
- return 1;
-}
-
diff --git a/allocate_pages_test/memtest86+/bios/linuxbios_tables.h b/allocate_pages_test/memtest86+/bios/linuxbios_tables.h
deleted file mode 100644
index 38f2038..0000000
--- a/allocate_pages_test/memtest86+/bios/linuxbios_tables.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef LINUXBIOS_TABLES_H
-#define LINUXBIOS_TABLES_H
-
-#include "stdint.h"
-
-/* The linuxbios table information is for conveying information
- * from the firmware to the loaded OS image. Primarily this
- * is expected to be information that cannot be discovered by
- * other means, such as quering the hardware directly.
- *
- * All of the information should be Position Independent Data.
- * That is it should be safe to relocated any of the information
- * without it's meaning/correctnes changing. For table that
- * can reasonably be used on multiple architectures the data
- * size should be fixed. This should ease the transition between
- * 32 bit and 64 bit architectures etc.
- *
- * The completeness test for the information in this table is:
- * - Can all of the hardware be detected?
- * - Are the per motherboard constants available?
- * - Is there enough to allow a kernel to run that was written before
- * a particular motherboard is constructed? (Assuming the kernel
- * has drivers for all of the hardware but it does not have
- * assumptions on how the hardware is connected together).
- *
- * With this test it should be straight forward to determine if a
- * table entry is required or not. This should remove much of the
- * long term compatibility burden as table entries which are
- * irrelevant or have been replaced by better alternatives may be
- * dropped. Of course it is polite and expidite to include extra
- * table entries and be backwards compatible, but it is not required.
- */
-
-
-struct lb_header
-{
- uint8_t signature[4]; /* LBIO */
- uint32_t header_bytes;
- uint32_t header_checksum;
- uint32_t table_bytes;
- uint32_t table_checksum;
- uint32_t table_entries;
-};
-
-/* Every entry in the boot enviroment list will correspond to a boot
- * info record. Encoding both type and size. The type is obviously
- * so you can tell what it is. The size allows you to skip that
- * boot enviroment record if you don't know what it easy. This allows
- * forward compatibility with records not yet defined.
- */
-struct lb_record {
- uint32_t tag; /* tag ID */
- uint32_t size; /* size of record (in bytes) */
-};
-
-#define LB_TAG_UNUSED 0x0000
-
-#define LB_TAG_MEMORY 0x0001
-#define LB_TAG_FORWARD 0x0011
-
-struct lb_memory_range {
- uint64_t start;
- uint64_t size;
- uint32_t type;
-#define LB_MEM_RAM 1
-#define LB_MEM_RESERVED 2
-
-};
-
-struct lb_memory {
- uint32_t tag;
- uint32_t size;
- struct lb_memory_range map[0];
-};
-
-#define LB_TAG_HWRPB 0x0002
-struct lb_hwrpb {
- uint32_t tag;
- uint32_t size;
- uint64_t hwrpb;
-};
-
-struct lb_forward {
- uint32_t tag;
- uint32_t size;
- uint64_t forward;
-};
-
-#endif /* LINUXBIOS_TABLES_H */
diff --git a/allocate_pages_test/memtest86+/bios/logger.c b/allocate_pages_test/memtest86+/bios/logger.c
deleted file mode 100644
index 483f745..0000000
--- a/allocate_pages_test/memtest86+/bios/logger.c
+++ /dev/null
@@ -1,6 +0,0 @@
-
-void print_log(char *msg, const int length) {
-
-}
-
-void print_pmap() {} \ No newline at end of file
diff --git a/allocate_pages_test/memtest86+/bios/main_asm.h b/allocate_pages_test/memtest86+/bios/main_asm.h
deleted file mode 100644
index 8e6efbc..0000000
--- a/allocate_pages_test/memtest86+/bios/main_asm.h
+++ /dev/null
@@ -1,49 +0,0 @@
-static inline void enable_fp_processing(void) {
- if (cpu_id.fid.bits.fpu)
- __asm__ __volatile__
- (
- "movl %%cr0, %%eax\n\t"
- "andl $0x7, %%eax\n\t"
- "movl %%eax, %%cr0\n\t"
- : :
- : "ax"
- );
- if (cpu_id.fid.bits.sse)
- __asm__ __volatile__
- (
- "movl %%cr4, %%eax\n\t"
- "orl $0x00000200, %%eax\n\t"
- "movl %%eax, %%cr4\n\t"
- : :
- : "ax"
- );
-
-}
-
-static inline void setup_mm_modes(void) {
- /* If we have PAE, turn it on */
- if (cpu_id.fid.bits.pae == 1) {
- __asm__ __volatile__
- (
- "movl %%cr4, %%eax\n\t"
- "orl $0x00000020, %%eax\n\t"
- "movl %%eax, %%cr4\n\t"
- : :
- : "ax"
- );
- cprint(LINE_TITLE+1, COL_MODE, "(PAE Mode)");
- }
- /* If this is a 64 CPU enable long mode */
- if (cpu_id.fid.bits.lm == 1) {
- __asm__ __volatile__
- (
- "movl $0xc0000080, %%ecx\n\t"
- "rdmsr\n\t"
- "orl $0x00000100, %%eax\n\t"
- "wrmsr\n\t"
- : :
- : "ax", "cx"
- );
- cprint(LINE_TITLE+1, COL_MODE, "(X64 Mode)");
- }
-} \ No newline at end of file
diff --git a/allocate_pages_test/memtest86+/bios/memory_tables.c b/allocate_pages_test/memtest86+/bios/memory_tables.c
deleted file mode 100644
index a5d40fd..0000000
--- a/allocate_pages_test/memtest86+/bios/memory_tables.c
+++ /dev/null
@@ -1,277 +0,0 @@
-static void memsize_820(void);
-static void memsize_801(void);
-static int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios, short old_nr);
-static void memsize_linuxbios();
-
-int query_memory_table(void) {
- int flag = 0;
-
- if (query_linuxbios()) {
- flag = 1;
- } else if (query_pcbios()) {
- flag = 2;
- }
-
- return flag; // TODO boolean value?
-}
-
-void get_mem_size(int flag) {
- if (flag == 1) {
- memsize_linuxbios();
- } else if (flag == 2) {
- memsize_820();
- }
-}
-
-static void memsize_linuxbios(void)
-{
- int i, n;
- /* Build the memory map for testing */
- n = 0;
- for (i=0; i < e820_nr; i++) {
- unsigned long long end;
-
- if (e820[i].type != E820_RAM) {
- continue;
- }
- end = e820[i].addr;
- end += e820[i].size;
- vv->pmap[n].start = (e820[i].addr + 4095) >> 12;
- vv->pmap[n].end = end >> 12;
- vv->test_pages += vv->pmap[n].end - vv->pmap[n].start;
- n++;
- }
- vv->msegs = n;
-}
-static void memsize_820()
-{
- int i, n, nr;
- struct e820entry nm[E820MAX];
- unsigned long long start;
- unsigned long long end;
-
- /* Clean up, adjust and copy the BIOS-supplied E820-map. */
- nr = sanitize_e820_map(e820, nm, e820_nr);
-
- /* If there is not a good 820 map use the BIOS 801/88 info */
- if (nr < 1 || nr > E820MAX) {
- memsize_801();
- return;
- }
-
- /* Build the memory map for testing */
- n = 0;
- for (i=0; i<nr; i++) {
- if (nm[i].type == E820_RAM || nm[i].type == E820_ACPI) {
- start = nm[i].addr;
- end = start + nm[i].size;
-
- /* Don't ever use memory between 640 and 1024k */
- if (start > RES_START && start < RES_END) {
- if (end < RES_END) {
- continue;
- }
- start = RES_END;
- }
- if (end > RES_START && end < RES_END) {
- end = RES_START;
- }
- vv->pmap[n].start = (start + 4095) >> 12;
- vv->pmap[n].end = end >> 12;
- vv->test_pages += vv->pmap[n].end - vv->pmap[n].start;
- n++;
-#if 0
- int epmap = 0;
- int lpmap = 0;
- if(n > 12) { epmap = 34; lpmap = -12; }
- hprint (11+n+lpmap,0+epmap,vv->pmap[n-1].start);
- hprint (11+n+lpmap,10+epmap,vv->pmap[n-1].end);
- hprint (11+n+lpmap,20+epmap,vv->pmap[n-1].end - vv->pmap[n-1].start);
- dprint (11+n+lpmap,30+epmap,nm[i].type,0,0);
-#endif
- }
- }
- vv->msegs = n;
-}
-
-static void memsize_801(void)
-{
- ulong mem_size;
-
- /* compare results from 88 and 801 methods and take the greater */
- /* These sizes are for extended memory in 1k units. */
-
- if (alt_mem_k < ext_mem_k) {
- mem_size = ext_mem_k;
- } else {
- mem_size = alt_mem_k;
- }
- /* First we map in the first 640k */
- vv->pmap[0].start = 0;
- vv->pmap[0].end = RES_START >> 12;
- vv->test_pages = RES_START >> 12;
-
- /* Now the extended memory */
- vv->pmap[1].start = (RES_END + 4095) >> 12;
- vv->pmap[1].end = (mem_size + 1024) >> 2;
- vv->test_pages += mem_size >> 2;
- vv->msegs = 2;
-}
-
-/*
- * Sanitize the BIOS e820 map.
- *
- * Some e820 responses include overlapping entries. The following
- * replaces the original e820 map with a new one, removing overlaps.
- *
- */
-static int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios,
- short old_nr)
-{
- struct change_member {
- struct e820entry *pbios; /* pointer to original bios entry */
- unsigned long long addr; /* address for this change point */
- };
- struct change_member change_point_list[2*E820MAX];
- struct change_member *change_point[2*E820MAX];
- struct e820entry *overlap_list[E820MAX];
- struct e820entry biosmap[E820MAX];
- struct change_member *change_tmp;
- ulong current_type, last_type;
- unsigned long long last_addr;
- int chgidx, still_changing;
- int overlap_entries;
- int new_bios_entry;
- int i;
-
- /*
- Visually we're performing the following (1,2,3,4 = memory types)...
- Sample memory map (w/overlaps):
- ____22__________________
- ______________________4_
- ____1111________________
- _44_____________________
- 11111111________________
- ____________________33__
- ___________44___________
- __________33333_________
- ______________22________
- ___________________2222_
- _________111111111______
- _____________________11_
- _________________4______
-
- Sanitized equivalent (no overlap):
- 1_______________________
- _44_____________________
- ___1____________________
- ____22__________________
- ______11________________
- _________1______________
- __________3_____________
- ___________44___________
- _____________33_________
- _______________2________
- ________________1_______
- _________________4______
- ___________________2____
- ____________________33__
- ______________________4_
- */
- /* First make a copy of the map */
- for (i=0; i<old_nr; i++) {
- biosmap[i].addr = orig_map[i].addr;
- biosmap[i].size = orig_map[i].size;
- biosmap[i].type = orig_map[i].type;
- }
-
- /* bail out if we find any unreasonable addresses in bios map */
- for (i=0; i<old_nr; i++) {
- if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
- return 0;
- }
-
- /* create pointers for initial change-point information (for sorting) */
- for (i=0; i < 2*old_nr; i++)
- change_point[i] = &change_point_list[i];
-
- /* record all known change-points (starting and ending addresses) */
- chgidx = 0;
- for (i=0; i < old_nr; i++) {
- change_point[chgidx]->addr = biosmap[i].addr;
- change_point[chgidx++]->pbios = &biosmap[i];
- change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
- change_point[chgidx++]->pbios = &biosmap[i];
- }
-
- /* sort change-point list by memory addresses (low -> high) */
- still_changing = 1;
- while (still_changing) {
- still_changing = 0;
- for (i=1; i < 2*old_nr; i++) {
- /* if <current_addr> > <last_addr>, swap */
- /* or, if current=<start_addr> & last=<end_addr>, swap */
- if ((change_point[i]->addr < change_point[i-1]->addr) ||
- ((change_point[i]->addr == change_point[i-1]->addr) &&
- (change_point[i]->addr == change_point[i]->pbios->addr) &&
- (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
- )
- {
- change_tmp = change_point[i];
- change_point[i] = change_point[i-1];
- change_point[i-1] = change_tmp;
- still_changing=1;
- }
- }
- }
-
- /* create a new bios memory map, removing overlaps */
- overlap_entries=0; /* number of entries in the overlap table */
- new_bios_entry=0; /* index for creating new bios map entries */
- last_type = 0; /* start with undefined memory type */
- last_addr = 0; /* start with 0 as last starting address */
- /* loop through change-points, determining affect on the new bios map */
- for (chgidx=0; chgidx < 2*old_nr; chgidx++)
- {
- /* keep track of all overlapping bios entries */
- if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
- {
- /* add map entry to overlap list (> 1 entry implies an overlap) */
- overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
- }
- else
- {
- /* remove entry from list (order independent, so swap with last) */
- for (i=0; i<overlap_entries; i++)
- {
- if (overlap_list[i] == change_point[chgidx]->pbios)
- overlap_list[i] = overlap_list[overlap_entries-1];
- }
- overlap_entries--;
- }
- /* if there are overlapping entries, decide which "type" to use */
- /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
- current_type = 0;
- for (i=0; i<overlap_entries; i++)
- if (overlap_list[i]->type > current_type)
- current_type = overlap_list[i]->type;
- /* continue building up new bios map based on this information */
- if (current_type != last_type) {
- if (last_type != 0) {
- new_bios[new_bios_entry].size =
- change_point[chgidx]->addr - last_addr;
- /* move forward only if the new size was non-zero */
- if (new_bios[new_bios_entry].size != 0)
- if (++new_bios_entry >= E820MAX)
- break; /* no more space left for new bios entries */
- }
- if (current_type != 0) {
- new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
- new_bios[new_bios_entry].type = current_type;
- last_addr=change_point[chgidx]->addr;
- }
- last_type = current_type;
- }
- }
- return(new_bios_entry);
-} \ No newline at end of file
diff --git a/allocate_pages_test/memtest86+/bios/rsdp.h b/allocate_pages_test/memtest86+/bios/rsdp.h
deleted file mode 100644
index 69403a7..0000000
--- a/allocate_pages_test/memtest86+/bios/rsdp.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// BIOS VERSION / 32-bit
-
-#define RSDPSignature ('R' | ('S' << 8) | ('D' << 16) | (' ' << 24))
-typedef struct {
- char signature[8]; // "RSD "
- uint8_t checksum;
- char oemid[6];
- uint8_t revision;
- uint32_t rsdt;
- uint32_t length;
- uint32_t xrsdt[2];
- uint8_t xsum;
-} rsdp_t; \ No newline at end of file
diff --git a/allocate_pages_test/memtest86+/bios/stdin.h b/allocate_pages_test/memtest86+/bios/stdin.h
deleted file mode 100644
index 2fe2bba..0000000
--- a/allocate_pages_test/memtest86+/bios/stdin.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef I386_STDINT_H
-#define I386_STDINT_H
-
-/* Exact integral types */
-typedef unsigned char uint8_t;
-typedef signed char int8_t;
-
-typedef unsigned short uint16_t;
-typedef signed short int16_t;
-
-typedef unsigned int uint32_t;
-typedef signed int int32_t;
-
-typedef unsigned long long uint64_t;
-typedef signed long long int64_t;
-
-/* Small types */
-typedef unsigned char uint_least8_t;
-typedef signed char int_least8_t;
-
-typedef unsigned short uint_least16_t;
-typedef signed short int_least16_t;
-
-typedef unsigned int uint_least32_t;
-typedef signed int int_least32_t;
-
-typedef unsigned long long uint_least64_t;
-typedef signed long long int_least64_t;
-
-/* Fast Types */
-typedef unsigned char uint_fast8_t;
-typedef signed char int_fast8_t;
-
-typedef unsigned int uint_fast16_t;
-typedef signed int int_fast16_t;
-
-typedef unsigned int uint_fast32_t;
-typedef signed int int_fast32_t;
-
-typedef unsigned long long uint_fast64_t;
-typedef signed long long int_fast64_t;
-
-/* Types for `void *' pointers. */
-typedef int intptr_t;
-typedef unsigned int uintptr_t;
-
-
-/* Largest integral types */
-typedef long long int intmax_t;
-typedef unsigned long long uintmax_t;
-
-
-#endif /* I386_STDINT_H */
diff --git a/allocate_pages_test/memtest86+/bios/stdint.h b/allocate_pages_test/memtest86+/bios/stdint.h
deleted file mode 100644
index 3a51041..0000000
--- a/allocate_pages_test/memtest86+/bios/stdint.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef I386_STDINT_H
-#define I386_STDINT_H
-
-/* Exact integral types */
-typedef unsigned char uint8_t;
-typedef signed char int8_t;
-
-typedef unsigned short uint16_t;
-typedef signed short int16_t;
-
-typedef unsigned int uint32_t;
-typedef signed int int32_t;
-
-typedef unsigned long long uint64_t;
-typedef signed long long int64_t;
-
-/* Small types */
-typedef unsigned char uint_least8_t;
-typedef signed char int_least8_t;
-
-typedef unsigned short uint_least16_t;
-typedef signed short int_least16_t;
-
-typedef unsigned int uint_least32_t;
-typedef signed int int_least32_t;
-
-typedef unsigned long long uint_least64_t;
-typedef signed long long int_least64_t;
-
-/* Fast Types */
-typedef unsigned char uint_fast8_t;
-typedef signed char int_fast8_t;
-
-typedef unsigned int uint_fast16_t;
-typedef signed int int_fast16_t;
-
-typedef unsigned int uint_fast32_t;
-typedef signed int int_fast32_t;
-
-typedef unsigned long long uint_fast64_t;
-typedef signed long long int_fast64_t;
-
-/* Types for `void *' pointers. */
-typedef int intptr_t;
-typedef unsigned int uintptr_t;
-
-/* Largest integral types */
-typedef long long int intmax_t;
-typedef unsigned long long uintmax_t;
-
-typedef char bool;
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#endif /* I386_STDINT_H */
diff --git a/allocate_pages_test/memtest86+/bios/test.c b/allocate_pages_test/memtest86+/bios/test.c
deleted file mode 100644
index 864dfcc..0000000
--- a/allocate_pages_test/memtest86+/bios/test.c
+++ /dev/null
@@ -1,1549 +0,0 @@
-/* test.c - MemTest-86 Version 3.4
- *
- * Released under version 2 of the Gnu Public License.
- * By Chris Brady
- * ----------------------------------------------------
- * MemTest86+ V5 Specific code (GPL V2.0)
- * By Samuel DEMEULEMEESTER, sdemeule@memtest.org
- * http://www.canardpc.com - http://www.memtest.org
- * Thanks to Passmark for calculate_chunk() and various comments !
- */
-
-#include "test.h"
-#include "config.h"
-#include "stdint.h"
-#include "cpuid.h"
-#include "smp.h"
-#include "io.h"
-
-extern struct cpu_ident cpu_id;
-extern volatile int mstr_cpu;
-extern volatile int run_cpus;
-extern volatile int test;
-extern volatile int segs, bail;
-extern int test_ticks, nticks;
-extern struct tseq tseq[];
-extern void update_err_counts(void);
-extern void print_err_counts(void);
-void rand_seed( unsigned int seed1, unsigned int seed2, int me);
-ulong rand(int me);
-void poll_errors();
-
-// NOTE(jcoiner):
-// Defining 'STATIC' to empty string results in crashes. (It should
-// work fine, of course.) I suspect relocation problems in reloc.c.
-// When we declare these routines static, we use relative addresses
-// for them instead of looking up their addresses in (supposedly
-// relocated) global elf tables, which avoids the crashes.
-
-#define STATIC static
-//#define STATIC
-
-#define PREFER_C 0
-
-static const void* const nullptr = 0x0;
-
-// Writes *start and *end with the VA range to test.
-//
-// me - this threads CPU number
-// j - index into v->map for current segment we are testing
-// align - number of bytes to align each block to
-STATIC void calculate_chunk(ulong** start, ulong** end, int me,
- int j, int makeMultipleOf) {
- ulong chunk;
-
- // If we are only running 1 CPU then test the whole block
- if (run_cpus == 1) {
- *start = vv->map[j].start;
- *end = vv->map[j].end;
- } else {
-
- // Divide the current segment by the number of CPUs
- chunk = (ulong)vv->map[j].end-(ulong)vv->map[j].start;
- chunk /= run_cpus;
-
- // Round down to the nearest desired bitlength multiple
- chunk = (chunk + (makeMultipleOf-1)) & ~(makeMultipleOf-1);
-
- // Figure out chunk boundaries
- *start = (ulong*)((ulong)vv->map[j].start+(chunk*me));
- /* Set end addrs for the highest CPU num to the
- * end of the segment for rounding errors */
- /* Also rounds down to boundary if needed, may miss some ram but
- better than crashing or producing false errors. */
- /* This rounding probably will never happen as the segments should
- be in 4096 bytes pages if I understand correctly. */
- if (me == mstr_cpu) {
- *end = (ulong*)(vv->map[j].end);
- } else {
- *end = (ulong*)((ulong)(*start) + chunk);
- (*end)--;
- }
- }
-}
-
-/* Call segment_fn() for each up-to-SPINSZ segment between
- * 'start' and 'end'.
- */
-void foreach_segment
-(ulong* start, ulong* end,
- int me, const void* ctx, segment_fn func) {
-
- ASSERT(start < end);
-
- // Confirm 'start' points to an even dword, and 'end'
- // should point to an odd dword
- ASSERT(0 == (((ulong)start) & 0x7));
- ASSERT(0x4 == (((ulong)end) & 0x7));
-
- // 'end' may be exactly 0xfffffffc, right at the 4GB boundary.
- //
- // To avoid overflow in our loop tests and length calculations,
- // use dword indices (the '_dw' vars) to avoid overflows.
- ulong start_dw = ((ulong)start) >> 2;
- ulong end_dw = ((ulong) end) >> 2;
-
- // end is always xxxxxffc, but increment end_dw to an
- // address beyond the segment for easier boundary calculations.
- ++end_dw;
-
- ulong seg_dw = start_dw;
- ulong seg_end_dw = start_dw;
-
- int done = 0;
- do {
- do_tick(me);
- { BAILR }
-
- // ensure no overflow
- ASSERT((seg_end_dw + SPINSZ_DWORDS) > seg_end_dw);
- seg_end_dw += SPINSZ_DWORDS;
-
- if (seg_end_dw >= end_dw) {
- seg_end_dw = end_dw;
- done++;
- }
- if (seg_dw == seg_end_dw) {
- break;
- }
-
- ASSERT(((ulong)seg_end_dw) <= 0x40000000);
- ASSERT(seg_end_dw > seg_dw);
- ulong seg_len_dw = seg_end_dw - seg_dw;
-
- func((ulong*)(seg_dw << 2), seg_len_dw, ctx);
-
- seg_dw = seg_end_dw;
- } while (!done);
-}
-
-/* Calls segment_fn() for each segment in vv->map.
- *
- * Does not slice by CPU number, so it covers the entire memory.
- * Contrast to sliced_foreach_segment().
- */
-STATIC void unsliced_foreach_segment
-(const void* ctx, int me, segment_fn func) {
- int j;
- for (j=0; j<segs; j++) {
- foreach_segment(vv->map[j].start,
- vv->map[j].end,
- me, ctx, func);
- }
-}
-
-/* Calls segment_fn() for each segment to be tested by CPU 'me'.
- *
- * In multicore mode, slices the segments by 'me' (the CPU ordinal
- * number) so that each call will cover only 1/Nth of memory.
- */
-STATIC void sliced_foreach_segment
-(const void *ctx, int me, segment_fn func) {
- int j;
- ulong *start, *end; // VAs
- ulong* prev_end = 0;
- for (j=0; j<segs; j++) {
- calculate_chunk(&start, &end, me, j, 64);
-
- // Ensure no overlap among chunks
- ASSERT(end > start);
- if (prev_end > 0) {
- ASSERT(prev_end < start);
- }
- prev_end = end;
-
- foreach_segment(start, end, me, ctx, func);
- }
-}
-
-STATIC void addr_tst1_seg(ulong* restrict buf,
- ulong len_dw, const void* unused) {
- // Within each segment:
- // - choose a low dword offset 'off'
- // - write pat to *off
- // - write ~pat to addresses that are above off by
- // 1, 2, 4, ... dwords up to the top of the segment. None
- // should alias to the original dword.
- // - write ~pat to addresses that are below off by
- // 1, 2, 4, etc dwords, down to the start of the segment. None
- // should alias to the original dword. If adding a given offset
- // doesn't produce a single bit address flip (because it produced
- // a carry) subtracting the same offset should give a single bit flip.
- // - repeat this, moving off ahead in increments of 1MB;
- // this covers address bits within physical memory banks, we hope?
-
- ulong pat;
- int k;
-
- for (pat=0x5555aaaa, k=0; k<2; k++) {
- hprint(LINE_PAT, COL_PAT, pat);
-
- for (ulong off_dw = 0; off_dw < len_dw; off_dw += (1 << 18)) {
- buf[off_dw] = pat;
- pat = ~pat;
-
- for (ulong more_off_dw = 1; off_dw + more_off_dw < len_dw;
- more_off_dw = more_off_dw << 1) {
- ASSERT(more_off_dw); // it should never get to zero
- buf[off_dw + more_off_dw] = pat;
- ulong bad;
- if ((bad = buf[off_dw]) != ~pat) {
- ad_err1(buf + off_dw,
- buf + off_dw + more_off_dw,
- bad, ~pat);
- break;
- }
- }
- for (ulong more_off_dw = 1; off_dw > more_off_dw;
- more_off_dw = more_off_dw << 1) {
- ASSERT(more_off_dw); // it should never get to zero
- buf[off_dw - more_off_dw] = pat;
- ulong bad;
- if ((bad = buf[off_dw]) != ~pat) {
- ad_err1(buf + off_dw,
- buf + off_dw - more_off_dw,
- bad, ~pat);
- break;
- }
- }
- }
- }
-}
-
-/*
- * Memory address test, walking ones
- */
-void addr_tst1(int me)
-{
- unsliced_foreach_segment(nullptr, me, addr_tst1_seg);
-}
-
-STATIC void addr_tst2_init_segment(ulong* p,
- ulong len_dw, const void* unused) {
- ulong* pe = p + (len_dw - 1);
-
- /* Original C code replaced with hand tuned assembly code
- * for (; p <= pe; p++) {
- * *p = (ulong)p;
- * }
- */
- asm __volatile__ (
- "jmp L91\n\t"
- ".p2align 4,,7\n\t"
- "L90:\n\t"
- "addl $4,%%edi\n\t"
- "L91:\n\t"
- "movl %%edi,(%%edi)\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L90\n\t"
- : : "D" (p), "d" (pe)
- );
-}
-
-STATIC void addr_tst2_check_segment(ulong* p,
- ulong len_dw, const void* unused) {
- ulong* pe = p + (len_dw - 1);
-
- /* Original C code replaced with hand tuned assembly code
- * for (; p <= pe; p++) {
- * if((bad = *p) != (ulong)p) {
- * ad_err2((ulong)p, bad);
- * }
- * }
- */
- asm __volatile__
- (
- "jmp L95\n\t"
- ".p2align 4,,7\n\t"
- "L99:\n\t"
- "addl $4,%%edi\n\t"
- "L95:\n\t"
- "movl (%%edi),%%ecx\n\t"
- "cmpl %%edi,%%ecx\n\t"
- "jne L97\n\t"
- "L96:\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L99\n\t"
- "jmp L98\n\t"
-
- "L97:\n\t"
- "pushl %%edx\n\t"
- "pushl %%ecx\n\t"
- "pushl %%edi\n\t"
- "call ad_err2\n\t"
- "popl %%edi\n\t"
- "popl %%ecx\n\t"
- "popl %%edx\n\t"
- "jmp L96\n\t"
-
- "L98:\n\t"
- : : "D" (p), "d" (pe)
- : "ecx"
- );
-}
-
-/*
- * Memory address test, own address
- */
-void addr_tst2(int me)
-{
- cprint(LINE_PAT, COL_PAT, "address ");
-
- /* Write each address with its own address */
- unsliced_foreach_segment(nullptr, me, addr_tst2_init_segment);
- { BAILR }
-
- /* Each address should have its own address */
- unsliced_foreach_segment(nullptr, me, addr_tst2_check_segment);
-}
-
-typedef struct {
- int me;
- ulong xorVal;
-} movinvr_ctx;
-
-STATIC void movinvr_init(ulong* p,
- ulong len_dw, const void* vctx) {
- ulong* pe = p + (len_dw - 1);
- const movinvr_ctx* ctx = (const movinvr_ctx*)vctx;
- /* Original C code replaced with hand tuned assembly code */
- /*
- for (; p <= pe; p++) {
- *p = rand(me);
- }
- */
-
- asm __volatile__
- (
- "jmp L200\n\t"
- ".p2align 4,,7\n\t"
- "L201:\n\t"
- "addl $4,%%edi\n\t"
- "L200:\n\t"
- "pushl %%ecx\n\t"
- "call rand\n\t"
- "popl %%ecx\n\t"
- "movl %%eax,(%%edi)\n\t"
- "cmpl %%ebx,%%edi\n\t"
- "jb L201\n\t"
- : : "D" (p), "b" (pe), "c" (ctx->me)
- : "eax"
- );
-}
-
-STATIC void movinvr_body(ulong* p, ulong len_dw, const void* vctx) {
- ulong* pe = p + (len_dw - 1);
- const movinvr_ctx* ctx = (const movinvr_ctx*)vctx;
-
- /* Original C code replaced with hand tuned assembly code */
-
- /*for (; p <= pe; p++) {
- num = rand(me);
- if (i) {
- num = ~num;
- }
- if ((bad=*p) != num) {
- mt86_error((ulong*)p, num, bad);
- }
- *p = ~num;
- }*/
-
- asm __volatile__
- (
- "pushl %%ebp\n\t"
-
- // Skip first increment
- "jmp L26\n\t"
- ".p2align 4,,7\n\t"
-
- // increment 4 bytes (32-bits)
- "L27:\n\t"
- "addl $4,%%edi\n\t"
-
- // Check this byte
- "L26:\n\t"
-
- // Get next random number, pass in me(edx), random value returned in num(eax)
- // num = rand(me);
- // cdecl call maintains all registers except eax, ecx, and edx
- // We maintain edx with a push and pop here using it also as an input
- // we don't need the current eax value and want it to change to the return value
- // we overwrite ecx shortly after this discarding its current value
- "pushl %%edx\n\t" // Push function inputs onto stack
- "call rand\n\t"
- "popl %%edx\n\t" // Remove function inputs from stack
-
- // XOR the random number with xorVal(ebx), which is either 0xffffffff or 0 depending on the outer loop
- // if (i) { num = ~num; }
- "xorl %%ebx,%%eax\n\t"
-
- // Move the current value of the current position p(edi) into bad(ecx)
- // (bad=*p)
- "movl (%%edi),%%ecx\n\t"
-
- // Compare bad(ecx) to num(eax)
- "cmpl %%eax,%%ecx\n\t"
-
- // If not equal jump the error case
- "jne L23\n\t"
-
- // Set a new value or not num(eax) at the current position p(edi)
- // *p = ~num;
- "L25:\n\t"
- "movl $0xffffffff,%%ebp\n\t"
- "xorl %%ebp,%%eax\n\t"
- "movl %%eax,(%%edi)\n\t"
-
- // Loop until current position p(edi) equals the end position pe(esi)
- "cmpl %%esi,%%edi\n\t"
- "jb L27\n\t"
- "jmp L24\n"
-
- // Error case
- "L23:\n\t"
- // Must manually maintain eax, ecx, and edx as part of cdecl call convention
- "pushl %%edx\n\t"
- "pushl %%ecx\n\t" // Next three pushes are functions input
- "pushl %%eax\n\t"
- "pushl %%edi\n\t"
- "call mt86_error\n\t"
- "popl %%edi\n\t" // Remove function inputs from stack and restore register values
- "popl %%eax\n\t"
- "popl %%ecx\n\t"
- "popl %%edx\n\t"
- "jmp L25\n"
-
- "L24:\n\t"
- "popl %%ebp\n\t"
- :: "D" (p), "S" (pe), "b" (ctx->xorVal),
- "d" (ctx->me)
- : "eax", "ecx"
- );
-}
-
-/*
- * Test all of memory using a "half moving inversions" algorithm using random
- * numbers and their complement as the data pattern. Since we are not able to
- * produce random numbers in reverse order testing is only done in the forward
- * direction.
- */
-void movinvr(int me)
-{
- int i, seed1, seed2;
-
- movinvr_ctx ctx;
- ctx.me = me;
- ctx.xorVal = 0;
-
- /* Initialize memory with initial sequence of random numbers. */
- if (cpu_id.fid.bits.rdtsc) {
- asm __volatile__ ("rdtsc":"=a" (seed1),"=d" (seed2));
- } else {
- seed1 = 521288629 + vv->pass;
- seed2 = 362436069 - vv->pass;
- }
-
- /* Display the current seed */
- if (mstr_cpu == me) hprint(LINE_PAT, COL_PAT, seed1);
- rand_seed(seed1, seed2, me);
-
- sliced_foreach_segment(&ctx, me, movinvr_init);
- { BAILR }
-
- /* Do moving inversions test. Check for initial pattern and then
- * write the complement for each memory location.
- */
- for (i=0; i<2; i++) {
- rand_seed(seed1, seed2, me);
-
- if (i) {
- ctx.xorVal = 0xffffffff;
- } else {
- ctx.xorVal = 0;
- }
-
- sliced_foreach_segment(&ctx, me, movinvr_body);
- { BAILR }
- }
-}
-
-typedef struct {
- ulong p1;
- ulong p2;
-} movinv1_ctx;
-
-STATIC void movinv1_init(ulong* start,
- ulong len_dw, const void* vctx) {
- const movinv1_ctx* ctx = (const movinv1_ctx*)vctx;
-
- ulong p1 = ctx->p1;
- ulong* p = start;
-
- asm __volatile__
- (
- "rep\n\t"
- "stosl\n\t"
- : : "c" (len_dw), "D" (p), "a" (p1)
- );
-}
-
-STATIC void movinv1_bottom_up(ulong* start,
- ulong len_dw, const void* vctx) {
- const movinv1_ctx* ctx = (const movinv1_ctx*)vctx;
- ulong p1 = ctx->p1;
- ulong p2 = ctx->p2;
- ulong* p = start;
- ulong* pe = p + (len_dw - 1);
-
- // Original C code replaced with hand tuned assembly code
- // seems broken
- /*for (; p <= pe; p++) {
- if ((bad=*p) != p1) {
- mt86_error((ulong*)p, p1, bad);
- }
- *p = p2;
- }*/
-
- asm __volatile__
- (
- "jmp L2\n\t"
- ".p2align 4,,7\n\t"
- "L0:\n\t"
- "addl $4,%%edi\n\t"
- "L2:\n\t"
- "movl (%%edi),%%ecx\n\t"
- "cmpl %%eax,%%ecx\n\t"
- "jne L3\n\t"
- "L5:\n\t"
- "movl %%ebx,(%%edi)\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L0\n\t"
- "jmp L4\n"
-
- "L3:\n\t"
- "pushl %%edx\n\t"
- "pushl %%ebx\n\t"
- "pushl %%ecx\n\t"
- "pushl %%eax\n\t"
- "pushl %%edi\n\t"
- "call mt86_error\n\t"
- "popl %%edi\n\t"
- "popl %%eax\n\t"
- "popl %%ecx\n\t"
- "popl %%ebx\n\t"
- "popl %%edx\n\t"
- "jmp L5\n"
-
- "L4:\n\t"
- :: "a" (p1), "D" (p), "d" (pe), "b" (p2)
- : "ecx"
- );
-}
-
-STATIC void movinv1_top_down(ulong* start,
- ulong len_dw, const void* vctx) {
- const movinv1_ctx* ctx = (const movinv1_ctx*)vctx;
- ulong p1 = ctx->p1;
- ulong p2 = ctx->p2;
- ulong* p = start + (len_dw - 1);
- ulong* pe = start;
-
- //Original C code replaced with hand tuned assembly code
- // seems broken
- /*do {
- if ((bad=*p) != p2) {
- mt86_error((ulong*)p, p2, bad);
- }
- *p = p1;
- } while (--p >= pe);*/
-
- asm __volatile__
- (
- "jmp L9\n\t"
- ".p2align 4,,7\n\t"
- "L11:\n\t"
- "subl $4, %%edi\n\t"
- "L9:\n\t"
- "movl (%%edi),%%ecx\n\t"
- "cmpl %%ebx,%%ecx\n\t"
- "jne L6\n\t"
- "L10:\n\t"
- "movl %%eax,(%%edi)\n\t"
- "cmpl %%edi, %%edx\n\t"
- "jne L11\n\t"
- "jmp L7\n\t"
-
- "L6:\n\t"
- "pushl %%edx\n\t"
- "pushl %%eax\n\t"
- "pushl %%ecx\n\t"
- "pushl %%ebx\n\t"
- "pushl %%edi\n\t"
- "call mt86_error\n\t"
- "popl %%edi\n\t"
- "popl %%ebx\n\t"
- "popl %%ecx\n\t"
- "popl %%eax\n\t"
- "popl %%edx\n\t"
- "jmp L10\n"
-
- "L7:\n\t"
- :: "a" (p1), "D" (p), "d" (pe), "b" (p2)
- : "ecx"
- );
-}
-
-/*
- * Test all of memory using a "moving inversions" algorithm using the
- * pattern in p1 and its complement in p2.
- */
-void movinv1 (int iter, ulong p1, ulong p2, int me)
-{
- int i;
-
- /* Display the current pattern */
- if (mstr_cpu == me) hprint(LINE_PAT, COL_PAT, p1);
-
- movinv1_ctx ctx;
- ctx.p1 = p1;
- ctx.p2 = p2;
- sliced_foreach_segment(&ctx, me, movinv1_init);
- { BAILR }
-
- /* Do moving inversions test. Check for initial pattern and then
- * write the complement for each memory location. Test from bottom
- * up and then from the top down. */
- for (i=0; i<iter; i++) {
- sliced_foreach_segment(&ctx, me, movinv1_bottom_up);
- { BAILR }
-
- // NOTE(jcoiner):
- // For the top-down pass, the original 5.01 code iterated over
- // 'segs' in from n-1 down to 0, and then within each mapped segment,
- // it would form the SPINSZ windows from the top down -- thus forming
- // a different set of windows than the bottom-up pass, when the segment
- // is not an integer number of windows.
- //
- // My guess is that this buys us very little additional coverage, that
- // the value in going top-down happens at the word or cache-line level
- // and that there's little to be gained from reversing the direction of
- // the outer loops. So I'm leaving a 'direction' bit off of the
- // foreach_segment() routines for now.
- sliced_foreach_segment(&ctx, me, movinv1_top_down);
- { BAILR }
- }
-}
-
-typedef struct {
- ulong p1;
- ulong lb;
- ulong hb;
- int sval;
- int off;
-} movinv32_ctx;
-
-STATIC void movinv32_init(ulong* restrict buf,
- ulong len_dw, const void* vctx) {
- const movinv32_ctx* restrict ctx = (const movinv32_ctx*)vctx;
-
- ulong* p = buf;
- ulong* pe = buf + (len_dw - 1);
-
- int k = ctx->off;
- ulong pat = ctx->p1;
- ulong lb = ctx->lb;
- int sval = ctx->sval;
-
- /* Original C code replaced with hand tuned assembly code
- * while (p <= pe) {
- * *p = pat;
- * if (++k >= 32) {
- * pat = lb;
- * k = 0;
- * } else {
- * pat = pat << 1;
- * pat |= sval;
- * }
- * p++;
- * }
- */
- asm __volatile__
- (
- "jmp L20\n\t"
- ".p2align 4,,7\n\t"
- "L923:\n\t"
- "addl $4,%%edi\n\t"
- "L20:\n\t"
- "movl %%ecx,(%%edi)\n\t"
- "addl $1,%%ebx\n\t"
- "cmpl $32,%%ebx\n\t"
- "jne L21\n\t"
- "movl %%esi,%%ecx\n\t"
- "xorl %%ebx,%%ebx\n\t"
- "jmp L22\n"
- "L21:\n\t"
- "shll $1,%%ecx\n\t"
- "orl %%eax,%%ecx\n\t"
- "L22:\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L923\n\t"
- :: "D" (p),"d" (pe),"b" (k),"c" (pat),
- "a" (sval), "S" (lb)
- );
-}
-
-STATIC void movinv32_bottom_up(ulong* restrict buf, ulong len_dw,
- const void* vctx) {
- const movinv32_ctx* restrict ctx = (const movinv32_ctx*)vctx;
-
- ulong* p = buf;
- ulong* pe = buf + (len_dw - 1);
-
- int k = ctx->off;
- ulong pat = ctx->p1;
- ulong lb = ctx->lb;
- int sval = ctx->sval;
-
- /* Original C code replaced with hand tuned assembly code
- * while (1) {
- * if ((bad=*p) != pat) {
- * mt86_error((ulong*)p, pat, bad);
- * }
- * *p = ~pat;
- * if (p >= pe) break;
- * p++;
- *
- * if (++k >= 32) {
- * pat = lb;
- * k = 0;
- * } else {
- * pat = pat << 1;
- * pat |= sval;
- * }
- * }
- */
- asm __volatile__
- (
- "pushl %%ebp\n\t"
- "jmp L30\n\t"
- ".p2align 4,,7\n\t"
- "L930:\n\t"
- "addl $4,%%edi\n\t"
- "L30:\n\t"
- "movl (%%edi),%%ebp\n\t"
- "cmpl %%ecx,%%ebp\n\t"
- "jne L34\n\t"
-
- "L35:\n\t"
- "notl %%ecx\n\t"
- "movl %%ecx,(%%edi)\n\t"
- "notl %%ecx\n\t"
- "incl %%ebx\n\t"
- "cmpl $32,%%ebx\n\t"
- "jne L31\n\t"
- "movl %%esi,%%ecx\n\t"
- "xorl %%ebx,%%ebx\n\t"
- "jmp L32\n"
- "L31:\n\t"
- "shll $1,%%ecx\n\t"
- "orl %%eax,%%ecx\n\t"
- "L32:\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L930\n\t"
- "jmp L33\n\t"
-
- "L34:\n\t"
- "pushl %%esi\n\t"
- "pushl %%eax\n\t"
- "pushl %%ebx\n\t"
- "pushl %%edx\n\t"
- "pushl %%ebp\n\t"
- "pushl %%ecx\n\t"
- "pushl %%edi\n\t"
- "call mt86_error\n\t"
- "popl %%edi\n\t"
- "popl %%ecx\n\t"
- "popl %%ebp\n\t"
- "popl %%edx\n\t"
- "popl %%ebx\n\t"
- "popl %%eax\n\t"
- "popl %%esi\n\t"
- "jmp L35\n"
-
- "L33:\n\t"
- "popl %%ebp\n\t"
- : "=b" (k),"=c" (pat)
- : "D" (p),"d" (pe),"b" (k),"c" (pat),
- "a" (sval), "S" (lb)
- );
-}
-
-STATIC void movinv32_top_down(ulong* restrict buf,
- ulong len_dw, const void* vctx) {
- const movinv32_ctx* restrict ctx = (const movinv32_ctx*)vctx;
-
- ulong* pe = buf;
- ulong* p = buf + (len_dw - 1);
-
- int k = ctx->off;
- ulong pat = ctx->p1;
- ulong hb = ctx->hb;
- int sval = ctx->sval;
- ulong p3 = (ulong)sval << 31;
-
- // Advance 'k' and 'pat' to where they would have been
- // at the end of the corresponding bottom_up segment.
- //
- // The '-1' is because we didn't advance 'k' or 'pat'
- // on the final bottom_up loop, so they're off by one...
- ulong mod_len = (len_dw - 1) % 32;
- for (int i = 0; i < mod_len; i++) {
- if (++k >= 32) {
- pat = ctx->lb;
- k = 0;
- } else {
- pat = pat << 1;
- pat |= sval;
- }
- }
-
- // Increment 'k' only because the code below has an off-by-one
- // interpretation of 'k' relative to the bottom_up routine.
- // There it ranges from 0:31, and here it ranges from 1:32.
- k++;
-
- /* Original C code replaced with hand tuned assembly code */
-#if PREFER_C
- ulong bad;
- while(1) {
- if ((bad=*p) != ~pat) {
- mt86_error((ulong*)p, ~pat, bad);
- }
- *p = pat;
- if (p <= pe) break;
- p--;
-
- if (--k <= 0) {
- k = 32;
- pat = hb;
- } else {
- pat = pat >> 1;
- pat |= p3;
- }
- };
-#else
- asm __volatile__
- (
- "pushl %%ebp\n\t"
- "jmp L40\n\t"
- ".p2align 4,,7\n\t"
- "L49:\n\t"
- "subl $4,%%edi\n\t"
- "L40:\n\t"
- "movl (%%edi),%%ebp\n\t"
- "notl %%ecx\n\t"
- "cmpl %%ecx,%%ebp\n\t"
- "jne L44\n\t"
-
- "L45:\n\t"
- "notl %%ecx\n\t"
- "movl %%ecx,(%%edi)\n\t"
- "decl %%ebx\n\t"
- "cmpl $0,%%ebx\n\t"
- "jg L41\n\t"
- "movl %%esi,%%ecx\n\t"
- "movl $32,%%ebx\n\t"
- "jmp L42\n"
- "L41:\n\t"
- "shrl $1,%%ecx\n\t"
- "orl %%eax,%%ecx\n\t"
- "L42:\n\t"
- "cmpl %%edx,%%edi\n\t"
- "ja L49\n\t"
- "jmp L43\n\t"
-
- "L44:\n\t"
- "pushl %%esi\n\t"
- "pushl %%eax\n\t"
- "pushl %%ebx\n\t"
- "pushl %%edx\n\t"
- "pushl %%ebp\n\t"
- "pushl %%ecx\n\t"
- "pushl %%edi\n\t"
- "call mt86_error\n\t"
- "popl %%edi\n\t"
- "popl %%ecx\n\t"
- "popl %%ebp\n\t"
- "popl %%edx\n\t"
- "popl %%ebx\n\t"
- "popl %%eax\n\t"
- "popl %%esi\n\t"
- "jmp L45\n"
-
- "L43:\n\t"
- "popl %%ebp\n\t"
- : : "D" (p),"d" (pe),"b" (k),"c" (pat),
- "a" (p3), "S" (hb)
- );
-#endif
-}
-
-void movinv32(int iter, ulong p1, ulong lb, ulong hb, int sval, int off,int me)
-{
- // First callsite:
- // - p1 has 1 bit set (somewhere)
- // - lb = 1 ("low bit")
- // - hb = 0x80000000 ("high bit")
- // - sval = 0
- // - 'off' indicates the position of the set bit in p1
- //
- // Second callsite is the same, but inverted:
- // - p1 has 1 bit clear (somewhere)
- // - lb = 0xfffffffe
- // - hb = 0x7fffffff
- // - sval = 1
- // - 'off' indicates the position of the cleared bit in p1
-
- movinv32_ctx ctx;
- ctx.p1 = p1;
- ctx.lb = lb;
- ctx.hb = hb;
- ctx.sval = sval;
- ctx.off = off;
-
- /* Display the current pattern */
- if (mstr_cpu == me) hprint(LINE_PAT, COL_PAT, p1);
-
- sliced_foreach_segment(&ctx, me, movinv32_init);
- { BAILR }
-
- /* Do moving inversions test. Check for initial pattern and then
- * write the complement for each memory location. Test from bottom
- * up and then from the top down. */
- for (int i=0; i<iter; i++) {
- sliced_foreach_segment(&ctx, me, movinv32_bottom_up);
- { BAILR }
-
- sliced_foreach_segment(&ctx, me, movinv32_top_down);
- { BAILR }
- }
-}
-
-typedef struct {
- int offset;
- ulong p1;
- ulong p2;
-} modtst_ctx;
-
-STATIC void modtst_sparse_writes(ulong* restrict start,
- ulong len_dw, const void* vctx) {
- const modtst_ctx* restrict ctx = (const modtst_ctx*)vctx;
- ulong p1 = ctx->p1;
- ulong offset = ctx->offset;
-
-#if PREFER_C
- for (ulong i = offset; i < len_dw; i += MOD_SZ) {
- start[i] = p1;
- }
-#else
- ulong* p = start + offset;
- ulong* pe = start + len_dw;
- asm __volatile__
- (
- "jmp L60\n\t"
- ".p2align 4,,7\n\t"
-
- "L60:\n\t"
- "movl %%eax,(%%edi)\n\t"
- "addl $80,%%edi\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L60\n\t"
- :: "D" (p), "d" (pe), "a" (p1)
- );
-#endif
-}
-
-STATIC void modtst_dense_writes(ulong* restrict start, ulong len_dw,
- const void* vctx) {
- const modtst_ctx* restrict ctx = (const modtst_ctx*)vctx;
- ulong p2 = ctx->p2;
- ulong offset = ctx->offset;
-
- ASSERT(offset < MOD_SZ);
-
- ulong k = 0;
-#if PREFER_C
- for (ulong i = 0; i < len_dw; i++) {
- if (k != offset) {
- start[i] = p2;
- }
- if (++k >= MOD_SZ) {
- k = 0;
- }
- }
-#else
- ulong* pe = start + (len_dw - 1);
- asm __volatile__
- (
- "jmp L50\n\t"
- ".p2align 4,,7\n\t"
-
- "L54:\n\t"
- "addl $4,%%edi\n\t"
- "L50:\n\t"
- "cmpl %%ebx,%%ecx\n\t"
- "je L52\n\t"
- "movl %%eax,(%%edi)\n\t"
- "L52:\n\t"
- "incl %%ebx\n\t"
- "cmpl $19,%%ebx\n\t"
- "jle L53\n\t"
- "xorl %%ebx,%%ebx\n\t"
- "L53:\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L54\n\t"
- : : "D" (start), "d" (pe), "a" (p2),
- "b" (k), "c" (offset)
- );
-#endif
-}
-
-STATIC void modtst_check(ulong* restrict start,
- ulong len_dw, const void* vctx) {
- const modtst_ctx* restrict ctx = (const modtst_ctx*)vctx;
- ulong p1 = ctx->p1;
- ulong offset = ctx->offset;
-
- ASSERT(offset < MOD_SZ);
-
-#if PREFER_C
- ulong bad;
- for (ulong i = offset; i < len_dw; i += MOD_SZ) {
- if ((bad = start[i]) != p1)
- mt86_error(start + i, p1, bad);
- }
-#else
- ulong* p = start + offset;
- ulong* pe = start + len_dw;
- asm __volatile__
- (
- "jmp L70\n\t"
- ".p2align 4,,7\n\t"
-
- "L70:\n\t"
- "movl (%%edi),%%ecx\n\t"
- "cmpl %%eax,%%ecx\n\t"
- "jne L71\n\t"
- "L72:\n\t"
- "addl $80,%%edi\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L70\n\t"
- "jmp L73\n\t"
-
- "L71:\n\t"
- "pushl %%edx\n\t"
- "pushl %%ecx\n\t"
- "pushl %%eax\n\t"
- "pushl %%edi\n\t"
- "call mt86_error\n\t"
- "popl %%edi\n\t"
- "popl %%eax\n\t"
- "popl %%ecx\n\t"
- "popl %%edx\n\t"
- "jmp L72\n"
-
- "L73:\n\t"
- : : "D" (p), "d" (pe), "a" (p1)
- : "ecx"
- );
-#endif
-}
-
-/*
- * Test all of memory using modulo X access pattern.
- */
-void modtst(int offset, int iter, ulong p1, ulong p2, int me)
-{
- modtst_ctx ctx;
- ctx.offset = offset;
- ctx.p1 = p1;
- ctx.p2 = p2;
-
- /* Display the current pattern */
- if (mstr_cpu == me) {
- hprint(LINE_PAT, COL_PAT-2, p1);
- cprint(LINE_PAT, COL_PAT+6, "-");
- dprint(LINE_PAT, COL_PAT+7, offset, 2, 1);
- }
-
- /* Write every nth location with pattern */
- sliced_foreach_segment(&ctx, me, modtst_sparse_writes);
- { BAILR }
-
- /* Write the rest of memory "iter" times with the pattern complement */
- for (ulong i=0; i<iter; i++) {
- sliced_foreach_segment(&ctx, me, modtst_dense_writes);
- { BAILR }
- }
-
- /* Now check every nth location */
- sliced_foreach_segment(&ctx, me, modtst_check);
-}
-
-#if PREFER_C
-
-STATIC void movsl(ulong* dest,
- ulong* src,
- ulong size_in_dwords) {
- /* Logically equivalent to:
-
- for (ulong i = 0; i < size_in_dwords; i++)
- dest[i] = src[i];
-
- However: the movsl instruction does the entire loop
- in one instruction -- this is probably how 'memcpy'
- is implemented -- so hardware makes it very fast.
-
- Even in PREFER_C mode, we want the brute force of movsl!
- */
- asm __volatile__
- (
- "cld\n"
- "jmp L1189\n\t"
-
- ".p2align 4,,7\n\t"
- "L1189:\n\t"
-
- "movl %1,%%edi\n\t" // dest
- "movl %0,%%esi\n\t" // src
- "movl %2,%%ecx\n\t" // len in dwords
- "rep\n\t"
- "movsl\n\t"
-
- :: "g" (src), "g" (dest), "g" (size_in_dwords)
- : "edi", "esi", "ecx"
- );
-}
-#endif // PREFER_C
-
-STATIC ulong block_move_normalize_len_dw(ulong len_dw) {
- // The block_move test works with sets of 64-byte blocks,
- // so ensure our total length is a multiple of 64.
- //
- // In fact, since we divide the region in half, and each half-region
- // is a set of 64-byte blocks, the full region should be a multiple of 128
- // bytes.
- //
- // Note that there's no requirement for the start address of the region to
- // be 64-byte aligned, it can be any dword.
- ulong result = (len_dw >> 5) << 5;
- ASSERT(result > 0);
- return result;
-}
-
-STATIC void block_move_init(ulong* restrict buf,
- ulong len_dw, const void* unused_ctx) {
- len_dw = block_move_normalize_len_dw(len_dw);
-
- // Compute 'len' in units of 64-byte chunks:
- ulong len = len_dw >> 4;
-
- // We only need to initialize len/2, since we'll just copy
- // the first half onto the second half in the move step.
- len = len >> 1;
-
- ulong base_val = 1;
-#if PREFER_C
- while(len > 0) {
- ulong neg_val = ~base_val;
-
- // Set a block of 64 bytes // first block DWORDS are:
- buf[0] = base_val; // 0x00000001
- buf[1] = base_val; // 0x00000001
- buf[2] = base_val; // 0x00000001
- buf[3] = base_val; // 0x00000001
- buf[4] = neg_val; // 0xfffffffe
- buf[5] = neg_val; // 0xfffffffe
- buf[6] = base_val; // 0x00000001
- buf[7] = base_val; // 0x00000001
- buf[8] = base_val; // 0x00000001
- buf[9] = base_val; // 0x00000001
- buf[10] = neg_val; // 0xfffffffe
- buf[11] = neg_val; // 0xfffffffe
- buf[12] = base_val; // 0x00000001
- buf[13] = base_val; // 0x00000001
- buf[14] = neg_val; // 0xfffffffe
- buf[15] = neg_val; // 0xfffffffe
-
- buf += 16; // advance to next 64-byte block
- len--;
-
- // Rotate the bit left, including an all-zero state.
- // It can't hurt to have a periodicity of 33 instead of
- // a power of two.
- if (base_val == 0) {
- base_val = 1;
- } else if (base_val & 0x80000000) {
- base_val = 0;
- } else {
- base_val = base_val << 1;
- }
- }
-#else
- asm __volatile__
- (
- "jmp L100\n\t"
-
- ".p2align 4,,7\n\t"
- "L100:\n\t"
-
- // First loop eax is 0x00000001, edx is 0xfffffffe
- "movl %%eax, %%edx\n\t"
- "notl %%edx\n\t"
-
- // Set a block of 64-bytes // First loop DWORDS are
- "movl %%eax,0(%%edi)\n\t" // 0x00000001
- "movl %%eax,4(%%edi)\n\t" // 0x00000001
- "movl %%eax,8(%%edi)\n\t" // 0x00000001
- "movl %%eax,12(%%edi)\n\t" // 0x00000001
- "movl %%edx,16(%%edi)\n\t" // 0xfffffffe
- "movl %%edx,20(%%edi)\n\t" // 0xfffffffe
- "movl %%eax,24(%%edi)\n\t" // 0x00000001
- "movl %%eax,28(%%edi)\n\t" // 0x00000001
- "movl %%eax,32(%%edi)\n\t" // 0x00000001
- "movl %%eax,36(%%edi)\n\t" // 0x00000001
- "movl %%edx,40(%%edi)\n\t" // 0xfffffffe
- "movl %%edx,44(%%edi)\n\t" // 0xfffffffe
- "movl %%eax,48(%%edi)\n\t" // 0x00000001
- "movl %%eax,52(%%edi)\n\t" // 0x00000001
- "movl %%edx,56(%%edi)\n\t" // 0xfffffffe
- "movl %%edx,60(%%edi)\n\t" // 0xfffffffe
-
- // rotate left with carry,
- // second loop eax is 0x00000002
- // second loop edx is (~eax) 0xfffffffd
- "rcll $1, %%eax\n\t"
-
- // Move current position forward 64-bytes (to start of next block)
- "leal 64(%%edi), %%edi\n\t"
-
- // Loop until end
- "decl %%ecx\n\t"
- "jnz L100\n\t"
-
- : : "D" (buf), "c" (len), "a" (base_val)
- : "edx"
- );
-#endif
-}
-
-typedef struct {
- int iter;
- int me;
-} block_move_ctx;
-
-STATIC void block_move_move(ulong* restrict buf,
- ulong len_dw, const void* vctx) {
- const block_move_ctx* restrict ctx = (const block_move_ctx*)vctx;
- ulong iter = ctx->iter;
- int me = ctx->me;
-
- len_dw = block_move_normalize_len_dw(len_dw);
-
- /* Now move the data around
- * First move the data up half of the segment size we are testing
- * Then move the data to the original location + 32 bytes
- */
- ulong half_len_dw = len_dw / 2; // Half the size of this block in DWORDS
- ASSERT(half_len_dw > 8);
-
- ulong* mid = buf + half_len_dw; // VA at mid-point of this block.
- for (int i=0; i<iter; i++) {
- if (i > 0) {
- // foreach_segment() called this before the 0th iteration,
- // so don't tick twice in quick succession.
- do_tick(me);
- }
- { BAILR }
-
-#if PREFER_C
- // Move first half to 2nd half:
- movsl(/*dest=*/ mid, /*src=*/ buf, half_len_dw);
-
- // Move the second half, less the last 8 dwords
- // to the first half plus an offset of 8 dwords.
- movsl(/*dest=*/ buf + 8, /*src=*/ mid, half_len_dw - 8);
-
- // Finally, move the last 8 dwords of the 2nd half
- // to the first 8 dwords of the first half.
- movsl(/*dest=*/ mid + half_len_dw - 8, /*src=*/ buf, 8);
-#else
- asm __volatile__
- (
- "cld\n"
- "jmp L110\n\t"
-
- ".p2align 4,,7\n\t"
- "L110:\n\t"
-
- //
- // At the end of all this
- // - the second half equals the inital value of the first half
- // - the first half is right shifted 32-bytes (with wrapping)
- //
-
- // Move first half to second half
- "movl %1,%%edi\n\t" // Destination 'mid' (mid point)
- "movl %0,%%esi\n\t" // Source, 'buf' (start point)
- "movl %2,%%ecx\n\t" // Length, 'half_len_dw' (size of a half in DWORDS)
- "rep\n\t"
- "movsl\n\t"
-
- // Move the second half, less the last 32-bytes. To the first half, offset plus 32-bytes
- "movl %0,%%edi\n\t"
- "addl $32,%%edi\n\t" // Destination 'buf' plus 32 bytes
- "movl %1,%%esi\n\t" // Source, 'mid'
- "movl %2,%%ecx\n\t"
- "subl $8,%%ecx\n\t" // Length, 'half_len_dw'
- "rep\n\t"
- "movsl\n\t"
-
- // Move last 8 DWORDS (32-bytes) of the second half to the start of the first half
- "movl %0,%%edi\n\t" // Destination 'buf'
- // Source, 8 DWORDS from the end of the second half, left over by the last rep/movsl
- "movl $8,%%ecx\n\t" // Length, 8 DWORDS (32-bytes)
- "rep\n\t"
- "movsl\n\t"
-
- :: "g" (buf), "g" (mid), "g" (half_len_dw)
- : "edi", "esi", "ecx"
- );
-#endif
- }
-}
-
-STATIC void block_move_check(ulong* restrict buf,
- ulong len_dw, const void* unused_ctx) {
- len_dw = block_move_normalize_len_dw(len_dw);
-
- /* Now check the data.
- * This is rather crude, we just check that the
- * adjacent words are the same.
- */
-#if PREFER_C
- for (ulong i = 0; i < len_dw; i = i + 2) {
- if (buf[i] != buf[i+1]) {
- mt86_error(buf+i, buf[i], buf[i+1]);
- }
- }
-#else
- ulong* pe = buf + (len_dw - 2);
- asm __volatile__
- (
- "jmp L120\n\t"
-
- ".p2align 4,,7\n\t"
- "L124:\n\t"
- "addl $8,%%edi\n\t" // Next QWORD
- "L120:\n\t"
-
- // Compare adjacent DWORDS
- "movl (%%edi),%%ecx\n\t"
- "cmpl 4(%%edi),%%ecx\n\t"
- "jnz L121\n\t" // Print error if they don't match
-
- // Loop until end of block
- "L122:\n\t"
- "cmpl %%edx,%%edi\n\t"
- "jb L124\n"
- "jmp L123\n\t"
-
- "L121:\n\t"
- // eax not used so we don't need to save it as per cdecl
- // ecx is used but not restored, however we don't need it's value anymore after this point
- "pushl %%edx\n\t"
- "pushl 4(%%edi)\n\t"
- "pushl %%ecx\n\t"
- "pushl %%edi\n\t"
- "call mt86_error\n\t"
- "popl %%edi\n\t"
- "addl $8,%%esp\n\t"
- "popl %%edx\n\t"
- "jmp L122\n"
- "L123:\n\t"
- :: "D" (buf), "d" (pe)
- : "ecx"
- );
-#endif
-}
-
-/*
- * Test memory using block moves
- * Adapted from Robert Redelmeier's burnBX test
- */
-void block_move(int iter, int me)
-{
- cprint(LINE_PAT, COL_PAT-2, " ");
-
- block_move_ctx ctx;
- ctx.iter = iter;
- ctx.me = me;
-
- /* Initialize memory with the initial pattern. */
- sliced_foreach_segment(&ctx, me, block_move_init);
- { BAILR }
- s_barrier();
-
- /* Now move the data around */
- sliced_foreach_segment(&ctx, me, block_move_move);
- { BAILR }
- s_barrier();
-
- /* And check it. */
- sliced_foreach_segment(&ctx, me, block_move_check);
-}
-
-typedef struct {
- ulong pat;
-} bit_fade_ctx;
-
-STATIC void bit_fade_fill_seg(ulong* restrict p,
- ulong len_dw, const void* vctx) {
- const bit_fade_ctx* restrict ctx = (const bit_fade_ctx*)vctx;
- ulong pat = ctx->pat;
-
- for (ulong i = 0; i < len_dw; i++) {
- p[i] = pat;
- }
-}
-
-/*
- * Test memory for bit fade, fill memory with pattern.
- */
-void bit_fade_fill(ulong p1, int me)
-{
- /* Display the current pattern */
- hprint(LINE_PAT, COL_PAT, p1);
-
- /* Initialize memory with the initial pattern. */
- bit_fade_ctx ctx;
- ctx.pat = p1;
- unsliced_foreach_segment(&ctx, me, bit_fade_fill_seg);
-}
-
-STATIC void bit_fade_chk_seg(ulong* restrict p,
- ulong len_dw, const void* vctx) {
- const bit_fade_ctx* restrict ctx = (const bit_fade_ctx*)vctx;
- ulong pat = ctx->pat;
-
- for (ulong i = 0; i < len_dw; i++) {
- ulong bad;
- if ((bad=p[i]) != pat) {
- mt86_error(p+i, pat, bad);
- }
- }
-}
-
-void bit_fade_chk(ulong p1, int me)
-{
- bit_fade_ctx ctx;
- ctx.pat = p1;
-
- /* Make sure that nothing changed while sleeping */
- unsliced_foreach_segment(&ctx, me, bit_fade_chk_seg);
-}
-
-/* Sleep for N seconds */
-void sleep(long n, int flag, int me,
- int sms /* interpret 'n' as milliseconds instead */)
-{
- ulong sh, sl, l, h, t, ip=0;
-
- /* save the starting time */
- asm __volatile__(
- "rdtsc":"=a" (sl),"=d" (sh));
-
- /* loop for n seconds */
- while (1) {
- asm __volatile__(
- "rep ; nop\n\t"
- "rdtsc":"=a" (l),"=d" (h));
- asm __volatile__ (
- "subl %2,%0\n\t"
- "sbbl %3,%1"
- :"=a" (l), "=d" (h)
- :"g" (sl), "g" (sh),
- "0" (l), "1" (h));
-
- if (sms != 0) {
- t = h * ((unsigned)0xffffffff / vv->clks_msec);
- t += (l / vv->clks_msec);
- } else {
- t = h * ((unsigned)0xffffffff / vv->clks_msec) / 1000;
- t += (l / vv->clks_msec) / 1000;
- }
-
- /* Is the time up? */
- if (t >= n) {
- break;
- }
-
- /* Only display elapsed time if flag is set */
- if (flag == 0) {
- continue;
- }
-
- if (t != ip) {
- do_tick(me);
- { BAILR }
- ip = t;
- }
- }
-}
-
-void beep(unsigned int frequency)
-{
-#if 0
- // BOZO(jcoiner)
- // Removed this, we need to define outb_p() and inb_p()
- // before reintroducing it.
-#else
- unsigned int count = 1193180 / frequency;
-
- // Switch on the speaker
- outb_p(inb_p(0x61)|3, 0x61);
-
- // Set command for counter 2, 2 byte write
- outb_p(0xB6, 0x43);
-
- // Select desired Hz
- outb_p(count & 0xff, 0x42);
- outb((count >> 8) & 0xff, 0x42);
-
- // Block for 100 microseconds
- sleep(100, 0, 0, 1);
-
- // Switch off the speaker
- outb(inb_p(0x61)&0xFC, 0x61);
-#endif
-}
diff --git a/allocate_pages_test/memtest86+/bios/test_cache.h b/allocate_pages_test/memtest86+/bios/test_cache.h
deleted file mode 100644
index 48b4869..0000000
--- a/allocate_pages_test/memtest86+/bios/test_cache.h
+++ /dev/null
@@ -1,20 +0,0 @@
-static inline void cache_off(void)
-{
- asm(
- "push %eax\n\t"
- "movl %cr0,%eax\n\t"
- "orl $0x40000000,%eax\n\t" /* Set CD */
- "movl %eax,%cr0\n\t"
- "wbinvd\n\t"
- "pop %eax\n\t");
-}
-
-static inline void cache_on(void)
-{
- asm(
- "push %eax\n\t"
- "movl %cr0,%eax\n\t"
- "andl $0x9fffffff,%eax\n\t" /* Clear CD and NW */
- "movl %eax,%cr0\n\t"
- "pop %eax\n\t");
-}
diff --git a/allocate_pages_test/memtest86+/bios/vmem.c b/allocate_pages_test/memtest86+/bios/vmem.c
deleted file mode 100644
index 6125e0d..0000000
--- a/allocate_pages_test/memtest86+/bios/vmem.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* vmem.c - MemTest-86
- *
- * Virtual memory handling (PAE)
- *
- * Released under version 2 of the Gnu Public License.
- * By Chris Brady
- */
-#include "stdint.h"
-#include "test.h"
-#include "cpuid.h"
-
-extern struct cpu_ident cpu_id;
-
-static unsigned long mapped_win = 1;
-void paging_off(void)
-{
- if (!cpu_id.fid.bits.pae)
- return;
- __asm__ __volatile__
- (
- /* Disable paging */
- "movl %%cr0, %%eax\n\t"
- "andl $0x7FFFFFFF, %%eax\n\t"
- "movl %%eax, %%cr0\n\t"
- : :
- : "ax"
- );
-}
-
-static void paging_on(void *pdp)
-{
- if (!cpu_id.fid.bits.pae)
- return;
- __asm__ __volatile__
- (
- /* Load the page table address */
- "movl %0, %%cr3\n\t"
- /* Enable paging */
- "movl %%cr0, %%eax\n\t"
- "orl $0x80000000, %%eax\n\t"
- "movl %%eax, %%cr0\n\t"
- :
- : "r" (pdp)
- : "ax"
- );
-}
-
-static void paging_on_lm(void *pml)
-{
- if (!cpu_id.fid.bits.pae)
- return;
- __asm__ __volatile__
- (
- /* Load the page table address */
- "movl %0, %%cr3\n\t"
- /* Enable paging */
- "movl %%cr0, %%eax\n\t"
- "orl $0x80000000, %%eax\n\t"
- "movl %%eax, %%cr0\n\t"
- :
- : "r" (pml)
- : "ax"
- );
-}
-
-int map_page(unsigned long page)
-{
- unsigned long i;
- struct pde {
- unsigned long addr_lo;
- unsigned long addr_hi;
- };
- extern unsigned char pdp[];
- extern unsigned char pml4[];
- extern struct pde pd2[];
- unsigned long win = page >> 19;
-
- /* Less than 2 GB so no mapping is required */
- if (win == 0) {
- return 0;
- }
- if (cpu_id.fid.bits.pae == 0) {
- /* Fail, we don't have PAE */
- return -1;
- }
- if (cpu_id.fid.bits.lm == 0 && (page > 0x1000000)) {
- /* Fail, we want an address that is out of bounds (> 64GB)
- * for PAE and no long mode (ie. 32 bit CPU).
- */
- return -1;
- }
- /* Compute the page table entries... */
- for(i = 0; i < 1024; i++) {
- /*-----------------10/30/2004 12:37PM---------------
- * 0xE3 --
- * Bit 0 = Present bit. 1 = PDE is present
- * Bit 1 = Read/Write. 1 = memory is writable
- * Bit 2 = Supervisor/User. 0 = Supervisor only (CPL 0-2)
- * Bit 3 = Writethrough. 0 = writeback cache policy
- * Bit 4 = Cache Disable. 0 = page level cache enabled
- * Bit 5 = Accessed. 1 = memory has been accessed.
- * Bit 6 = Dirty. 1 = memory has been written to.
- * Bit 7 = Page Size. 1 = page size is 2 MBytes
- * --------------------------------------------------*/
- pd2[i].addr_lo = ((win & 1) << 31) + ((i & 0x3ff) << 21) + 0xE3;
- pd2[i].addr_hi = (win >> 1);
- }
- paging_off();
- if (cpu_id.fid.bits.lm == 1) {
- paging_on_lm(pml4);
- } else {
- paging_on(pdp);
- }
- mapped_win = win;
- return 0;
-}
-
-void *mapping(unsigned long phys_page)
-{
- void *result;
- if (phys_page < WIN_SZ_PAGES) {
- /* If the page is below 2GB, address it directly */
- result = (void *)(phys_page << 12);
- }
- else {
- // Higher physical pages map to a virtual address
- // in the 2G-4G range.
- unsigned long alias;
- alias = phys_page & 0x7FFFF;
- alias += 0x80000;
- result = (void *)(alias << 12);
- }
- return result;
-}
-
-void *emapping(unsigned long phys_page)
-{
- void *result;
- result = mapping(phys_page - 1);
- /* Fill in the low address bits */
- result = ((unsigned char *)result) + 0xffc;
- return result;
-}
-
-unsigned long page_of(void *addr)
-{
- unsigned long page;
- page = ((unsigned long)addr) >> 12;
- if (page >= 0x80000) {
- page &= 0x7FFFF;
- page += mapped_win << 19;
- }
-#if 0
- cprint(LINE_SCROLL -2, 0, "page_of( )-> ");
- hprint(LINE_SCROLL -2, 8, ((unsigned long)addr));
- hprint(LINE_SCROLL -2, 20, page);
-#endif
- return page;
-}
diff --git a/allocate_pages_test/memtest86+/bootsect.S b/allocate_pages_test/memtest86+/bootsect.S
deleted file mode 100644
index 96aa22b..0000000
--- a/allocate_pages_test/memtest86+/bootsect.S
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * bootsect.s Copyright (C) 1991, 1992 Linus Torvalds
- *
- * bootsect.s is loaded at 0x7c00 by the bios-startup routines, and moves
- * itself out of the way to address 0x90000, and jumps there.
- *
- * It then loads 'setup' directly after itself (0x90200), and the system
- * at 0x10000, using BIOS interrupts.
- *
- * The loader has been made as simple as possible, and continuos
- * read errors will result in a unbreakable loop. Reboot by hand. It
- * loads pretty fast by getting whole tracks at a time whenever possible.
- *
- * 1-Jan-96 Modified by Chris Brady for use as a boot loader for MemTest-86.
- */
-
-#include "defs.h"
-
-ROOT_DEV = 0
-
-.code16
-.section ".bootsect", "ax", @progbits
-_boot:
-
-
-# ld86 requires an entry symbol. This may as well be the usual one.
-.globl _main
-_main:
- movw $BOOTSEG, %ax
- movw %ax, %ds
- movw $INITSEG, %ax
- movw %ax, %es
- movw $256, %cx
- subw %si, %si
- subw %di, %di
- cld
- rep
- movsw
- ljmp $INITSEG, $go - _boot
-
-go:
- movw %cs, %ax
- movw $(0x4000-12), %dx # 0x4000 is arbitrary value >= length of
- # bootsect + length of setup + room for stack
- # 12 is disk parm size
-
-# bde - changed 0xff00 to 0x4000 to use debugger at 0x6400 up (bde). We
-# wouldn't have to worry about this if we checked the top of memory. Also
-# my BIOS can be configured to put the wini drive tables in high memory
-# instead of in the vector table. The old stack might have clobbered the
-# drive table.
-
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %ss # put stack at INITSEG:0x4000-12.
- movw %dx, %sp
-
-/*
- * Many BIOS's default disk parameter tables will not
- * recognize multi-sector reads beyond the maximum sector number
- * specified in the default diskette parameter tables - this may
- * mean 7 sectors in some cases.
- *
- * Since single sector reads are slow and out of the question,
- * we must take care of this by creating new parameter tables
- * (for the first disk) in RAM. We will set the maximum sector
- * count to 18 - the most we will encounter on an HD 1.44.
- *
- * High doesn't hurt. Low does.
- *
- * Segments are as follows: ds=es=ss=cs - INITSEG,
- * fs = 0, gs = parameter table segment
- */
- pushw $0
- popw %fs
- movw $0x78, %bx # fs:bx is parameter table address
- lgs %fs:(%bx),%si # gs:si is source
-
- movw %dx, %di # es:di is destination
- movw $6, %cx # copy 12 bytes
- cld
-
- rep movsw %gs:(%si), (%di)
-
- movw %dx, %di
- movb $18, 4(%di) # patch sector count
-
- movw %di, %fs:(%bx)
- movw %es, %fs:2(%bx)
-
- movw %cs, %ax
- movw %ax, %fs
- movw %ax, %gs
-
- xorb %ah, %ah # reset FDC
- xorb %dl, %dl
- int $0x13
-
-# load the setup-sectors directly after the bootblock.
-# Note that 'es' is already set up.
-
-load_setup:
- xorw %dx, %dx # drive 0, head 0
- movw $0x0002, %cx # sector 2, track 0
- movw $0x0200, %bx # address = 512, in INITSEG
- movw $(0x0200 + SETUPSECS), %ax # service 2, nr of sectors
- # (assume all on head 0, track 0)
- int $0x13 # read it
- jnc ok_load_setup # ok - continue
-
- pushw %ax # dump error code
- call print_nl
- movw %sp, %bp
- call print_hex
- popw %ax
-
- xorb %dl, %dl # reset FDC
- xorb %ah, %ah
- int $0x13
- jmp load_setup
-
-ok_load_setup:
-
-# Get disk drive parameters, specifically nr of sectors/track
-
-
-/* It seems that there is no BIOS call to get the number of sectors. Guess
- * 18 sectors if sector 18 can be read, 15 if sector 15 can be read.
- * Otherwise guess 9
- */
-
- xorw %dx, %dx # drive 0, head 0
- movw $0x0012, %cx # sector 18, track 0
- movw $(0x200+(SETUPSECS*0x200)), %bx # address after setup (es = cs)
- movw $0x0201, %ax # service 2, 1 sector
- int $0x13
- jnc got_sectors
- movb $0x0f, %cl # sector 15
- movw $0x0201, %ax # service 2, 1 sector
- int $0x13
- jnc got_sectors
- movb $0x09, %cl
-
-got_sectors:
- movw %cx, %cs:sectors - _boot
- movw $INITSEG, %ax
- movw %ax, %es
-
-# Print some inane message
-
- movb $0x03, %ah # read cursor pos
- xorb %bh, %bh
- int $0x10
-
- movw $9, %cx
- movw $0x0007, %bx # page 0, attribute 7 (normal)
- movw $msg1 - _boot, %bp
- movw $0x1301, %ax # write string, move cursor
- int $0x10
-
-# ok, we've written the message, now
-# we want to load the system (at 0x10000)
-
- movw $TSTLOAD, %ax
- movw %ax, %es # segment of 0x010000
- call read_it
- call kill_motor
- call turnoffcursor
- call print_nl
-
-# after that (everyting loaded), we jump to
-# the setup-routine loaded directly after
-# the bootblock:
-
- ljmp $SETUPSEG,$0
-
-# This routine loads the system at address 0x10000, making sure
-# no 64kB boundaries are crossed. We try to load it as fast as
-# possible, loading whole tracks whenever we can.
-#
-# in: es - starting address segment (normally 0x1000)
-#
-sread: .word 1+SETUPSECS # sectors read of current track
-head: .word 0 # current head
-track: .word 0 # current track
-
-read_it:
- movw %es, %ax
- testw $0x0fff, %ax
-die:
- jne die # es must be at 64kB boundary
- xorw %bx,%bx # bx is starting address within segment
-rp_read:
- movw %es, %ax
- subw $TSTLOAD, %ax # have we loaded all yet?
- cmpw syssize - _boot, %ax
- jbe ok1_read
- ret
-ok1_read:
- movw %cs:sectors - _boot, %ax
- subw sread - _boot, %ax
- movw %ax, %cx
- shlw $9, %cx
- addw %bx, %cx
- jnc ok2_read
- je ok2_read
- xorw %ax, %ax
- subw %bx, %ax
- shrw $9, %ax
-ok2_read:
- call read_track
- movw %ax, %cx
- add sread - _boot, %ax
- cmpw %cs:sectors - _boot, %ax
- jne ok3_read
- movw $1, %ax
- subw head - _boot, %ax
- jne ok4_read
- incw track - _boot
-ok4_read:
- movw %ax, head - _boot
- xorw %ax, %ax
-ok3_read:
- movw %ax, sread - _boot
- shlw $9, %cx
- addw %cx, %bx
- jnc rp_read
- movw %es, %ax
- addb $0x10, %ah
- movw %ax, %es
- xorw %bx, %bx
- jmp rp_read
-
-read_track:
- pusha
- pusha
- movw $0xe2e, %ax # loading... message 2e = .
- movw $7, %bx
- int $0x10
- popa
-
- movw track - _boot, %dx
- movw sread - _boot, %cx
- incw %cx
- movb %dl, %ch
- movw head - _boot, %dx
- movb %dl, %dh
- andw $0x0100, %dx
- movb $2, %ah
-
- pushw %dx # save for error dump
- pushw %cx
- pushw %bx
- pushw %ax
-
- int $0x13
- jc bad_rt
- addw $8, %sp
- popa
- ret
-
-bad_rt:
- pushw %ax # save error code
- call print_all # ah = error, al = read
-
- xorb %ah, %ah
- xorb %dl, %dl
- int $0x13
-
- addw $10, %sp
- popa
- jmp read_track
-
-/*
- * print_all is for debugging purposes.
- * It will print out all of the registers. The assumption is that this is
- * called from a routine, with a stack frame like
- * dx
- * cx
- * bx
- * ax
- * error
- * ret <- sp
- *
-*/
-
-print_all:
- movw $5, %cx # error code + 4 registers
- movw %sp, %bp
-
-print_loop:
- pushw %cx # save count left
- call print_nl # nl for readability
-
- cmpb 5, %cl # see if register name is needed
- jae no_reg
-
- movw $(0xe05 + 'A' - 1), %ax
- subb %cl, %al
- int $0x10
- movb $'X', %al
- int $0x10
- movb $':', %al
- int $0x10
-
-no_reg:
- addw $2, %bp # next register
- call print_hex # print it
- popw %cx
- loop print_loop
- ret
-
-print_nl:
- movw $0xe0d, %ax # CR
- int $0x10
- movb $0x0a, %al # LF
- int $0x10
- ret
-
-/*
- * print_hex is for debugging purposes, and prints the word
- * pointed to by ss:bp in hexadecmial.
- */
-
-print_hex:
- movw $4, %cx # 4 hex digits
- movw (%bp), %dx # load word into dx
-
-print_digit:
- rolw $4, %dx # rotate so that lowest 4 bits are used
- movb $0xe, %ah
- movb %dl, %al # mask off so we have only next nibble
- andb $0xf, %al
- addb $'0', %al # convert to 0-based digit
- cmpb $'9', %al # check for overflow
- jbe good_digit
- addb $('A' - '0' - 10), %al
-
-good_digit:
- int $0x10
- loop print_digit
- ret
-
-
-/*
- * This procedure turns off the floppy drive motor, so
- * that we enter the kernel in a known state, and
- * don't have to worry about it later.
- */
-kill_motor:
- pushw %dx
- movw $0x3f2, %dx
- xorb %al, %al
- outb %al, %dx
- popw %dx
- ret
-
-turnoffcursor:
- movb $0x01, %ah # turn off the cursor
- movb $0x00, %bh
- movw $0x2000, %cx
- int $0x10
- ret
-
-sectors:
- .word 0
-
-msg1:
- .byte 13,10
- .ascii "Loading"
-
-.org 497
-setup_sects:
- .byte SETUPSECS
-.org 500
-syssize:
- .word _syssize
-.org 508
-root_dev:
- .word ROOT_DEV
-boot_flag:
- .word 0xAA55
-_eboot:
diff --git a/allocate_pages_test/memtest86+/build.number b/allocate_pages_test/memtest86+/build.number
deleted file mode 100644
index e110e8d..0000000
--- a/allocate_pages_test/memtest86+/build.number
+++ /dev/null
@@ -1 +0,0 @@
-617
diff --git a/allocate_pages_test/memtest86+/build_number.h b/allocate_pages_test/memtest86+/build_number.h
deleted file mode 100644
index d1f2abc..0000000
--- a/allocate_pages_test/memtest86+/build_number.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef BUILD_NUMBER_STR
-#define BUILD_NUMBER_STR "617"
-#endif
-#ifndef VERSION_STR
-#define VERSION_STR "4.99617 - Thu May 3 11:45:57 CEST 2012"
-#endif
-#ifndef VERSION_STR_SHORT
-#define VERSION_STR_SHORT "4.99617"
-#endif
diff --git a/allocate_pages_test/memtest86+/buildnumber.mak b/allocate_pages_test/memtest86+/buildnumber.mak
deleted file mode 100644
index 8d5b85d..0000000
--- a/allocate_pages_test/memtest86+/buildnumber.mak
+++ /dev/null
@@ -1,10 +0,0 @@
-# Create an auto-incrementing build number.
-
-BUILD_NUMBER_LDFLAGS = -Xlinker --defsym -Xlinker __BUILD_DATE=$$(date +'%Y%m%d')
-BUILD_NUMBER_LDFLAGS += -Xlinker --defsym -Xlinker __BUILD_NUMBER=$$(cat $(BUILD_NUMBER_FILE))
-
-# Build number file. Increment if any object file changes.
-$(BUILD_NUMBER_FILE): $(OBJS)
- @if ! test -f $(BUILD_NUMBER_FILE); then echo 0 > $(BUILD_NUMBER_FILE); fi
- @echo $$(($$(cat $(BUILD_NUMBER_FILE)) + 1)) > $(BUILD_NUMBER_FILE)
-
diff --git a/allocate_pages_test/memtest86+/changelog b/allocate_pages_test/memtest86+/changelog
deleted file mode 100644
index 9379a5b..0000000
--- a/allocate_pages_test/memtest86+/changelog
+++ /dev/null
@@ -1,25 +0,0 @@
-Memtest86+ V5.01 changelog
-----------------------------
-
- - Added support for up to 2 TB of RAM on X64 CPUs
- - Added experimental SMT support up to 32 cores
- - Added complete detection for memory controllers.
- - Added Motherboard Manufacturer & Model reporting
- - Added CPU temperature reporting
- - Added enhanced Fail Safe Mode (Press F1 at startup)
- - Added support for Intel "Sandy Bridge-E" CPUs
- - Added support for Intel "Ivy Bridge" CPUs
- - Added preliminary support for Intel "Haswell" CPUs
- - Added preliminary support for Intel "Haswell-ULT" CPUs
- - Added support for AMD "Kabini" (K16) CPUs
- - Added support for AMD "Bulldozer" CPUs
- - Added support for AMD "Trinity" CPUs
- - Added support for AMD E-/C-/G-/Z- "Bobcat" CPUs
- - Added support for Intel Atom "Pineview" CPUs
- - Added support for Intel Atom "Cedar Trail" CPUs
- - Added SPD detection on most AMD Chipsets
- - Enforced Coreboot support
- - Optimized run time for faster memory error detection
- - Rewriten lots of memory timings detection code
- - Corrected bugs, bugs and more bugs
-
diff --git a/allocate_pages_test/memtest86+/head.S b/allocate_pages_test/memtest86+/head.S
deleted file mode 100644
index d551336..0000000
--- a/allocate_pages_test/memtest86+/head.S
+++ /dev/null
@@ -1,847 +0,0 @@
-/*
- * linux/boot/head.S
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-/*
- * head.S contains the 32-bit startup code.
- *
- * 1-Jan-96 Modified by Chris Brady for use as a boot/loader for MemTest-86.
- * Setup the memory management for flat non-paged linear addressing.
- * 17 May 2004 : Added X86_PWRCAP for AMD64 (Memtest86+ - Samuel D.)
- */
-
-.text
-#define __ASSEMBLY__
-#include "defs.h"
-#include "config.h"
-#include "test.h"
-
- .code32
- .globl startup_32
-startup_32:
- cld
- cli
-
- /* Ensure I have a boot_stack pointer */
- testl %esp, %esp
- jnz 0f
- movl $(LOW_TEST_ADR + _GLOBAL_OFFSET_TABLE_), %esp
- leal boot_stack_top@GOTOFF(%esp), %esp
-0:
-
- /* Load the GOT pointer */
- call 0f
-0: popl %ebx
- addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx
-
- /* Pick the appropriate boot_stack address */
- leal boot_stack_top@GOTOFF(%ebx), %esp
-
- /* Reload all of the segment registers */
- leal gdt@GOTOFF(%ebx), %eax
- movl %eax, 2 + gdt_descr@GOTOFF(%ebx)
- lgdt gdt_descr@GOTOFF(%ebx)
- leal flush@GOTOFF(%ebx), %eax
- pushl $KERNEL_CS
- pushl %eax
- lret
-flush: movl $KERNEL_DS, %eax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %gs
- movw %ax, %ss
-
-/*
- * Zero BSS
- */
- cmpl $1, zerobss@GOTOFF(%ebx)
- jnz zerobss_done
- xorl %eax, %eax
- leal _bss@GOTOFF(%ebx), %edi
- leal _end@GOTOFF(%ebx), %ecx
- subl %edi, %ecx
-1: movl %eax, (%edi)
- addl $4, %edi
- subl $4, %ecx
- jnz 1b
- movl $0, zerobss@GOTOFF(%ebx)
-zerobss_done:
-
-/*
- * Setup an exception handler
- */
- leal idt@GOTOFF(%ebx), %edi
-
- leal vec0@GOTOFF(%ebx), %edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx, %ax /* selector = 0x0010 = cs */
- movw $0x8E00, %dx /* interrupt gate - dpl=0, present */
- movl %eax, (%edi)
- movl %edx, 4(%edi)
- addl $8, %edi
-
- leal vec1@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec2@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec3@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec4@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec5@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec6@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec7@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec8@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec9@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec10@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec11@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec12@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec13@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec14@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec15@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec16@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec17@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec18@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- leal vec19@GOTOFF(%ebx),%edx
- movl $(KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
-
- /* Now that it is initialized load the interrupt descriptor table */
- leal idt@GOTOFF(%ebx), %eax
- movl %eax, 2 + idt_descr@GOTOFF(%ebx)
- lidt idt_descr@GOTOFF(%ebx)
-
- leal _dl_start@GOTOFF(%ebx), %eax
- call *%eax
-
- /* Never forget to initialize the FPU ... Never ! */
- finit
-
- call test_start
-
- /* In case we return simulate an exception */
- pushfl
- pushl %cs
- call 0f
-0: pushl $0 /* error code */
- pushl $257 /* vector */
- jmp int_hand
-
-vec0:
- pushl $0 /* error code */
- pushl $0 /* vector */
- jmp int_hand
-vec1:
- pushl $0 /* error code */
- pushl $1 /* vector */
- jmp int_hand
-
-vec2:
- pushl $0 /* error code */
- pushl $2 /* vector */
- jmp int_hand
-
-vec3:
- pushl $0 /* error code */
- pushl $3 /* vector */
- jmp int_hand
-
-vec4:
- pushl $0 /* error code */
- pushl $4 /* vector */
- jmp int_hand
-
-vec5:
- pushl $0 /* error code */
- pushl $5 /* vector */
- jmp int_hand
-
-vec6:
- pushl $0 /* error code */
- pushl $6 /* vector */
- jmp int_hand
-
-vec7:
- pushl $0 /* error code */
- pushl $7 /* vector */
- jmp int_hand
-
-vec8:
- /* error code */
- pushl $8 /* vector */
- jmp int_hand
-
-vec9:
- pushl $0 /* error code */
- pushl $9 /* vector */
- jmp int_hand
-
-vec10:
- /* error code */
- pushl $10 /* vector */
- jmp int_hand
-
-vec11:
- /* error code */
- pushl $11 /* vector */
- jmp int_hand
-
-vec12:
- /* error code */
- pushl $12 /* vector */
- jmp int_hand
-
-vec13:
- /* error code */
- pushl $13 /* vector */
- jmp int_hand
-
-vec14:
- /* error code */
- pushl $14 /* vector */
- jmp int_hand
-
-vec15:
- pushl $0 /* error code */
- pushl $15 /* vector */
- jmp int_hand
-
-vec16:
- pushl $0 /* error code */
- pushl $16 /* vector */
- jmp int_hand
-
-vec17:
- /* error code */
- pushl $17 /* vector */
- jmp int_hand
-
-vec18:
- pushl $0 /* error code */
- pushl $18 /* vector */
- jmp int_hand
-
-vec19:
- pushl $0 /* error code */
- pushl $19 /* vector */
- jmp int_hand
-
-int_hand:
- pushl %eax
- pushl %ebx
- pushl %ecx
- pushl %edx
- pushl %edi
- pushl %esi
- pushl %ebp
-
- /* original boot_stack pointer */
- leal 48(%esp), %eax
- pushl %eax
- pushl %ds
- pushl %ss
- pushl %esp /* pointer to trap regs struct on the boot_stack */
- call inter
- addl $8, %esp
-
- popl %ebp
- popl %esi
- popl %edi
- popl %edx
- popl %ecx
- popl %ebx
- popl %eax
- iret
-
-/*
- * The interrupt descriptor table has room for 32 idt's
- */
-.align 4
-.word 0
-idt_descr:
- .word 20*8-1 # idt contains 32 entries
- .long 0
-
-idt:
- .fill 20,8,0 # idt is uninitialized
-
-gdt_descr:
- .word gdt_end - gdt - 1
- .long 0
-
-.align 4
-.globl gdt, gdt_end
-gdt:
- .quad 0x0000000000000000 /* NULL descriptor */
- .quad 0x0000000000000000 /* not used */
- .quad 0x00cf9b000000ffff /* 0x10 main 4gb code at 0x000000 */
- .quad 0x00cf93000000ffff /* 0x18 main 4gb data at 0x000000 */
-
- .word 0xFFFF # 16bit 64KB - (0x10000*1 = 64KB)
- .word 0 # base address = SETUPSEG
- .byte 0x00, 0x9b # code read/exec/accessed
- .byte 0x00, 0x00 # granularity = bytes
-
-
- .word 0xFFFF # 16bit 64KB - (0x10000*1 = 64KB)
- .word 0 # base address = SETUPSEG
- .byte 0x00, 0x93 # data read/write/accessed
- .byte 0x00, 0x00 # granularity = bytes
-
-gdt_end:
-
-.data
-
-.macro ptes64 start, count=64
-.quad \start + 0x0000000 + 0xE3
-.quad \start + 0x0200000 + 0xE3
-.quad \start + 0x0400000 + 0xE3
-.quad \start + 0x0600000 + 0xE3
-.quad \start + 0x0800000 + 0xE3
-.quad \start + 0x0A00000 + 0xE3
-.quad \start + 0x0C00000 + 0xE3
-.quad \start + 0x0E00000 + 0xE3
-.if \count-1
-ptes64 "(\start+0x01000000)",\count-1
-.endif
-.endm
-
-.macro maxdepth depth=1
-.if \depth-1
-maxdepth \depth-1
-.endif
-.endm
-
-maxdepth
-
-# Page Directory Tables:
-# There are 4 tables, the first two map the first 2 GB of memory. The last two are used with # PAE to map
-# the rest of memory in 2 GB segments. The last two tables are changed in vmem.c to map each segment.
-# We use 2 MB pages so only the Page Directory Table is used (no page tables).
-.balign 4096
-.globl pd0
-pd0:
- ptes64 0x0000000000000000
-
-.balign 4096
-.globl pd1
-pd1:
- ptes64 0x0000000040000000
-
-.balign 4096
-.globl pd2
-pd2:
- ptes64 0x0000000080000000
-
-.balign 4096
-.globl pd3
-pd3:
- ptes64 0x00000000C0000000
-
-# Legacy Mode Page Directory Pointer Table:
-# 4 Entries, pointing to the Page Directory Tables
-.balign 4096
-.globl pdp
-pdp:
- .long pd0 + 1
- .long 0
- .long pd1 + 1
- .long 0
- .long pd2 + 1
- .long 0
- .long pd3 + 1
- .long 0
-
-# Long Mode Page Directory Pointer Table:
-# 4 Entries, pointing to the Page Directory Tables
-.balign 4096
-lpdp:
- .long pd0 + 3
- .long 0
- .long pd1 + 3
- .long 0
- .long pd2 + 3
- .long 0
- .long pd3 + 3
- .long 0
-
-
-# The long mode level 4 page map table
-.balign 4096
-.globl pml4
-pml4:
- .long lpdp + 3
- .long 0
-.previous
-
-#define RSTART startup_32
-
- .globl query_pcbios
-query_pcbios:
- /* Save the caller save registers */
- pushl %ebx
- pushl %esi
- pushl %edi
- pushl %ebp
- call 1f
-1: popl %ebx
- addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
-
- /* Compute the reloc address */
- leal RSTART@GOTOFF(%ebx), %esi
-
- /* Fixup real code pointer */
- movl %esi, %eax
- shrl $4, %eax
- movw %ax, 2 + realptr@GOTOFF(%ebx)
-
- /* Fixup protected code pointer */
- leal prot@GOTOFF(%ebx), %eax
- movl %eax, protptr@GOTOFF(%ebx)
-
- /* Compute the gdt fixup */
- movl %esi, %eax
- shll $16, %eax # Base low
-
- movl %esi, %ecx
- shrl $16, %ecx
- andl $0xff, %ecx
-
- movl %esi, %edx
- andl $0xff000000, %edx
- orl %edx, %ecx
-
- /* Fixup the gdt */
- andl $0x0000ffff, REAL_CS + 0 + gdt@GOTOFF(%ebx)
- orl %eax, REAL_CS + 0 + gdt@GOTOFF(%ebx)
- andl $0x00ffff00, REAL_CS + 4 + gdt@GOTOFF(%ebx)
- orl %ecx, REAL_CS + 4 + gdt@GOTOFF(%ebx)
- andl $0x0000ffff, REAL_DS + 0 + gdt@GOTOFF(%ebx)
- orl %eax, REAL_DS + 0 + gdt@GOTOFF(%ebx)
- andl $0x00ffff00, REAL_DS + 4 + gdt@GOTOFF(%ebx)
- orl %ecx, REAL_DS + 4 + gdt@GOTOFF(%ebx)
-
- /* Fixup the gdt_descr */
- leal gdt@GOTOFF(%ebx), %eax
- movl %eax, 2 + gdt_descr@GOTOFF(%ebx)
-
- lidt idt_real@GOTOFF(%ebx)
-
- /* Don't disable the a20 line */
-
- /* Load 16bit data segments, to ensure the segment limits are set */
- movl $REAL_DS, %eax
- movl %eax, %ds
- movl %eax, %es
- movl %eax, %ss
- movl %eax, %fs
- movl %eax, %gs
-
- /* Compute the boot_stack base */
- leal boot_stack@GOTOFF(%ebx), %ecx
- /* Compute the address of meminfo */
- leal mem_info@GOTOFF(%ebx), %edi
-
- /* switch to 16bit mode */
- ljmp $REAL_CS, $1f - RSTART
-1:
- .code16
- /* Disable Paging and protected mode */
- /* clear the PG & PE bits of CR0 */
- movl %cr0,%eax
- andl $~((1 << 31)|(1<<0)),%eax
- movl %eax,%cr0
-
- /* make intersegment jmp to flush the processor pipeline
- * and reload %cs:%eip (to clear upper 16 bits of %eip).
- */
- ljmp *(realptr - RSTART)
-real:
- /* we are in real mode now
- * set up the real mode segment registers : %ds, %ss, %es, %gs, %fs
- */
- movw %cs, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %gs
- movw %ax, %ss
-
- /* Adjust the boot_stack pointer */
- movl %ecx, %eax
- shrl $4, %eax
- movw %ax, %ss
- subl %ecx, %esp
-
- /* Save my base pointer */
- pushl %ebx
-
- /* Setup %ds to point to my data area */
- shrl $4, %edi
- movl %edi, %ds
-
- /* Enable interrupts or BIOS's go crazy */
- sti
-
-# Get memory size (extended mem, kB)
-
-#define SMAP 0x534d4150
-
- xorl %eax, %eax
- movl %eax, (E88)
- movl %eax, (E801)
- movl %eax, (E820NR)
-
-# Try three different memory detection schemes. First, try
-# e820h, which lets us assemble a memory map, then try e801h,
-# which returns a 32-bit memory size, and finally 88h, which
-# returns 0-64m
-
-# method E820H:
-# the memory map from hell. e820h returns memory classified into
-# a whole bunch of different types, and allows memory holes and
-# everything. We scan through this memory map and build a list
-# of the first 32 memory areas, which we return at [E820MAP].
-# This is documented at http://www.teleport.com/~acpi/acpihtml/topic245.htm
-
-meme820:
- xorl %ebx, %ebx # continuation counter
- movw $E820MAP, %di # point into the whitelist
- # so we can have the bios
- # directly write into it.
-
-jmpe820:
- movl $0x0000e820, %eax # e820, upper word zeroed
- movl $SMAP, %edx # ascii 'SMAP'
- movl $20, %ecx # size of the e820rec
- pushw %ds # data record.
- popw %es
- int $0x15 # make the call
- jc bail820 # fall to e801 if it fails
-
- cmpl $SMAP, %eax # check the return is `SMAP'
- jne bail820 # fall to e801 if it fails
-
-# cmpl $1, 16(%di) # is this usable memory?
-# jne again820
-
- # If this is usable memory, we save it by simply advancing %di by
- # sizeof(e820rec).
- #
-good820:
- movb (E820NR), %al # up to 32 entries
- cmpb $E820MAX, %al
- jnl bail820
-
- incb (E820NR)
- movw %di, %ax
- addw $E820ENTRY_SIZE, %ax
- movw %ax, %di
-again820:
- cmpl $0, %ebx # check to see if
- jne jmpe820 # %ebx is set to EOF
-bail820:
-
-
-# method E801H:
-# memory size is in 1k chunksizes, to avoid confusing loadlin.
-# we store the 0xe801 memory size in a completely different place,
-# because it will most likely be longer than 16 bits.
-
-meme801:
- stc # fix to work around buggy
- xorw %cx,%cx # BIOSes which dont clear/set
- xorw %dx,%dx # carry on pass/error of
- # e801h memory size call
- # or merely pass cx,dx though
- # without changing them.
- movw $0xe801, %ax
- int $0x15
- jc mem88
-
- cmpw $0x0, %cx # Kludge to handle BIOSes
- jne e801usecxdx # which report their extended
- cmpw $0x0, %dx # memory in AX/BX rather than
- jne e801usecxdx # CX/DX. The spec I have read
- movw %ax, %cx # seems to indicate AX/BX
- movw %bx, %dx # are more reasonable anyway...
-
-e801usecxdx:
- andl $0xffff, %edx # clear sign extend
- shll $6, %edx # and go from 64k to 1k chunks
- movl %edx, (E801) # store extended memory size
- andl $0xffff, %ecx # clear sign extend
- addl %ecx, (E801) # and add lower memory into
- # total size.
-
-# Ye Olde Traditional Methode. Returns the memory size (up to 16mb or
-# 64mb, depending on the bios) in ax.
-mem88:
-
- movb $0x88, %ah
- int $0x15
- movw %ax, (E88)
-
-#ifdef APM_OFF
-# check for APM BIOS
- movw $0x5300, %ax # APM BIOS installation check
- xorw %bx, %bx
- int $0x15
- jc done_apm_bios # error -> no APM BIOS
-
- cmpw $0x504d, %bx # check for "PM" signature
- jne done_apm_bios # no signature -> no APM BIOS
-
- movw $0x5304, %ax # Disconnect first just in case
- xorw %bx, %bx
- int $0x15 # ignore return code
-
- movw $0x5301, %ax # Real Mode connect
- xorw %bx, %bx
- int $0x15
- jc done_apm_bios # error
-
- movw $0x5308, %ax # Disable APM
- mov $0xffff, %bx
- xorw %cx, %cx
- int $0x15
-
-done_apm_bios:
-#endif
-
- /* O.k. the BIOS query is done switch back to protected mode */
- cli
-
- /* Restore my saved variables */
- popl %ebx
-
- /* Get an convinient %ds */
- movw %cs, %ax
- movw %ax, %ds
-
- /* Load the global descriptor table */
- addr32 lgdt gdt_descr - RSTART
-
- /* Turn on protected mode */
- /* Set the PE bit in CR0 */
- movl %cr0,%eax
- orl $(1<<0),%eax
- movl %eax,%cr0
-
- /* flush the prefetch queue, and relaod %cs:%eip */
- data32 ljmp *(protptr - RSTART)
-prot:
- .code32
- /* Reload other segment registers */
- movl $KERNEL_DS, %eax
- movl %eax, %ds
- movl %eax, %es
- movl %eax, %fs
- movl %eax, %gs
- movl %eax, %ss
-
- /* Adjust the boot_stack pointer */
- leal boot_stack@GOTOFF(%ebx), %eax
- addl %eax, %esp
-
- /* Restore the caller saved registers */
- popl %ebp
- popl %edi
- popl %esi
- popl %ebx
- movl $1, %eax
- ret
-
-realptr:
- .word real - RSTART
- .word 0x0000
-protptr:
- .long 0
- .long KERNEL_CS
-
-idt_real:
- .word 0x400 - 1 # idt limit ( 256 entries)
- .word 0, 0 # idt base = 0L
-
-/* _ap_trampoline_start is the entry point for cpus other than the
- * bootstrap cpu. The code between _ap_trampoline_start to
- * _ap_trampoline_protmode is copied to BootCodeStart(0x9000).
- * The ljmp after turning on CR0.PE will jump to the
- * relocatable code which usually resides at 0x10000 + _ap_trampoline_protmode.
- *
- * The trampoline code uses a temporary GDT. The entries of this temporary
- * GDT must match the first few entries of the GDT used by the relocatble
- * memtest code(see 'gdt' sybmol in this file).
- *
- */
- .globl _ap_trampoline_start
- .globl _ap_trampoline_protmode
- .code16
-_ap_trampoline_start:
- lgdt 0x0 /* will be fixed up later, see smp.c:BootAP()*/
- movl %cr0, %eax
- orl $1, %eax
- movl %eax, %cr0
- data32 ljmp $KERNEL_CS, $_ap_trampoline_protmode
-_ap_trampoline_protmode:
- .code32
- movw $KERNEL_DS, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %gs
- movw %ax, %ss
- movl $(LOW_TEST_ADR + _GLOBAL_OFFSET_TABLE_), %esp
- leal boot_stack_top@GOTOFF(%esp), %esp
- pushl $0
- popf
- call startup_32
- /* if we ever return, we'll just loop forever */
- cli
-2: hlt
- jmp 2b
-.data
-zerobss: .long 1
-.previous
-.data
-.balign 16
- .globl mem_info
-mem_info:
- . = . + MEMINFO_SIZE
-.previous
-.bss
-.balign 16
-boot_stack:
- .globl boot_stack
- . = . + 4096
-boot_stack_top:
- .globl boot_stack_top
-.previous
diff --git a/allocate_pages_test/memtest86+/mt86+_loader b/allocate_pages_test/memtest86+/mt86+_loader
deleted file mode 100644
index 030ea1a..0000000
--- a/allocate_pages_test/memtest86+/mt86+_loader
+++ /dev/null
Binary files differ
diff --git a/allocate_pages_test/memtest86+/mt86+_loader.asm b/allocate_pages_test/memtest86+/mt86+_loader.asm
deleted file mode 100644
index 8472262..0000000
--- a/allocate_pages_test/memtest86+/mt86+_loader.asm
+++ /dev/null
@@ -1,231 +0,0 @@
-; A loader for www.memtest.org images, by Eric Auer 2003.
-; This assumes that the image starts with the boot sector,
-; which has the size of setup.S in sectors in a byte at offset
-; 1f1h (497). Further, I assume setup.S directly after the boot
-; sector and the actual memtest head.S after setup.S ...
-
-; This version is derived from memtestL loader, which loads
-; memtest.bin from a separate file. This version is meant to
-; be used like (DOS / Unix variants):
-; copy /b memteste.bin + memtest.bin memtest.exe
-; cat memteste.bin memtest.bin > memtest.exe
-; The good thing is that you get a single file which can be
-; compressed, for example with http://upx.sf.net/ (UPX).
-
-%define fullsize (150024 + buffer - exeh)
- ; 150024 is the size of memtest86+ V5.01, adjust as needed!
-
-%define stacksize 2048
-%define stackpara ((stacksize + 15) / 16)
-
- ; the trick is that NASM believes the header would be part
- ; of the loaded image, so we "org 20h bytes too early" to fix:
- org 0e0h ; NASM thinks after header we have 100h
- ; which is what we want it to think.
-
-exeh: db "MZ"
- dw fullsize % 512 ; how much to load from
- dw (fullsize + 511) / 512 ; .exe to RAM
- dw 0 ; no relocations used
- dw 2 ; header size is 2 * 16 bytes
- dw stackpara ; minimum heap is 128 * 16 bytes, for stack
- dw stackpara ; we do not need more heap either
- dw (fullsize + 15) / 16 ; SS is after file
- ; segment offsets are relative to PSPseg+10h
- ; initial DS and ES point to PSPseg, and file
- ; except headers is loaded to PSPseg+10h.
-
- dw stacksize-4 ; initial SP value
- dw 0 ; no checksum
- dw 100h ; initial IP
- dw -10h ; initial CS relative to PSPseg+10h
- dw 0 ; no relocation table, "offset 0 in file"
- dw 0 ; this is not an overlay
- db "MEMT" ; padding to a multiple of 16 bytes
-
- ; loaded part begins here (set CS so that IP is 100h here)
-
-start: ; entry point ; if you use obj + linker, use "..start:"
- mov ah, 01h
- mov bh, 00h
- mov cx, 2000h
- int 10h
-
- mov ax,cs ; ***
- mov ds,ax ; ***
- mov es,ax ; ***
-
- ; test if we have 386 or better:
- pushf ; save flags
- xor ax,ax
- push ax
- popf ; try to clear all bits
- pushf
- pop ax
- and ax,0f000h
- cmp ax,0f000h
- jz noinst1 ; 4 msb stuck to 1: 808x or 80186
- mov ax,0f000h
- push ax
- popf ; try to set 4 msb
- pushf
- pop ax
- test ax,0f000h
- jz noinst1 ; 4 msb stuck to 0: 80286
- popf ; restore flags
- jmp short found386
-
-noinst1:
- popf ; restore flags
- mov dx,need386
- jmp generror
-
-
-found386: ; now test if the system is in real mode:
- smsw ax ; MSW is the low half of CR0
- ; (smsw is not priv'd, unlike mov eax,cr0)
- test al,1 ; if the PE (protected mode) flag on?
-%ifndef DEBUG ; ignore findings in debug mode
- jnz foundprotected
-%endif
- jmp foundreal
-
-foundprotected:
- mov dx,noreal
- jmp generror
-
-; ------------
-
-need386 db "Sorry, you need at least a 386 CPU to use Memtest86+."
- db 13,10,"$"
-noreal db "You cannot run Memtest86+ if the system already is in"
- db " protected mode.",13,10,"$"
-
-; ------------
-
-generror: ; generic error exit
- push cs
- pop ds
- push cs
- pop es
- mov ah,9
- int 21h
- mov ax,4c01h
- int 21h
-
-; ------------
-
-foundreal:
- mov cx,buffer+15
- shr cx,4 ; buffer offset in paragraphs
- mov ax,cs
- add ax,cx ; buffer offset in paragraphs
- ; now AX is the buffer segment
- mov [cs:bufsetup+2],ax ; far pointer to boot sector now
- mov cx,20h ; size of boot sector in paragraphs
- add [cs:bufsetup+2],cx ; far pointer to setup now
- movzx eax,ax
- shl eax,4 ; linear buffer offset
- mov [cs:buflinear],eax
-
-findpoint: ; now patch the loader!
- mov al,[buffer+1f1h] ; size of setup.S in sectors
- ; should be 4 ...
- inc al ; the boot sector itself
- movzx eax,al
- shl eax,9 ; log 2 of sector size
- add [cs:buflinear],eax ; linear address of head.S now
- mov ax,[buffer+251h] ; should be jmp far dword (ofs, seg)
- cmp ax,0ea66h
- jz foundpatch
-patchbug: ; could not patch the jump
- mov dx,nopatch
- jmp generror
-
-gdtbug:
- mov dx,nogdt
- jmp generror
-
-foundpatch:
- mov eax,[cs:buflinear]
- mov [buffer+253h],eax ; patch the protected mode entry jump
- ; (offset only - segment selector unchanged: flat linear CS)
-
-findgdt:
- mov eax,[cs:buffer+20ch] ; should be lgdt offset
- and eax,00ffffffh
- cmp eax,0016010fh ; lgdt ...
- jnz gdtbug
-
- mov ax,[cs:buffer+20fh] ; GDTR contents pointer
- mov bx,ax
- mov eax,[cs:buffer+200h+bx+2] ; GDT linear offset
- and eax,1ffh ; assume GDT in first sector of setup.S
- ; *** WARNING: this is needed because setup.S contains
- ; *** HARDCODED offset of setup.S on linear 90200h, which
- ; *** is 90000h + bootsect.S ... flaw in Memtest86!
-
- mov cx,[cs:bufsetup+2] ; setup.S segment
- movzx ecx,cx
- shl ecx,4 ; linear setup.S address
- add eax,ecx ; fixed GDT linear offset
- mov [cs:buffer+200h+bx+2],eax ; patch it
-
- ;mov dx,trying
- ;mov ah,9
- ;int 21h
-
- ;xor ax,ax
- ;int 16h ; wait for a keypress from the user
-
- mov ax,[cs:bufsetup+2] ; setup segment
- mov ds,ax ; set nice data segments for setup.S ...
- mov es,ax
- xor ax,ax
- mov fs,ax
- mov gs,ax
-
- cli
- lss sp,[cs:newstack] ; stack in first 64k now!
- movzx esp,sp ; ensure 16bit stack pointer
- ; Memtest86 head.S assumes that it can just turn SS to
- ; linear. This would put the stack at 0:200h or so for us
- ; if we fail to move the stack around ...
-
-%ifdef DEBUG
- mov ebp,[cs:buflinear] ; will show up in debugging logs
- mov esi,[cs:bufsetup] ; will show up in debugging logs
-%endif
-
- jmp far [cs:bufsetup]
- ; setup.S will enable the A20 (ignoring HIMEM, just using
- ; the classic 8042 programming trick) and turn on protected
- ; mode. Then it will jump to head.S, which luckily can run
- ; from any offset inside the linear 4 GB CS ...
-
-; ------------
-
-buflinear dd 0 ; linear address of head.S entry point
-bufsetup dw 0,0 ; far pointer to setup.S entry point
-
-newstack dw 03fch,0 ; beware, stack will overwrite IDT.
-
-; ------------
-
-nopatch db "jmp far dword not found at setup.S offset 37h,",13,10
- db "(file offset 237h is not 66h, 0eah)",13,10
- db "please adjust and recompile memtestl...",13,10,"$"
-
-nogdt db "lgdt [...] not found at setup.S offset 0ch,",13,10
- db "(file offset 20ch is not 0fh, 01h, 16h)",13,10
- db "please adjust and recompile memtestl...",13,10,"$"
-
-trying db "Now trying to start Memtest86...",13,10
- db "You have to reboot to leave Memtest86 again.",13,10
- db "Press a key to go on.",13,10,"$"
-
-; ------------
-
- align 16
-buffer: ; a label pointing to where in the file memtest.bin will be.
-
diff --git a/allocate_pages_test/memtest86+/precomp.bin b/allocate_pages_test/memtest86+/precomp.bin
deleted file mode 100755
index 5738e08..0000000
--- a/allocate_pages_test/memtest86+/precomp.bin
+++ /dev/null
Binary files differ
diff --git a/allocate_pages_test/memtest86+/setup.S b/allocate_pages_test/memtest86+/setup.S
deleted file mode 100644
index f80875b..0000000
--- a/allocate_pages_test/memtest86+/setup.S
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * setup.s is responsible for getting the system data from the BIOS,
- * and putting them into the appropriate places in system memory.
- * both setup.s and system has been loaded by the bootblock.
- *
- * 1-Jan-96 Modified by Chris Brady for use as a boot/loader for memtest-86.
- */
-
-#define __ASSEMBLY__
-#include "defs.h"
-
-.code16
-.section ".setup", "ax", @progbits
-.globl start
-start:
-# ok, the read went well
-# now we want to move to protected mode ...
-
-
- cli # no interrupts allowed #
- movb $0x80, %al # disable NMI for the bootup sequence
- outb %al, $0x70
-
-# The system will move itself to its rightful place.
-# reload the segment registers and the stack since the
-# APs also execute this code
-#ljmp $INITSEG, $(reload - start + 0x200)
-reload:
- movw $INITSEG, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %ss # reset the stack to INITSEG:0x4000-12.
- movw %dx, %sp
- push %cs
- pop %ds
- lidt idt_48 - start # load idt with 0,0
- lgdt gdt_48 - start # load gdt with whatever appropriate
-
-# that was painless, now we enable A20
-# start from grub-a20.patch
- /*
- * try to switch gateA20 using PORT92, the "Fast A20 and Init"
- * register
- */
- mov $0x92, %dx
- inb %dx, %al
- /* skip the port92 code if it's unimplemented (read returns 0xff) */
- cmpb $0xff, %al
- jz alt_a20_done
-
- /* set or clear bit1, the ALT_A20_GATE bit */
- movb 4(%esp), %ah
- testb %ah, %ah
- jz alt_a20_cont1
- orb $2, %al
- jmp alt_a20_cont2
-alt_a20_cont1:
- and $0xfd, %al
-
- /* clear the INIT_NOW bit; don't accidently reset the machine */
-alt_a20_cont2:
- and $0xfe, %al
- outb %al, %dx
-
-alt_a20_done:
-# end from grub-a20.patch
-
- call empty_8042
-
- movb $0xD1, %al # command write
- outb %al, $0x64
- call empty_8042
-
- movb $0xDF, %al # A20 on
- outb %al, $0x60
- call empty_8042
-
-/*
- * Note that the short jump isn't strictly needed, althought there are
- * reasons why it might be a good idea. It won't hurt in any case.
- */
- movw $0x0001, %ax # protected mode (PE) bit
- lmsw %ax # This is it#
- jmp flush_instr
-flush_instr:
- movw $KERNEL_DS, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %ss
- movw %ax, %fs
- movw %ax, %gs
-
-data32 ljmp $KERNEL_CS, $(TSTLOAD <<4) # jmp offset 2000 of segment 0x10 (cs)
-
-/*
- * This routine checks that the keyboard command queue is empty
- * (after emptying the output buffers)
- *
- * No timeout is used - if this hangs there is something wrong with
- * the machine, and we probably couldn't proceed anyway.
- */
-empty_8042:
- call delay
- inb $0x64, %al # 8042 status port
- cmpb $0xff, %al # from grub-a20-patch, skip if not impl
- jz empty_8042_ret
- testb $1, %al # output buffer?
- jz no_output
- call delay
- inb $0x60, %al # read it
- jmp empty_8042
-
-no_output:
- testb $2, %al # is input buffer full?
- jnz empty_8042 # yes - loop
-empty_8042_ret:
- ret
-#
-# Delay is needed after doing i/o
-#
-delay:
- .word 0x00eb # jmp $+2
- ret
-
-gdt:
- .word 0,0,0,0 # dummy
-
- .word 0,0,0,0 # unused
-
- .word 0x7FFF # limit 128mb
- .word 0x0000 # base address=0
- .word 0x9A00 # code read/exec
- .word 0x00C0 # granularity=4096, 386
-
- .word 0x7FFF # limit 128mb
- .word 0x0000 # base address=0
- .word 0x9200 # data read/write
- .word 0x00C0 # granularity=4096, 386
-
-idt_48:
- .word 0 # idt limit=0
- .long 0 # idt base=0L
-
-gdt_48:
- .word 0x800 # gdt limit=2048, 256 GDT entries
- .word 512+gdt - start,0x9 # gdt base = 0X9xxxx
-
-msg1:
- .asciz "Setup.S\r\n"
-
- /* Pad setup to the proper size */
- .org (SETUPSECS*512)
-
diff --git a/allocate_pages_test/memtest86+/version.number b/allocate_pages_test/memtest86+/version.number
deleted file mode 100644
index 6b0b9f8..0000000
--- a/allocate_pages_test/memtest86+/version.number
+++ /dev/null
@@ -1 +0,0 @@
-4.99617 - Thu May 3 11:45:57 CEST 2012