OOStuBS - Technische Informatik II (TI-II)  2.4
task1.cc
gehe zur Dokumentation dieser Datei
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2  * Technische Informatik II *
3  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * *
5  * T A S K 1 *
6  * *
7 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8 
9 #include "user/task1.h"
10 #include "device/cgastr.h"
11 #include "machine/keyctrl.h"
12 
13 extern CGA_Stream kout;
15 
16 void Task1::setup(uint32_t magic, const ::Multiboot_Info* mbi){
17  this->magic=magic;
18  this->mbi=reinterpret_cast<const Multiboot_Info*>(mbi);
19 }
20 
22  return (mbi->flags&flag);
23 }
24 
26  //Var init
27  unsigned long long ullTmp;
28 
30  kout << "Not booted by multiboot compliant loader" << endl;
31  return;
32  }
33 
34  kout << "flags= " << bin << mbi->flags << dec << endl;
35 
36  if (checkFlag(memSize))
37  kout << "mem_lower = " << mbi->mem_lower
38  << "KB, mem_upper = " << mbi->mem_upper
39  << "KB" << endl;
40 
41  if (checkFlag(bootDev))
42  kout << "boot_device = " << hex << mbi->boot_device << endl;
43 
44  if (checkFlag(cmdLine))
45  kout << "cmdline = " << (const char*)mbi->cmdline << endl;
46 
47  if (checkFlag(modules)) {
48  kout << "mods_count = " << dec << mbi->mods_count
49  << ", mods_addr = " << hex << mbi->mods_addr << endl;
50 
51  Module *mod=reinterpret_cast<Module*>(mbi->mods_addr);
52  for(uint32_t i=0;i < mbi->mods_count; i++) {
53  kout << " mod_start = " << mod->mod_start
54  << ", mod_end = " << mod->mod_end
55  << ", string = " << mod->string << endl;
56  mod++;
57  }
58  }
59 
60  if (checkFlag(aOut) && checkFlag(elf)) {
61  kout << "Both bits 4 and 5 are set." << endl;
62  return;
63  }
64 
65  if (checkFlag(aOut)) {
66  const AOut_Symbol_Table *aout_sym = &(mbi->executable_info.aout);
67 
68  kout << "aout_symbol_table: tabsize = "
69  << dec << aout_sym->tabsize << endl
70  << "strsize = " << aout_sym->strsize
71  << ", addr = " << hex << aout_sym->addr << endl;
72  }
73 
74  if (checkFlag(elf)) {
75  const ELF_Section_Header_Table *elf_sec = &(mbi->executable_info.elf);
76 
77  kout << "elf_sec: num = "<< dec << elf_sec->num
78  << ", size = " << elf_sec->size << endl
79  << " " << (char)192 << (char)196 << "addr = " << hex << elf_sec->addr
80  << ", shndx = " << elf_sec->shndx << endl;
81  }
82 
83  if (checkFlag(memMap)) {
84 
85  kout << "mmap_addr = " << hex << mbi->mmap_addr
86  << ", mmap_length = " << dec << mbi->mmap_length << endl;
87 
88  for( const char* curr = (const char*)mbi->mmap_addr;
89  curr < (const char*)mbi->mmap_addr + mbi->mmap_length ;
90  curr+= ((const Memory_Map*)curr)->size + sizeof(((const Memory_Map*)curr)->size) ) {
91  const Memory_Map* currEntry=reinterpret_cast<const Memory_Map*>(curr);
92 
93  //Symbol des "aufgeklappten Menues"
94  if( (curr+((const Memory_Map*)curr)->size + sizeof(((const Memory_Map*)curr)->size))
95  < ((const char*)mbi->mmap_addr + mbi->mmap_length) ){
96 
97  kout << " " << (char)195 << (char)196;
98  }else{
99  kout << " " << (char)192 << (char)196;
100  }
101  kout << "base_addr = " << hex << currEntry->base_addr_low;
102  ullTmp = currEntry->length_low + (((unsigned long long)currEntry->length_high)<<32);
103  if(ullTmp<1024)
104  kout << ", length = " << dec << (unsigned long)(currEntry->length_low) << "B";
105  else if(ullTmp<1024*1024)
106  kout << ", length = " << dec << (unsigned long)(ullTmp/1024) << "KiB"; //zwar kB, aber KiB!
107  else if(ullTmp<1024*1024*1024)
108  kout << ", length = " << dec << (unsigned long)(ullTmp/(1024*1024)) << "MiB";
109  else if(ullTmp<1024LL*1024*1024*1024)
110  kout << ", length = " << dec << (unsigned long)(ullTmp/(1024*1024*1024)) << "GiB";
111  else
112  kout << ", length = " << dec << (unsigned long)(ullTmp/(1024LL*1024*1024*1024)) << "TiB";
113 
114  kout << ", type = "
115  << ((currEntry->type==0x1)?"ram":"reserved") << endl;
116  }
117  }
118 }
119 
121  //Var init
122  unsigned short x,y;
123  unsigned int i;
124  Colors col;
125  const char acText[] = "DAS_Farbenwunder";
126 
127  kout << endl << "kout test:" << endl;
128  kout.getpos(x,y);
129  for(i=0;i<18;i++){
130  if(i%6==0){
131  kout.flush();
132  kout.setpos(0,y+1+i/6);
133  }
134  kout << dec << "(" << i << ", " << hex << i << ") ";
135  }
136  kout << endl;
137 
138  //Farben ausgeben
139  kout << BGColor(LIGHTGREY);
140  for(i=0; i<sizeof(acText); i++){
141  kout << FGColor((Colors)i) << acText[i];
142  if(i==1){
143  kout << BGColor(BLACK);
144  }
145  }
146  kout << FGColor(RED) << Blink(true) << "--> DELUX <--" << Blink(false);
147  for(col=BLACK; col<=WHITE; col=(Colors)(col+1)){
148  if(col==DARKGREY){
149  kout << Blink(true);
150  }
151  kout << BGColor(col) << ' ';
152  }
153 
154  kout << FGColor(LIGHTGREY) << Blink(false) << BGColor(BLACK) << endl << endl;
155 }
156 
158  unsigned short x,y;
159  kout << endl << "Keyboard test: ";
160  kout.flush();
161  kout.getpos(x,y);
162 
163  while(true){
164  Key k=keyboard.key_hit();
165  if(k.valid()){
166  kout.setpos(x,y);
167  kout << k.ascii() << " (" << (unsigned int)k.scancode() << ") ";
168  kout.flush();
169  kout.setpos(x+1,y);
170  }
171  }
172 }
173 
175  kout.setpos(32, 1);
176  kout << "OOStuBs - Task 1" << endl;
177 
178  testKout();
179 
180  parseAndPrint();
181 
182  testKeyboard();
183 }