bootloader

BIOS int 0x13 modifies CS:IP?

陌路散爱 提交于 2021-02-10 15:46:55
问题 I'm writing an x86 bootloader which occupies two sections (1024 bytes) on disk and the first thing I want it to do is to load both sections to segment 0x60 before continuing execution Here is the relocation part of my code: _start: // relocate and load remaining bootloader code mov $0x60, %ax mov %ax, %es mov $0x02, %ah mov $2, %al xor %bx, %bx mov $0, %ch mov $2, %cl xor %dh, %dh int $0x13 jmp $0x60, $reloc_done reloc_done: // set up segment registers mov $0x60, %ax mov %ax, %ds mov %ax, %es

int 13h doesn't appear to read sectors containing my kernel

眉间皱痕 提交于 2021-02-08 05:07:19
问题 I am trying to load up a little data using my bootloader on a USB, but apparently int 13h won't work! Bootloader: [bits 16] [ORG 0x7c00] jmp 0x0000:start start: cli xor ax, ax mov ss, ax mov sp, 0x7c00 mov ax, cs mov ds, ax mov es, ax mov fs, ax mov gs, ax sti mov [driveno], dl reset: ;reset drive xor ax, ax mov dl, [driveno] int 0x13 or ah, ah jnz reset mov ah, 0x02 mov al, 0x01 mov bx, 0x0000 mov es, bx mov bx, 0x7e00 mov dl, [driveno] xor dh, dh mov cx, 0x0002 int 0x13 or ah, ah jnz reset

x86 NASM Indirect Far Jump In Real Mode

拈花ヽ惹草 提交于 2021-02-05 08:51:15
问题 I have been messing around with a multi-stage bootloader and I have got all of my code to work, except for the last part: The Jump . I have gotten this code to work out before now but I wanted to make it more modular by replacing this line: jmp 0x7E0:0 With this one: jmp far [Stage2Read + SectorReadParam.bufoff] Instead of hard coding where the code will load in, I wanted to do an indirect jump to it. Here's the rest of my code: ; This is stage 1 of a multi-stage bootloader bits 16 org 0x7C00

Getting INT 16h key scancode instead of character

▼魔方 西西 提交于 2021-01-28 09:26:14
问题 I'm writing a simple bootloader, and I have a getch function. char getch() { uint16_t inchar; __asm__ __volatile__ ("int $0x16\n\t" : "=a"(inchar) : "0"(0x0)); return (char)inchar; } I tried the first obvious solution, which is remove the casting to char of the inchar variable, but when I print it still returning a char instead of code. My println implementation: void println(char *str) { while (*str) { // AH=0x0e, AL=char to print, BH=page, BL=fg color __asm__ __volatile__ ("int $0x10" : :

Getting INT 16h key scancode instead of character

冷暖自知 提交于 2021-01-28 09:26:00
问题 I'm writing a simple bootloader, and I have a getch function. char getch() { uint16_t inchar; __asm__ __volatile__ ("int $0x16\n\t" : "=a"(inchar) : "0"(0x0)); return (char)inchar; } I tried the first obvious solution, which is remove the casting to char of the inchar variable, but when I print it still returning a char instead of code. My println implementation: void println(char *str) { while (*str) { // AH=0x0e, AL=char to print, BH=page, BL=fg color __asm__ __volatile__ ("int $0x10" : :

Assembly - Problems running a bootloader in bochs

∥☆過路亽.° 提交于 2021-01-27 20:22:37
问题 I am currently trying to compile and run a simple bootloader in bochs. Currently, this is my bootloader.asm file: [BITS 16] [ORG 0x7C00] ;Where the code gets mapped top: jmp top ;Loop forever times 510-($-$$) db 0 ;Pad with 0 dw 0xAA55 ;Bootloader signature (backwards) ;; dw declares a word (2 bytes because we’re 16 bits) From my pragmalinux-img directory I then type in the following commands: yasm bootloader.asm dd if=bootloader bs=512 bochs Upon running bochs I get the following error

General Protection Fault when trying to `sti`

微笑、不失礼 提交于 2021-01-05 09:23:22
问题 Trying to implement hardware interrupts on a test bootloader. Exceptions are working(thus found it is GPF). When trying to sti , a GPF is occured. Here is my main code: cli lgdt [gdt_desc] lidt [idt_desc] mov eax, cr0 or eax, 1 mov cr0, eax jmp 0x8:bit_32 bit_32: [bits 32] mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax mov eax, 0x8000 mov esp, eax mov ebp, esp sti ; exception raised This is how my GDT looks like: start_gdt: null: dd 0x0 dd 0x0 code: dw 0xffff dw 0x0 db

General Protection Fault when trying to `sti`

蹲街弑〆低调 提交于 2021-01-05 09:23:18
问题 Trying to implement hardware interrupts on a test bootloader. Exceptions are working(thus found it is GPF). When trying to sti , a GPF is occured. Here is my main code: cli lgdt [gdt_desc] lidt [idt_desc] mov eax, cr0 or eax, 1 mov cr0, eax jmp 0x8:bit_32 bit_32: [bits 32] mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax mov eax, 0x8000 mov esp, eax mov ebp, esp sti ; exception raised This is how my GDT looks like: start_gdt: null: dd 0x0 dd 0x0 code: dw 0xffff dw 0x0 db

Load Sectors to RAM in qemu

和自甴很熟 提交于 2021-01-02 12:50:21
问题 I code a simple program which loads the sector (sector num.2) to the RAM but prints nothing. first, I tried this code for bootsector: org 0x7c00 mov ax, 0x1000 ; ES:BX = 1000:0000 mov es, ax mov bx, 0x00 LoadSectortoMemory: mov al, 0x01 ; Load 1 sectors mov ah, 0x02 ; Load disk data to ES:BX mov cl, 0x02 ; Sector = 2 mov ch, 0x00 ; Cylinder = 0 mov dl, 0x00 ; Drive = 0 mov dh, 0x00 ; Head = 0 int 13h ; Read jc LoadSectortoMemory ; ERROR => Try again jmp 0x1000:0x0000 times 510-($-$$) db 0 dw

Reading more sectors than there are on a track with int 13h

偶尔善良 提交于 2020-12-11 08:55:16
问题 What is the order int 13h with ah=02h will read 19 sectors starting at (C, H, S) = (0, 0, 1) provided a (floppy) disk geometry of 2 heads, 18 sectors per track and 80 tracks per side. Or, more generally, what happens when it reaches the end of track 0, head 0? Does it go to track 1 or head 1? Does it even work properly in this case? EDIT: Wait.. is this actually like hours, minutes, seconds? If we reach the end of the track (S is greater than 18), then H is increased? 回答1: Modern BIOSes