Highlight selected menu item with > ... <.

Moved global variables on the stack.
Hide cursor while menu is displayed.
Print error message at correct location.
Reboot on error.
Display "Loading <name>".

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25089 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2008-04-20 18:42:59 +00:00
parent 7b51470a32
commit 7ca9a33b59
2 changed files with 255 additions and 135 deletions
+53 -46
View File
@@ -2,19 +2,21 @@
// ./make_array kBootLoader bootman.bin // ./make_array kBootLoader bootman.bin
static const uint8 kBootLoader[] = { static const uint8 kBootLoader[] = {
0xb8, 0xc0, 0x07, 0x8e, 0xd8, 0x8e, 0xc0, 0x8e, 0xd0, 0xbc, 0xff, 0xff, 0xfc, 0xb4, 0x06, 0x30, 0xb8, 0xc0, 0x07, 0x8e, 0xd8, 0x8e, 0xc0, 0x8e, 0xd0, 0xbc, 0xf3, 0xff, 0x89, 0xe5, 0xfc, 0xb4,
0xc0, 0xb7, 0x0f, 0x31, 0xc9, 0xba, 0x4f, 0x18, 0xcd, 0x10, 0xb7, 0x00, 0xb4, 0x02, 0xba, 0x1f, 0x06, 0x30, 0xc0, 0xb7, 0x0f, 0x31, 0xc9, 0xba, 0x4f, 0x18, 0xcd, 0x10, 0xe8, 0x63, 0x00, 0xb7,
0x01, 0xcd, 0x10, 0xbe, 0x83, 0x00, 0xb3, 0x0f, 0xe8, 0x2c, 0x00, 0xb4, 0x02, 0xba, 0x1b, 0x17, 0x00, 0xba, 0x1f, 0x01, 0x89, 0x56, 0x08, 0xbe, 0xa9, 0x00, 0xb3, 0x0f, 0xe8, 0x2f, 0x00, 0xba,
0xb3, 0x07, 0xcd, 0x10, 0xbe, 0x96, 0x00, 0xe8, 0x1d, 0x00, 0xb4, 0x42, 0xb2, 0x80, 0xbe, 0x73, 0x1b, 0x17, 0x89, 0x56, 0x08, 0xb3, 0x07, 0xbe, 0xbc, 0x00, 0xe8, 0x21, 0x00, 0xb4, 0x42, 0xb2,
0x00, 0xcd, 0x13, 0x72, 0x03, 0xe9, 0xb8, 0x01, 0xbe, 0xb1, 0x00, 0xb3, 0x04, 0xe8, 0x07, 0x00, 0x80, 0xbe, 0x99, 0x00, 0xcd, 0x13, 0x72, 0x03, 0xe9, 0xb5, 0x01, 0xe8, 0x43, 0x00, 0xbe, 0xd7,
0xb4, 0x00, 0xcd, 0x16, 0xf4, 0xeb, 0xf9, 0x51, 0xe9, 0x11, 0x00, 0xb9, 0x01, 0x00, 0xb4, 0x09, 0x00, 0xb3, 0x04, 0xe8, 0x08, 0x00, 0xb4, 0x00, 0xcd, 0x16, 0xb2, 0x80, 0xcd, 0x19, 0x50, 0x53,
0xcd, 0x10, 0xb4, 0x03, 0xcd, 0x10, 0xfe, 0xc2, 0xb4, 0x02, 0xcd, 0x10, 0xac, 0x3c, 0x00, 0x75, 0x51, 0x52, 0x30, 0xff, 0xe9, 0x11, 0x00, 0x8b, 0x56, 0x08, 0xb4, 0x02, 0xcd, 0x10, 0xfe, 0x46,
0xea, 0x59, 0xc3, 0x10, 0x00, 0x03, 0x00, 0x00, 0x02, 0xc0, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0xb9, 0x01, 0x00, 0xb4, 0x09, 0xcd, 0x10, 0xac, 0x3c, 0x00, 0x75, 0xea, 0x5a, 0x59, 0x5b,
0x00, 0x00, 0x00, 0x48, 0x61, 0x69, 0x6b, 0x75, 0x20, 0x42, 0x6f, 0x6f, 0x74, 0x20, 0x4d, 0x61, 0x58, 0xc3, 0xb4, 0x03, 0xcd, 0x10, 0x89, 0x4e, 0x0a, 0xb4, 0x01, 0xb9, 0x00, 0x20, 0xcd, 0x10,
0x6e, 0x61, 0x67, 0x65, 0x72, 0x00, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x61, 0x6e, 0x20, 0xc3, 0x8b, 0x4e, 0x0a, 0xb4, 0x01, 0xcd, 0x10, 0xc3, 0x10, 0x00, 0x03, 0x00, 0x00, 0x02, 0xc0,
0x4f, 0x53, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x61, 0x69, 0x6b, 0x75, 0x20, 0x42,
0x00, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x6f, 0x6f, 0x74, 0x20, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x00, 0x53, 0x65, 0x6c, 0x65,
0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x21, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x63, 0x74, 0x20, 0x61, 0x6e, 0x20, 0x4f, 0x53, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68,
0x65, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x00, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x61,
0x64, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x21, 0x00, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
@@ -27,37 +29,42 @@ static const uint8 kBootLoader[] = {
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0xa1, 0x09, 0x04, 0x89, 0x46, 0x00, 0xb8, 0x13, 0x00, 0xf7, 0x26, 0x0b, 0x04, 0x89, 0xd3, 0x50,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x55, 0xaa, 0xb4, 0x00, 0xcd, 0x1a, 0x58, 0x01, 0xd0, 0x11, 0xcb, 0x89, 0x46, 0x04, 0x89, 0x5e, 0x06, 0xa0,
0xa1, 0x9a, 0x03, 0xa3, 0x47, 0x03, 0xb8, 0x13, 0x00, 0xf7, 0x26, 0x9c, 0x03, 0x89, 0xd3, 0x50, 0x07, 0x04, 0xd0, 0xe8, 0xb3, 0x0c, 0x28, 0xc3, 0x88, 0x5e, 0x02, 0xe8, 0x64, 0x00, 0x81, 0x3e,
0xb4, 0x00, 0xcd, 0x1a, 0x58, 0x01, 0xd0, 0x11, 0xcb, 0xa3, 0x4b, 0x03, 0x89, 0x1e, 0x4d, 0x03, 0x0b, 0x04, 0xff, 0xff, 0x74, 0x25, 0xb4, 0x01, 0xcd, 0x16, 0x75, 0x1f, 0xe8, 0x05, 0x00, 0x73,
0xa0, 0x98, 0x03, 0xd0, 0xe8, 0xb3, 0x0c, 0x28, 0xc3, 0x88, 0x1e, 0x49, 0x03, 0xe8, 0x65, 0x00, 0xf5, 0xe9, 0xa6, 0x00, 0xb4, 0x00, 0xcd, 0x1a, 0x3b, 0x4e, 0x06, 0x72, 0x07, 0x77, 0x07, 0x3b,
0x81, 0x3e, 0x9c, 0x03, 0xff, 0xff, 0x74, 0x27, 0xb4, 0x01, 0xcd, 0x16, 0x75, 0x21, 0xe8, 0x05, 0x56, 0x04, 0x77, 0x02, 0xf8, 0xc3, 0xf9, 0xc3, 0xe8, 0x37, 0x00, 0xb4, 0x00, 0xcd, 0x16, 0x80,
0x00, 0x73, 0xf5, 0xe9, 0x9b, 0x00, 0xb4, 0x00, 0xcd, 0x1a, 0x3b, 0x0e, 0x4d, 0x03, 0x72, 0x08, 0xfc, 0x50, 0x74, 0x0d, 0x80, 0xfc, 0x48, 0x74, 0x19, 0x80, 0xfc, 0x1c, 0x75, 0xed, 0xe9, 0x79,
0x77, 0x08, 0x3b, 0x16, 0x4b, 0x03, 0x77, 0x02, 0xf8, 0xc3, 0xf9, 0xc3, 0xe8, 0x36, 0x00, 0xb4, 0x00, 0x8b, 0x46, 0x00, 0x40, 0x3b, 0x06, 0x07, 0x04, 0x75, 0x02, 0x31, 0xc0, 0x89, 0x46, 0x00,
0x00, 0xcd, 0x16, 0x80, 0xfc, 0x50, 0x74, 0x0c, 0x80, 0xfc, 0x48, 0x74, 0x18, 0x80, 0xfc, 0x1c, 0xeb, 0xd6, 0x8b, 0x46, 0x00, 0x09, 0xc0, 0x75, 0x03, 0xa1, 0x07, 0x04, 0x48, 0x89, 0x46, 0x00,
0x74, 0x6f, 0xeb, 0xeb, 0xa1, 0x47, 0x03, 0x40, 0x3b, 0x06, 0x98, 0x03, 0x75, 0x02, 0x31, 0xc0, 0xeb, 0xc6, 0x8a, 0x46, 0x02, 0x88, 0x46, 0x09, 0xbe, 0x0d, 0x04, 0x31, 0xc9, 0xac, 0x04, 0x03,
0xa3, 0x47, 0x03, 0xeb, 0xd7, 0xa1, 0x47, 0x03, 0x09, 0xc0, 0x75, 0x03, 0xa1, 0x98, 0x03, 0x48, 0xd0, 0xe8, 0xb2, 0x28, 0x28, 0xc2, 0x88, 0x56, 0x08, 0xb0, 0x10, 0xe8, 0x30, 0x00, 0xfe, 0x46,
0xa3, 0x47, 0x03, 0xeb, 0xc7, 0xa0, 0x49, 0x03, 0xa2, 0x4a, 0x03, 0xbe, 0x9e, 0x03, 0x31, 0xc9, 0x08, 0x89, 0xcf, 0x81, 0xe7, 0x03, 0x00, 0x8a, 0x9d, 0xcc, 0x03, 0x3b, 0x4e, 0x00, 0x75, 0x03,
0xac, 0xfe, 0xc8, 0xd0, 0xe8, 0xb2, 0x28, 0x28, 0xc2, 0x8a, 0x36, 0x4a, 0x03, 0xb4, 0x02, 0xcd, 0x80, 0xf3, 0x08, 0xe8, 0xb6, 0x00, 0x81, 0xc6, 0x09, 0x00, 0x80, 0x46, 0x08, 0x01, 0xb0, 0x11,
0x10, 0x89, 0xcf, 0x81, 0xe7, 0x03, 0x00, 0x8a, 0x9d, 0x5f, 0x03, 0x3b, 0x0e, 0x47, 0x03, 0x75, 0xe8, 0x0b, 0x00, 0xfe, 0x46, 0x09, 0x41, 0x3b, 0x0e, 0x07, 0x04, 0x75, 0xc0, 0xc3, 0x3b, 0x4e,
0x03, 0x80, 0xf3, 0x08, 0xe8, 0x57, 0x00, 0x81, 0xc6, 0x09, 0x00, 0xfe, 0x06, 0x4a, 0x03, 0x41, 0x00, 0x74, 0x02, 0xb0, 0x20, 0xb3, 0x0f, 0xe9, 0xb6, 0x00, 0xe8, 0xa4, 0xfd, 0xe8, 0x83, 0x00,
0x3b, 0x0e, 0x98, 0x03, 0x75, 0xca, 0xb4, 0x02, 0xba, 0x1a, 0x15, 0xba, 0x1c, 0x18, 0xcd, 0x10, 0xac, 0x88, 0xc2, 0xbf, 0xc4, 0x03, 0xb9, 0x04, 0x00, 0xad, 0xab, 0xe2, 0xfc, 0xb4, 0x42, 0xbe,
0xc3, 0xbe, 0x9e, 0x03, 0x8b, 0x0e, 0x47, 0x03, 0x41, 0x30, 0xe4, 0xe9, 0x04, 0x00, 0x81, 0xc6, 0xbc, 0x03, 0xcd, 0x13, 0xbe, 0xd0, 0x03, 0x72, 0x40, 0xa1, 0xfe, 0x01, 0x3d, 0x55, 0xaa, 0xbe,
0x09, 0x00, 0xac, 0x01, 0xc6, 0xe2, 0xf7, 0xac, 0x88, 0xc2, 0xbf, 0x57, 0x03, 0xb9, 0x04, 0x00, 0xe6, 0x03, 0x75, 0x35, 0xb4, 0x06, 0x30, 0xc0, 0xb7, 0x0f, 0x31, 0xc9, 0xba, 0x4f, 0x18, 0xcd,
0xad, 0xab, 0xe2, 0xfc, 0xb4, 0x42, 0xbe, 0x4f, 0x03, 0xcd, 0x13, 0xbe, 0x63, 0x03, 0x72, 0x2a, 0x10, 0xc7, 0x46, 0x08, 0x00, 0x00, 0xbe, 0xff, 0x03, 0xb3, 0x07, 0xe8, 0x4e, 0x00, 0xfe, 0x46,
0xa1, 0xfe, 0x01, 0x3d, 0x55, 0xaa, 0xbe, 0x79, 0x03, 0x75, 0x1f, 0xe9, 0xe2, 0xfc, 0x51, 0xe9, 0x08, 0xe8, 0x29, 0x00, 0x46, 0xe8, 0x44, 0x00, 0xba, 0x00, 0x01, 0x30, 0xff, 0xb4, 0x02, 0xcd,
0x11, 0x00, 0xb9, 0x01, 0x00, 0xb4, 0x09, 0xcd, 0x10, 0xb4, 0x03, 0xcd, 0x10, 0xfe, 0xc2, 0xb4, 0x10, 0xe8, 0x2f, 0x00, 0x8a, 0x14, 0xe9, 0xb7, 0xfc, 0xba, 0x1a, 0x15, 0x89, 0x56, 0x08, 0xbb,
0x02, 0xcd, 0x10, 0xac, 0x3c, 0x00, 0x75, 0xea, 0x59, 0xc3, 0xbb, 0x0f, 0x00, 0xe8, 0xde, 0xff, 0x0f, 0x00, 0xe8, 0x27, 0x00, 0xb4, 0x00, 0xcd, 0x16, 0xb2, 0x80, 0xcd, 0x19, 0xbe, 0x0d, 0x04,
0xb4, 0x00, 0xcd, 0x16, 0xf4, 0xeb, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x8b, 0x4e, 0x00, 0x41, 0x30, 0xe4, 0xe9, 0x07, 0x00, 0xac, 0x01, 0xc6, 0x81, 0xc6, 0x09, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe2, 0xf7, 0xc3, 0xe8, 0xe7, 0xff, 0xac, 0x30, 0xe4, 0x01, 0xc6, 0xc3, 0x50, 0x53, 0x51, 0x52,
0x04, 0x03, 0x02, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x30, 0xff, 0xe9, 0x11, 0x00, 0x8b, 0x56, 0x08, 0xb4, 0x02, 0xcd, 0x10, 0xfe, 0x46, 0x08, 0xb9,
0x20, 0x73, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x00, 0x4e, 0x6f, 0x74, 0x20, 0x61, 0x20, 0x62, 0x01, 0x00, 0xb4, 0x09, 0xcd, 0x10, 0xac, 0x3c, 0x00, 0x75, 0xea, 0x5a, 0x59, 0x5b, 0x58, 0xc3,
0x6f, 0x6f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x50, 0x53, 0x51, 0x52, 0x30, 0xff, 0x8b, 0x56, 0x08, 0xb4, 0x02, 0xcd, 0x10, 0xfe, 0x46, 0x08,
0x6e, 0x00, 0x42, 0x6f, 0x6f, 0x74, 0x21, 0x00 0xb9, 0x01, 0x00, 0xb4, 0x09, 0xcd, 0x10, 0x5a, 0x59, 0x5b, 0x58, 0xc3, 0x10, 0x00, 0x01, 0x00,
0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x02, 0x03,
0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x65,
0x63, 0x74, 0x6f, 0x72, 0x73, 0x00, 0x4e, 0x6f, 0x74, 0x20, 0x61, 0x20, 0x62, 0x6f, 0x6f, 0x74,
0x61, 0x62, 0x6c, 0x65, 0x20, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x4c,
0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x00
}; };
+202 -89
View File
@@ -22,12 +22,15 @@
%assign BIOS_VIDEO_SERVICES 0x10 %assign BIOS_VIDEO_SERVICES 0x10
%assign BIOS_DISK_SERVICES 0x13 %assign BIOS_DISK_SERVICES 0x13
%assign BIOS_KEYBOARD_SERVICES 0x16 %assign BIOS_KEYBOARD_SERVICES 0x16
%assign BIOS_REBOOT 0x19 %assign BIOS_REBOOT 0x19 ; dl - boot drive number
%assign BIOS_TIME_SERVICES 0x1A %assign BIOS_TIME_SERVICES 0x1A
; video services ; video services
%assign SET_VIDEO_MODE 0x00 ; al - mode %assign SET_VIDEO_MODE 0x00 ; al - mode
%assign SET_CURSOR_SHAPE 0x01 ; ch - starting scan line (5 bits)
; cl - ending scan line (5 bits)
%assign SET_CURSOR 0x02 ; dl - column %assign SET_CURSOR 0x02 ; dl - column
; dh - row ; dh - row
; bh - page ; bh - page
@@ -154,6 +157,18 @@ BITS 16
resb sizeof(%1) * %2 resb sizeof(%1) * %2
%endmacro %endmacro
; Variables on stack
struc Locals
selection resw 1
firstLine resb 2 ; low byte used only
timeoutTicks resd 1
cursorX resb 1
cursorY resb 1
cursorShape resw 1
endstruc
cursorPosition equ cursorX
%macro DEBUG_PAUSE 0 %macro DEBUG_PAUSE 0
push ax push ax
mov ah, READ_CHAR mov ah, READ_CHAR
@@ -161,7 +176,7 @@ BITS 16
pop ax pop ax
%endmacro %endmacro
%macro clearScreen 0 %macro CLEAR_SCREEN 0
mov ah, SCROLL_UP mov ah, SCROLL_UP
xor al, al xor al, al
mov bh, WHITE mov bh, WHITE
@@ -171,24 +186,33 @@ BITS 16
%endmacro %endmacro
; Prints a null terminated string ; Prints a null terminated string
; bl ... color
; si ... offset to string ; si ... offset to string
%macro printString 0 %macro PRINT_STRING 0
push ax
push bx
push cx push cx
push dx
xor bh, bh ; write on page 0
jmp .loop_condition jmp .loop_condition
.loop .loop
mov dx, [bp + cursorPosition]
mov ah, SET_CURSOR
int BIOS_VIDEO_SERVICES
inc byte [bp + cursorX]
mov cx, 1 mov cx, 1
mov ah, WRITE_CHAR mov ah, WRITE_CHAR
int BIOS_VIDEO_SERVICES int BIOS_VIDEO_SERVICES
mov ah, GET_CURSOR
int BIOS_VIDEO_SERVICES
inc dl
mov ah, SET_CURSOR
int BIOS_VIDEO_SERVICES
.loop_condition .loop_condition
lodsb lodsb
cmp al, 0 cmp al, 0
jnz .loop jnz .loop
pop dx
pop cx pop cx
pop bx
pop ax
ret ret
%endmacro %endmacro
@@ -222,29 +246,29 @@ stage1:
mov es, ax mov es, ax
mov ss, ax mov ss, ax
mov sp, 0xFFFF ; Make stack empty mov sp, 0xFFFF - sizeof(Locals) ; Make stack empty
mov bp, sp
cld ; String operations increment index registers cld ; String operations increment index registers
clearScreen CLEAR_SCREEN
call hideCursor
mov bh, 0 ; Text output on page 0 mov bh, 0 ; Text output on page 0
; Print title centered at row 2 ; Print title centered at row 2
mov ah, SET_CURSOR
mov dx, 1 * 0x100 + (40 - TITLE_LENGTH / 2) mov dx, 1 * 0x100 + (40 - TITLE_LENGTH / 2)
int BIOS_VIDEO_SERVICES mov [bp + cursorPosition], dx
mov si, kTitle mov si, kTitle
mov bl, WHITE mov bl, WHITE
call printstr call printstr
; Print message centered at second last row ; Print message centered at second last row
mov ah, SET_CURSOR
mov dx, (TEXT_ROWS-2) * 0x100 + (40 - SELECT_OS_MESSAGE_LENGTH / 2) mov dx, (TEXT_ROWS-2) * 0x100 + (40 - SELECT_OS_MESSAGE_LENGTH / 2)
mov bl, LIGHT_GRAY mov [bp + cursorPosition], dx
int BIOS_VIDEO_SERVICES
mov bl, LIGHT_GRAY
mov si, kSelectOSMessage mov si, kSelectOSMessage
call printstr call printstr
@@ -257,18 +281,36 @@ stage1:
jmp stage2 ; Continue in loaded stage 2 jmp stage2 ; Continue in loaded stage 2
.error: .error:
call showCursor
mov si, kError mov si, kError
mov bl, RED mov bl, RED
call printstr call printstr
.halt
mov ah, READ_CHAR mov ah, READ_CHAR
int BIOS_KEYBOARD_SERVICES int BIOS_KEYBOARD_SERVICES
hlt
jmp .halt mov dl, 0x80
int BIOS_REBOOT
printStringStage1: printStringStage1:
printString PRINT_STRING
hideCursor:
mov ah, GET_CURSOR
int BIOS_VIDEO_SERVICES
mov [bp + cursorShape], cx
mov ah, SET_CURSOR_SHAPE
mov cx, 0x2000
int BIOS_VIDEO_SERVICES
ret
showCursor:
mov cx, [bp + cursorShape]
mov ah, SET_CURSOR_SHAPE
int BIOS_VIDEO_SERVICES
ret
nextStageDAP: nextStageDAP:
istruc AddressPacket istruc AddressPacket
at AddressPacket.packet_size, db 0x10 at AddressPacket.packet_size, db 0x10
@@ -284,10 +326,18 @@ kSelectOSMessage:
kError: kError:
db 'Error loading sectors!', 0x00 db 'Error loading sectors!', 0x00
; Fill the missing space to reach 510 byte kStage1UnusedSpace equ 440 - ($-$$)
times 510 -($-$$) db 'B' ; Fill the missing space to reach byte 440
times kStage1UnusedSpace db 'B'
signature: kDiskSignatue:
dw 0, 0
kReserved
dw 0
kPartitionTable
times 64 db 0
kMBRSignature:
; Magic marker "AA55" (to identify a valid boot record) ; Magic marker "AA55" (to identify a valid boot record)
dw MBR_SIGNATURE dw MBR_SIGNATURE
@@ -303,7 +353,7 @@ signature:
stage2: stage2:
mov ax, [defaultItem] ; Select default item mov ax, [defaultItem] ; Select default item
mov [selection], ax mov [bp + selection], ax
mov ax, TICKS_PER_SECOND ; Calculate timeout ticks mov ax, TICKS_PER_SECOND ; Calculate timeout ticks
mul word [timeout] mul word [timeout]
@@ -316,14 +366,14 @@ stage2:
pop ax ; Add current ticks pop ax ; Add current ticks
add ax, dx add ax, dx
adc bx, cx adc bx, cx
mov [timeoutTicks], ax mov [bp + timeoutTicks], ax
mov [timeoutTicks + 2], bx mov [bp + timeoutTicks + 2], bx
mov al, [listItemCount] ; Calculate start row for menu mov al, [listItemCount] ; Calculate start row for menu
shr al, 1 shr al, 1
mov bl, TEXT_ROWS / 2 mov bl, TEXT_ROWS / 2
sub bl, al ; y = TEXT_ROWS / 2 - number of items / 2 sub bl, al ; y = TEXT_ROWS / 2 - number of items / 2
mov [firstLine], bl mov [bp + firstLine], bl
call printMenu call printMenu
@@ -341,10 +391,10 @@ timeoutLoop:
isTimeoutReached: isTimeoutReached:
mov ah, READ_CLOCK mov ah, READ_CLOCK
int BIOS_TIME_SERVICES int BIOS_TIME_SERVICES
cmp cx, [timeoutTicks + 2] cmp cx, [bp + timeoutTicks + 2]
jb .returnFalse jb .returnFalse
ja .returnTrue ja .returnTrue
cmp dx, [timeoutTicks] cmp dx, [bp + timeoutTicks]
ja .returnTrue ja .returnTrue
.returnFalse: .returnFalse:
clc clc
@@ -368,96 +418,89 @@ inputLoop:
je selectPreviousPartition je selectPreviousPartition
cmp ah, KEY_RETURN cmp ah, KEY_RETURN
je bootSelectedPartition jne inputLoop
jmp bootSelectedPartition
jmp inputLoop
selectNextPartition: selectNextPartition:
mov ax, [selection] mov ax, [bp + selection]
inc ax inc ax
cmp ax, [listItemCount] cmp ax, [listItemCount]
jne .done ; At end of list? jne .done ; At end of list?
xor ax, ax ; Then jump to first entry xor ax, ax ; Then jump to first entry
.done: .done:
mov [selection], ax mov [bp + selection], ax
jmp mainLoop jmp mainLoop
selectPreviousPartition: selectPreviousPartition:
mov ax, [selection] mov ax, [bp + selection]
or ax, ax or ax, ax
jnz .done ; At top of list? jnz .done ; At top of list?
mov ax, [listItemCount] ; Then jump to last entry mov ax, [listItemCount] ; Then jump to last entry
.done: .done:
dec ax dec ax
mov [selection], ax mov [bp + selection], ax
jmp mainLoop jmp mainLoop
; ======================= Print the OS list ============================ ; ======================= Print the OS list ============================
printMenu: printMenu:
mov al, [firstLine] mov al, [bp + firstLine]
mov [currentLine], al mov [bp + cursorY], al
mov si, list ; Start at top of list mov si, list ; Start at top of list
xor cx, cx ; The index of the current item xor cx, cx ; The index of the current item
.loop: .loop:
lodsb ; String length incl. 0-terminator lodsb ; String length incl. 0-terminator
dec al ; center menu item add al, 3 ; center menu item
shr al, 1 ; x = TEXT_COLUMNS / 2 - length / 2 shr al, 1 ; x = TEXT_COLUMNS / 2 - length / 2
mov dl, TEXT_COLUMNS / 2 mov dl, TEXT_COLUMNS / 2
sub dl, al sub dl, al
mov [bp + cursorX], dl
mov dh, [currentLine]
mov ah, SET_CURSOR mov al, TRIANGLE_TO_RIGHT
int BIOS_VIDEO_SERVICES call updateMarker
inc byte [bp + cursorX]
mov di, cx mov di, cx
and di, 3 and di, 3
mov bl, [kColorTable + di] ; Text color mov bl, [kColorTable + di] ; Text color
cmp cx, [selection] cmp cx, [bp + selection]
jne .print ; Selected item reached? jne .print ; Selected item reached?
xor bl, BRIGHT_COLOR_MASK ; Highlight it xor bl, BRIGHT_COLOR_MASK ; Highlight it
.print: .print:
call printstr call printstr
add si, sizeof(BootLoaderAddress) add si, sizeof(BootLoaderAddress)
inc byte [currentLine] add byte [bp + cursorX], 1
mov al, TRIANGLE_TO_LEFT
call updateMarker
inc byte [bp + cursorY]
inc cx inc cx
cmp cx, [listItemCount] cmp cx, [listItemCount]
jne .loop jne .loop
mov ah, SET_CURSOR ; Set cursor position
mov dx, (TEXT_ROWS-4) * 0x100 + (TEXT_COLUMNS / 3)
mov dx, 0x181C
int BIOS_VIDEO_SERVICES
ret ret
updateMarker:
cmp cx, [bp + selection]
je .print
mov al, ' ' ; Clear marker
.print
mov bl, WHITE
jmp printChar ; return from subroutine
; ========================== Chainload ========================== ; ========================== Chainload ==========================
bootSelectedPartition: bootSelectedPartition:
mov si, list ; Search address of start sector call showCursor
; of the selected item.
mov cx, [selection]
inc cx ; Number of required iterations
xor ah, ah ; The high-byte of the string length
; see loop body
jmp .search_loop_entry
.search_loop:
add si, sizeof(BootLoaderAddress)
.search_loop_entry: call getSelectedBootLoaderAddress
lodsb ; Length of menu item name
add si, ax ; Skip name to BootLoaderAddess
loop .search_loop
lodsb ; Set boot drive lodsb ; Set boot drive
mov dl, al mov dl, al
@@ -474,39 +517,107 @@ bootSelectedPartition:
mov si, kReadError mov si, kReadError
jc printAndHalt ; Failed to read sector jc printAndHalt ; Failed to read sector
mov ax, [signature] mov ax, [kMBRSignature]
cmp ax, MBR_SIGNATURE cmp ax, MBR_SIGNATURE
mov si, kNoBootablePartitionError mov si, kNoBootablePartitionError
jne printAndHalt ; Missing signature jne printAndHalt ; Missing signature
CLEAR_SCREEN
; Print "Loading <name>" at top of screen
mov word [bp + cursorPosition], 0
mov si, kLoadingMessage
mov bl, LIGHT_GRAY
call printstr
inc byte [bp + cursorX]
call getSelectedMenuItem
inc si ; Skip string length byte
call printstr
mov dx, 0x100
xor bh, bh
mov ah, SET_CURSOR
int BIOS_VIDEO_SERVICES
call getSelectedBootLoaderAddress
mov dl, [si] ; drive number in dl
jmp $$ ; Start loaded boot loader jmp $$ ; Start loaded boot loader
; ====================== THE printMenu function ================
printStringStage2:
printString
printAndHalt: printAndHalt:
mov dx, (TEXT_ROWS-4) * 0x100 + (TEXT_COLUMNS / 3)
mov [bp + cursorPosition], dx
mov bx, 0x0F ; Page number and foreground color mov bx, 0x0F ; Page number and foreground color
call printstr call printstr
.halt
mov ah, READ_CHAR mov ah, READ_CHAR
int BIOS_KEYBOARD_SERVICES int BIOS_KEYBOARD_SERVICES
hlt mov dl, 0x80
jmp .halt int BIOS_REBOOT
; Output:
; si address of selected menu item
; Trashes:
; ax, cx
getSelectedMenuItem:
mov si, list ; Search address of start sector
; of the selected item.
mov cx, [bp + selection]
inc cx ; Number of required iterations
xor ah, ah ; The high-byte of the string length
; see loop body
jmp .entry
.loop:
lodsb ; Length of menu item name
add si, ax ; Skip name to BootLoaderAddess
add si, sizeof(BootLoaderAddress)
.entry:
loop .loop
ret
getSelectedBootLoaderAddress:
call getSelectedMenuItem
lodsb
xor ah, ah
add si, ax ; Skip name
ret
printStringStage2:
PRINT_STRING
; al ... ASCII character
; bl ... color
printChar:
push ax
push bx
push cx
push dx
xor bh, bh ; Write on page 0
mov dx, [bp + cursorPosition]
mov ah, SET_CURSOR
int BIOS_VIDEO_SERVICES
inc byte [bp + cursorX]
mov cx, 1
mov ah, WRITE_CHAR
int BIOS_VIDEO_SERVICES
pop dx
pop cx
pop bx
pop ax
ret
; ================================ DATA =========================== ; ================================ DATA ===========================
selection:
dw 0x0000
firstLine:
db 0
currentLine:
db 0
timeoutTicks:
dw 0, 0
bootSectorDAP: bootSectorDAP:
istruc AddressPacket istruc AddressPacket
at AddressPacket.packet_size, db 0x10 at AddressPacket.packet_size, db 0x10
@@ -515,13 +626,13 @@ bootSectorDAP:
iend iend
kColorTable: kColorTable:
db BLUE, RED, CYAN, GREEN db BLUE, RED, GREEN, CYAN
kReadError: kReadError:
db 'Error loading sectors', 0x00 db 'Error loading sectors', 0x00
kNoBootablePartitionError: kNoBootablePartitionError:
db 'Not a bootable partition', 0x00 db 'Not a bootable partition', 0x00
kBootMessage: kLoadingMessage:
db 'Boot!', 0x00 db 'Loading', 0x00
listItemCount: listItemCount:
@@ -574,5 +685,7 @@ list equ timeout + 2
db 'OpenBSD', 0 db 'OpenBSD', 0
db 0x80 db 0x80
dw 0xAAAA, 0, 0, 0 dw 0xAAAA, 0, 0, 0
dw kStage1UnusedSpace
%endif %endif