One task runs the clock, one task runs the shell.

This commit is contained in:
Kevin Lange 2011-03-24 20:18:14 -05:00
parent 80804862a4
commit fffa6d99ae
3 changed files with 33 additions and 25 deletions

View File

@ -5,7 +5,8 @@
*/
unsigned short * textmemptr;
int attrib = 0x0F;
int csr_x = 0, csr_y = 0;
int csr_x = 0, csr_y = 0, use_serial = 1;
int old_x = 0, old_y = 0, old_s = 1;
/*
* scroll
@ -31,6 +32,25 @@ scroll() {
}
}
void
set_serial(int on) {
use_serial = on;
}
void
store_csr() {
old_x = csr_x;
old_y = csr_y;
old_s = use_serial;
}
void
restore_csr() {
csr_x = old_x;
csr_y = old_y;
use_serial = old_s;
}
/*
* move_csr
* Update the hardware cursor
@ -144,7 +164,9 @@ writech(
*where = c | att;
csr_x++;
}
serial_send(c);
if (use_serial) {
serial_send(c);
}
if (csr_x >= 80) {
csr_x = 0;

View File

@ -41,6 +41,9 @@ extern void placech(unsigned char c, int x, int y, int attr);
extern void writechf(unsigned char c);
extern void writech(unsigned char c);
extern void place_csr(uint32_t x, uint32_t y);
extern void store_csr();
extern void restore_csr();
extern void set_serial(int);
/* GDT */
extern void gdt_install();

View File

@ -133,17 +133,10 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp)
}
__asm__ __volatile__ ("sti");
start_shell();
/*
* Aw man...
*/
fork();
fork();
fork();
fork();
uint32_t i = getpid() * 10000;
if (getpid() == 0) {
while (1) {
@ -161,25 +154,15 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp)
uint16_t seconds = from_bcd(values[0]);
__asm__ __volatile__ ("cli");
place_csr(0,0);
settextcolor(10,0);
kprintf("%d:%d:%d", hours, minutes, seconds);
store_csr();
place_csr(70,0);
set_serial(0);
kprintf("[%d:%d:%d]", hours, minutes, seconds);
restore_csr();
__asm__ __volatile__ ("sti");
}
} else {
while (1) {
++i;
__asm__ __volatile__ ("cli");
if (getpid() % 2 == 0) {
place_csr(0, getpid() / 2);
} else {
place_csr(30, getpid()/ 2);
}
settextcolor(getpid() + 1, 0);
kprintf("%d:%d", getpid(), i);
__asm__ __volatile__ ("sti");
}
start_shell();
}
return 0;