osdev

Creating a simple multiboot kernel loaded with grub2

≯℡__Kan透↙ 提交于 2019-11-27 16:56:41
问题 I'm trying to follow the instructions here to build a simple OS kernel: http://mikeos.sourceforge.net/write-your-own-os.html Except, instead of booting from a floppy, I want to create a grub-based ISO image and boot a multiboot CD in the emulator. I've added the following to the source listed at that page, for the multiboot header: MBALIGN equ 1<<0 ; align loaded modules on page boundaries MEMINFO equ 1<<1 ; provide memory map FLAGS equ MBALIGN | MEMINFO ; this is the Multiboot 'flag' field

Why does passing a char to a function change it's value in c?

梦想与她 提交于 2019-11-27 16:19:32
I am currently following this workbook on build an operating system. My intention is to write a 64-bit kernel. I have got as far as loading the "kernel" code and writing individual characters to the frame buffer while in text mode. My problem appears when I add a level of indirection to writing a single character to the frame buffer by wrapping the code in a function. It would appear that the char value passed into the function is being corrupted in some way. I have three files: bootloader.asm ; bootloader.asm [org 0x7c00] KERNEL_OFFSET equ 0x1000 mov bp, 0x9000 mov sp, bp ; load the kernel

How do I write a bin file (512 bytes) to the first sector (sector 0) of a floppy disk?

China☆狼群 提交于 2019-11-27 14:10:51
How do I write a .bin file to be in the first sector of a floppy disk/virtual floppy disk/floppy image? I'm trying to boot a simple 512-byte bootloader. The size on everywhere says "512 bytes" so I should be good already. Additional Information: The bootloader simply displays a string, and I'm learning simple assembly. Some of the work is made in Windows and some in Ubuntu 14.04 (Trusty Tahr) (if this matters). It doesn't boot even though it has the bootloader sign. If you are on Linux you can do it with DD utility. There is a version of DD for Microsoft Windows as well. General DD usage If

Unexpected output when printing directly to text video memory

那年仲夏 提交于 2019-11-27 09:34:25
I am developing a kernel in C and created something to print on screen on video memory. I expected that the first byte in video memory would be the character to print and the second byte tells the color. But my program has something different but it works!! It is very unexpected and unusual. My kernel code - #define VIDEO_MEM 0xb8000 void write_string( int colour, const unsigned char *string ); void main() { unsigned char *vid = (unsigned char*) VIDEO_MEM; int i=0; for (i = 0; i < 2000; i++) { *vid = ' '; *(vid+2) = 0x1f; vid += 2; } write_string(0x1f,"The Kernel has been loaded successfully!!

Constant reboot after setting up the Global Descriptor Table and protected mode

我只是一个虾纸丫 提交于 2019-11-27 04:52:34
问题 I must have done something wrong with the GDT setup and the switch to protected mode because it keeps constantly rebooting. Here is my kernel.asm that should setup the GDT and switch to protected mode : bits 16 jmp main %include "gdt.inc" main: cli xor ax,ax mov ds,ax mov es,ax mov ax,0x9000 mov ss,ax mov sp,0xffff sti call InstallGDT cli mov eax,cr0 or eax,1 jmp 08h:Stage3 bits 32 Stage3: mov ax,0x10 mov ds,ax mov ss,ax mov es,ax mov esp,90000h Stop: mov byte [0xb8000],'A' cli hlt and there

Creating a bootable ISO image with custom bootloader

风格不统一 提交于 2019-11-27 02:49:18
问题 I am trying to convert a bootloader I wrote in Assembly Language to an ISO image file. The following is the code from MikeOS bootloader. Here is my bootloader code: BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this bootloader add ax, 288 ; (4096 + 512) / 16 bytes per paragraph mov ss, ax mov sp, 4096 mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax mov si, text_string ; Put string position into SI call print_string ; Call our string-printing routine jmp $ ; Jump

Keyboard IRQ within an x86 kernel

一个人想着一个人 提交于 2019-11-26 21:22:16
问题 I'm trying to program a very simple kernel for learning purposes. After reading a bunch of articles about the PIC and IRQs in the x86 architecture, I've figured out that IRQ1 is the keyboard handler. I'm using the following code to print the keys being pressed: #include "port_io.h" #define IDT_SIZE 256 #define PIC_1_CTRL 0x20 #define PIC_2_CTRL 0xA0 #define PIC_1_DATA 0x21 #define PIC_2_DATA 0xA1 void keyboard_handler(); void load_idt(void*); struct idt_entry { unsigned short int offset

Developing an operating system for the x86 architecture [closed]

青春壹個敷衍的年華 提交于 2019-11-26 18:54:19
问题 I am planning to develop an operating system for the x86 architecture. What options of programming languages do I have? What types of compilers are there available, preferably on a Windows environment? Are there any good sources that will help me learn more about operating system development? Is it better to test my operating system on a Virtual Machine or on physical hardware? Any suggestions? 回答1: For my final year project in collage I developed a small x86 OS with a virtual memory manager,

Why does passing a char to a function change it's value in c?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 17:20:09
问题 I am currently following this workbook on build an operating system. My intention is to write a 64-bit kernel. I have got as far as loading the "kernel" code and writing individual characters to the frame buffer while in text mode. My problem appears when I add a level of indirection to writing a single character to the frame buffer by wrapping the code in a function. It would appear that the char value passed into the function is being corrupted in some way. I have three files: bootloader

Enable the boot loader to load the second sector of a USB

巧了我就是萌 提交于 2019-11-26 14:34:36
问题 I am learning the assembly language. I wrote a simple bootloader. After testing it out, it didn't work. Here is my code: [bits 16] [org 0x7c00] jmp start data: wolf_wel_msg db 'Welcome to Bootloader!!!',0x0D,0x0A,0 wolf_kernel_load db 'Loading kernel....',0x0D,0x0A,0 wolf_error_msg db 'Kernel.bin not found!',0x0D,0x0A,0 wolf_error_msg1 db 'Press any key to restart..',0 start: mov si, wolf_wel_msg call wolf_print mov si, wolf_kernel_load call wolf_print pushf stc mov ah,00 mov dl,00 int 13h