osdev

Do I have to pop the error code pushed to stack by certain exceptions before returning from the interrupt handler?

泪湿孤枕 提交于 2019-12-04 06:44:57
I have loaded an idt table with 256 entries, all pointing to similar handlers: for exceptions 8 and 10-14, push the exception number (these exceptions push an error code automatically) for the others, push a "dummy" error code and the exception number; then jump to a common handler So when the common handler enters, the stack is properly aligned and contains the exception/interrupt number, error code (which may just be a dummy), eflags, cs and eip. My question regards returning from the interrupt handler. I use iret to return after taking out the exception number and the error code from the

Call a raw address from Rust

倖福魔咒の 提交于 2019-12-04 03:28:40
问题 I am writing an OS in Rust and need to directly call into a virtual address that I'm calculating (of type u32 ). I expected this to be relatively simple: let code = virtual_address as (extern "C" fn ()); (code)(); However, this complains that the cast is non-primitive. It suggests I use the From trait, but I don't see how this could help (although I am relatively new to Rust and so could be missing something). error[E0605]: non-primitive cast: `u32` as `extern "C" fn()` --> src/main.rs:3:16 |

Disk Read Error while loading sectors into memory

北慕城南 提交于 2019-12-03 12:05:19
I tried to develop a bootloader using this , but when it is run it shows: disk read error! If I ignore it, in a later part, it shows me wrong memory mapping. I also followed some other sources too but in vain. It feels like I'm just copying what they are doing. If I do even a little different a new kind of error generates every time. Should I use an already built bootloader or what to do? The code of disk load error is as follow: [org 0x7c00] KERNEL_OFFSET equ 0x1000 mov [BOOT_DRIVE], dl mov bp, 0x9000 mov sp, bp mov bx, MSG_REAL_MODE call print_string call load_kernel jmp $ print_string:

Return value of a C function to ASM

时光怂恿深爱的人放手 提交于 2019-12-03 11:28:25
I'm trying to call a function from within ASM. I know how to call it, but i'm having trouble finding how to get the return value of this function. An example follows: C code: int dummy() { return 5; } (N)ASM code: dummyFunction: call dummy ;grab return into eax inc eax ; eax should be 6 now ret Any ideas? The return value is in eax . If you've called a C function from asm, you can read the return value from eax . If you're trying to return from an asm function to C, store the intended return value in eax . Things get a little bit more complicated for returning floating point values, long long

Other than malloc/free does a program need the OS to provide anything else?

只愿长相守 提交于 2019-12-03 04:35:21
问题 I'm working on designing the kernel (which I'm going to actually call the "core" just to be different, but its basically the same) for an OS I'm working on. The specifics of the OS itself are irrelevant if I can't get multi-tasking, memory management, and other basic things up and running, so I need to work on that first. I've some questinos about designing a malloc routine. I figure that malloc() is either going to be a part of the kernel itself (I'm leaning towards this) or a part of the

How are Operating Systems “Made”?

痴心易碎 提交于 2019-12-03 01:43:37
问题 Creating an OS seems like a massive project. How would anyone even get started? For example, when I pop Ubuntu into my drive, how can my computer just run it? (This, I guess, is what I'd really like to know.) Or, looking at it from another angle, what is the least amount of bytes that could be on a disk and still be "run" as an OS? (I'm sorry if this is vague. I just have no idea about this subject, so I can't be very specific. I pretend to know a fair amount about how computers work, but I'm

How to load a kernel from disk with BIOS int 13h in NASM assembly?

六月ゝ 毕业季﹏ 提交于 2019-12-02 21:03:55
I've been stuck with this for weeks now and have no idea where I'm going wrong because NASM hasn't given me any errors. The code is pretty self explanatory because of the comments. this is the code that is loaded from the BIOS ;-------------------------------------------- ; 'boot.asm' ; loaded from BIOS [org 0x7C00] [bits 16] ;-------------------------------------------- main: mov ah, 0x0E ; print function mov al, '.' ; ascii char int 0x10 ; IO int resetdisk: mov ah, 0x00 ; reset function mov dl, 0x00 ; drive int 0x13 ; disk int jc resetdisk readdisk: mov bx, 0x8000 ; segment mov es, bx mov bx

Other than malloc/free does a program need the OS to provide anything else?

北城以北 提交于 2019-12-02 18:53:24
I'm working on designing the kernel (which I'm going to actually call the "core" just to be different, but its basically the same) for an OS I'm working on. The specifics of the OS itself are irrelevant if I can't get multi-tasking, memory management, and other basic things up and running, so I need to work on that first. I've some questinos about designing a malloc routine. I figure that malloc() is either going to be a part of the kernel itself (I'm leaning towards this) or a part of the program, but I'm going to have to write my own implementation of the C standard library either way, so I

How can I build a small operating system on an old desktop computer? [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-02 13:46:34
This might be in vain, as I know writing an operating system is unbearably complicated (especially by oneself). I don't expect to build the next linux, or windows. I know it will be horrible, and buggy, and won't work, but that's fine. I want to write everything myself, in Assembly , C , and (some) C++ . This is a future project, as I'm busy with some other things at the moment and don't have the time immediately, but I figured I would ask it now, so maybe I could get lots of answers to this, and it could build up and be a useful resource for this kind of approach (everything else I have seen

Error while creating a bootable floppy that contains a bootloader and a kernel

∥☆過路亽.° 提交于 2019-12-02 11:47:30
问题 I'm trying to create a bootable floppy drive for my boot.bin and kernel.bin files. My boot.asm code is: bits 16 section .text start: JMP MAIN WAIT_FOR_KEY: MOV AH, 00H INT 16H RET CLEAR: MOV AH, 0H ;CHANGING THE VIDEO MODE TO CLEAR THE SCREEN MOV AL, 03H ;VIDEO MODE COD INT 10H RET LOG_TO_HTS: PUSH BX PUSH AX MOV BX, AX MOV DX, 0 DIV WORD[ALL_SECTORS] ADD DL, 01H MOV CL, DL MOV AX, BX MOV DX, 0 DIV WORD [ALL_SECTORS] MOV DX, 0 DIV WORD[FACES] MOV DH, DL MOV CH, AL POP AX POP BX MOV DL, BYTE