独自のブートローダー (MBR) の作成をいじっています。これは、オペレーティング システムをよりよく理解するための最初のステップです。
私の構成は次のとおりです。
MacBook Air、OsX 10.8.4、Parallels Desktop、Xcode、XCode コマンド ライン ツール、Nasm、LD、gcc、...
ブートローダーを作成しました:
;
; FpLoader.s
;
bits 16 ; 16-bit Real Mode
org 0x7c00 ; Set origin to BIOS boot origin
;
; Bootloader entry-code
;
Main: cli ; Enable interrupts
mov ax, cs ; Setup stack segments
mov ds, ax
mov es, ax
mov ss, ax
sti ; Enable interrupts
mov si, Message_1 ; Print string
call PrintLn
mov si, Message_2 ; Print string
call PrintLn
call PrintCrLf
call PrintCrLf
call Reboot
;
; Read keypress
;
ReadKeypress:
mov ah, 0 ; BIOS function - Wait for and read keyboard
int 0x16 ; Call BIOS Keyboard Service
ret ; Return from procedure
;
; PrintLn string
;
PrintLn:
lodsb ; Load [Si] in Al and increment Si
or al, al ; Check if end of string reached (Al == 0)
jz .PrintLnEnd
mov ah, 0x0e ; BIOS function - Print character on screen
int 0x10 ; Call BIOS Screen Service
jmp PrintLn ; Loop
.PrintLnEnd call PrintCrLf
;
; Print Cr/Lf
PrintCrLf: mov ah, 0x0E ; BIOS function - Print character on screen
mov al, 0x0D ; Character to print: Cr
int 0x10 ; Call BIOS Screen Service
mov al, 0x0A ; Character to print: Lf
int 0x10 ; Call BIOS Screen Service
ret ; Return from procedure
;
; Reboot the machine
;
Reboot: mov si, AnyKey ; Print string
call PrintLn
call ReadKeypress
db 0x0ea ; Sends us to the end of the memory causing reboot
dw 0x0000
dw 0xffff
;
; Data
;
; Program data
Message_1 db "Hello World...", 0x0
Message_2 db "Painted Black bootloader.", 0x0
AnyKey db "Press any key to reboot...", 0x0
; Filler bytes
times 510 - ($-$$) db 0
; Trailer bytes
dw 0xAA55 ;Boot signature
私はこのコードを次のように組み立てています:
nasm -f bin FpLoader.s -o FpLoader.img
sudo dd if=FpLoader.img of=FpLoader.iso bs=2k
FpLoader.iso から Parallels Virtual Machine を起動しようとすると、起動を拒否し、iso (Parallels 構成で CD として構成されている) からは起動できないというメッセージが表示されます。
私はこのトピックにまったく慣れていないため、利用可能なツールをどのように使用すればよいか戸惑っています。ご協力いただければ幸いです。
Linux、Bochs などの部分的な解決策をいくつか見つけましたが、正しい方向に導くものは何もありませんでした。
私は Iso ファイルについて厳格ではありません。私の開発をテストするための img ファイル、実際の起動可能な USB (Parallels Virtual Machine 内)、またはその他のソリューション (私の構成と互換性がある) を使用する方法を誰かが教えてくれれば、それも問題ありません。
よろしくお願いします、PB