|
|
Operating System Layers
Booting Vesp With a Boot Sector Vesp RAM-Memory-map ------------------------------------------------ Memory[0x000]--A | Memory[0x001]--B | Memory[0x002]--IX | -Bootstrap code begins here | Block 0 Memory[0x003]----cursor position -x | Memory[0x004]----cursor-position -y | Memory[0x005]----pixel color (or ASCII code) | Memory[0x006]----display mode | Memory[0x007]----pixel pattern(when not ASCII) | Memory[0x008]----space | Memory[0x009]----carriage return | Memory[0x00A]----temp | | Memory[0x020]----boot-vector begins here | ------------------------------------------------ Memory[0x100]------Keyboard driver and ASCII | Memory[0x101]------tables are stored here | | | Memory[0x2FF] | Blocks 1,2 (Keyboard input driver) | | | | | | ------------------------------------------------ Memory[0x300]------Frame buffer (video) and | Memory[0x301]------video drivers are | Memory[0x302]------ stored here | | | | Blocks 3,4,5,6 (Screen output) | 16x64 screen = 2^10 pixels Memory[0x6FF]------ | ----------------------------------------------- Memory[0x700]------VESP Kernel Code | Memory[0x701]------OS routines and code | Memory[0x8FF]------ | | | Blocks 7,8 Operating System (Kernel) | | | | ------------------------------------------------ |
void initialize(void)
{vesp.PC = vesp.MEMORY[0] = vesp.MEMORY[1] = vesp.IR = 0;
vesp.reset = 0; vesp.clock = 0;
//vesp's boot code begins at location 0x020.
/* Boot code will
clear the screen
write "vesp is booting" into the frame buffer
delay
clear "vesp is booting" in the frame buffer
load "vesp:" into the framebuffer
load "-" and blink it for command entry.
*/
// initialize the screen variables
vesp.BOOTSTRAP[0] = 0x2003; vesp.BOOTSTRAP[1] = 0x0000; // Clear location 3 (cursor-x) //020-021
vesp.BOOTSTRAP[2] = 0x2004; vesp.BOOTSTRAP[3] = 0x0000; // Clear location 4 (cursor-y) //022-023
vesp.BOOTSTRAP[4] = 0x2005; vesp.BOOTSTRAP[5] = 0x000F; // Set location 5 (pixel color) //024-025
vesp.BOOTSTRAP[6] = 0x2006; vesp.BOOTSTRAP[7] = 0x0000; // Set display mode (ASCII) //026-027
vesp.BOOTSTRAP[8] = 0x2007; vesp.BOOTSTRAP[9] = 0x002B; // Set pixel symbol ('+' sign) //028-029
// clear the frame buffer (insert white space)
vesp.BOOTSTRAP[10] = 0x2002; vesp.BOOTSTRAP[11] = 0x0300; // Load IX with 0x300 //02A-02B
vesp.BOOTSTRAP[12] = 0x2000; vesp.BOOTSTRAP[13] = 0x0400; // Load 0x400 into A //02C-02D
vesp.BOOTSTRAP[14] = 0x2008; vesp.BOOTSTRAP[15] = 0x0020; // Load space into location 0x008 //02E-02F
vesp.BOOTSTRAP[16] = 0x5034; vesp.BOOTSTRAP[17] = 0xF008; // If A is 0 then jump out of the loop //030-031
// Load space into the next framebuffer location
vesp.BOOTSTRAP[18] = 0x9000; // Decrement A //032
vesp.BOOTSTRAP[19] = 0x4030; // Loop back to check if A is 0 //033
// insert a carriage return at the end of each line
vesp.BOOTSTRAP[20] = 0x2002; vesp.BOOTSTRAP[21] = 0x033F; // Load IX with 0x033F //034-035
vesp.BOOTSTRAP[22] = 0x2000; vesp.BOOTSTRAP[23] = 0x0010; // Load 0x0010 into A //036-037
vesp.BOOTSTRAP[24] = 0x2009; vesp.BOOTSTRAP[25] = '\n'; // Load CR into location 0x009 //038-039
// The location for CR is vesp.MEMORY[9].
vesp.BOOTSTRAP[26] = 0x2001; vesp.BOOTSTRAP[27] = 0x003F; // load B with 63 //03A-03B
vesp.BOOTSTRAP[28] = 0x5049; vesp.BOOTSTRAP[29] = 0xF009; // If A is 0 then jump out of the loop //03C-03D
// Load CR into the next framebuffer location
vesp.BOOTSTRAP[30] = 0x9000; // Decrement A //03E
vesp.BOOTSTRAP[31] = 0x300A; vesp.BOOTSTRAP[32] = 0x0000; // save A into temp [0x00A] //03F-040
vesp.BOOTSTRAP[33] = 0x3000; vesp.BOOTSTRAP[34] = 0x0002; // copy IX into A //041-042
vesp.BOOTSTRAP[35] = 0x0000; // add //043
vesp.BOOTSTRAP[36] = 0x3002; vesp.BOOTSTRAP[37] = 0x0000; // save A into IX //044-045
vesp.BOOTSTRAP[38] = 0x3000; vesp.BOOTSTRAP[39] = 0x000A; // Restore A from temp //046-047
vesp.BOOTSTRAP[40] = 0x403C; // Loop back to check if A is 0 //048
// write the message "vesp is booting"
vesp.BOOTSTRAP[41] = 0x2300; vesp.BOOTSTRAP[42] = 0x0076; // write v //049-04A
vesp.BOOTSTRAP[43] = 0x2301; vesp.BOOTSTRAP[44] = 0x0065; // write e //04B-04C
vesp.BOOTSTRAP[45] = 0x2302; vesp.BOOTSTRAP[46] = 0x0073; // write s //04D-04E
vesp.BOOTSTRAP[47] = 0x2303; vesp.BOOTSTRAP[48] = 0x0070; // write p //04F-050
vesp.BOOTSTRAP[49] = 0x2304; vesp.BOOTSTRAP[50] = 0x0020; // write ' ' //051-052
vesp.BOOTSTRAP[51] = 0x2305; vesp.BOOTSTRAP[52] = 0x0069; // write i //053-054
vesp.BOOTSTRAP[53] = 0x2306; vesp.BOOTSTRAP[54] = 0x0073; // write s //055-056
vesp.BOOTSTRAP[55] = 0x2307; vesp.BOOTSTRAP[56] = 0x0020; // write ' ' //057-058
vesp.BOOTSTRAP[57] = 0x2308; vesp.BOOTSTRAP[58] = 0x0062; // write b //059-05A
vesp.BOOTSTRAP[59] = 0x2309; vesp.BOOTSTRAP[60] = 0x006F; // write o //05B-05C
vesp.BOOTSTRAP[61] = 0x230A; vesp.BOOTSTRAP[62] = 0x006F; // write o //05D-05E
vesp.BOOTSTRAP[63] = 0x230B; vesp.BOOTSTRAP[64] = 0x0074; // write t //05F-060
vesp.BOOTSTRAP[65] = 0x230C; vesp.BOOTSTRAP[66] = 0x0069; // write i //061-062
vesp.BOOTSTRAP[67] = 0x230D; vesp.BOOTSTRAP[68] = 0x006E; // write n //063-064
vesp.BOOTSTRAP[69] = 0x230E; vesp.BOOTSTRAP[70] = 0x0067; // write g //065-066
// display the prompt: "enter command:-"
vesp.BOOTSTRAP[71] = 0x2340; vesp.BOOTSTRAP[72] = 0x0065; // write e //067-068
vesp.BOOTSTRAP[73] = 0x2341; vesp.BOOTSTRAP[74] = 0x006E; // write n //069-06A
vesp.BOOTSTRAP[75] = 0x2342; vesp.BOOTSTRAP[76] = 0x0074; // write t //06B-06C
vesp.BOOTSTRAP[77] = 0x2343; vesp.BOOTSTRAP[78] = 0x0065; // write e //06D-06E
vesp.BOOTSTRAP[79] = 0x2344; vesp.BOOTSTRAP[80] = 0x0072; // write r //051-052
vesp.BOOTSTRAP[81] = 0x2345; vesp.BOOTSTRAP[82] = 0x0020; // write ' ' //053-054
vesp.BOOTSTRAP[83] = 0x2346; vesp.BOOTSTRAP[84] = 0x0063; // write c //055-056
vesp.BOOTSTRAP[85] = 0x2347; vesp.BOOTSTRAP[86] = 0x006F; // write o //057-058
vesp.BOOTSTRAP[87] = 0x2348; vesp.BOOTSTRAP[88] = 0x006D; // write m //059-05A
vesp.BOOTSTRAP[89] = 0x2349; vesp.BOOTSTRAP[90] = 0x006D; // write m //05B-05C
vesp.BOOTSTRAP[91] = 0x234A; vesp.BOOTSTRAP[92] = 0x0061; // write a //05D-05E
vesp.BOOTSTRAP[93] = 0x234B; vesp.BOOTSTRAP[94] = 0x006E; // write n //05F-060
vesp.BOOTSTRAP[95] = 0x234C; vesp.BOOTSTRAP[96] = 0x0064; // write d //061-062
vesp.BOOTSTRAP[97] = 0x234D; vesp.BOOTSTRAP[98] = 0x003A; // write : //063-064
vesp.BOOTSTRAP[99] = 0x234E; vesp.BOOTSTRAP[100] = 0x005F; // write _ //065-066
vesp.BOOTSTRAP[100] = 0x7000; // vesp halts here until we determine the next step.
//
}
|
void bootstrap(void)
{unsigned int address = 0;
vesp.MEMORY[0] = vesp.MEMORY[1] = 0;
//copy the bootstrap into vesp.MEMORY[0x020...]
do
{vesp.MEMORY[address + 0x20] = vesp.BOOTSTRAP[address];
} while (address++ <= 100);
// set vesp.PC to 0x020,i.e.,the first
// instruction in the bootstrap code.
vesp.PC = 0x020;
boot();
}
void boot(void)
{short i;
for(i = 1; i<= 4289 && vesp.reset == 0; i++) maincycle(0);
updatescreen();
}
|
void bootstrap(void)
{unsigned int address = 0;
vesp.MEMORY[0] = vesp.MEMORY[1] = 0;
//copy the bootstrap into vesp.MEMORY[0x020...]
do
{vesp.MEMORY[address + 0x20] = vesp.BOOTSTRAP[address];
} while (address++ <= 100);
// set vesp.PC to 0x020,i.e.,the first
// instruction in the bootstrap code.
vesp.PC = 0x020;
boot();
}
void boot(void)
{short i;
for(i = 1; i<= 4289 && vesp.reset == 0; i++) maincycle(0);
updatescreen();
}
|
void updatescreen(void)
{ short i,j;
for (i=0; i <= 15; i++)
{for (j=0; j <= 63; j++)
{vesp.SCREEN[i][j] = vesp.MEMORY[0x300 + 64*i+j];}
}
for (i=0; i<= 15; i++)
{for (j=0;j<= 63; j++) cout << (char) vesp.SCREEN[i][j];}
}
|