osdev

Roadblocks in creating a custom operating system [closed]

偶尔善良 提交于 2019-11-29 20:29:34
It seems to me that the most common overly ambitious project that programmers (esp. Comp. Sci. grads) try to tackle is building your own operating system. (Trying to create your own programming language + compiler is probably even more common but not nearly as ambitious.) For those (like myself) foolish enough to try: aside from the sheer size, what are the biggest gotcha s or unexpected roadblocks you've encountered in trying to create your own OS from the ground up? Edit: A great OS question: What are some resources for getting started in operating system development? Being able to speak

INT 13, 2 hanging on x86 real mode when trying to read sectors from floppy drive

天大地大妈咪最大 提交于 2019-11-29 15:18:32
I'm writing a DOS clone for a school project and I'm trying to read some sectors from a floppy drive (mainly the root directory of a FAT12 file system, sector 19) using BIOS INT 13, 2. I set the parameters right - or at least I think I do so - and then call INT 0x13 with AH = 2. Then, though, the system hangs. I can't figure why. I'm using the following code to call the interrupt: mov ah, 0x2 ;Read sectors function mov al, 1 ;I want to read one sector mov ch, 0 ;From track 0 mov cl, 2 ;Sector 2 mov dh, 1 ;Head 1 mov dl, [device_number] ;Obtained from BIOS during boot mov bx, 0x7C0 ;Buffer

Problem switching to v8086 mode from 32-bit protected mode by setting EFLAGS.VM to 1

寵の児 提交于 2019-11-29 13:58:54
I'm in 32-bit protected mode running at current privilege level (CPL=0). I'm trying to enter v8086 mode by setting EFLAGS.VM (Bit 17) flag to 1 (and IOPL to 0) and doing a FAR JMP to my 16-bit real mode code. I get the current flags using PUSHF ; set EFLAGS.VM (bit 17) to 1; set EFLAGS.IOPL (bit 22 and bit 23) to 0; set the new EFLAGS with POPF . The code for this looks like: bits 32 cli [snip] pushf ; Get current EFLAGS pop eax or eax, 1<<EFLAGS_VM_BIT ; Set VM flag to enter v8086 mode and eax, ~(3<<EFLAGS_IOPL_BITS) ; Set IOPL to 0 ; IF flag already 0 because of earlier CLI push eax popf ;

OsDev syscall/sysret and sysenter/sysexit instructions enabling

拈花ヽ惹草 提交于 2019-11-29 08:59:21
I am building an 32 bit OS in assembly. I have setup the IDT and I am handling program interruptus through int instruction. How can I enable the syscall and sysenter instructions and how do I handle them/return? Is true that syscall instruction isn't supported in 32 bit by Intel processors so I can't use it? Is true that sysret instruction isn't safe? Do somewhere exist a tutorial for that? EDIT : My main question is how to enable the syscall and sysenter instructions! (No duplication) See the OSdev wiki for details on sysenter , including a note about how to avoid a security/safety problem.

Creating a simple multiboot kernel loaded with grub2

爱⌒轻易说出口 提交于 2019-11-29 02:27:10
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 MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header CHECKSUM equ -(MAGIC + FLAGS) ;

Roadblocks in creating a custom operating system [closed]

一个人想着一个人 提交于 2019-11-28 17:10:18
问题 It seems to me that the most common overly ambitious project that programmers (esp. Comp. Sci. grads) try to tackle is building your own operating system. (Trying to create your own programming language + compiler is probably even more common but not nearly as ambitious.) For those (like myself) foolish enough to try: aside from the sheer size, what are the biggest gotcha s or unexpected roadblocks you've encountered in trying to create your own OS from the ground up? Edit: A great OS

How to do computations with addresses at compile/linking time?

自闭症网瘾萝莉.ら 提交于 2019-11-28 10:00:16
问题 I wrote some code for initializing the IDT, which stores 32-bit addresses in two non-adjacent 16-bit halves. The IDT can be stored anywhere, and you tell the CPU where by running the LIDT instruction. This is the code for initializing the table: void idt_init(void) { /* Unfortunately, we can't write this as loops. The first option, * initializing the IDT with the addresses, here looping over it, and * reinitializing the descriptors didn't work because assigning a * a uintptr_t (from (uintptr

Protected Mode Keyboard Access on x86 Assembly

浪尽此生 提交于 2019-11-28 07:37:10
I'm working on keyboard input for a very basic kernel that I'm developing and I'm completely stuck. I can't seem to find any information online that can show me the information I need to know. My kernel is running in protected mode right now, so I can't use the real mode keyboard routines without jumping into real mode and back, which I'm trying to avoid. I want to be able to access my keyboard from protected mode. Does anyone know how to do this? The only thing I have found so far is that it involves talking to the controller directly using in/out ports, but beyond that I'm stumped. This is,

Legacy BIOS bootloader to bootstrap real-mode code in second stage

梦想的初衷 提交于 2019-11-27 22:56:30
I am working on writing my own operating system. So far, my code exceeds 512 bytes, which is too large to fit in a simple boot sector. I understand that I now have to write a bootloader that reads arbitrary code that may or may not be greater than a single 512-byte sector. The bootloader would need to: Function as a boot record with disk signature 0xaa55. Read a second stage (the test code) start from LBA 1 (LBA 0 is boot sector) of arbitrary length starting at memory address 0x7E00. Transfer control to it using a FAR JMP to 0x0000:0x7E00. Be usable as a 1.44 MiB floppy disk image for use in

Developing an operating system for the x86 architecture [closed]

房东的猫 提交于 2019-11-27 17:05:17
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? QAZ For my final year project in collage I developed a small x86 OS with a virtual memory manager, a virtual file system and fully preemptive multitasking. I made it open source and the code is heavily