Kernel loading
Kernel loading
OK, I?ve created my own filesystem, because so it was easier for me to laod my kernel from a floppy disk. But now I get into troublw ith this, because although I load my kernel 0x1000 and then moving it to 0x100000, there is some code of the bootsector in the kernel. I think so, because there are 4bytes, which are equal to the first 4bytes of the bootsector. But the problem is that my code is hard to read and that you need time and you have to be good at assembly. So first I want to ask, if here is anyone who would help me with my problem. If not, I needn?t to upload my source code.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Kernel loading
1. Hmmm ... can't you load the kernel directly to 1 mb by passing the proper information to bios int 13h? I did it and it worked as I expected it to.
2. Beeing good at assembler ot not beeng good at assembler that is the question here ... well I can write and read assembler code, but: I won't read UNCOMMENTED assembler code. This is a mess for you and a mess for me as well as for anyone else who wants to help you.
stay safe
2. Beeing good at assembler ot not beeng good at assembler that is the question here ... well I can write and read assembler code, but: I won't read UNCOMMENTED assembler code. This is a mess for you and a mess for me as well as for anyone else who wants to help you.
stay safe
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Kernel loading
My bootsector is commented. Maybe you could post the values I need to load my kernel to the 1mb mark?!
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Kernel loading
I am looking ...
this I use to tell int 13h to load kernel to 0x100000.
found how to do this btw in the fritzos boot loader and in perica senjaks real mode adressing doc.
Code: Select all
mov ax,0xffff
mov es,ax
mov bx.0x10
found how to do this btw in the fritzos boot loader and in perica senjaks real mode adressing doc.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Kernel loading
Thank you, but I will use my variant. I also will comment my kernel code and then I upload it. Maybe there is someone who have a look at my code. Is there a way, how I can debug my kernel code with Bochs? I mean I want to look at every instruction so that I may see from where I?m writing into my kernel.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Kernel loading
debug with box:
start the debugger; indicate a bochserr.txt for trace-log;
make ctrl-c as soon as you enter your boot loader; enter 'trace-on' at box-cli; enter 'c' -> the show goes on.
with 'step n' you can have box execute the next 10 instructions.
In windows, you'll find the debugger option by right click on your *.bxrc-file to call the context menu.
start the debugger; indicate a bochserr.txt for trace-log;
make ctrl-c as soon as you enter your boot loader; enter 'trace-on' at box-cli; enter 'c' -> the show goes on.
with 'step n' you can have box execute the next 10 instructions.
In windows, you'll find the debugger option by right click on your *.bxrc-file to call the context menu.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Kernel loading
Thanks, I used this, but I didn?t found a failure. But I also haven?t got time to take a deeper look. I attached the source of my bootloader and my kernel. If you have questions please ask. I didn?t comment all, because I don?t think that you will look at the whole code. I only commented the important code!
[attachment deleted by admin]
[attachment deleted by admin]
Re:Kernel loading
OK, I?ve forgotten to describe my problem more detailed. I have the problem that when the code grows that the values of the last vars get overwritten! You can test this when you make the following changes:
Old code:
New code:
The value of the var should be 0, but it isn?t 0.
Now try this code:
Now the value is 0. But why? Because of that I deleted some code? Please help me!
Edit::
I believe now that there is a problem with my bootsector. I assemble my bootsector and my kernel and then I copy both into 1 file so that I have a diskimage! Then I write this diskimage with rawwritewin on a disk. I use logical sectors to load my kernel file of the disk. Maybe this is the problem, but I don?t think so! But it would be good if someone have a look at my bootcode!
Old code:
Code: Select all
call mem_info
lidt [IDTR]
sti
.hang
jmp $
Code: Select all
call mem_info
lidt [IDTR]
sti
mov eax,[taskmngr_thread_desc]
call hex2ascii32bit_str
.hang
jmp $
Now try this code:
Code: Select all
;call mem_info
;lidt [IDTR]
;sti
mov eax,[taskmngr_thread_desc]
call hex2ascii32bit_str
.hang
jmp $
Edit::
I believe now that there is a problem with my bootsector. I assemble my bootsector and my kernel and then I copy both into 1 file so that I have a diskimage! Then I write this diskimage with rawwritewin on a disk. I use logical sectors to load my kernel file of the disk. Maybe this is the problem, but I don?t think so! But it would be good if someone have a look at my bootcode!
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Kernel loading
sounds like nobody did ...
what do you mean by "logical sectors" ? you're booting from a floppy, right ? what is "logical sector" on a floppy ... afaik, only CHS is available on such a disk.
what do you mean by "logical sectors" ? you're booting from a floppy, right ? what is "logical sector" on a floppy ... afaik, only CHS is available on such a disk.
Re:Kernel loading
By logical sectory I mean that I start with sector 0 and go on till sector 2879 (a floppy has 2880 sectors). This is my function to get the head/track/sector from a logical sector:
Code: Select all
SectorsPertrack dw 18
Heads dw 2
;----------------------------
; Input:
; AX - logical sector
; Output:
; CL - sector
; CH - track
; DH - head
trans_lsn:
???xor dx,dx
???div word[SectorsPerTrack]
???inc dx
???mov cl,dl
???xor dx,dx
???div word[Heads]
???shr dx,8
???mov ch,al
.end
???ret
;----------------------------
Re:Kernel loading
Finally I found the failure ;D My "trans_lsn" function wasn?t right.
This is the right code:
This is the right code:
Code: Select all
;----------------------------
; Input:
; AX - logical sector
; Output:
; CL - sector
; CH - track
; DH - head
trans_lsn:
xor dx,dx
div word[SectorsPerTrack]
inc dl
mov cl,dl
xor dx,dx
div word[Heads]
shl dx,8
mov ch,al
.end
ret
;----------------------------
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact: