Rev 1649 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1649 | Rev 1694 | ||
|---|---|---|---|
| Line 47... | Line 47... | ||
| 47 | #include <as.h> |
47 | #include <as.h> |
| 48 | #include <ipc/fb.h> |
48 | #include <ipc/fb.h> |
| 49 | #include <ipc/ipc.h> |
49 | #include <ipc/ipc.h> |
| 50 | #include <ipc/ns.h> |
50 | #include <ipc/ns.h> |
| 51 | #include <ipc/services.h> |
51 | #include <ipc/services.h> |
| - | 52 | #include <libarch/ddi.h> |
|
| 52 | 53 | ||
| 53 | #include "ega.h" |
54 | #include "ega.h" |
| 54 | #include "../console/screenbuffer.h" |
55 | #include "../console/screenbuffer.h" |
| 55 | #include "main.h" |
56 | #include "main.h" |
| 56 | 57 | ||
| Line 68... | Line 69... | ||
| 68 | #define NORMAL_COLOR 0x0f |
69 | #define NORMAL_COLOR 0x0f |
| 69 | #define INVERTED_COLOR 0xf0 |
70 | #define INVERTED_COLOR 0xf0 |
| 70 | 71 | ||
| 71 | #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) |
72 | #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) |
| 72 | 73 | ||
| 73 | typedef unsigned char u8; |
- | |
| 74 | typedef unsigned short u16; |
- | |
| 75 | typedef unsigned int u32; |
- | |
| 76 | - | ||
| 77 | - | ||
| 78 | /* Allow only 1 connection */ |
74 | /* Allow only 1 connection */ |
| 79 | static int client_connected = 0; |
75 | static int client_connected = 0; |
| 80 | 76 | ||
| 81 | static unsigned int scr_width; |
77 | static unsigned int scr_width; |
| 82 | static unsigned int scr_height; |
78 | static unsigned int scr_height; |
| 83 | static char *scr_addr; |
79 | static char *scr_addr; |
| 84 | 80 | ||
| 85 | static unsigned int style = NORMAL_COLOR; |
81 | static unsigned int style = NORMAL_COLOR; |
| 86 | 82 | ||
| 87 | static inline void outb(u16 port, u8 b) |
- | |
| 88 | { |
- | |
| 89 | asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port)); |
- | |
| 90 | } |
- | |
| 91 | - | ||
| 92 | static inline void outw(u16 port, u16 w) |
- | |
| 93 | { |
- | |
| 94 | asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port)); |
- | |
| 95 | } |
- | |
| 96 | - | ||
| 97 | static inline void outl(u16 port, u32 l) |
- | |
| 98 | { |
- | |
| 99 | asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port)); |
- | |
| 100 | } |
- | |
| 101 | - | ||
| 102 | static inline u8 inb(u16 port) |
- | |
| 103 | { |
- | |
| 104 | u8 val; |
- | |
| 105 | - | ||
| 106 | asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port)); |
- | |
| 107 | return val; |
- | |
| 108 | } |
- | |
| 109 | - | ||
| 110 | static inline u16 inw(u16 port) |
- | |
| 111 | { |
- | |
| 112 | u16 val; |
- | |
| 113 | - | ||
| 114 | asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port)); |
- | |
| 115 | return val; |
- | |
| 116 | } |
- | |
| 117 | - | ||
| 118 | static inline u32 inl(u16 port) |
- | |
| 119 | { |
- | |
| 120 | u32 val; |
- | |
| 121 | - | ||
| 122 | asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port)); |
- | |
| 123 | return val; |
- | |
| 124 | } |
- | |
| 125 | - | ||
| 126 | - | ||
| 127 | - | ||
| 128 | - | ||
| 129 | static void clrscr(void) |
83 | static void clrscr(void) |
| 130 | { |
84 | { |
| 131 | int i; |
85 | int i; |
| 132 | 86 | ||
| 133 | for (i=0; i < scr_width*scr_height; i++) { |
87 | for (i=0; i < scr_width*scr_height; i++) { |
| Line 148... | Line 102... | ||
| 148 | outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff); |
102 | outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff); |
| 149 | } |
103 | } |
| 150 | 104 | ||
| 151 | static void cursor_disable(void) |
105 | static void cursor_disable(void) |
| 152 | { |
106 | { |
| 153 | u8 stat; |
107 | uint8_t stat; |
| - | 108 | ||
| 154 | outb(EGA_IO_ADDRESS , 0xa); |
109 | outb(EGA_IO_ADDRESS , 0xa); |
| 155 | stat=inb(EGA_IO_ADDRESS + 1); |
110 | stat=inb(EGA_IO_ADDRESS + 1); |
| 156 | outb(EGA_IO_ADDRESS , 0xa); |
111 | outb(EGA_IO_ADDRESS , 0xa); |
| 157 | outb(EGA_IO_ADDRESS +1 ,stat | (1<<5) ); |
112 | outb(EGA_IO_ADDRESS +1 ,stat | (1<<5) ); |
| 158 | } |
113 | } |
| 159 | 114 | ||
| 160 | static void cursor_enable(void) |
115 | static void cursor_enable(void) |
| 161 | { |
116 | { |
| 162 | u8 stat; |
117 | uint8_t stat; |
| - | 118 | ||
| 163 | outb(EGA_IO_ADDRESS , 0xa); |
119 | outb(EGA_IO_ADDRESS , 0xa); |
| 164 | stat=inb(EGA_IO_ADDRESS + 1); |
120 | stat=inb(EGA_IO_ADDRESS + 1); |
| 165 | outb(EGA_IO_ADDRESS , 0xa); |
121 | outb(EGA_IO_ADDRESS , 0xa); |
| 166 | outb(EGA_IO_ADDRESS +1 ,stat & (~(1<<5)) ); |
122 | outb(EGA_IO_ADDRESS +1 ,stat & (~(1<<5)) ); |
| 167 | } |
123 | } |