Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1874 → Rev 1875

/trunk/kernel/genarch/include/kbd/z8530.h
37,8 → 37,12
#ifndef KERN_Z8530_H_
#define KERN_Z8530_H_
 
#include <typedefs.h>
 
#define Z8530_INTRCV_DATA0 0x39 /* hardcoded for use in Simics */
 
extern bool z8530_belongs_to_kernel;
 
extern void z8530_init(void);
extern void z8530_poll(void);
extern void z8530_grab(void);
/trunk/kernel/genarch/src/kbd/key.c
67,11 → 67,11
{
spinlock_lock(&keylock);
switch (sc) {
case SC_LSHIFT:
case SC_RSHIFT:
case SC_LSHIFT:
case SC_RSHIFT:
keyflags &= ~PRESSED_SHIFT;
break;
case SC_CAPSLOCK:
case SC_CAPSLOCK:
keyflags &= ~PRESSED_CAPSLOCK;
if (lockflags & LOCKED_CAPSLOCK)
lockflags &= ~LOCKED_CAPSLOCK;
78,7 → 78,7
else
lockflags |= LOCKED_CAPSLOCK;
break;
default:
default:
break;
}
spinlock_unlock(&keylock);
/trunk/kernel/genarch/src/kbd/z8530.c
41,6 → 41,7
#include <arch/drivers/fhc.h>
#include <arch/drivers/z8530.h>
#include <arch/interrupt.h>
#include <arch/drivers/kbd.h>
#include <cpu.h>
#include <arch/asm.h>
#include <arch.h>
48,6 → 49,8
#include <console/chardev.h>
#include <console/console.h>
#include <interrupt.h>
#include <sysinfo/sysinfo.h>
#include <print.h>
 
/*
* These codes read from z8530 data register are silently ignored.
54,6 → 57,8
*/
#define IGNORE_CODE 0x7f /* all keys up */
 
bool z8530_belongs_to_kernel = true;
 
static void z8530_suspend(chardev_t *);
static void z8530_resume(chardev_t *);
 
69,11 → 74,13
/** Initialize keyboard and service interrupts using kernel routine */
void z8530_grab(void)
{
z8530_belongs_to_kernel = true;
}
 
/** Resume the former interrupt vector */
void z8530_release(void)
{
z8530_belongs_to_kernel = false;
}
 
/** Initialize z8530. */
82,14 → 89,24
chardev_initialize("z8530_kbd", &kbrd, &ops);
stdin = &kbrd;
 
sysinfo_set_item_val("kbd", NULL, true);
sysinfo_set_item_val("kbd.irq", NULL, 0);
sysinfo_set_item_val("kbd.address.virtual", NULL, (uintptr_t) kbd_virt_address);
 
(void) z8530_read_a(RR8);
 
z8530_write_a(WR1, WR1_IARCSC); /* interrupt on all characters */
/*
* Clear any pending TX interrupts or we never manage
* to set FHC UART interrupt state to idle.
*/
z8530_write_a(WR0, WR0_TX_IP_RST);
 
z8530_write_a(WR1, WR1_IARCSC); /* interrupt on all characters */
 
/* 8 bits per character and enable receiver */
z8530_write_a(WR3, WR3_RX8BITSCH | WR3_RX_ENABLE);
z8530_write_a(WR9, WR9_MIE); /* Master Interrupt Enable. */
z8530_write_a(WR9, WR9_MIE); /* Master Interrupt Enable. */
/*
* We need to initialize the FireHose Controller,
/trunk/kernel/genarch/src/fb/fb.c
60,12 → 60,16
static unsigned int scanline = 0;
static unsigned int bitspp = 0;
static unsigned int pixelbytes = 0;
#ifdef FB_INVERT_COLORS
static bool invert_colors = true;
#else
static bool invert_colors = false;
#endif
 
static unsigned int position = 0;
static unsigned int columns = 0;
static unsigned int rows = 0;
 
 
#define COL_WIDTH 8
#define ROW_BYTES (scanline * FONT_SCANLINES)
 
85,6 → 89,11
static void (*rgb2scr)(void *, int);
static int (*scr2rgb)(void *);
 
static inline int COLOR(int color)
{
return invert_colors ? ~color : color;
}
 
/* Conversion routines between different color representations */
static void rgb_4byte(void *dst, int rgb)
{
159,11 → 168,11
 
static void putpixel(unsigned int x, unsigned int y, int color)
{
(*rgb2scr)(&fbaddress[POINTPOS(x,y)],color);
(*rgb2scr)(&fbaddress[POINTPOS(x,y)], COLOR(color));
 
if (dbbuffer) {
int dline = (y + dboffset) % yres;
(*rgb2scr)(&dbbuffer[POINTPOS(x,dline)],color);
(*rgb2scr)(&dbbuffer[POINTPOS(x,dline)], COLOR(color));
}
}
 
172,9 → 181,9
{
if (dbbuffer) {
int dline = (y + dboffset) % yres;
return (*scr2rgb)(&dbbuffer[POINTPOS(x,dline)]);
return COLOR((*scr2rgb)(&dbbuffer[POINTPOS(x,dline)]));
}
return (*scr2rgb)(&fbaddress[POINTPOS(x,y)]);
return COLOR((*scr2rgb)(&fbaddress[POINTPOS(x,y)]));
}
 
 
274,7 → 283,7
byte = helenos_bits[rowbytes * y + x / 8];
byte >>= x % 8;
if (byte & 1)
putpixel(startx + x, starty + y, LOGOCOLOR);
putpixel(startx + x, starty + y, COLOR(LOGOCOLOR));
}
}
 
