Help for James Molloy's Tutorial Known Bugs

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.
Post Reply
redoyk20
Posts: 3
Joined: Sun Apr 05, 2020 3:14 pm
Location: GNU/LINUX

Help for James Molloy's Tutorial Known Bugs

Post 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
Octocontrabass
Member
Member
Posts: 5578
Joined: Mon Mar 25, 2013 7:01 pm

Re: Help for James Molloy's Tutorial Known Bugs

Post 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.
redoyk20
Posts: 3
Joined: Sun Apr 05, 2020 3:14 pm
Location: GNU/LINUX

Re: Help for James Molloy's Tutorial Known Bugs

Post 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
nullplan
Member
Member
Posts: 1794
Joined: Wed Aug 30, 2017 8:24 am

Re: Help for James Molloy's Tutorial Known Bugs

Post 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.
Carpe diem!
redoyk20
Posts: 3
Joined: Sun Apr 05, 2020 3:14 pm
Location: GNU/LINUX

Re: Help for James Molloy's Tutorial Known Bugs

Post 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!
Post Reply