about summary refs log tree commit diff stats
path: root/baremetal
diff options
context:
space:
mode:
Diffstat (limited to 'baremetal')
-rw-r--r--baremetal/boot.hex19
1 files changed, 16 insertions, 3 deletions
diff --git a/baremetal/boot.hex b/baremetal/boot.hex
index 6a14017d..6fa874c2 100644
--- a/baremetal/boot.hex
+++ b/baremetal/boot.hex
@@ -143,6 +143,20 @@
   cd 13  # int 13h, BIOS disk service
   0f 82 9b 00  # jump-if-carry disk_error [label]
 
+  # load two more tracks of disk into addresses [0x27400, 0x37000)
+  b4 02  # ah <- 2  # read sectors from disk
+  # dl comes conveniently initialized at boot time with the index of the device being booted
+  b5 00  # ch <- 0  # cylinder 0
+  b6 02  # dh <- 2  # track 0
+  b1 01  # cl <- 1  # first sector, 1-based
+  b0 7e  # al <- 126  # number of sectors to read = 2*63
+  # address to write sectors to = es:bx = 0x17800
+  bb 80 17  # bx <- 0x1780 [label]
+  8e c3  # es <- bx
+  bb 00 00  # bx <- 0
+  cd 13  # int 13h, BIOS disk service
+  0f 82 9b 00  # jump-if-carry disk_error [label]
+
   # reset es
   bb 00 00  # bx <- 0
   8e c3  # es <- bx
@@ -172,9 +186,8 @@
   ea 00 7d 08 00  # far jump to initialize_32bit_mode after setting cs to the record at offset 8 in the gdt (gdt_code) [label]
 
 # padding
-# 76:
-                  00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# 8e:
+                                          00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package main

import (
	"fmt"
	"math/rand"
	"strings"
	"time"
)

type Graph struct {
	adjacencyList map[int][]int
}

func NewGraph() *Graph {
	return &Graph{adjacencyList: make(map[int][]int)}
}

func (g *Graph) addEdge(node1, node2 int) {
	g.adjacencyList[node1] = append(g.adjacencyList[node1], node2)
	g.adjacencyList[node2] = append(g.adjacencyList[node2], node1)
}

func generateConnectedGraph(n int) *Graph {
	rand.Seed(time.Now().UnixNano())
	graph := NewGraph()

	// Start with node 0
	for i := 1; i < n; i++ {
		// Connect the new node i to a random existing node
		existingNode := rand.Intn(i)
		graph.addEdge(i, existingNode)
	}

	return graph
}

func generateMermaid(graph *Graph) string {
	var sb strings.Builder

	sb.WriteString("graph TD;\n")

	visited := make(map[string]bool)

	for node, edges := range graph.adjacencyList {
		for _, edge := range edges {
			// Ensure each edge is only printed once
			if !visited[fmt.Sprintf("%d-%d", node, edge)] && !visited[fmt.Sprintf("%d-%d", edge, node)] {
				sb.WriteString(fmt.Sprintf("    %d --> %d;\n", node, edge))
				visited[fmt.Sprintf("%d-%d", node, edge)] = true
			}
		}
	}

	return sb.String()
}

func main() {
	graph := generateConnectedGraph(100)
	mermaid := generateMermaid(graph)

	fmt.Println(mermaid)
}