Page 1 of 1
Help for James Molloy's Tutorial Known Bugs
Posted: Sun Apr 05, 2020 3:30 pm
by redoyk20
Hello everyone,
I am following JamesM's kernel development tutorials. I am trying to fix the erros in James Molloy's Tutorial Known Bugs in Osdev.
13 Problem: struct registers::esp is useless
I made the following fix for Problem 13. Is it true?
Code: Select all
typedef struct registers{
u32int ds; // Data segment selector
u32int edi, esi, ebp, esp, ebx, edx, ecx, eax; // Pushed by pusha.
u32int int_no, err_code; // Interrupt number and error code (if applicable)
u32int eip, cs, eflags, useresp, ss; // Pushed by the processor automatically.
} registers_t;
to;
Code: Select all
typedef struct registers{
u32int ds; // Data segment selector
u32int edi, esi, ebp, useless_value, ebx, edx, ecx, eax; // Pushed by pusha.
u32int int_no, err_code; // Interrupt number and error code (if applicable)
u32int eip, cs, eflags, useresp, ss; // Pushed by the processor automatically.
} registers_t;
12 Problem: ISR 17 and 30 have error codes
15 Problem: cli and sti in interrupt handlers
But,i don't know how to fix 12th and 15th problems.What changes are needed? I would be glad if your help
ISR handler's code
Re: Help for James Molloy's Tutorial Known Bugs
Posted: Wed Apr 08, 2020 1:50 am
by Octocontrabass
redoyk20 wrote:But,i don't know how to fix 12th and 15th problems.
Learning more about NASM macros might help you figure out the 12th problem.
Learning more about the
interrupt descriptor table might help you figure out the 15th problem. Take a close look at the difference between interrupt gates and trap gates.
It's important to understand the code you're writing when you're developing an OS.
Re: Help for James Molloy's Tutorial Known Bugs
Posted: Mon Apr 13, 2020 3:42 pm
by redoyk20
Octocontrabass wrote:redoyk20 wrote:But,i don't know how to fix 12th and 15th problems.
Learning more about NASM macros might help you figure out the 12th problem.
Learning more about the
interrupt descriptor table might help you figure out the 15th problem. Take a close look at the difference between interrupt gates and trap gates.
It's important to understand the code you're writing when you're developing an OS.
Hello again,
I have some changes about 12th and 15th problems.Can you review it?Is those correct?
https://github.com/jupiteer/JupiteerOS/ ... /asm/irq.s
https://github.com/jupiteer/JupiteerOS/ ... /asm/isr.s
Re: Help for James Molloy's Tutorial Known Bugs
Posted: Mon Apr 13, 2020 10:34 pm
by nullplan
irq.s:20: You know you can just "push ds", right?
irq.s:31: You are not handing the registers over as arguments... oh, you apparently haven't fixed problem 11 yet. Suffice it to say, you should push the base address of the structure before calling and remove it from stack afterwards ("push esp" beforehand and "add esp, 4" afterwards) and change irq_handler() to take as first argument a reg_t* instead of a plain reg_t.
isr.s: I am having major deja vu right now. Is that the same file as irq.s, only with a few things changed? That is copy-shake-paste, which is a horrible way of writing any code. You should probably refactor that with some macros, at least.
In general: Why did you remove the macros in favor of expanding them? It makes your code less readable. Your previous version only had four bytes wrong ("ISR_NOERRCODE" instead of "ISR_ERRCODE" for ISR 17 and 30). But your code appears to be correct now.
Re: Help for James Molloy's Tutorial Known Bugs
Posted: Wed Apr 15, 2020 7:13 am
by redoyk20
nullplan wrote:irq.s:20: You know you can just "push ds", right?
irq.s:31: You are not handing the registers over as arguments... oh, you apparently haven't fixed problem 11 yet. Suffice it to say, you should push the base address of the structure before calling and remove it from stack afterwards ("push esp" beforehand and "add esp, 4" afterwards) and change irq_handler() to take as first argument a reg_t* instead of a plain reg_t.
isr.s: I am having major deja vu right now. Is that the same file as irq.s, only with a few things changed? That is copy-shake-paste, which is a horrible way of writing any code. You should probably refactor that with some macros, at least.
In general: Why did you remove the macros in favor of expanding them? It makes your code less readable. Your previous version only had four bytes wrong ("ISR_NOERRCODE" instead of "ISR_ERRCODE" for ISR 17 and 30). But your code appears to be correct now.
Hello null plan,
I have overlooked the 11 th problem. I tried to be different from James molloy so I removed the macros and wrote them separately for each irq and isr, adding comment lines. I sent a pr based on what he said.Thank you!
https://github.com/jupiteer/JupiteerOS/ ... 18fe0ceb8e
I'm an amateur programmer trying to write OS. I would be glad if you can report any other problems and errors that attract your attention. Have a nice day!