397,6 → 406,7
sysinfo_set_item_val("fb.bpp-align", NULL, align);
sysinfo_set_item_val("fb.scanline", NULL, scan);
sysinfo_set_item_val("fb.address.physical", NULL, addr);
sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
 
/* Allocate double buffer */
int totsize = scanline * yres;
416,9 → 426,11
blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC);
if (!blankline)
panic("Failed to allocate blank line for framebuffer.");
for (y=0; y < FONT_SCANLINES; y++)
for (x=0; x < xres; x++)
(*rgb2scr)(&blankline[POINTPOS(x,y)],BGCOLOR);
for (y=0; y < FONT_SCANLINES; y++) {
for (x=0; x < xres; x++) {
(*rgb2scr)(&blankline[POINTPOS(x,y)], COLOR(BGCOLOR));
}
}
 
clear_screen();
 
/trunk/kernel/generic/src/ipc/sysipc.c
47,6 → 47,7
#include <syscall/copy.h>
#include <security/cap.h>
#include <mm/as.h>
#include <print.h>
 
#define GET_CHECK_PHONE(phone,phoneid,err) { \
if (phoneid > IPC_MAX_PHONES) { err; } \
/trunk/kernel/generic/src/ipc/irq.c
55,6 → 55,7
#include <atomic.h>
#include <syscall/copy.h>
#include <console/console.h>
#include <print.h>
 
typedef struct {
SPINLOCK_DECLARE(lock);
67,7 → 68,7
static ipc_irq_t *irq_conns = NULL;
static int irq_conns_size;
 
#include <print.h>
 
/* Execute code associated with IRQ notification */
static void code_execute(call_t *call, irq_code_t *code)
{
/trunk/kernel/arch/sparc64/include/drivers/z8530.h
71,6 → 71,7
#define RR15 15
 
/* Write Register 0 */
#define WR0_TX_IP_RST (0x5<<3) /** Reset pending TX interrupt. */
#define WR0_ERR_RST (0x6<<3)
 
/* Write Register 1 */
/trunk/kernel/arch/sparc64/Makefile.inc
76,6 → 76,8
DEFS += -DCONFIG_NS16550
DEFS += -DKBD_ADDR_OVRD=0x1fff13083f8ULL
DEFS += -DFB_INVERT_COLORS
endif
 
 
/trunk/kernel/arch/sparc64/src/console.c
93,5 → 93,24
}
}
 
/** Acquire console back for kernel
*
*/
void arch_grab_console(void)
{
#ifdef CONFIG_Z8530
z8530_grab();
#endif
}
 
/** Return console to userspace
*
*/
void arch_release_console(void)
{
#ifdef CONFIG_Z8530
z8530_release();
#endif
}
/** @}
*/
/trunk/kernel/arch/sparc64/src/sparc64.c
93,19 → 93,6
{
}
 
/** Acquire console back for kernel
*
*/
void arch_grab_console(void)
{
}
/** Return console to userspace
*
*/
void arch_release_console(void)
{
}
 
/** Switch to userspace. */
void userspace(uspace_arg_t *kernel_uarg)
{
/trunk/kernel/arch/sparc64/src/trap/interrupt.c
42,7 → 42,7
#include <ipc/sysipc.h>
#include <arch/asm.h>
#include <arch/barrier.h>
 
#include <print.h>
#include <genarch/kbd/z8530.h>
 
/** Register Interrupt Level Handler.
61,7 → 61,9
/* Reregister irq to be IPC-ready */
void irq_ipc_bind_arch(unative_t irq)
{
/* TODO */
#ifdef CONFIG_Z8530
z8530_belongs_to_kernel = false;
#endif
}
 
void interrupt(int n, istate_t *istate)
82,9 → 84,14
* we cannot handle it by scheduling one of the level
* interrupt traps. Call the interrupt handler directly.
*/
 
if (z8530_belongs_to_kernel)
z8530_interrupt();
else
ipc_irq_send_notif(0);
fhc_uart_reset();
z8530_interrupt();
break;
 
#endif
}
 
