From 5584f6adcf704cc0dd4ffa390935a4afc2545d45 Mon Sep 17 00:00:00 2001 From: tkchia Date: Sun, 14 Aug 2022 23:32:58 +0800 Subject: [PATCH] Improve detection of boot media on bare metal (#535) hello.com now starts up correctly on QEMU when run as a hard disk image. --- ape/ape.S | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ape/ape.S b/ape/ape.S index e0cc12183..6a9a08b3e 100644 --- a/ape/ape.S +++ b/ape/ape.S @@ -301,7 +301,21 @@ pc: cld // @since IBM Personal Computer XT dsknfo: push %bx 1: push %dx - mov $0x08,%ah # get disk params + mov $0x16,%ah # make sure there is disk in drive, + int $0x13 # by querying change-line status + jnc 2f + xor %ax,%ax # if error or change line active, + int $0x13 # do a reset... + jc 9f + mov $0x0201,%ax # ...then do a read, to confirm that + mov $0x0001,%cx # there is disk in drive + mov $0,%dh # (verify (%ah = 4) does not work + mov $IMAGE_BASE_REAL>>4,%bx # under QEMU, which always returns + mov %bx,%es # success) + xor %bx,%bx + int $0x13 + jc 9f +2: mov $0x08,%ah # get disk params int $0x13 jc 9f mov %cl,%bh