bootloader

How does UEFI work?

谁说我不能喝 提交于 2019-12-05 20:20:09
问题 I was studying about bootloaders when exactly came upon the term UEFI. I can understand some things about UEFI. But still, In what mode(Real,Protected,Long) does a system with UEFI start? If normal boot loaders cant work with UEFI, Then what is the alternate of boot loader while dealing with UEFI? And do I need any other programming to create one, than assembly? 回答1: UEFI firmware runs in 64 bit long mode for 64 bit platforms and flat mode for 32 bit platforms; Unlike BIOS, UEFI features its

Triple fault when jumping into protected mode

折月煮酒 提交于 2019-12-05 14:41:38
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 0x1000 mov [BOOT_DRIVE], dl ;Get the current boot drive from the BIOS mov bp, 0x9000 ;Set up stack, with

How can I JMP to relocated code in my MBR?

不想你离开。 提交于 2019-12-05 13:41:45
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 , the address of the relocated code. I tried using just jmp continue and then as seen uncommented below,

Using db to declare a string in assembly NASM

隐身守侯 提交于 2019-12-05 10:30:33
I am following a tutorial to write a hello world bootloader in assembly and I am using the NASM assembler for an x-86 machine. This is the code I am using : [BITS 16] ;Tells the assembler that its a 16 bit code [ORG 0x7C00] ;Origin, tell the assembler that where the code will ;be in memory after it is been loaded MOV SI, HelloString ;Store string pointer to SI CALL PrintString ;Call print string procedure JMP $ ;Infinite loop, hang it here. PrintCharacter: ;Procedure to print character on screen ;Assume that ASCII value is in register AL MOV AH, 0x0E ;Tell BIOS that we need to print one

Can ARM qemu system emulator boot from card image without kernel param?

心已入冬 提交于 2019-12-05 08:54:36
I've seen a lot of examples how to run a QEMU ARM board emulator. In every case, besides SD card image param, QEMU was also always supplied with kernel param, i.e.: qemu-system-arm -M versatilepb \ -kernel vmlinuz-2.6.18-6-versatile \ #KERNEL PARAM HERE -initrd initrd.gz \ -hda hda.img -append "root=/dev/ram" I am palying with bootloaders and want to create my own bootable SD card, but don't have a real board yet and want to learn with an emulated one. However, if run as described above, QEMU skips bootloader stage and runs kernel. So what should I do to emulate a full boot sequence on QEMU so

Lab1:bootloader操作系统的启动

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 07:29:40
前言 最近接了一个外包项目再加上填一些之前立的flag,发现好像很久没有发博客了。现在编译原理操作系统算法方面都还有大坑没有填,加上离实习越来越近,应用层方面的学习也要加强了,但反倒是压力越大越想摸鱼 之前暑假的时候跟着书上写过一个 玩具操作系统 ,然后之后还翻了一下Linux0.11一起写了一个 系列的博客 ,但是还是觉得认识的太浅薄,然后最近发现清华大学的一个操作系统课程,就跟着了。准备用博客来记录一下,虽然会和之前的那个系列有些重复,但是也算是加强巩固了 BIOS 对于所有寄存器开机时都有各自的初始值,在X86中,CS和EIP寄存器分别是F000H,0000FFF0H,所以X86开机执行的第一条指令就是位于这个位置的指令,一般这条指令都是长跳转指令,从这里跳到BIOS程序的起始位置。 BIOS的工作是硬件自检和初始化,并且读取该设备的第一扇区,并且转交CPU控制权 bootloader 由BIOS加载的第一扇区一般放的都是bootloader,bootloader的工作就是 切换到保护模式,启用分段机制 读取磁盘中的操作系统内核 将CPU控制权转交到操作系统 实模式 实模式的存在主要是为了兼容老的操作系统(16bit),在这种状态下软件可访问的物理内存空间不能超过1MB,主要的区别就是实模式的寻址能力和方式,实模式将整个物理内存看成分段的区域,程序代码和数据位于不同区域

ucore实验Lab1知识点总结

ε祈祈猫儿з 提交于 2019-12-04 16:20:56
Intel 80386 ucore目前支持的硬件环境是基于Intel 80386以上的计算机系统。 Intel 80386是80x86系列中的第一种32位微处理器。80386的内部和外部数据总线都是32位,地址总线也是32位,可寻址高达4GB内存。 工作方式包括实模式、保护模式以及虚拟86模式。 Bootloader 我们知道计算机启动是从BIOS开始,再由BIOS决定从哪个设备启动以及启动顺序,比如先从DVD启动再从硬盘启动等。计算机启动后,BIOS根据配置找到启动设备,并读取这个设备的第0个扇区,把这个扇区的内容加载到0x7c00,之后让CPU从0x7c00开始执行,这时BIOS已经交出了计算机的控制权,由被加载的扇区程序接管计算机。 这第一个扇区的程序就叫Boot,它一般做一些准备工作,把操作系统内核加载进内存,并把控制权交给内核。由于Boot只能有一个扇区大小,即512字节,它所能做的工作很有限,因此它有可能不直接加载内核,而是加载一个叫Loader的程序,再由Loader加载内核。因为Loader不是BIOS直接加载的,所以它可以突破512字节的程序大小限制(在实模式下理论上可以达到1M)。如果Boot没有加载Loader而直接加载内核,我们可以把它叫做Bootloader。 Bootloader加载内核就要读取文件,在实模式下可以用BIOS的INT 13h中断

nasm/ld “relocation truncated to fit: R_386_16”

荒凉一梦 提交于 2019-12-04 15:51:34
问题 Assembly: [BITS 16] global _start _start: mov ax, 0x07C0 mov ds, ax mov si, hw call print_string jmp $ print_string: mov ah, 0x0E .char: lodsb cmp al, 0 je .exit int 0x10 jmp .char .exit: ret times 0x100-($-$$) db 0 hw: db "Hello, World!", 0 times 510-($-$$) db 0 dw 0xAA55 Assembling this with: $ nasm file.asm -felf -o file.o And then linking it with: $ ld -melf_i386 -o file.bin file.o --oformat binary Gives the following error: file.asm:(.text+0x6): relocation truncated to fit: R_386_16

Compile an asm bootloader with external c code

寵の児 提交于 2019-12-04 12:49:27
问题 I write a boot loader in asm and want to add some compiled C code in my project. I created a test function here: test.c __asm__(".code16\n"); void print_str() { __asm__ __volatile__("mov $'A' , %al\n"); __asm__ __volatile__("mov $0x0e, %ah\n"); __asm__ __volatile__("int $0x10\n"); } And here is the asm code (the boot loader): hw.asm [org 0x7C00] [BITS 16] [extern print_str] ;nasm tip start: mov ax, 0 mov ds, ax mov es, ax mov ss, ax mov sp, 0x7C00 mov si, name call print_string mov al, ' '

Why 55 AA is used as the boot signature on IBM PCs? [closed]

扶醉桌前 提交于 2019-12-04 11:15:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Why does the IBM PC architecture use 55 AA magic numbers in the last two bytes of a bootsector for the boot signature ? I suspect that has something to do with the bit patterns they are: 01010101 10101010 , but don't know what. My guesses are that: BIOS is making some bitwise and/or/xor operations on these bytes