serial: make awesome

This commit is contained in:
Ciro Santilli
2019-08-24 00:00:01 +00:00
parent 9dbe6fb939
commit 52a22c4b18
4 changed files with 35 additions and 8 deletions

1
.gitignore vendored
View File

@@ -6,5 +6,6 @@
*.o
*.so
*.tmp
*.tmp.*
/README.html
tmp.S

View File

@@ -55,6 +55,7 @@ bochs: $(RUN_FILE)
CYLINDERS="$$(($$(stat -c '%s' '$(RUN_FILE)') / 512))" && \
bochs -qf /dev/null \
'ata0-master: type=disk, path="$(RUN_FILE)", mode=flat, cylinders='"$$CYLINDERS"', heads=1, spt=1' \
'com1: enabled=1, mode=file, dev=$(RUN).tmp.serial' \
'boot: disk' \
'display_library: sdl2' \
'megs: 128'

View File

@@ -68,6 +68,11 @@ Then on the terminal start the simulation with:
c
....
To quit Bochs either:
* press the poweroff button inside its GUI
* Ctrl + C on terminal and the type `quit` and hit enter
TODO: automate this step.
Bibliography: https://stackoverflow.com/questions/6142925/how-can-i-use-bochs-to-run-assembly-code/32871939#32871939
@@ -2164,6 +2169,23 @@ While it is possible to learn those topics as you go along, and it is almost cer
=== Serial UART
TODO: get working on QEMU, working on Bochs:
....
./run bios_hello_world_serial bochs
cat bios_hello_world_serial.tmp.serial
....
File content:
....
hello world
....
Source: link:bios_hello_world_serial.S[]
Bibliography:
* https://stackoverflow.com/questions/22571379/intel-galileo-bare-metal-uart
* https://stackoverflow.com/questions/27594297/how-to-print-a-string-to-the-terminal-in-x86-64-assembly-nasm-without-syscall

View File

@@ -1,14 +1,17 @@
#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
/* Initialize COM port. */
mov $0x00, %ah
/* Initialization value. */
mov $0xe3, %al
/* Port number. */
mov $0x00, %dx
int $0x14
mov $msg, %si
loop:
lodsb
mov $0x01, %ah//Send value
/* Send value */
mov $0x01, %ah
or %al, %al
jz halt
int $0x14
@@ -16,4 +19,4 @@ loop:
halt:
hlt
msg:
.asciz "hello World!\n"
.asciz "hello world\n"