updated script and asm

Alphons van der Heijden <alphons@alphons> 12 Feb 2023, 14:07
70d820d0f69cb2a377b4cd9d882692ce8d5746ea
2 files changed
  • bsect.asm
  • build.sh
diff --git a/bsect.asm b/bsect.asm
index 87b478e..594d3cf 100644
--- a/bsect.asm
+++ b/bsect.asm
@@ -1,20 +1,21 @@
-; Bootsector Linux loader
+;
+; Bootsector Linux loader 1.3
+; (c) 2023- Alphons van der Heijden alphons@heijden.com
+;
; (c) 2014- Dr Gareth Owen (www.ghowen.me). All rights reserved.
; Some code adapted from Sebastian Plotz - rewritten, adding pmode and initrd support.
-
-; This program is free software: you can redistribute it and/or modify
-; it under the terms of the GNU General Public License as published by
-; the Free Software Foundation, either version 3 of the License, or
-; (at your option) any later version.
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, either version 3 of the License, or
+; (at your option) any later version.
;
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-; GNU General Public License for more details.
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
;
-; You should have received a copy of the GNU General Public License
-; along with this program. If not, see <http://www.gnu.org/licenses/>.
-; Adapted 2023- Alphons van der Heijden
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see <http://www.gnu.org/licenses/>.
[BITS 16]
org 0x7c00
@@ -29,13 +30,11 @@ org 0x7c00
int 0x15 ; A20 line enable via BIOS
jc err
- lgdt [gdt_desc]
+ lgdt [gdt_desc] ; Global Descriptor Table
mov eax, cr0
or eax, 1
mov cr0, eax
- jmp $+2 ; nop
-
mov bx, 0x8 ; first descriptor in GDT
mov ds, bx
mov es, bx
@@ -113,12 +112,11 @@ kernel_start:
mov ss, ax
mov sp, 0xe000
jmp 0x1020:0
- jmp $ ; infinity
-; ================= functions ====================
-; length in bytes into edx
-; uses hddread [hddLBA] and highmove [highmove_addr] vars
-; clobbers 0x2000 segment
+ ; ================= functions ====================
+ ; length in bytes into edx
+ ; uses hddread [hddLBA] and highmove [highmove_addr] vars
+ ; clobbers 0x2000 segment
loader:
.loop:
cmp edx, 127*512
@@ -149,9 +147,9 @@ loader:
ret
highmove_addr dd 0x100000
-; source = 0x2000
-; count = 127*512 fixed, doesn't if matter we copy junk at end
-; don't think we can use rep movsb here as it wont use EDI/ESI in unreal mode
+ ; source = 0x2000
+ ; count = 127*512 fixed, doesn't if matter we copy junk at end
+ ; don't think we can use rep movsb here as it wont use EDI/ESI in unreal mode
highmove:
mov esi, 0x20000
mov edi, [highmove_addr]
@@ -168,10 +166,9 @@ highmove:
ret
err:
- jmp $ ; infinity calls
-; cli
-; hlt
-; jmp err
+ cli ; don't do the jmp $ here
+ hlt ; it will eat your cpu by thermal heat
+ jmp err
hddread:
push eax
@@ -204,13 +201,13 @@ dap:
dd 0 ; lba low bits
dd 0 ; lba high bits
-;descriptor
+ ;descriptor
gdt_desc:
dw gdt_end - gdt - 1
dd gdt
-; access byte: [present, priv[2] (0=highest), 1, Execbit, Direction=0, rw=1, accessed=0]
-; flags: Granuality (0=limitinbytes, 1=limitin4kbs), Sz= [0=16bit, 1=32bit], 0, 0
+ ; access byte: [present, priv[2] (0=highest), 1, Execbit, Direction=0, rw=1, accessed=0]
+ ; flags: Granuality (0=limitinbytes, 1=limitin4kbs), Sz= [0=16bit, 1=32bit], 0, 0
gdt:
dq 0 ; first entry 0
@@ -221,7 +218,6 @@ gdt:
db 10010010b ; access byte
db 11001111b ; [7..4]= flags [3..0] = limit[16:19]
db 0 ; base[24:31]
-
gdt_end:
; config options
diff --git a/build.sh b/build.sh
index aca8c47..1e1d323 100755
--- a/build.sh
+++ b/build.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-ME="Bootsector Linux loader 1.2 (C) 2023 By Alphons van der Heijden"
+ME="Bootsector Linux loader 1.3 (C) 2023 By Alphons van der Heijden"
#
# Making bootable disk file and an additional .vmdk file for booting in vmware
#
@@ -31,9 +31,10 @@ ME="Bootsector Linux loader 1.2 (C) 2023 By Alphons van der Heijden"
# INITRD can have multiple gz files, for example INITRD=rootfs.gz,modules.gz
-WORK=/mnt/sda1/Alpha
+WORK=/mnt/sdb1/release/iso_contents/boot
KERNEL=$WORK/vmlinuz64
-INITRD=$WORK/rootfs64.gz,$WORK/modules64.gz
+INITRD=$WORK/corepure64.gz
+#rootfs64.gz,$WORK/modules64.gz
CMDLINE="'loglevel=3'"
OUTPUT=/tmp/linux