problem with using printk in tftpbootable code
Re: problem with using printk in tftpbootable code
Your GDT is wrong. Look at what the far jump is trying to use as its descriptor.
The first GDT entry is unused; fill that with zeros, moving everything down one entry.
Don't be surprised when none of this works. The print_assembly file will be useless because you can't use BIOS interrupts in protected mode, and you haven't shown us where printk is defined, but since it looks like yoou did not write, you're doing it wrong. If you're trying to use something from Linux I'll have to assume (like everyone else who has tried to point it out), that's not going to work either.
Have you read Beginner Mistakes? And then after that, Bare bones ?
The first GDT entry is unused; fill that with zeros, moving everything down one entry.
Don't be surprised when none of this works. The print_assembly file will be useless because you can't use BIOS interrupts in protected mode, and you haven't shown us where printk is defined, but since it looks like yoou did not write, you're doing it wrong. If you're trying to use something from Linux I'll have to assume (like everyone else who has tried to point it out), that's not going to work either.
Have you read Beginner Mistakes? And then after that, Bare bones ?
Re: problem with using printk in tftpbootable code
hi,
What the problem in this, can't figure it out (bootloader was provided by Gigasoft).
The part about bare bones i've seen it but i need a bootloader first that sets up gdt and PM. Also i'm not using bochs. Testing it with a tftpboot.
Thanks
Alok
What the problem in this, can't figure it out (bootloader was provided by Gigasoft).
Code: Select all
bits 16
org 7c00h
cli
xor ax,ax
mov ds,ax
mov es,ax
lgdt [gdt_desc]
mov si,7e00h ; if your kernel has been placed at offset 200h, like you did
mov di,1000h ; the address where the kernel should be
mov cx,512 ; whatever the size of the kernel is
rep movsb
mov eax,cr0
or al,1
mov cr0,eax
jmp 8:clear_pipe
bits 32
clear_pipe:
mov ax,10h
mov ds,eax
mov es,eax
mov ss,eax
mov esp,90000h
jmp 1000h
gdt dd 0ffffh,0cf9a00h,0ffffh,0cf9200h
gdt_desc dw 23
dd gdt-8
Thanks
Alok
Re: problem with using printk in tftpbootable code
@Hangin10: Actually, that version of the GDT was mine, and it's fine. If you look at gdt_desc, you'll see why there is no zero-filled entry at the label "gdt".
@aloktiagi: Trust me, it's much easier to find out what's wrong by using Bochs. With testing on a real machine, at this stage you'll have a lot of trial and error and there will be almost no hope of making it work, especially when you don't have a firm grasp of the PC architecture to begin with. If you can't get TFTP booting to work in Bochs, you can always make a boot sector that relocates itself to another location, and then loads the entire Network Boot Program image from the virtual floppy, which is guarranteed to always work in Bochs. Use the debugging version of Bochs, and step through each instruction (stepping over BIOS services) to make sure the program works exactly how you expect it to.
@aloktiagi: Trust me, it's much easier to find out what's wrong by using Bochs. With testing on a real machine, at this stage you'll have a lot of trial and error and there will be almost no hope of making it work, especially when you don't have a firm grasp of the PC architecture to begin with. If you can't get TFTP booting to work in Bochs, you can always make a boot sector that relocates itself to another location, and then loads the entire Network Boot Program image from the virtual floppy, which is guarranteed to always work in Bochs. Use the debugging version of Bochs, and step through each instruction (stepping over BIOS services) to make sure the program works exactly how you expect it to.
Re: problem with using printk in tftpbootable code
Hi,
Found the problem!!! Just put the infinite loop instead of a jump to 1000h in the bootloader
Didn't reboot now, so am i jumping to the wrong place now?
Alok
Found the problem!!! Just put the infinite loop instead of a jump to 1000h in the bootloader
Code: Select all
bits 16
org 7c00h
cli
xor ax,ax
mov ds,ax
mov es,ax
lgdt [gdt_desc]
mov si,7e00h ; if your kernel has been placed at offset 200h, like you did
mov di,1000h ; the address where the kernel should be
mov cx,512 ; whatever the size of the kernel is
rep movsb
mov eax,cr0
or al,1
mov cr0,eax
jmp 8:clear_pipe
bits 32
clear_pipe:
mov ax,10h
mov ds,eax
mov es,eax
mov ss,eax
mov esp,90000h
[b];jmp 1000h[/b]
[b]jmp $[/b]
gdt dd 0ffffh,0cf9a00h,0ffffh,0cf9200h
gdt_desc dw 23
dd gdt-8
times 510-($-$$) db 0 ; Fill up the file with zeros
dw 0AA55h ; Boot sector identifyer
Alok
Re: problem with using printk in tftpbootable code
Aloktiagi,
Congratulations. So glad you found the problem!
- gerryg400
Congratulations. So glad you found the problem!
- gerryg400
If a trainstation is where trains stop, what is a workstation ?
Re: problem with using printk in tftpbootable code
Hi,
Thanks gerryg400!!
Now my bootloader code looks like this
My C code sits at 0x1000( linked it there). How do i find out that the jump from the bootloader is reaching the c code?
Thanks
Alok
Thanks gerryg400!!
Now my bootloader code looks like this
Code: Select all
bits 16
org 7c00h
cli
xor ax,ax
mov ds,ax
mov es,ax
lgdt [gdt_desc]
mov si,7e00h ; if your kernel has been placed at offset 200h, like you did
mov di,1000h ; the address where the kernel should be
mov cx,512 ; whatever the size of the kernel is
rep movsb
mov eax,cr0
or al,1
mov cr0,eax
jmp 08h:clear_pipe
bits 32
clear_pipe:
mov ax,10h
mov ds,eax
mov es,eax
mov ss,eax
mov esp,90000h
jmp 08h:01000h
mov byte [ds:0B8000h], 'P' ; Move the ASCII-code of 'P' into first video memory
mov byte [ds:0B8001h], 1Bh ; Assign a color code
jmp $
gdt dd 0ffffh,0cf9a00h,0ffffh,0cf9200h
gdt_desc dw 23
dd gdt-8
times 510-($-$$) db 0 ; Fill up the file with zeros
dw 0AA55h ; Boot sector identifyer
My C code sits at 0x1000( linked it there). How do i find out that the jump from the bootloader is reaching the c code?
Thanks
Alok
Re: problem with using printk in tftpbootable code
*sigh*
Is that so difficult to think up?
Make the C code print another character would be a good start.
Is that so difficult to think up?
Make the C code print another character would be a good start.
Every good solution is obvious once you've found it.
Re: problem with using printk in tftpbootable code
No, you didn't "find the problem". You just verified that the problem is in your C program, which was already known. What does your C program look like now?
By the way, it doesn't matter if you have jmp 1000h or jmp 8:1000h, since it's already running in segment 8.
By the way, it doesn't matter if you have jmp 1000h or jmp 8:1000h, since it's already running in segment 8.
Re: problem with using printk in tftpbootable code
Since GDT is configured now and i'm in protected mode (hopefully), what all can be done in the C code. Is anything else to be done?
Re: problem with using printk in tftpbootable code
Like, making it work?
"Hopefully" is a very poor status for a piece of code...
/me is looking for the candid camera...
"Hopefully" is a very poor status for a piece of code...
/me is looking for the candid camera...
Every good solution is obvious once you've found it.
Re: problem with using printk in tftpbootable code
Hi,
To make it work i put something like
(from http://wiki.osdev.org/Bare_bones)
And the computer reboots. If i only put a infinte loop in c code the computer hangs and doesn't reboot.
To make it work i put something like
Code: Select all
unsigned char *videoram = (unsigned char *) 0xb8000;
videoram[0] = 65; /* character 'A' */
videoram[1] = 0x07; /* forground, background color. */
And the computer reboots. If i only put a infinte loop in c code the computer hangs and doesn't reboot.
Re: problem with using printk in tftpbootable code
What happens if you have the above followed by an infinite loop?
Re: problem with using printk in tftpbootable code
Hi,
It worked Thanks. Now after this what shud be the next step. My first main requirement is initializing the ethernet card. Can that be done now or i need to enable things like ISR, IDT etc...
Thanks
Alok
It worked Thanks. Now after this what shud be the next step. My first main requirement is initializing the ethernet card. Can that be done now or i need to enable things like ISR, IDT etc...
Thanks
Alok
Re: problem with using printk in tftpbootable code
Hello,
Do you know exactly why your software was crashing? We do not know your design goals so we are limited in helping you plan your system.
I personally would work on the basic system components before anything else. Before that though you should decide on the basic structure of your system - microkernel? monolithic kernel? What do you want to support? If you are unsure, go with monolithic for now and focus on the IDT and adding hardware interrupt support (PIC or APIC).
Do you know exactly why your software was crashing? We do not know your design goals so we are limited in helping you plan your system.
I personally would work on the basic system components before anything else. Before that though you should decide on the basic structure of your system - microkernel? monolithic kernel? What do you want to support? If you are unsure, go with monolithic for now and focus on the IDT and adding hardware interrupt support (PIC or APIC).
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: problem with using printk in tftpbootable code
What you need to do next, honestly, is to take a look at these two Wiki pages:aloktiagi wrote:Hi,
It worked Thanks. Now after this what shud be the next step. My first main requirement is initializing the ethernet card. Can that be done now or i need to enable things like ISR, IDT etc...
Thanks
Alok
http://wiki.osdev.org/What_order_should ... ings_in%3F
http://wiki.osdev.org/Nick_Stacky
Come up with a design plan - design documents aren't just for corporate environments. They're a good idea for anyone who is setting out on a large project (like an OS). Once you've figured out where you need (and want) to go, split it up into the things that must happen, the things that should happen, and then the things you would like to have happen. Write out a roadmap of features that you will code (including dependancies). Get your head on straight about what you're doing.
Then, and only then, should you start actually coding.