/trunk/kernel/arch/sparc64/src/drivers/fhc.c
57,17 → 57,12
{
fhc = (void *) hw_map(FHC_UART_ADDR, PAGE_SIZE);
 
(void) fhc[FHC_UART_ICLR];
fhc[FHC_UART_ICLR] = 0;
(void) fhc[FHC_UART_IMAP];
fhc[FHC_UART_IMAP] = Z8530_INTRCV_DATA0; /* hardcoded for Simics simulation */
(void) fhc[FHC_UART_IMAP];
fhc[FHC_UART_IMAP] = 0x80000000; /* hardcoded for Simics simulation */
fhc[FHC_UART_IMAP] = 0x80000000;
}
 
void fhc_uart_reset(void)
{
(void) fhc[FHC_UART_ICLR];
fhc[FHC_UART_ICLR] = 0;
}
 
/trunk/uspace/fb/fb.c
70,12 → 70,13
typedef int (*conv2rgb_fn_t)(void *);
 
struct {
uint8_t *fbaddress ;
uint8_t *fbaddress;
 
unsigned int xres ;
unsigned int yres ;
unsigned int scanline ;
unsigned int pixelbytes ;
unsigned int xres;
unsigned int yres;
unsigned int scanline;
unsigned int pixelbytes;
unsigned int invert_colors;
 
conv2scr_fn_t rgb2scr;
conv2rgb_fn_t scr2rgb;
140,6 → 141,11
 
#define POINTPOS(x, y) ((y) * screen.scanline + (x) * screen.pixelbytes)
 
static inline int COLOR(int color)
{
return screen.invert_colors ? ~color : color;
}
 
/* Conversion routines between different color representations */
static void rgb_4byte(void *dst, int rgb)
{
163,8 → 169,6
scr[1] = GREEN(rgb, 8);
scr[0] = BLUE(rgb, 8);
#endif
 
 
}
 
static int byte3_rgb(void *src)
217,12 → 221,12
int dy = vport->y + y;
 
if (! (vport->paused && vport->dbdata))
(*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],color);
(*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)], COLOR(color));
 
if (vport->dbdata) {
int dline = (y + vport->dboffset) % vport->height;
int doffset = screen.pixelbytes * (dline * vport->width + x);
(*screen.rgb2scr)(&vport->dbdata[doffset],color);
(*screen.rgb2scr)(&vport->dbdata[doffset], COLOR(color));
}
}
 
232,13 → 236,13
int dx = vport->x + x;
int dy = vport->y + y;
 
return (*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]);
return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]));
}
 
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y,
int color)
{
(*screen.rgb2scr)(&mem[POINTPOS(x,y)],color);
(*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
}
 
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
454,10 → 458,12
* @param bpp Bits per pixel (8, 16, 24, 32)
* @param scan Bytes per one scanline
* @param align Alignment for 24bpp mode.
* @param invert_colors Inverted colors.
*
*/
static void
screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan, int align)
screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan,
int align, int invert_colors)
{
switch (bpp) {
case 8:
490,6 → 496,7
screen.xres = xres;
screen.yres = yres;
screen.scanline = scan;
screen.invert_colors = invert_colors;
/* Create first viewport */
viewport_create(0,0,xres,yres);
593,7 → 600,7
pixmap_t *pmap = &pixmaps[pm];
int pos = (y * pmap->width + x) * screen.pixelbytes;
 
(*screen.rgb2scr)(&pmap->data[pos],color);
(*screen.rgb2scr)(&pmap->data[pos],COLOR(color));
}
 
/** Create a new pixmap and return appropriate ID */
1223,6 → 1230,7
unsigned int fb_bpp;
unsigned int fb_bpp_align;
unsigned int fb_scanline;
unsigned int fb_invert_colors;
void *fb_addr;
size_t asz;
 
1234,6 → 1242,7
fb_bpp=sysinfo_value("fb.bpp");
fb_bpp_align=sysinfo_value("fb.bpp-align");
fb_scanline=sysinfo_value("fb.scanline");
fb_invert_colors=sysinfo_value("fb.invert-colors");
 
asz = fb_scanline*fb_height;
fb_addr = as_get_mappable_page(asz);
1241,7 → 1250,7
map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz,PAGE_SIZE) >>PAGE_WIDTH,
AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, fb_bpp_align);
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, fb_bpp_align, fb_invert_colors);
 
return 0;
}