Serial hello world on COM1

This commit is contained in:
kunalgulati29
2019-08-24 00:00:00 +00:00
committed by Ciro Santilli
parent cb6f8cdf1c
commit 9dbe6fb939
2 changed files with 34 additions and 1 deletions

View File

@@ -13,11 +13,12 @@ OUT_EXT ?= .img
QEMU ?= qemu-system-i386
RUN ?= bios_hello_world
RUN_ARGS ?= -soundhw pcspk
RUN_SERIAL ?= bios_hello_world_serial
TMP_EXT ?= .tmp
OUTS := $(sort $(foreach IN_EXT,$(NASM_EXT) $(GAS_EXT),$(patsubst %$(IN_EXT),%$(OUT_EXT),$(wildcard *$(IN_EXT)))))
RUN_FILE := $(RUN)$(OUT_EXT)
RUN_FILE_SERIAL := $(RUN_SERIAL)$(OUT_EXT)
.PRECIOUS: %$(OBJ_EXT)
.PHONY: all clean doc run
@@ -58,6 +59,19 @@ bochs: $(RUN_FILE)
'display_library: sdl2' \
'megs: 128'
bochs_serial: $(RUN_FILE_SERIAL)
# Supposes size is already multiples of 512.
# We force that with our linker script,
# and `grub-mkrescue` also seems to respect it as well.
CYLINDERS="$$(($$(stat -c '%s' '$(RUN_FILE_SERIAL)') / 512))" && \
bochs -qf /dev/null \
'ata0-master: type=disk, path="$(RUN_FILE_SERIAL)", mode=flat, cylinders='"$$CYLINDERS"', heads=1, spt=1' \
'boot: disk' \
'display_library: x' \
'megs: 128'\
'com1: enabled=1, mode=file, dev=serial.out'
BIG_IMG_DIR := big_img$(TMP_EXT)
BOOT_DIR := $(BIG_IMG_DIR)/boot
GRUB_DIR := $(BOOT_DIR)/grub

19
bios_hello_world_serial.S Normal file
View File

@@ -0,0 +1,19 @@
#include "common.h"
BEGIN
DBG
mov $0x00, %ah// Initialize COM port
mov $0xe3, %al// Initialization value
mov $0x00, %dx// Port number
int $0x14
mov $msg, %si
loop:
lodsb
mov $0x01, %ah//Send value
or %al, %al
jz halt
int $0x14
jmp loop
halt:
hlt
msg:
.asciz "hello World!\n"