Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Hi, I have did this before many years ago, implementing code to enter pmode after preparing gdts and disabling interrupts. But recently I am working on the project after losing all the old code, I re-wrote the code. However, it is not working. As soon as I enter pmode by setting the bit in cr0 register, machine resets. I know it is tricky and I can not remember what i did to make it work. I am still trying to fix when the time allows.
Can someone look at my code to see what could be wrong?
I decided to paste the entire code here:
Being able to do is extremely important to me as it blocks all my further development efforts.
I am willing to pay for person who can nail this for me (nego)
HEre is the lowdown:
I am using 2 HYPER-V VMs. One is dev machine running XP and
masm32 6.1 + VS.NET2003 (VS is not necesary except for makefile)
I created vfdd (virtual fdd with dos bootable partition from which I launch the pmode program)
conn-fd-dev.ps1 will connect the fdd into dev VM so I can copy the file to it.
conn-fd-boot.ps1 will connect the fdd into target VM from which I run the program from
once code loaded
simply type nmake pmsw to compile the code.
and to make the debugging easier, i made this neat function in the code called parseDesc that will print out every entry in the GDT verbosely.
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
Start with using Bochs and reading the logs when it crashes.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:Start with using Bochs and reading the logs when it crashes.
what is bochs btw? ???
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
it has to be compiled, duhhh, another project. anything ready to use? is there any compiled installable binary can be available for bochs?
or any x86 emulator to suggest. appreciate it.
Thanks.,
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
ok there is an bochs executable already available on the internet. downloaded and ran it. havent tried my program yet, but i can see it is a sweet stuff!! thanks a BUNCH! i am going to try what i can see when it crashes!
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
I DONT understand this tool. I have tried HOURS trying to create bootable image and tried to boot. Whatever I managed to create, it never able to boot off it. None of the tools in it works. There are also mtools.zip with bunch of tools inside but really nothing worked. I have tried to create blank disk image, msdos disk image, copy from bootable cdrom image, all fails one way or the other. it mentions about freeDOS which I downloaded but it can not recognize. I am not sure if i should waste any of my time with this. In my opinion, it is hard to use and poorly written.
The help files says there are lot of uncertainty about the how the tool will function.
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
on hyper-v i found there is event viewer can be inspected for VM events.
and i found event log in the hyper-v log that VM has definitely caused a triple-fault obviously due to pmode enter is crashing.
now i recalled, i used the jmp $ to place it in each successive line to see when it crashes vs. when it does not.
and i found that exact point it is causing triple fault:
mov eax, cr0
or eax, 01
mov cr0, eax
mov ax, 10h
mov ds, ax <---- this caused triple fault, meaning if i put jmp $ before this line, machine stays on, but if i put jmp $ after this, machine triple-fault and reboots.
i created 3 entries in the GDT which the parseDesc displays as follows:
I am currently inspecting which field of it could have caused it, enough for today though.
==============
Descriptor No: 00
===============:
Descriptor Info:
---------------:
Segment base: 00000000
Segment size(lim): 00000000
Rx06[7] - Granularity (0: multiplier 1, 1: multiplier 4K):00
Rx06[6] - Default Rx size: (0: 16-bit, 1: 32-bit):00
Rx06[5:4] - AVL (for O/S use any way):00
Rx05[7] - Present bit: (0: not present, 1: present):00
Rx05[5] - DPL(desc.priv.lvl bit:00
Rx05[4] - Segment bit (0: system segment, 1: data/code segment):00
Rx05[3] - Executable bit (0: data/stack/non-exec, 1: code segment):00
Rx05[2] - X - E0:direction of data seg/E=1:privilege level
(E0: 0: segment expands up(data), 1: segment expands down(stack)):00
Rx05[1] - RW bit
(E1: 0: data segment can NOT be W, 1: data segment can be W:00
Rx05[0] - A bit(accessed, each time CPU accesses it)00
==============
Descriptor No: 01
===============:
Descriptor Info:
---------------:
Segment base: 00000000
Segment size(lim): 0003FFFF
Rx06[7] - Granularity (0: multiplier 1, 1: multiplier 4K):01
Rx06[6] - Default Rx size: (0: 16-bit, 1: 32-bit):00
Rx06[5:4] - AVL (for O/S use any way):00
Rx05[7] - Present bit: (0: not present, 1: present):01
Rx05[5] - DPL(desc.priv.lvl bit:00
Rx05[4] - Segment bit (0: system segment, 1: data/code segment):01
Rx05[3] - Executable bit (0: data/stack/non-exec, 1: code segment):01
Rx05[2] - X - E0:direction of data seg/E=1:privilege level
(E=1: privilege level):01
Rx05[1] - RW bit
(E=1: 0: code segment can NOT be read, 1: code segment can be read):01
Rx05[0] - A bit(accessed, each time CPU accesses it)00
==============
Descriptor No: 02
===============:
Descriptor Info:
---------------:
Segment base: 40000000
Segment size(lim): 0003FFFF
Rx06[7] - Granularity (0: multiplier 1, 1: multiplier 4K):01
Rx06[6] - Default Rx size: (0: 16-bit, 1: 32-bit):00
Rx06[5:4] - AVL (for O/S use any way):00
Rx05[7] - Present bit: (0: not present, 1: present):01
Rx05[5] - DPL(desc.priv.lvl bit:00
Rx05[4] - Segment bit (0: system segment, 1: data/code segment):01
Rx05[3] - Executable bit (0: data/stack/non-exec, 1: code segment):00
Rx05[2] - X - E0:direction of data seg/E=1:privilege level
(E0: 0: segment expands up(data), 1: segment expands down(stack)):00
Rx05[1] - RW bit
(E1: 0: data segment can NOT be W, 1: data segment can be W:01
Rx05[0] - A bit(accessed, each time CPU accesses it)00
==============
Descriptor No: 03
===============:
Descriptor Info:
---------------:
Segment base: 80000000
Segment size(lim): 0003FFFF
Rx06[7] - Granularity (0: multiplier 1, 1: multiplier 4K):01
Rx06[6] - Default Rx size: (0: 16-bit, 1: 32-bit):00
Rx06[5:4] - AVL (for O/S use any way):00
Rx05[7] - Present bit: (0: not present, 1: present):01
Rx05[5] - DPL(desc.priv.lvl bit:00
Rx05[4] - Segment bit (0: system segment, 1: data/code segment):01
Rx05[3] - Executable bit (0: data/stack/non-exec, 1: code segment):00
Rx05[2] - X - E0:direction of data seg/E=1:privilege level
(E0: 0: segment expands up(data), 1: segment expands down(stack)):01
Rx05[1] - RW bit
(E1: 0: data segment can NOT be W, 1: data segment can be W:01
Rx05[0] - A bit(accessed, each time CPU accesses it)00
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails