Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3844 → Rev 3790

/trunk/kernel/genarch/src/fb/fb.c
184,13 → 184,12
/** Hide logo and refresh screen
*
*/
static void logo_hide(bool silent)
static void logo_hide(void)
{
ylogo = 0;
ytrim = yres;
rowtrim = rows;
if (!silent)
fb_redraw();
fb_redraw();
}
 
 
197,7 → 196,7
/** Draw character at given position
*
*/
static void glyph_draw(uint8_t glyph, unsigned int col, unsigned int row, bool silent)
static void glyph_draw(uint8_t glyph, unsigned int col, unsigned int row)
{
unsigned int x = COL2X(col);
unsigned int y = ROW2Y(row);
204,15 → 203,13
unsigned int yd;
if (y >= ytrim)
logo_hide(silent);
logo_hide();
backbuf[BB_POS(col, row)] = glyph;
if (!silent) {
for (yd = 0; yd < FONT_SCANLINES; yd++)
memcpy(&fb_addr[FB_POS(x, y + yd + ylogo)],
&glyphs[GLYPH_POS(glyph, yd)], glyphscanline);
}
for (yd = 0; yd < FONT_SCANLINES; yd++)
memcpy(&fb_addr[FB_POS(x, y + yd + ylogo)],
&glyphs[GLYPH_POS(glyph, yd)], glyphscanline);
}
 
 
220,41 → 217,39
*
*
*/
static void screen_scroll(bool silent)
static void screen_scroll(void)
{
if (ylogo > 0) {
logo_hide(silent);
logo_hide();
return;
}
if (!silent) {
unsigned int row;
unsigned int row;
for (row = 0; row < rows; row++) {
unsigned int y = ROW2Y(row);
unsigned int yd;
for (row = 0; row < rows; row++) {
unsigned int y = ROW2Y(row);
unsigned int yd;
for (yd = 0; yd < FONT_SCANLINES; yd++) {
unsigned int x;
unsigned int col;
for (yd = 0; yd < FONT_SCANLINES; yd++) {
unsigned int x;
unsigned int col;
for (col = 0, x = 0; col < cols; col++,
x += FONT_WIDTH) {
uint8_t glyph;
for (col = 0, x = 0; col < cols; col++,
x += FONT_WIDTH) {
uint8_t glyph;
if (row < rows - 1) {
if (backbuf[BB_POS(col, row)] ==
backbuf[BB_POS(col, row + 1)])
continue;
if (row < rows - 1) {
if (backbuf[BB_POS(col, row)] ==
backbuf[BB_POS(col, row + 1)])
continue;
glyph = backbuf[BB_POS(col, row + 1)];
} else
glyph = 0;
memcpy(&fb_addr[FB_POS(x, y + yd)],
&glyphs[GLYPH_POS(glyph, yd)],
glyphscanline);
}
glyph = backbuf[BB_POS(col, row + 1)];
} else
glyph = 0;
memcpy(&fb_addr[FB_POS(x, y + yd)],
&glyphs[GLYPH_POS(glyph, yd)],
glyphscanline);
}
}
}
264,15 → 259,15
}
 
 
static void cursor_put(bool silent)
static void cursor_put(void)
{
glyph_draw(CURSOR, position % cols, position / cols, silent);
glyph_draw(CURSOR, position % cols, position / cols);
}
 
 
static void cursor_remove(bool silent)
static void cursor_remove(void)
{
glyph_draw(0, position % cols, position / cols, silent);
glyph_draw(0, position % cols, position / cols);
}
 
 
281,45 → 276,44
* Emulate basic terminal commands.
*
*/
static void fb_putchar(chardev_t *dev, char ch, bool silent)
static void fb_putchar(chardev_t *dev, char ch)
{
spinlock_lock(&fb_lock);
switch (ch) {
case '\n':
cursor_remove(silent);
cursor_remove();
position += cols;
position -= position % cols;
break;
case '\r':
cursor_remove(silent);
cursor_remove();
position -= position % cols;
break;
case '\b':
cursor_remove(silent);
cursor_remove();
if (position % cols)
position--;
break;
case '\t':
cursor_remove(silent);
cursor_remove();
do {
glyph_draw((uint8_t) ' ', position % cols,
position / cols, silent);
position / cols);
position++;
} while ((position % 8) && (position < cols * rows));
break;
default:
glyph_draw((uint8_t) ch, position % cols,
position / cols, silent);
glyph_draw((uint8_t) ch, position % cols, position / cols);
position++;
}
if (position >= cols * rows) {
position -= cols;
screen_scroll(silent);
screen_scroll();
}
cursor_put(silent);
cursor_put();
spinlock_unlock(&fb_lock);
}
/trunk/kernel/genarch/src/drivers/ega/ega.c
62,8 → 62,54
static uint8_t *backbuf;
static ioport_t ega_base;
 
static void ega_putchar(chardev_t *d, const char ch);
 
chardev_t ega_console;
static chardev_operations_t ega_ops = {
.write = ega_putchar
};
 
static void ega_move_cursor(void);
 
void ega_init(ioport_t base, uintptr_t videoram_phys)
{
/* Initialize the software structure. */
ega_base = base;
 
backbuf = (uint8_t *) malloc(SCREEN * 2, 0);
if (!backbuf)
panic("Unable to allocate backbuffer.");
videoram = (uint8_t *) hw_map(videoram_phys, SCREEN * 2);
/* Clear the screen and set the cursor position. */
memsetw(videoram, SCREEN, 0x0720);
memsetw(backbuf, SCREEN, 0x0720);
ega_move_cursor();
 
chardev_initialize("ega_out", &ega_console, &ega_ops);
stdout = &ega_console;
ega_parea.pbase = videoram_phys;
ega_parea.vbase = (uintptr_t) videoram;
ega_parea.frames = 1;
ega_parea.cacheable = false;
ddi_parea_register(&ega_parea);
 
sysinfo_set_item_val("fb", NULL, true);
sysinfo_set_item_val("fb.kind", NULL, 2);
sysinfo_set_item_val("fb.width", NULL, ROW);
sysinfo_set_item_val("fb.height", NULL, ROWS);
sysinfo_set_item_val("fb.blinking", NULL, true);
sysinfo_set_item_val("fb.address.physical", NULL, videoram_phys);
}
 
static void ega_display_char(char ch)
{
videoram[ega_cursor * 2] = ch;
backbuf[ega_cursor * 2] = ch;
}
 
/*
* This function takes care of scrolling.
*/
81,29 → 127,13
ega_cursor = ega_cursor - ROW;
}
 
static void ega_move_cursor(void)
void ega_putchar(chardev_t *d __attribute__((unused)), const char ch)
{
outb(ega_base + EGA_INDEX_REG, 0xe);
outb(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff));
outb(ega_base + EGA_INDEX_REG, 0xf);
outb(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));
}
ipl_t ipl;
 
static void ega_display_char(char ch, bool silent)
{
backbuf[ega_cursor * 2] = ch;
if (!silent)
videoram[ega_cursor * 2] = ch;
}
 
static void ega_putchar(chardev_t *d __attribute__((unused)), const char ch, bool silent)
{
ipl_t ipl;
ipl = interrupts_disable();
spinlock_lock(&egalock);
 
switch (ch) {
case '\n':
ega_cursor = (ega_cursor + ROW) - ega_cursor % ROW;
116,54 → 146,23
ega_cursor--;
break;
default:
ega_display_char(ch, silent);
ega_display_char(ch);
ega_cursor++;
break;
}
ega_check_cursor();
if (!silent)
ega_move_cursor();
ega_move_cursor();
 
spinlock_unlock(&egalock);
interrupts_restore(ipl);
}
 
static chardev_operations_t ega_ops = {
.write = ega_putchar
};
 
void ega_init(ioport_t base, uintptr_t videoram_phys)
void ega_move_cursor(void)
{
/* Initialize the software structure. */
ega_base = base;
backbuf = (uint8_t *) malloc(SCREEN * 2, 0);
if (!backbuf)
panic("Unable to allocate backbuffer.");
videoram = (uint8_t *) hw_map(videoram_phys, SCREEN * 2);
/* Clear the screen and set the cursor position. */
memsetw(videoram, SCREEN, 0x0720);
memsetw(backbuf, SCREEN, 0x0720);
ega_move_cursor();
chardev_initialize("ega_out", &ega_console, &ega_ops);
stdout = &ega_console;
ega_parea.pbase = videoram_phys;
ega_parea.vbase = (uintptr_t) videoram;
ega_parea.frames = 1;
ega_parea.cacheable = false;
ddi_parea_register(&ega_parea);
sysinfo_set_item_val("fb", NULL, true);
sysinfo_set_item_val("fb.kind", NULL, 2);
sysinfo_set_item_val("fb.width", NULL, ROW);
sysinfo_set_item_val("fb.height", NULL, ROWS);
sysinfo_set_item_val("fb.blinking", NULL, true);
sysinfo_set_item_val("fb.address.physical", NULL, videoram_phys);
outb(ega_base + EGA_INDEX_REG, 0xe);
outb(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff));
outb(ega_base + EGA_INDEX_REG, 0xf);
outb(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));
}
 
void ega_redraw(void)