我正在按照本教程了解如何检查和启用 A20 线路。我想我明白了,但是有人可以帮我澄清一下吗?
该教程中已有的评论开始; <comment>,
我的评论开始;<comment>
; The following code is public domain licensed
[bits 16]
; Function: check_a20
;
; Purpose: to check the status of the a20 line in a completely self-contained state-preserving way.
; The function can be modified as necessary by removing push's at the beginning and their
; respective pop's at the end if complete self-containment is not required.
;
; Returns: 0 in ax if the a20 line is …Run Code Online (Sandbox Code Playgroud) 我写了一个小bootloader用于学习目的,它会打印出bootloader第一条指令的内存地址,肯定是0x7c00。看下面的汇编源代码运行良好。
boot.s
.code16
.global init
init:
mov $0x07c0, %ax
mov %ax, %ds
mov $0x07e0, %ax
mov %ax, %ss
mov $0x2000, %sp
call next
next:
pop %bx
sub $(next-init), %bx # starting point of memory address, now stored in %bx
call print_register
jmp .
print_register: # always print out value in %bx
mov %bh, %cl
shr $0x4, %cl
and $0x0f, %cl
call print_digit
mov %bh, %cl
and $0x0f, %cl
call print_digit
mov %bl, %cl
shr $0x4, %cl
and $0x0f, %cl
call …Run Code Online (Sandbox Code Playgroud) 在我的引导加载程序代码中有一个部分,我们通过加载 GDT 并启用控制寄存器位来将 cpu 切换到保护模式。
这是引导加载程序代码的部分:
init_pm:
...
cli
lgdt [GDT_descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax
; far jump
jmp CODE_SEG:start_protected_mode
[bits 32]
start_protected_mode:
...
Run Code Online (Sandbox Code Playgroud)
这些是常数:
CODE_SEG equ code_descriptor - GDT_start
DATA_SEG equ data_descriptor - GDT_start
Run Code Online (Sandbox Code Playgroud)
所以我的问题如下:
什么是远跳?
进入保护模式到底对CPU有什么影响?
什么是CODE_SEG以及为什么我们将它与偏移量
start_protected_mode一起使用?我们不能像这样进行正常的跳跃吗jmp start_protected_mode?我知道它是 GDT 中代码描述符的位置,但这是否会自动被 cpu 识别为引导加载程序代码的位置?
我知道这个问题被问了很多,但我找到的每个答案都不适合我。我正在尝试加载stage 2位于图像文件第二个扇区的操作系统(0x200)
这是我尝试使用的代码:
bits 16 ; Starting at 16 bits
org 0x0 ; And starting at 0
jmp main ; Hop to main!
; TODO: copy comment from prev. loader
; args: SI
print:
lodsb ; Load the next/first character to AL
or al, al ; Is it 0?
jz donePrint ; Yes - Done.
mov ah, 0eh ; No - keep going.
int 10h ; Print character.
jmp print ; Repeat
donePrint:
ret ; Return …Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个引导加载程序。但有一个部分我不明白。我知道当我的汇编文件中定义了 ORG 7C00 时,程序将加载到磁盘 7C00 上。我将其编译为二进制文件并在 Magic ISO 中创建了 iso 文件。然后,当我查看 ISO 文件的十六进制版本时,我看到我编写的代码是从 D800 地址开始的。不是应该安装在7C00吗?
org 0x7C00
bits 16
start:
cli
times 510 - ($ - $$) db 0
dw 0xAA55
Run Code Online (Sandbox Code Playgroud)
https://i.stack.imgur.com/TFVDE.png
我还有另一个问题。地址 D010 处还有另一个引导加载程序签名。为什么?
https://i.stack.imgur.com/dyZgl.png
另外,我还想知道一件事。我想将一些文件放入我的 ISO 文件中,并且想在此级别读取这些文件。我在 VirtualBox 中进行实验。如何读取 ISO 文件中的文件。或者我如何运行一个程序。所以我想做的就是将内核放置在这里并从引导加载程序加载它。
如果我错了,是否有资源详细说明如何加载引导加载程序以及如何加载 BIOS?
我有一个评估板(Olimex STM32-P103),它支持SD卡连接器.我想将我的程序放入SD存储器而不是微控制器的内部闪存; 并从那里运行它.根据boot-loader问题,我不知道是否可以这样做!
PS我的目标是在这块板上运行linux,然后将我的应用程序移植到它上面.
最近几天,我试图制作一个引导程序,这是结果:
BITS 16
;CONSTANTS
BOOTSEG equ 07C0h
STACKSEG equ 1BC0h ; BOOTSEG + 512 Byte (bootloader) + 512 Byte (second stage) + 4096 Byte (buffer) = 1BC0h
STACKSIZE equ 0400h ; 1KB stack
; INIT
mov AX, BOOTSEG
mov DS, AX ; set data segment to adress where bootloader will be loaded to
mov AX, STACKSEG
cli ; disable interrupts while set up stack
mov SS, AX
mov SP, STACKSIZE ; set up stack
sti ; restore interrupts
mov [bootdev], …Run Code Online (Sandbox Code Playgroud) 关于来自串行闪存设备的现代系统的启动概念,我有点迷失.在裸机上编程了大量简单的微控制器,从8位PIC到32位Power架构(总是通过重新编程正常的总线可寻址闪存),我想知道现代SoC如何从串行设备启动.我没有在网上找到太多,因为每个系统似乎都依赖于SD卡编程工具和辅助引导程序的组合,这两者都很少得到关注.
我试图在Atmel AVR微控制器上编写自己的启动加载程序.我已经从github引用了一个代码库.我要感谢ZEVERO的代码库
在初级阶段,我理解代码库.但是在第224行,我发现了一行 参考代码
**if (pgm_read_word(0) != 0xFFFF) ((void(*)(void))0)(); //EXIT BOOTLOADER**
Run Code Online (Sandbox Code Playgroud)
我理解if条件部分,但是当我试图理解真正的陈述部分时,即
**((void(*)(void))0)();**
代码编写者给出的解释是 // EXIT BOOTLOADER
我的第一个问题是这个复杂宣言的含义是什么
**((void(*)(void))0)();**
第二个问题是,它是否退出微控制器中代码的执行.
我正在基于Assembly x86编程语言的内核上工作。我只是想知道.bin文件和.com文件之间有什么区别。我可以从.com文件启动吗?在哪里以及如何使用.com文件?