| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #include <console.h> |
|---|
| 20 | #include <fs/devfs.h> |
|---|
| 21 | #include <fs/vfs.h> |
|---|
| 22 | #include <init.h> |
|---|
| 23 | #include <error.h> |
|---|
| 24 | #include <malloc.h> |
|---|
| 25 | #include <i386/ioports.h> |
|---|
| 26 | #include <task.h> |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | #define VGA_ATT_INDEX 0x3C0 |
|---|
| 31 | #define VGA_ATT_WRITE 0x3C0 |
|---|
| 32 | |
|---|
| 33 | #define VGA_SEQ_INDEX 0x3C4 |
|---|
| 34 | #define VGA_SEQ_DATA 0x3C5 |
|---|
| 35 | |
|---|
| 36 | #define VGA_GFX_INDEX 0x3CE |
|---|
| 37 | #define VGA_GFX_DATA 0x3CF |
|---|
| 38 | |
|---|
| 39 | #define VGA_CRT_INDEXC 0x3D4 |
|---|
| 40 | #define VGA_CRT_DATAC 0x3D5 |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | BYTE attribRegisters[0x15]={ |
|---|
| 45 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, |
|---|
| 46 | 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, |
|---|
| 47 | 0x0C, 0x00, 0x0F, 0x08, 0x00, |
|---|
| 48 | }; |
|---|
| 49 | |
|---|
| 50 | BYTE seqRegisters[5]={ |
|---|
| 51 | 0x03, 0x00, 0x03, 0x00, 0x02, |
|---|
| 52 | }; |
|---|
| 53 | |
|---|
| 54 | BYTE gfxRegisters[9]={ |
|---|
| 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x0F, 0xFF, |
|---|
| 56 | }; |
|---|
| 57 | |
|---|
| 58 | BYTE crtcRegisters[0x19]={ |
|---|
| 59 | 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x4F, |
|---|
| 60 | 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, |
|---|
| 61 | 0x1F, 0x96, 0xB9, 0xA3, 0xFF, |
|---|
| 62 | }; |
|---|
| 63 | |
|---|
| 64 | void ConsoleSwitchToText() |
|---|
| 65 | { |
|---|
| 66 | int i; |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | if (!(consoles[currConsole].flags & CONSOLE_GRAPHICS)) |
|---|
| 72 | return; |
|---|
| 73 | |
|---|
| 74 | inb(0x3DA); |
|---|
| 75 | |
|---|
| 76 | for (i=0; i<0x15; i++) |
|---|
| 77 | { |
|---|
| 78 | outb(VGA_ATT_INDEX, i); |
|---|
| 79 | outb(VGA_ATT_WRITE, attribRegisters[i]); |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | for (i=0; i<5; i++) |
|---|
| 83 | { |
|---|
| 84 | outb(VGA_SEQ_INDEX, i); |
|---|
| 85 | outb(VGA_SEQ_INDEX, seqRegisters[i]); |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | for (i=0; i<9; i++) |
|---|
| 89 | { |
|---|
| 90 | outb(VGA_GFX_INDEX, i); |
|---|
| 91 | outb(VGA_GFX_DATA, gfxRegisters[i]); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | outw(VGA_CRT_INDEXC, 0x0011); |
|---|
| 95 | |
|---|
| 96 | for (i=0; i<0x19; i++) |
|---|
| 97 | { |
|---|
| 98 | outb(VGA_CRT_INDEXC, i); |
|---|
| 99 | outb(VGA_CRT_DATAC, crtcRegisters[i]); |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | outb(0x3C2, 0x67); |
|---|
| 103 | outb(0x3C0, 0x20); |
|---|
| 104 | inb(0x3DA); |
|---|
| 105 | |
|---|
| 106 | consoles[currConsole].flags &= ~CONSOLE_GRAPHICS; |
|---|
| 107 | } |
|---|