Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ros-playground
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
ros-playground
Commits
14a9ce27
There was an error fetching the commit references. Please try again later.
Commit
14a9ce27
authored
4 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
kernel working
parent
58da7e98
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bootloader/boot.asm
+41
-28
41 additions, 28 deletions
bootloader/boot.asm
with
41 additions
and
28 deletions
bootloader/boot.asm
+
41
−
28
View file @
14a9ce27
[
bits
16
]
[
org
0x7c00
]
mov
[
_boot_drive_id
],
dl
; Load the kernel image from boot disk, disk offset 512B to 64KB.
KERN_ADDR
equ
0x7e00
mov
ah
,
0x02
mov
dl
,
[
_boot_drive_id
]
mov
ch
,
0
mov
dh
,
0
mov
cl
,
2
; from the second one,
mov
al
,
127
; read 127 sectors in total.
mov
bx
,
KERN_ADDR
int
0x13
; Set carry on error, and set AL to sectors that actual read.
KERN_ADDR
equ
0x7e00
jc
di
sk_io_error
mov
dl
,
0x7f
cmp
dl
,
al
jne
di
sk_io_error
; kernel successfully loaded now!
mov
bx
,
_motd_kern_ok
call
println_bios
jmp
_init_prot_mode
mov
[
_boot_drive_id
],
dl
jmp
_load_kern
; jmp _init_prot_mode
%include "./str.16.inc"
...
...
@@ -60,6 +44,35 @@ gdt_desc:
CODE_SEG_OFFSET
equ
gdt_entry_1
-
gdt_begin
DATA_SEG_OFFSET
equ
gdt_entry_2
-
gdt_begin
_load_kern:
; Load the kernel image from boot disk, disk offset 512B to 64KB.
; This is a 16bit real mode function.
mov
ah
,
0x02
mov
dl
,
[
_boot_drive_id
]
mov
ch
,
0
mov
dh
,
0
mov
cl
,
2
; from the second one,
mov
al
,
127
; read 127 sectors in total.
mov
bx
,
KERN_ADDR
int
0x13
; Set carry on error, and set AL to sectors that actual read.
jc
di
sk_io_error
mov
dl
,
0x7f
cmp
dl
,
al
jne
di
sk_io_error
; kernel successfully loaded now!
mov
bx
,
_motd_kern_ok
call
println_bios
jmp
_init_prot_mode
disk_io_error:
mov
bx
,
_motd_disk_error
call
println_bios
jmp
_stall
_init_prot_mode:
cli
lgdt
[
gdt_desc
]
...
...
@@ -85,24 +98,24 @@ _prot_begin:
mov
ebx
,
_motd_32
call
println_vga
; Enter the kernel. This should never return.
call
KERN_ADDR
; Kernel returns.
mov
ebx
,
_motd_endk
call
println_vga
_stall:
jmp
$
disk_io_error:
mov
ebx
,
_motd_disk_error
call
println_vga
jmp
_stall
_motd_disk_error:
db
'DISK_IO_ERROR'
,
0x0
_motd_32:
db
'[ENTER X86 MODE SUCC]'
,
0x0
db
'
[LOAD KERN SUCC]
[ENTER X86 MODE SUCC]'
,
0x0
_motd_kern_ok:
db
'
[ENTER X86 MODE SUCC]
[LOAD KERN SUCC]'
,
0x0
db
'[LOAD KERN SUCC]'
,
0x0
_motd_endk:
db
'[
ENTER X86 MODE SUCC] [LOAD KERN
SUCC] [KERN EXITED]'
,
0x0
db
'[
LOAD KERN SUCC] [ENTER X86 MODE
SUCC] [KERN EXITED]'
,
0x0
_boot_drive_id:
db
0x0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment