Commit Graph

57 Commits

Author SHA1 Message Date
Kartik K. Agaram c4bd8edae2 7720 - baremetal: load more sectors again 2021-02-11 01:14:30 -08:00
Kartik K. Agaram 64a1c14198 7717 - baremetal: enable FPU (I think) 2021-02-11 00:12:08 -08:00
Kartik Agaram c6b8df9d72 7686 2021-02-04 17:25:00 -08:00
Kartik Agaram 022ecb94f0 7684 - baremetal will have no mouse
I spent a week on trying to support it, and I am now past the five
stages of grief.

-- Important things I read
https://web.archive.org/web/20040604041507/http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/atkeyboard.html
https://web.archive.org/web/20040604043149/http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html

https://wiki.osdev.org/index.php?title=Mouse_Input&oldid=23086#Waiting_to_Send_Bytes_to_Port_0x60_and_0x64
  says command 0xa8 is optional

SaniK: https://forum.osdev.org/viewtopic.php?t=10247
  recommends command 0xa8 before setting Compaq Status byte

Setting Compaq status byte before 0xa8: https://forum.osdev.org/viewtopic.php?f=1&t=19873
  This thread also suggests that keeping reads from keyboard vs mouse straight
  is non-trivial.

-- Where I got stuck
Following SaniK's recipe doesn't seem to work. It seems like not sending
the 0xa8 command gets us a little closer. I saw the mouse handler
trigger, but it seems to not actually happen in response to mouse
events (vector 0x74 in the interrupt descriptor table).

-- Other options that may be worth considering
USB mouse
Serial mouse

Implementing a PS/2 handler in SubX
  would require somehow referring to SubX labels in this file

It seems clear that a mouse driver is complex enough to need a
higher-level language than just hex bytes. But it's _not_ clear how to
_explain_ a mouse driver. There's just a lot of random rules, historical
anecdotes, just-so stories and sheer black magic here. I'm going to try
to do without it all. Mu will be a keyboard-only computer for the
foreseeable future.
2021-02-03 09:49:40 -08:00
Kartik Agaram 7212178bc6 7683 2021-02-01 22:56:50 -08:00
Kartik Agaram cd83a22a59 7682 2021-02-01 13:26:48 -08:00
Kartik Agaram 2a9583414b 7679 - baremetal: delete mouse handler
What I have so far is crap. Roll baremetal/boot.hex back to commit 7673.
2021-01-31 21:03:59 -08:00
Kartik Agaram 78d3df417a 7676 2021-01-30 23:38:39 -08:00
Kartik Agaram 9e315ddf40 7674 - beginning of mouse driver
No handler yet, just initialization.

Bochs boots up; Qemu gets into a reboot loop.

Unlike the keyboard where I did the minimum necessary for Qemu, here I
am blindly copying something alleged to work on "real hardware." Makes
no difference to the failure modes I'm seeing.

Even in this tiny endeavor I see the abyss open up. Poke bytes at some
sequence of ports, read back bytes from some sequence ports; it's like
sending out prayers.
2021-01-28 00:39:50 -08:00
Kartik Agaram 49badfb697 7672 2021-01-27 21:52:44 -08:00
Kartik Agaram ca5ac5154e 7671
Make some room for a mouse handler.
2021-01-27 21:16:36 -08:00
Kartik Agaram 2c2ba73f65 7670 2021-01-27 21:09:45 -08:00
Kartik Agaram 9ebc8ad439 7569 2021-01-27 20:53:50 -08:00
Kartik Agaram c98476aa09 7568 2021-01-27 20:24:41 -08:00
Kartik Agaram bcb656a7e8 7567 - baremetal: shift-key support 2021-01-27 19:54:05 -08:00
Kartik Agaram 4c9587b5f4 7566 2021-01-27 16:51:23 -08:00
Kartik Agaram 212d72a2df 7565
Somehow everything worked with this bug.
2021-01-24 22:44:43 -08:00
Kartik Agaram 0373ace5e0 7564 2021-01-24 22:25:10 -08:00
Kartik Agaram 5d5b9b2e9b 7563
Yup, a single read suffices. Might not work on real hardware, but YAGNI.
2021-01-24 22:19:43 -08:00
Kartik Agaram d5ed008900 7562 - bochs working again
Holy crap, perhaps the limitations of int 13h were all a mirage. I just
needed to initialize the stack.
2021-01-24 22:00:53 -08:00
Kartik Agaram 4559206243 7561
Another attempt at reorganizing how I read disks. Everything continues
to work in Qemu, but Bochs still doesn't love me.
2021-01-24 21:24:35 -08:00
Kartik Agaram ec75fe7f28 7560 2021-01-24 20:54:53 -08:00
Kartik Agaram 3844651e49 7559 - reorganize sectors built in raw hex
This was tedious for three reasons beyond the usual one of having to
track and update offsets several time while I debug:
  - The Bochs troubles of the previous commit kept polluting my brain
    even though they were irrelevant.
  - I had to keep some changes locally to allow myself to use Bochs,
    which polluted my working directory.
  - I had to travel the long way to the realization that I'm not
    actually initializing the stack anywhere. BIOS was starting my stack
    off at 0x10000, which was promptly clobbered by my second read from
    disk.

The good news: while I'm here I grow the interrupt descriptor table. So
I don't have to go through this exercise when I get back to supporting
the mouse.
2021-01-24 20:16:27 -08:00
Kartik Agaram 1c77be68d7 7558
Bochs is still broken, but before we can fix it we need to make some
room in the boot sector. So we'll spend a few commits reorganizing
things.
2021-01-24 19:43:23 -08:00
Kartik Agaram 0cf7cecedc 7557
Oh, stupid mistake in segmented address calculation. Now Qemu's working
again everywhere. Bochs is again broken everywhere. But I think we're
getting closer. I think Bochs's BIOS implementation for reading sectors
has two interacting constraints:

  - Can't write to more than 0x10000 bytes past segment register.
  - Can't write across segment alignment boundaries.

Qemu only cares about the first.
2021-01-24 19:43:23 -08:00
Kartik Agaram 09f2f3075a 7555 - snapshot
While baremetal has been working with Qemu, it's been broken with Bochs
since commit 7547, where we started reading more than 63 sectors (1
track) from disk.

Good to know that Bochs simulates native hardware with so much
verisimilitude!

Unfortunately things aren't fixed yet. The current state:

             - Qemu -                 - Bochs -
  ex2.hex    never switches modes     works
  ex2.subx   never switches modes     works
  ex2.mu     never switches modes     fails unit tests

It sucks that Bochs doesn't have strictly superior verisimilitude
compared to Qemu :(
2021-01-24 19:43:23 -08:00
Kartik Agaram dba18f7f6f 7554 - bug in an error handler 2021-01-24 19:43:23 -08:00
Kartik Agaram 0e4e8355f0 7553 2021-01-24 19:43:23 -08:00
Kartik Agaram 8c0b93a9c3 7552 - I better understand a couple of things 2021-01-23 23:14:34 -08:00
Kartik Agaram ac00ea787d 7551 2021-01-23 23:11:24 -08:00
Kartik Agaram 0f73127ef1 7547 - baremetal: rpn calculator
Still in progress. Known bugs:
* Cursor management is broken. Every line currently seems to leave
  behind a shadow cursor.
* No shift-key support yet, which means no addition or multiplication.
  (This app doesn't have division yet.)
2021-01-22 23:29:04 -08:00
Kartik Agaram c316a11ffa 7539 - baremetal: handle unrecognized keys 2021-01-22 16:52:44 -08:00
Kartik Agaram 6efc1ebed7 7529 - baremetal: fake screen 2021-01-16 15:32:26 -08:00
Kartik Agaram dbd7082a0e 7489 - include GNU Unifont
https://en.wikipedia.org/wiki/GNU_Unifont#The_.hex_font_format
http://unifoundry.com/unifont/index.html

Since GNU Unifont is covered under the GPL v2, so I believe is this repo.
2021-01-09 18:20:28 -08:00
Kartik Agaram 8be561f599 7485 2021-01-09 10:15:33 -08:00
Kartik Agaram adf7fba7fe 7484 2021-01-09 10:07:41 -08:00
Kartik Agaram 3f7db804c9 7480 - baremetal/ex3.hex now draws multiple pixels
I was wrong in commit 7437 that only one keystroke was working. The problem
was just that I was getting _too_ many events. I wasn't handling key-up
events, and they were entering the buffer, and I was not skipping null
events since the circular buffer is currently considered to be null-terminated.

ex3 isn't done yet; it can only handle 16 events. Apps need to be clearing
the keyboard buffer.
2021-01-07 22:38:07 -08:00
Kartik Agaram 53d99784de 7479 2021-01-07 20:17:32 -08:00
Kartik Agaram 796f3b70f2 7461 2020-12-29 18:56:21 -08:00
Kartik Agaram 437fa654cb 7437 - baremetal: draw pixel on keyboard event
It's now clear that our keyboard handler doesn't trigger after the first
event.
2020-12-28 00:12:06 -08:00
Kartik Agaram 5d2f1c57a5 7436
Start highlighting lines that may need to be recomputed when offsets change.
2020-12-27 23:35:31 -08:00
Kartik Agaram bf50df60a1 7435 - baremetal: buffer for keyboard events
I'm trying to read the status register, but I'm still not seeing the breakpoint
being hit a second time. (And I again ran into the Bochs bug that breakpoints
at the first instruction of an interrupt handler don't work.)

Maybe this is just a debugger issue. Let's keep going, and try to start
using the keyboard events.
2020-12-27 23:22:20 -08:00
Kartik Agaram a9b25d62c1 7434
Fix a stale displacement.
2020-12-27 23:01:14 -08:00
Kartik Agaram 57fd753a01 7433 - some major layout changes
I'd missed that VBE call 0x4f01 (get video mode) can write up to 256 bytes.
Unexpected areas were getting clobbered because I wasn't reserving enough
space.
2020-12-27 22:54:54 -08:00
Kartik Agaram 4ffe861a45 7432
Bugfix: 32-bit code in 16-bit mode.
Seems like it was benign, maybe.
2020-12-27 22:38:07 -08:00
Kartik Agaram 74529e2e62 7431
Typo.
2020-12-27 22:33:47 -08:00
Kartik Agaram 2e24062f2f 7430 2020-12-27 21:09:22 -08:00
Kartik Agaram 5095021f77 7424 - baremetal: downsize graphics resolution
If it's large enough that I have doubts whether my top-of-the-line Mac
is showing the bottom of the screen inside an emulator, it's too large.

This way I also feel more confident that most modern hardware will support
this graphics mode, and that these programs will work for others.
2020-12-27 08:45:03 -08:00
Kartik Agaram 2628a51f37 7422 2020-12-26 23:45:37 -08:00
Kartik Agaram e5b2f3f169 7421 - baremetal: beginnings of keyboard map
First keypress is detected, but we need to ack it somehow.
2020-12-26 23:38:52 -08:00