10 static unsigned char _font[256 * 32];
12 /* Must be called from a firstrun context, where we don't care about saving
16 unsigned char oldread;
17 smram_state_t old_state = smram_save_state();
18 outb(0x3CE, 0x05 /* Mode register */);
19 outb(0x3CF, inb(0x3CF) & ~(0x10 /* Odd/even */));
20 outb(0x3CE, 0x04 /* Read register */);
22 outb(0x3CF, 0x02 /* Font plane */);
23 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
24 memcpy(_font, p2v(0xB8000), sizeof(_font));
25 smram_restore_state(old_state);
29 void text_render(char *buf, int x, int y, int w, int h)
31 unsigned char *video = (unsigned char *)0xB8000;
32 unsigned int textx = x / 9;
33 unsigned int texty = y / 14;
35 unsigned char ch, at, font;
36 smram_state_t old_state = smram_save_state();
38 outputf("text_render: (%d,%d),(%d,%d)", buf, x, y, w, h);
40 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
41 for (cy = y; cy < (y + h); cy++)
46 ch = video[texty * 160 + textx * 2];
47 at = video[texty * 160 + textx * 2 + 1];
48 font = _font[ch * 32 + cy % 14];
49 for (cx = x; cx < (x + w); cx++)
51 unsigned int pos = cx % 9;
55 ch = video[texty * 160 + textx * 2];
56 at = video[texty * 160 + textx * 2 + 1];
57 font = _font[ch * 32 + cy % 14];
59 /* XXX always BGR888 */
60 if (pos == 8) /* 9th pixel is cloned */
62 if ((font >> (7 - pos)) & 1)
64 *(buf++) = (at & 0x01) ? 0xFF : 0x00;
65 *(buf++) = (at & 0x02) ? 0xFF : 0x00;
66 *(buf++) = (at & 0x04) ? 0xFF : 0x00;
68 *(buf++) = (at & 0x10) ? 0xFF : 0x00;
69 *(buf++) = (at & 0x20) ? 0xFF : 0x00;
70 *(buf++) = (at & 0x40) ? 0xFF : 0x00;
75 smram_restore_state(old_state);
78 uint32_t text_checksum(int x, int y, int w, int h)
80 unsigned char *video = (unsigned char *)0xB8000;
81 unsigned int textx = x / 9;
82 unsigned int texty = y / 14;
85 smram_state_t old_state = smram_save_state();
87 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
89 for (cy = y; cy < (y + h); cy++)
94 cksm = crc32(video + texty * 160 + textx * 2, (w / 9) * 2 + 2, cksm); /* Err on the side of 'too many'. */
97 smram_restore_state(old_state);