osdev

How To Build a Operating System With C#

若如初见. 提交于 2019-12-07 20:40:41
问题 I was reading about Singularity and it was developed in part with C#, but how can I develop a operatin system in part with C#?(because the boot loader needs to be in Assembly, that I know) the thing that I want to know is where to start(tutorial, library...)? PS: Congratulations to the Singularity developers, very nice job! ;) 回答1: Renraku is an open source project to create an OS using .NET technologies as much as possible. This post has a link to the source on GitHub. 回答2: The major

Triple fault when jumping into protected mode

别说谁变了你拦得住时间么 提交于 2019-12-07 11:19:22
问题 I'm developing a boot loader, which will boot into a simple kernel after switching into protected mode. I used this paper as a tutorial, somewhere in chapter four or five. In theory it is supposed to start in 16-bit real mode, load the kernel into memory, switch to 32-bit protected mode and start executing the kernel code. However, when I switch into protected mode and far jump or jump to another segment, it triple faults. Here is the main boot sector code: [org 0x7c00] KERNEL_OFFSET equ

How can I JMP to relocated code in my MBR?

喜欢而已 提交于 2019-12-07 09:38:32
问题 I'm trying to write an extremely simple MBR to start learning how to write an MBR/Kernel. This is what I have so far (created from pieces of other MBRs). The binary I get from using nasm and then ld to link is a bit different from just using nasm for both, but that doesn't appear to be the problem. I first started with jmp 0:continue but that appears to jump to 0000:7c22 (or 001d with nasm alone... i believe i didnt specify that it starts at 7c00 ) but im looking to jump to :7a22 or :7a1d ,

Rebooting in Protected Mode

南笙酒味 提交于 2019-12-07 08:33:36
问题 In x86 Real Mode rebooting is very simple. You can either use the BIOS or: jmp 0xFFFF:0000 But how should one reboot when in Protected Mode? 回答1: I used to write 6 to port 0xcf9, but here is a bigger list: http://smackerelofopinion.blogspot.nl/2009/06/rebooting-pc.html?m=1 回答2: The proper way to reboot on protected mode (x86 or x86_64) is to use the power management functions (if available) Advanced Configuration and Power Interface (ACPI) Advanced power management (APM) BIOS (under vm86 or

GCC code that seems to break inline assembly rules but an expert believes otherwise

孤者浪人 提交于 2019-12-07 04:03:55
问题 I was engaged with an expert who allegedly has vastly superior coding skills than myself who understands inline assembly far better than I ever could. One of the claims is that as long as an operand appears as an input constraint, you don't need to list it as a clobber or specify that the register has been potentially modified by the inline assembly. The conversation came about when someone else was trying to get assistance on a memset implementation that was effectively coded this way: void

How To Build a Operating System With C#

折月煮酒 提交于 2019-12-06 13:31:20
I was reading about Singularity and it was developed in part with C#, but how can I develop a operatin system in part with C#?(because the boot loader needs to be in Assembly, that I know) the thing that I want to know is where to start(tutorial, library...)? PS: Congratulations to the Singularity developers, very nice job! ;) Renraku is an open source project to create an OS using .NET technologies as much as possible. This post has a link to the source on GitHub. The major difference between an operating system that runs on managed code vs. one that runs directly on machine code is really

Gcc inline assembly: what's wrong with the dynamic allocated register `r` in input operand?

泪湿孤枕 提交于 2019-12-06 09:19:17
问题 When I test the GCC inline-assembly, I use the test function to display a character on the screen with the BOCHS emulator. This code is running in 32-bit protected mode. The code is as follows: test() { char ch = 'B'; __asm__ ("mov $0x10, %%ax\n\t" "mov %%ax, %%es\n\t" "movl $0xb8000, %%ebx\n\t" "mov $0x04, %%ah\n\t" "mov %0, %%al\n\t" "mov %%ax, %%es: ((80 * 3 + 40) * 2)(%%ebx)\n\t" ::"r"(ch):); } The result I'm getting is: The red character on the screen isn't displaying B correctly.

Linking a file using ld to output a binary file gives error in OS development

蓝咒 提交于 2019-12-06 06:36:56
问题 I am learning Operating system tutorials. I created 2 files. boot.asm kernel.c The kernel.c is as follows : int main() { char *src = (char *)0xB8000000L; *src = 'M'; src += 2; *src = 'D'; return 0; } The kernel is used to write a character to the text mode video display area. The kernel was compiled using Windows version of GCC with: gcc -ffreestanding -c -m16 kernel.c -o kernel.o I link the kernel object to a binary file using LD : ld -Ttext 0x10000 --oformat binary -o kernel.bin kernel.o

Simple C Kernel char Pointers Aren't Working

烈酒焚心 提交于 2019-12-06 05:29:54
问题 I am trying to make a simple kernel using C. Everything loads and works fine, and I can access the video memory and display characters, but when i try to implement a simple puts function for some reason it doesn't work. I've tried my own code and other's. Also, when I try to use a variable which is declared outside a function it doesn't seem to work. This is my own code: #define PUTCH(C, X) pos = putc(C, X, pos) #define PUTSTR(C, X) pos = puts(C, X, pos) int putc(char c, char color, int spos)

“times 510-($-$$) db 0” does not work

穿精又带淫゛_ 提交于 2019-12-06 04:09:11
I am learning about boot sectors. I downloaded nasm-installer-x64.exe from the NASM website. My operating system is win7-64bit. When I run the following code it does not work correctly mov ah, 0x0e; mov al, the_secret; int 0x10; mov al, [the_secret]; int 0x10; mov bx, [the_secret]; add bx, 0x7c00; mov al, [bx]; int 0x10; mov al, [0x7c1e]; int 0x10; jmp $; the_secret:; db 'X'; times 510-($-$$) db 0; dw 0xaa55; Michael Petch I don't believe there is anything wrong with times 510-($-$$) db 0 . It seems to me your are attempting to find the proper way to access the variable the_secret and then