Commit Graph

1329 Commits

Author SHA1 Message Date
Kartik K. Agaram d771fb6bab more powerful load-sectors 2021-07-16 08:58:15 -07:00
Kartik K. Agaram 96c217ab1c . 2021-07-16 08:48:40 -07:00
Kartik K. Agaram 44d26b77c4 . 2021-07-16 08:28:56 -07:00
Kartik K. Agaram 71e4f38129 7842 - new directory organization
Baremetal is now the default build target and therefore has its sources
at the top-level. Baremetal programs build using the phase-2 Mu toolchain
that requires a Linux kernel. This phase-2 codebase which used to be at
the top-level is now under the linux/ directory. Finally, the phase-2 toolchain,
while self-hosting, has a way to bootstrap from a C implementation, which
is now stored in linux/bootstrap. The bootstrap C implementation uses some
literate programming tools that are now in linux/bootstrap/tools.

So the whole thing has gotten inverted. Each directory should build one
artifact and include the main sources (along with standard library). Tools
used for building it are relegated to sub-directories, even though those
tools are often useful in their own right, and have had lots of interesting
programs written using them.

A couple of things have gotten dropped in this process:
  - I had old ways to run on just a Linux kernel, or with a Soso kernel.
    No more.
  - I had some old tooling for running a single test at the cursor. I haven't
    used that lately. Maybe I'll bring it back one day.

The reorg isn't done yet. Still to do:
  - redo documentation everywhere. All the README files, all other markdown,
    particularly vocabulary.md.
  - clean up how-to-run comments at the start of programs everywhere
  - rethink what to do with the html/ directory. Do we even want to keep
    supporting it?

In spite of these shortcomings, all the scripts at the top-level, linux/
and linux/bootstrap are working. The names of the scripts also feel reasonable.
This is a good milestone to take stock at.
2021-03-03 22:21:03 -08:00
Kartik Agaram c6b928be29 7841 2021-03-03 11:04:07 -08:00
Kartik K. Agaram 446a6704cb 7757 2021-02-19 02:39:22 -08:00
Kartik K. Agaram 378ffca74c 7730 - baremetal/shell: boolean values
In the process I found a bug in the Mu compiler. Limitations of just asserting
the emitted code but not running it.
2021-02-12 23:49:00 -08:00
Kartik Agaram 94e43069c7 7700 2021-02-09 08:19:40 -08:00
Kartik Agaram f626421bc4 7692
It's bad enough that metadata comments are restricted to integer literals;
let's at least make them work on _all_ integer literals.
2021-02-07 10:52:04 -08:00
Kartik Agaram 74f1512ff1 7690
Convert comments about magic constants into metadata.
2021-02-07 00:20:29 -08:00
Kartik Agaram 6c4c25555c 7689 - permit metadata on Mu literal integers
Metadata is always ignored. It's purely for documentation purposes. But
as long as Mu has no named constants it's starting to feel increasingly
essential.

I'm still not going to bother to add metadata to other parts of the language.
Let's see if we need them. Even though it's a little warty that the rules
vary throughout the stack:

  - bare SubX: metadata everywhere
  - SubX with syntax sugar: no metadata in calls or addressing-mode sigil-expressions
  - Mu: metadata only for literal integers
2021-02-06 22:24:24 -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 b628655722 7526 2021-01-16 09:29:21 -08:00
Kartik Agaram 7f8770ae08 7490 - baremetal: draw a grapheme to screen 2021-01-09 18:28:14 -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 c5dfa89bb3 7462 - SubX version of baremetal/ex2.subx 2020-12-29 19:14:26 -08:00
Kartik Agaram c1b1d1f4e6 7460 - baremetal backend for SubX 2020-12-29 17:46:04 -08:00
Kartik Agaram 3618118c8d 7459
Bring baremetal variant up to date with recent changes.
2020-12-29 10:34:20 -08:00
Kartik Agaram c88af82232 7458
Switch survey_elf to the new approach.
2020-12-29 10:28:15 -08:00
Kartik Agaram 8836afbcbd 7457 2020-12-28 23:30:13 -08:00
Kartik Agaram 286faf6f0b 7456 2020-12-28 23:28:07 -08:00
Kartik Agaram d6d8ce2244 7454
Go back to commit 7448.
2020-12-28 23:05:00 -08:00
Kartik Agaram c17b909b82 7453
Snapshot: this approach of disambiguating /disp32 based on metadata doesn't
work. The `survey` phase runs after `pack`, which gets rid of most metadata.
2020-12-28 23:03:26 -08:00
Kartik Agaram 59e4177c71 7452 2020-12-28 21:26:01 -08:00
Kartik Agaram cb7139956e 7451 2020-12-28 21:16:08 -08:00
Kartik Agaram 5da03f118c 7450 2020-12-28 21:05:50 -08:00
Kartik Agaram ce6aa0c9cc 7447 2020-12-28 17:05:17 -08:00
Kartik Agaram ec8c039abf 7446 2020-12-28 15:30:23 -08:00
Kartik Agaram d1c9894306 7445 2020-12-28 15:29:29 -08:00
Kartik Agaram 70b350dfba 7444 2020-12-28 12:36:51 -08:00
Kartik Agaram 2107d5f1f1 7443
A new phase for baremetal compilations. Doesn't work yet, but it passes
all its tests, so we can add it to CI.
2020-12-28 12:14:15 -08:00
Kartik Agaram a51af593b0 7442 2020-12-28 12:14:15 -08:00
Kartik Agaram 2e48fac480 7441 2020-12-28 11:52:54 -08:00
Kartik Agaram dff67029ad 7439 - start translating Mu programs to baremetal 2020-12-28 11:09:30 -08:00
Kartik Agaram d8eacb3893 7403 - baremetal/ for apps without a kernel 2020-12-26 13:30:04 -08:00
Kartik Agaram 2fcf7e24d1 7402 2020-12-26 13:09:16 -08:00
Kartik Agaram faef965611 7399 2020-12-24 16:31:45 -08:00
Kartik Agaram bf8f246e08 7398 2020-12-23 23:24:16 -08:00
Kartik Agaram 32fc6c2ddf 7395 - boot.hex: recognize '1' press on keyboard
https://stackoverflow.com/questions/37618111/keyboard-irq-within-an-x86-kernel
is right, no need to mess with the status port at the start.
2020-12-23 23:06:54 -08:00
Kartik Agaram 169adc36d3 7394
I think https://stackoverflow.com/questions/37618111/keyboard-irq-within-an-x86-kernel
has more insight to provide. Among other things the comment about grub
may answer the distinction between entry 0x21 and entry 9.
2020-12-23 22:48:47 -08:00
Kartik Agaram a94ac8f068 7393
Snapshot. Keyboard interrupt being triggered.

This was hard to debug until https://stackoverflow.com/questions/37618111/keyboard-irq-within-an-x86-kernel
reminded me that I'd forgotten to enable IRQ1 on port 0x21.

For a while I was confused by never hitting a breakpoint at the start of
the keyboard handler. Then I found https://sourceforge.net/p/bochs/discussion/39592/thread/5e397455
and started skipping one instruction in my breakpoint.

I still don't understand the discrepancy between some people installing
the handler at entry 9, and others installing at entry 0x21 = 33.
2020-12-23 22:18:11 -08:00
Kartik Agaram 3a66a90930 7392 2020-12-23 20:00:14 -08:00
Kartik Agaram 22bef2d148 7391
Turns out we just need a null handler at offset 8 rather than offset 9.

If the keyboard handler is indeed at offset 9 as
https://alex.dzyoba.com/blog/os-interrupts says (I don't understand
why), then the clock handler's at offset 8, which makes sense.
2020-12-23 12:24:36 -08:00
Kartik Agaram 63362f814b 7390 - null interrupt tables
Looks like the reset loops stop if we create null handlers for the first
10 indexes in the IDT.
2020-12-23 12:14:01 -08:00
Kartik Agaram e60e0e0645 7389 - snapshot
Ok, we're back at the reset loop. Let's keep going; maybe having a decent
keyboard handler will fix it.

The bug I fixed here was caused by misunderstanding what m16&32 mean in
the Intel manual. It's still a regular regmem operand that uses all of
the ModR/M byte (which can be interpreted in 16-bit mode, adding to the
complication). It's just constrained to not allow direct addressing (mod 00).

I needed to better internalize the format of the instruction set references
at the start of Volume 2, Chapter 3.
2020-12-23 11:10:52 -08:00
Kartik Agaram 286ccc40e0 7388 - snapshot initializing interrupt table
I'm now back at the state of commit 7382 (including 7376). The existing
print to screen surprisingly seems to work without reset-looping, but when
I step through I notice that the lidt isn't doing what I expect.

Desired: at address 0x7cce, the processor executes:
  0f 01 1e 00 7f  # lidt ds:*idt_descriptor

Observed: at address 0x7cce, the processor executes:
  0f 01 1e        # lidt ds:*esi
As a result the next instruction is:
  00 7f fb

So the `fb` isn't interpreted to enable interrupts. So the problem of commit
7376 is latent.

Past this point the instruction stream is lined up again, and everything
occurs as it should. Purely by chance.

I fully expect all hell to break loose again, like it did in commit 7376,
once I debug the lidt encoding. There's still something I don't understand
about enabling interrupts. Perhaps I need to fill in more entries in the
table.
2020-12-23 10:39:54 -08:00
Kartik Agaram 2ff765b658 7387
Redo commit 7381. There was a bug.

Current state: commit 7381 excluding 7376.
2020-12-23 10:10:53 -08:00
Kartik Agaram 5ba5f319db 7386
Commit 7380 excluding 7376.
2020-12-23 10:06:04 -08:00
Kartik Agaram 895aa71616 7385
Commit 7379 excluding 7376.
2020-12-23 10:04:21 -08:00
Kartik Agaram d70711e1b0 7384
Currently at commit 7378 (reset the A20 address line) except without 7376
(enabling interrupts).
2020-12-23 10:04:01 -08:00