osdev

Linux memory segmentation

ⅰ亾dé卋堺 提交于 2021-02-18 10:48:06
问题 Looking into the internals of Linux and memory management, I just stumbled upon the segmented paging model that Linux uses. Correct me if I am wrong, but Linux (protected mode) does use paging for mapping a linear virtual address space to the physical address space. This linear address space constituted of pages, is split into four segments for the process flat memory model, namely: The kernel code segment ( __KERNEL_CS ); The kernel data segment ( __KERNEL_DS ); The user code segment ( _

How is a GDT invoked?

血红的双手。 提交于 2021-02-16 21:50:36
问题 I know how a GDT (Global Descriptor Table) is implemented and the use of segment registers and segment descriptors. However how/when is a GDT entry accessed? Is it accessed in basic mov instructions like mov [eax],ebx Does this implicitly invoke ds segment register and then access the GDT segment descriptor or there is some other way via which access to the GDT entry happens? 回答1: TL;DR : The Global Descriptor Table (GDT) or Local Descriptor Table (LDT) is only accessed when a segment

How is a GDT invoked?

北城余情 提交于 2021-02-16 21:49:25
问题 I know how a GDT (Global Descriptor Table) is implemented and the use of segment registers and segment descriptors. However how/when is a GDT entry accessed? Is it accessed in basic mov instructions like mov [eax],ebx Does this implicitly invoke ds segment register and then access the GDT segment descriptor or there is some other way via which access to the GDT entry happens? 回答1: TL;DR : The Global Descriptor Table (GDT) or Local Descriptor Table (LDT) is only accessed when a segment

How do I call hex data stored in an array with inline assembly?

你。 提交于 2021-02-10 11:56:32
问题 I have an OS project that I am working on and I am trying to call data that I have read from the disk in C with inline assembly. I have already tried reading the code and executing it with the assembly call instruction, using inline assembly. void driveLoop() { uint16_t sectors = 31; uint16_t sector = 0; uint16_t basesector = 40000; uint32_t i = 40031; uint16_t code[sectors][256]; int x = 0; while(x==0) { read(i); for (int p=0; p < 256; p++) { if (readOut[p] == 0) { } else { x = 1; //kprint

How do I call hex data stored in an array with inline assembly?

[亡魂溺海] 提交于 2021-02-10 11:55:11
问题 I have an OS project that I am working on and I am trying to call data that I have read from the disk in C with inline assembly. I have already tried reading the code and executing it with the assembly call instruction, using inline assembly. void driveLoop() { uint16_t sectors = 31; uint16_t sector = 0; uint16_t basesector = 40000; uint32_t i = 40031; uint16_t code[sectors][256]; int x = 0; while(x==0) { read(i); for (int p=0; p < 256; p++) { if (readOut[p] == 0) { } else { x = 1; //kprint

Identifying faulting address on General Protection Fault (x86)

馋奶兔 提交于 2021-02-07 13:13:05
问题 I am trying to write a ISR for the General Protection Fault (GP#13) on x86. I am unable to figure out from the INTEL docs as to how I can find out the faulting address causing the exception. I know that for Page fault exceptions (GP#14) the cr2 register holds the faulting address. Any help is appreciated. 回答1: All references I make here are from AMD64 Architecture Programmer's Manual Volume 2: System Programming, which also describes the legacy protected-mode (i.e., x86) behavior. Figure 8-8

Identifying faulting address on General Protection Fault (x86)

人盡茶涼 提交于 2021-02-07 13:13:00
问题 I am trying to write a ISR for the General Protection Fault (GP#13) on x86. I am unable to figure out from the INTEL docs as to how I can find out the faulting address causing the exception. I know that for Page fault exceptions (GP#14) the cr2 register holds the faulting address. Any help is appreciated. 回答1: All references I make here are from AMD64 Architecture Programmer's Manual Volume 2: System Programming, which also describes the legacy protected-mode (i.e., x86) behavior. Figure 8-8

MinGW's ld cannot perform PE operations on non PE output file

喜你入骨 提交于 2021-02-07 08:08:44
问题 I know there are some other similar questions about this out there, be it StackOverflow or not. I've researched a lot for this, and still didn't find a single solution. I'm doing an operative system as a side project. I've been doing all in Assembly, but now I wanna join C code. To test, I made this assembly code file (called test.asm): [BITS 32] GLOBAL _a SECTION .text _a: jmp $ Then I made this C file (called main.c): extern void a(void); int main(void) { a(); } To link, I used this file

MinGW's ld cannot perform PE operations on non PE output file

喜你入骨 提交于 2021-02-07 08:06:17
问题 I know there are some other similar questions about this out there, be it StackOverflow or not. I've researched a lot for this, and still didn't find a single solution. I'm doing an operative system as a side project. I've been doing all in Assembly, but now I wanna join C code. To test, I made this assembly code file (called test.asm): [BITS 32] GLOBAL _a SECTION .text _a: jmp $ Then I made this C file (called main.c): extern void a(void); int main(void) { a(); } To link, I used this file

PS/2 Mouse Not Firing

孤街浪徒 提交于 2021-02-07 04:36:32
问题 Everyone! I just finished writing my Keyboard Driver. Right now the problem is that my PS/2 MOUSE IRQ won't fire(IRQ 12). I tested this by this code: #include "irq.h" #define PIC_MASTER_CONTROL 0x20 #define PIC_MASTER_MASK 0x21 #define PIC_SLAVE_CONTROL 0xa0 #define PIC_SLAVE_MASK 0xa1 typedef void(*regs_func)(struct regs *r); /*Get all irq's*/ extern "C" void irq0(void); extern "C" void irq1(void); extern "C" void irq2(void); extern "C" void irq3(void); extern "C" void irq4(void); extern "C"