/branches/dynload/contrib/conf/msim.conf |
---|
3,7 → 3,6 |
# |
add dcpu cpu0 |
add dcpu cpu1 |
add rwm mainmem 0x00000000 |
mainmem generic 16M |
11,7 → 10,7 |
add rom bootmem 0x1fc00000 |
bootmem generic 4096k |
bootmem load "image.boot" |
bootmem load "image.boot" |
add dprinter printer 0x10000000 |
add dkeyboard keyboard 0x10000000 2 |
/branches/dynload/kernel/test/fpu/fpu1_ia64.c |
---|
File deleted |
/branches/dynload/kernel/test/fpu/fpu1_x86.c |
---|
File deleted |
/branches/dynload/kernel/test/fpu/fpu1.c |
---|
0,0 → 1,226 |
/* |
* Copyright (c) 2005 Jakub Vana |
* Copyright (c) 2005 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <print.h> |
#include <debug.h> |
#include <test.h> |
#include <atomic.h> |
#include <proc/thread.h> |
#include <arch.h> |
#include <arch/arch.h> |
#define THREADS 150 |
#define ATTEMPTS 100 |
#define E_10e8 271828182 |
#define PI_10e8 314159265 |
#ifdef KERN_ia32_ARCH_H_ |
static inline double sqrt(double x) |
{ |
double v; |
asm ( |
"fsqrt\n" |
: "=t" (v) |
: "0" (x) |
); |
return v; |
} |
#endif |
#ifdef KERN_amd64_ARCH_H_ |
static inline double sqrt(double x) |
{ |
double v; |
asm ( |
"fsqrt\n" |
: "=t" (v) |
: "0" (x) |
); |
return v; |
} |
#endif |
#ifdef KERN_ia64_ARCH_H_ |
#undef PI_10e8 |
#define PI_10e8 3141592 |
static inline long double sqrt(long double a) |
{ |
long double x = 1; |
long double lx = 0; |
if (a < 0.00000000000000001) |
return 0; |
while(x != lx) { |
lx = x; |
x = (x + (a / x)) / 2; |
} |
return x; |
} |
#endif |
static atomic_t threads_ok; |
static atomic_t threads_fault; |
static waitq_t can_start; |
static bool sh_quiet; |
static void e(void *data) |
{ |
int i; |
double e, d, le, f; |
thread_detach(THREAD); |
waitq_sleep(&can_start); |
for (i = 0; i<ATTEMPTS; i++) { |
le = -1; |
e = 0; |
f = 1; |
for (d = 1; e != le; d *= f, f += 1) { |
le = e; |
e = e + 1 / d; |
} |
if ((int) (100000000 * e) != E_10e8) { |
if (!sh_quiet) |
printf("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8); |
atomic_inc(&threads_fault); |
break; |
} |
} |
atomic_inc(&threads_ok); |
} |
static void pi(void *data) |
{ |
int i; |
double lpi, pi; |
double n, ab, ad; |
thread_detach(THREAD); |
waitq_sleep(&can_start); |
for (i = 0; i < ATTEMPTS; i++) { |
lpi = -1; |
pi = 0; |
for (n = 2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) { |
double sc, cd; |
sc = sqrt(1 - (ab * ab / 4)); |
cd = 1 - sc; |
ad = sqrt(ab * ab / 4 + cd * cd); |
lpi = pi; |
pi = 2 * n * ad; |
} |
#ifdef KERN_ia64_ARCH_H_ |
if ((int) (1000000 * pi) != PI_10e8) { |
if (!sh_quiet) |
printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100)); |
atomic_inc(&threads_fault); |
break; |
} |
#else |
if ((int) (100000000 * pi) != PI_10e8) { |
if (!sh_quiet) |
printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8); |
atomic_inc(&threads_fault); |
break; |
} |
#endif |
} |
atomic_inc(&threads_ok); |
} |
char * test_fpu1(bool quiet) |
{ |
unsigned int i, total = 0; |
sh_quiet = quiet; |
waitq_initialize(&can_start); |
atomic_set(&threads_ok, 0); |
atomic_set(&threads_fault, 0); |
if (!quiet) |
printf("Creating %u threads... ", 2 * THREADS); |
for (i = 0; i < THREADS; i++) { |
thread_t *t; |
if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) { |
if (!quiet) |
printf("could not create thread %u\n", 2 * i); |
break; |
} |
thread_ready(t); |
total++; |
if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) { |
if (!quiet) |
printf("could not create thread %u\n", 2 * i + 1); |
break; |
} |
thread_ready(t); |
total++; |
} |
if (!quiet) |
printf("ok\n"); |
thread_sleep(1); |
waitq_wakeup(&can_start, WAKEUP_ALL); |
while (atomic_get(&threads_ok) != (long) total) { |
if (!quiet) |
printf("Threads left: %d\n", total - atomic_get(&threads_ok)); |
thread_sleep(1); |
} |
if (atomic_get(&threads_fault) == 0) |
return NULL; |
return "Test failed"; |
} |
/branches/dynload/kernel/test/debug/mips1_skip.c |
---|
File deleted |
/branches/dynload/kernel/test/debug/mips1.c |
---|
25,6 → 25,8 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifdef mips32 |
#include <print.h> |
#include <debug.h> |
47,3 → 49,5 |
return "Back from debug mode"; |
} |
#endif |
/branches/dynload/kernel/test/debug/mips1.def |
---|
1,3 → 1,4 |
#ifdef mips32 |
{ |
"mips1", |
"MIPS debug test", |
4,3 → 5,4 |
&test_mips1, |
false |
}, |
#endif |
/branches/dynload/kernel/test/mm/purge1_skip.c |
---|
File deleted |
/branches/dynload/kernel/test/mm/purge1.c |
---|
26,6 → 26,8 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifdef ia64 |
#include <print.h> |
#include <test.h> |
#include <mm/page.h> |
45,10 → 47,10 |
tlb_entry_t entryd; |
int i; |
entryd.word[0] = 0; |
entryd.word[1] = 0; |
entryd.p = true; /* present */ |
entryd.ma = MA_WRITEBACK; |
entryd.a = true; /* already accessed */ |
75,9 → 77,11 |
dtc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 9, entryd); |
} |
tlb_invalidate_pages(8, 0x0c000, 14); |
tlb_invalidate_pages(8,0x0c000,14); |
/* tlb_invalidate_all(); */ |
/*tlb_invalidate_all();*/ |
return NULL; |
} |
#endif |
/branches/dynload/kernel/test/mm/purge1.def |
---|
1,3 → 1,4 |
#ifdef ia64 |
{ |
"purge1", |
"Itanium TLB purge test", |
4,3 → 5,4 |
&test_purge1, |
true |
}, |
#endif |
/branches/dynload/kernel/genarch/include/kbd/z8530.h |
---|
49,8 → 49,8 |
extern void z8530_release(void); |
extern void z8530_interrupt(void); |
extern char z8530_key_read(chardev_t *); |
extern irq_ownership_t z8530_claim(void *); |
extern void z8530_irq_handler(irq_t *); |
extern irq_ownership_t z8530_claim(void); |
extern void z8530_irq_handler(irq_t *, void *, ...); |
#endif |
/branches/dynload/kernel/genarch/include/kbd/ns16550.h |
---|
37,7 → 37,7 |
#ifndef KERN_NS16550_H_ |
#define KERN_NS16550_H_ |
#include <console/chardev.h> |
#include <console/chardev.h> |
#include <ddi/irq.h> |
#include <ipc/irq.h> |
46,12 → 46,13 |
extern void ns16550_grab(void); |
extern void ns16550_release(void); |
extern char ns16550_key_read(chardev_t *); |
extern irq_ownership_t ns16550_claim(void *); |
extern void ns16550_irq_handler(irq_t *); |
extern irq_ownership_t ns16550_claim(void); |
extern void ns16550_irq_handler(irq_t *, void *, ...); |
#include <arch/types.h> |
#ifndef ia64 |
#include <arch/drivers/kbd.h> |
#endif |
/* NS16550 registers */ |
#define RBR_REG 0 /** Receiver Buffer Register. */ |
#define IER_REG 1 /** Interrupt Enable Register. */ |
76,56 → 77,56 |
static inline uint8_t ns16550_rbr_read(ns16550_t *dev) |
{ |
return pio_read_8(dev->io_port + RBR_REG); |
return inb(dev->io_port + RBR_REG); |
} |
static inline void ns16550_rbr_write(ns16550_t *dev, uint8_t v) |
{ |
pio_write_8(dev->io_port + RBR_REG, v); |
outb(dev->io_port + RBR_REG, v); |
} |
static inline uint8_t ns16550_ier_read(ns16550_t *dev) |
{ |
return pio_read_8(dev->io_port + IER_REG); |
return inb(dev->io_port + IER_REG); |
} |
static inline void ns16550_ier_write(ns16550_t *dev, uint8_t v) |
{ |
pio_write_8(dev->io_port + IER_REG, v); |
outb(dev->io_port + IER_REG, v); |
} |
static inline uint8_t ns16550_iir_read(ns16550_t *dev) |
{ |
return pio_read_8(dev->io_port + IIR_REG); |
return inb(dev->io_port + IIR_REG); |
} |
static inline void ns16550_fcr_write(ns16550_t *dev, uint8_t v) |
{ |
pio_write_8(dev->io_port + FCR_REG, v); |
outb(dev->io_port + FCR_REG, v); |
} |
static inline uint8_t ns16550_lcr_read(ns16550_t *dev) |
{ |
return pio_read_8(dev->io_port + LCR_REG); |
return inb(dev->io_port + LCR_REG); |
} |
static inline void ns16550_lcr_write(ns16550_t *dev, uint8_t v) |
{ |
pio_write_8(dev->io_port + LCR_REG, v); |
outb(dev->io_port + LCR_REG, v); |
} |
static inline uint8_t ns16550_lsr_read(ns16550_t *dev) |
{ |
return pio_read_8(dev->io_port + LSR_REG); |
return inb(dev->io_port + LSR_REG); |
} |
static inline uint8_t ns16550_mcr_read(ns16550_t *dev) |
{ |
return pio_read_8(dev->io_port + MCR_REG); |
return inb(dev->io_port + MCR_REG); |
} |
static inline void ns16550_mcr_write(ns16550_t *dev, uint8_t v) |
{ |
pio_write_8(dev->io_port + MCR_REG, v); |
outb(dev->io_port + MCR_REG, v); |
} |
#endif |
/branches/dynload/kernel/genarch/src/kbd/ns16550.c |
---|
138,9 → 138,11 |
sysinfo_set_item_val("kbd.address.virtual", NULL, port); |
sysinfo_set_item_val("kbd.port", NULL, port); |
#ifdef CONFIG_NS16550_INTERRUPT_DRIVEN |
/* Enable interrupts */ |
ns16550_ier_write(&ns16550, IER_ERBFI); |
ns16550_mcr_write(&ns16550, MCR_OUT2); |
#endif |
uint8_t c; |
// This switches rbr & ier to mode when accept baudrate constant |
196,6 → 198,28 |
*/ |
void ns16550_poll(void) |
{ |
#ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
ipl_t ipl; |
ipl = interrupts_disable(); |
spinlock_lock(&ns16550_irq.lock); |
if (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
if (ns16550_irq.notif_cfg.notify && ns16550_irq.notif_cfg.answerbox) { |
/* |
* Send IPC notification. |
*/ |
ipc_irq_send_notif(&ns16550_irq); |
spinlock_unlock(&ns16550_irq.lock); |
interrupts_restore(ipl); |
return; |
} |
} |
spinlock_unlock(&ns16550_irq.lock); |
interrupts_restore(ipl); |
#endif |
while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
uint8_t x; |
210,12 → 234,12 |
} |
} |
irq_ownership_t ns16550_claim(void *instance) |
irq_ownership_t ns16550_claim(void) |
{ |
return (ns16550_lsr_read(&ns16550) & LSR_DATA_READY); |
} |
void ns16550_irq_handler(irq_t *irq) |
void ns16550_irq_handler(irq_t *irq, void *arg, ...) |
{ |
if (irq->notif_cfg.notify && irq->notif_cfg.answerbox) |
ipc_irq_send_notif(irq); |
/branches/dynload/kernel/genarch/src/kbd/i8042.c |
---|
123,12 → 123,12 |
interrupts_restore(ipl); |
} |
static irq_ownership_t i8042_claim(void *instance) |
static irq_ownership_t i8042_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
static void i8042_irq_handler(irq_t *irq) |
static void i8042_irq_handler(irq_t *irq, void *arg, ...) |
{ |
if (irq->notif_cfg.notify && irq->notif_cfg.answerbox) |
ipc_irq_send_notif(irq); |
/branches/dynload/kernel/genarch/src/kbd/z8530.c |
---|
194,12 → 194,12 |
} |
} |
irq_ownership_t z8530_claim(void *instance) |
irq_ownership_t z8530_claim(void) |
{ |
return (z8530_read_a(&z8530, RR0) & RR0_RCA); |
} |
void z8530_irq_handler(irq_t *irq) |
void z8530_irq_handler(irq_t *irq, void *arg, ...) |
{ |
if (irq->notif_cfg.notify && irq->notif_cfg.answerbox) |
ipc_irq_send_notif(irq); |
/branches/dynload/kernel/genarch/src/fb/fb.c |
---|
52,6 → 52,9 |
SPINLOCK_INITIALIZE(fb_lock); |
/**< Physical memory area for fb. */ |
static parea_t fb_parea; |
static uint8_t *fb_addr; |
static uint8_t *backbuf; |
static uint8_t *glyphs; |
516,6 → 519,12 |
fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize); |
fb_parea.pbase = (uintptr_t) props->addr + props->offset; |
fb_parea.vbase = (uintptr_t) fb_addr; |
fb_parea.frames = SIZE2FRAMES(fbsize); |
fb_parea.cacheable = false; |
ddi_parea_register(&fb_parea); |
sysinfo_set_item_val("fb", NULL, true); |
sysinfo_set_item_val("fb.kind", NULL, 1); |
sysinfo_set_item_val("fb.width", NULL, xres); |
/branches/dynload/kernel/genarch/src/drivers/ega/ega.c |
---|
54,6 → 54,8 |
* Simple and short. Function for displaying characters and "scrolling". |
*/ |
static parea_t ega_parea; /**< Physical memory area for EGA video RAM. */ |
SPINLOCK_INITIALIZE(egalock); |
static uint32_t ega_cursor; |
static uint8_t *videoram; |
81,10 → 83,10 |
static void ega_move_cursor(void) |
{ |
pio_write_8(ega_base + EGA_INDEX_REG, 0xe); |
pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff)); |
pio_write_8(ega_base + EGA_INDEX_REG, 0xf); |
pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff)); |
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)); |
} |
static void ega_display_char(char ch, bool silent) |
150,6 → 152,12 |
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); |
/branches/dynload/kernel/generic/include/ddi/irq.h |
---|
79,10 → 79,10 |
} irq_trigger_t; |
struct irq; |
typedef void (* irq_handler_t)(struct irq *); |
typedef void (* irq_handler_t)(struct irq *irq, void *arg, ...); |
/** Type for function used to clear the interrupt. */ |
typedef void (* cir_t)(void *, inr_t); |
typedef void (* cir_t)(void *arg, inr_t inr); |
/** IPC notification config structure. |
* |
139,11 → 139,11 |
/** Trigger level of the IRQ. */ |
irq_trigger_t trigger; |
/** Claim ownership of the IRQ. */ |
irq_ownership_t (* claim)(void *); |
irq_ownership_t (* claim)(void); |
/** Handler for this IRQ and device. */ |
irq_handler_t handler; |
/** Instance argument for the handler and the claim function. */ |
void *instance; |
/** Argument for the handler. */ |
void *arg; |
/** Clear interrupt routine. */ |
cir_t cir; |
154,11 → 154,11 |
ipc_notif_cfg_t notif_cfg; |
} irq_t; |
extern void irq_init(count_t, count_t); |
extern void irq_initialize(irq_t *); |
extern void irq_register(irq_t *); |
extern irq_t *irq_dispatch_and_lock(inr_t); |
extern irq_t *irq_find_and_lock(inr_t, devno_t); |
extern void irq_init(count_t inrs, count_t chains); |
extern void irq_initialize(irq_t *irq); |
extern void irq_register(irq_t *irq); |
extern irq_t *irq_dispatch_and_lock(inr_t inr); |
extern irq_t *irq_find_and_lock(inr_t inr, devno_t devno); |
#endif |
/branches/dynload/kernel/generic/include/ddi/ddi.h |
---|
38,14 → 38,13 |
#include <ddi/ddi_arg.h> |
#include <arch/types.h> |
#include <proc/task.h> |
#include <adt/list.h> |
/** Structure representing contiguous physical memory area. */ |
typedef struct { |
uintptr_t pbase; /**< Physical base of the area. */ |
pfn_t frames; /**< Number of frames in the area. */ |
link_t link; /**< Linked list link */ |
uintptr_t pbase; /**< Physical base of the area. */ |
uintptr_t vbase; /**< Virtual base of the area. */ |
count_t frames; /**< Number of frames in the area. */ |
bool cacheable; /**< Cacheability. */ |
} parea_t; |
extern void ddi_init(void); |
/branches/dynload/kernel/generic/include/arch.h |
---|
63,11 → 63,12 |
as_t *as; /**< Current address space. */ |
} the_t; |
#define THE ((the_t * )(get_stack_base())) |
#define THE ((the_t *)(get_stack_base())) |
extern void the_initialize(the_t *the); |
extern void the_copy(the_t *src, the_t *dst); |
extern void arch_pre_main(void); |
extern void arch_pre_mm_init(void); |
extern void arch_post_mm_init(void); |
extern void arch_post_cpu_init(void); |
/branches/dynload/kernel/generic/include/macros.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup generic |
/** @addtogroup generic |
* @{ |
*/ |
/** @file |
37,47 → 37,44 |
#include <arch/types.h> |
#define isdigit(d) (((d) >= '0') && ((d) <= '9')) |
#define islower(c) (((c) >= 'a') && ((c) <= 'z')) |
#define isupper(c) (((c) >= 'A') && ((c) <= 'Z')) |
#define isalpha(c) (is_lower((c)) || is_upper((c))) |
#define isalphanum(c) (is_alpha((c)) || is_digit((c))) |
#define isspace(c) \ |
(((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r')) |
#define isdigit(d) (((d) >= '0') && ((d) <= '9')) |
#define islower(c) (((c) >= 'a') && ((c) <= 'z')) |
#define isupper(c) (((c) >= 'A') && ((c) <= 'Z')) |
#define isalpha(c) (is_lower((c)) || is_upper((c))) |
#define isalphanum(c) (is_alpha((c)) || is_digit((c))) |
#define isspace(c) (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || \ |
((c) == '\r')) |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
#define min3(a, b, c) ((a) < (b) ? (min(a, c)) : (min(b, c))) |
#define max3(a, b, c) ((a) > (b) ? (max(a, c)) : (max(b, c))) |
/** Return true if the intervals overlap. |
* |
* @param s1 Start address of the first interval. |
* @param sz1 Size of the first interval. |
* @param s2 Start address of the second interval. |
* @param sz2 Size of the second interval. |
* @param s1 Start address of the first interval. |
* @param sz1 Size of the first interval. |
* @param s2 Start address of the second interval. |
* @param sz2 Size of the second interval. |
*/ |
static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2, size_t sz2) |
{ |
uintptr_t e1 = s1 + sz1; |
uintptr_t e2 = s2 + sz2; |
return ((s1 < e2) && (s2 < e1)); |
return (s1 < e2) && (s2 < e1); |
} |
/* Compute overlapping of physical addresses */ |
#define PA_overlaps(x, szx, y, szy) \ |
#define PA_overlaps(x, szx, y, szy) \ |
overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy)) |
#define SIZE2KB(size) ((size) >> 10) |
#define SIZE2MB(size) ((size) >> 20) |
#define SIZE2KB(size) ((size) >> 10) |
#define SIZE2MB(size) ((size) >> 20) |
#define KB2SIZE(kb) ((kb) << 10) |
#define MB2SIZE(mb) ((mb) << 20) |
#define KB2SIZE(kb) ((kb) << 10) |
#define MB2SIZE(mb) ((mb) << 20) |
#define STRING(arg) STRING_ARG(arg) |
#define STRING_ARG(arg) #arg |
#define STRING(arg) STRING_ARG(arg) |
#define STRING_ARG(arg) #arg |
/** Pseudorandom generator |
* |
/branches/dynload/kernel/generic/include/proc/program.h |
---|
59,7 → 59,8 |
extern int program_create_loader(program_t *p, char *name); |
extern void program_ready(program_t *p); |
extern unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len); |
extern unative_t sys_program_spawn_loader(int *uspace_phone_id, |
char *uspace_name, size_t name_len); |
#endif |
/branches/dynload/kernel/generic/include/config.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup generic |
/** @addtogroup generic |
* @{ |
*/ |
/** @file |
38,9 → 38,9 |
#include <arch/types.h> |
#include <arch/mm/page.h> |
#define STACK_SIZE PAGE_SIZE |
#define STACK_SIZE PAGE_SIZE |
#define CONFIG_INIT_TASKS 32 |
#define CONFIG_INIT_TASKS 32 |
typedef struct { |
uintptr_t addr; |
63,14 → 63,14 |
} ballocs_t; |
typedef struct { |
count_t cpu_count; /**< Number of processors detected. */ |
volatile count_t cpu_active; /**< Number of processors that are up and running. */ |
count_t cpu_count; /**< Number of processors detected. */ |
volatile count_t cpu_active; /**< Number of processors that are up and running. */ |
uintptr_t base; |
size_t kernel_size; /**< Size of memory in bytes taken by kernel and stack */ |
size_t kernel_size; /**< Size of memory in bytes taken by kernel and stack */ |
uintptr_t stack_base; /**< Base adddress of initial stack */ |
size_t stack_size; /**< Size of initial stack */ |
uintptr_t stack_base; /**< Base adddress of initial stack */ |
size_t stack_size; /**< Size of initial stack */ |
} config_t; |
extern config_t config; |
/branches/dynload/kernel/generic/include/mm/page.h |
---|
42,7 → 42,7 |
/** Operations to manipulate page mappings. */ |
typedef struct { |
void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame, |
int flags); |
int flags); |
void (* mapping_remove)(as_t *as, uintptr_t page); |
pte_t *(* mapping_find)(as_t *as, uintptr_t page); |
} page_mapping_operations_t; |
59,9 → 59,7 |
extern pte_t *page_table_create(int flags); |
extern void page_table_destroy(pte_t *page_table); |
extern void map_structure(uintptr_t s, size_t size); |
extern uintptr_t hw_map(uintptr_t physaddr, size_t size); |
extern void hw_area(uintptr_t *physaddr, pfn_t *frames); |
#endif |
/branches/dynload/kernel/generic/src/console/cmd.c |
---|
529,7 → 529,7 |
spinlock_unlock(&hlp->lock); |
} |
spinlock_unlock(&cmd_lock); |
spinlock_unlock(&cmd_lock); |
return 1; |
} |
/branches/dynload/kernel/generic/src/console/console.c |
---|
101,7 → 101,7 |
* |
* @return Always returns IRQ_DECLINE. |
*/ |
static irq_ownership_t klog_claim(void *instance) |
static irq_ownership_t klog_claim(void) |
{ |
return IRQ_DECLINE; |
} |
126,7 → 126,9 |
devno_t devno = device_assign_devno(); |
klog_parea.pbase = (uintptr_t) faddr; |
klog_parea.vbase = (uintptr_t) klog; |
klog_parea.frames = SIZE2FRAMES(KLOG_SIZE); |
klog_parea.cacheable = true; |
ddi_parea_register(&klog_parea); |
sysinfo_set_item_val("klog.faddr", NULL, (unative_t) faddr); |
/branches/dynload/kernel/generic/src/console/kconsole.c |
---|
103,7 → 103,7 |
* @return Always returns IRQ_DECLINE. |
* |
*/ |
static irq_ownership_t kconsole_claim(void *instance) |
static irq_ownership_t kconsole_claim(void) |
{ |
return IRQ_DECLINE; |
} |
/branches/dynload/kernel/generic/src/proc/task.c |
---|
339,7 → 339,7 |
bool sleeping = false; |
thr = list_get_instance(cur, thread_t, th_link); |
spinlock_lock(&thr->lock); |
thr->interrupted = true; |
if (thr->state == Sleeping) |
/branches/dynload/kernel/generic/src/proc/program.c |
---|
184,20 → 184,32 |
/** Syscall for creating a new loader instance from userspace. |
* |
* Creates a new task from the program loader image and sets |
* the task name. |
* Creates a new task from the program loader image, connects a phone |
* to it and stores the phone id into the provided buffer. |
* |
* @param uspace_phone_id Userspace address where to store the phone id. |
* @param name Name to set on the new task (typically the same |
* as the command used to execute it). |
* |
* @return 0 on success or an error code from @ref errno.h. |
*/ |
unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len) |
unative_t sys_program_spawn_loader(int *uspace_phone_id, char *uspace_name, |
size_t name_len) |
{ |
program_t p; |
int fake_id; |
int rc; |
int phone_id; |
char namebuf[TASK_NAME_BUFLEN]; |
fake_id = 0; |
/* Before we even try creating the task, see if we can write the id */ |
rc = (unative_t) copy_to_uspace(uspace_phone_id, &fake_id, |
sizeof(fake_id)); |
if (rc != 0) |
return rc; |
/* Cap length of name and copy it from userspace. */ |
if (name_len > THREAD_NAME_BUFLEN - 1) |
209,6 → 221,12 |
namebuf[name_len] = '\0'; |
/* Allocate the phone for communicating with the new task. */ |
phone_id = phone_alloc(); |
if (phone_id < 0) |
return ELIMIT; |
/* Spawn the new task. */ |
rc = program_create_loader(&p, namebuf); |
215,6 → 233,18 |
if (rc != 0) |
return rc; |
phone_connect(phone_id, &p.task->answerbox); |
/* No need to aquire lock before task_ready() */ |
rc = (unative_t) copy_to_uspace(uspace_phone_id, &phone_id, |
sizeof(phone_id)); |
if (rc != 0) { |
/* Ooops */ |
ipc_phone_hangup(&TASK->phones[phone_id]); |
task_kill(p.task->taskid); |
return rc; |
} |
// FIXME: control the capabilities |
cap_set(p.task, cap_get(TASK)); |
/branches/dynload/kernel/generic/src/ipc/irq.c |
---|
101,10 → 101,10 |
code->cmds[i].value; |
break; |
case CMD_PORT_READ_1: |
dstval = pio_read_8((long) code->cmds[i].addr); |
dstval = inb((long) code->cmds[i].addr); |
break; |
case CMD_PORT_WRITE_1: |
pio_write_8((long) code->cmds[i].addr, code->cmds[i].value); |
outb((long) code->cmds[i].addr, code->cmds[i].value); |
break; |
default: |
break; |
/branches/dynload/kernel/generic/src/time/clock.c |
---|
88,7 → 88,9 |
uptime->useconds = 0; |
clock_parea.pbase = (uintptr_t) faddr; |
clock_parea.vbase = (uintptr_t) uptime; |
clock_parea.frames = 1; |
clock_parea.cacheable = true; |
ddi_parea_register(&clock_parea); |
/* |
/branches/dynload/kernel/generic/src/adt/avl.c |
---|
43,7 → 43,7 |
* |
* Every node has a pointer to its parent which allows insertion of multiple |
* identical keys into the tree. |
* |
* |
* Be careful when using this tree because of the base atribute which is added |
* to every inserted node key. There is no rule in which order nodes with the |
* same key are visited. |
/branches/dynload/kernel/generic/src/mm/as.c |
---|
122,7 → 122,7 |
int rc; |
link_initialize(&as->inactive_as_with_asid_link); |
mutex_initialize(&as->lock, MUTEX_PASSIVE); |
mutex_initialize(&as->lock, MUTEX_PASSIVE); |
rc = as_constructor_arch(as, flags); |
/branches/dynload/kernel/generic/src/lib/rd.c |
---|
88,7 → 88,9 |
rd_parea.pbase = ALIGN_DOWN((uintptr_t) KA2PA((void *) header + hsize), |
FRAME_SIZE); |
rd_parea.vbase = (uintptr_t) ((void *) header + hsize); |
rd_parea.frames = SIZE2FRAMES(dsize); |
rd_parea.cacheable = true; |
ddi_parea_register(&rd_parea); |
sysinfo_set_item_val("rd", NULL, true); |
/branches/dynload/kernel/generic/src/ddi/irq.c |
---|
39,8 → 39,7 |
* |
* This code is designed to support: |
* - multiple devices sharing single IRQ |
* - multiple IRQs per single device |
* - multiple instances of the same device |
* - multiple IRQs per signle device |
* |
* |
* Note about architectures. |
145,7 → 144,7 |
irq->trigger = (irq_trigger_t) 0; |
irq->claim = NULL; |
irq->handler = NULL; |
irq->instance = NULL; |
irq->arg = NULL; |
irq->cir = NULL; |
irq->cir_arg = NULL; |
irq->notif_cfg.notify = false; |
307,8 → 306,7 |
spinlock_lock(&irq->lock); |
if (devno == -1) { |
/* Invoked by irq_dispatch_and_lock(). */ |
rv = ((irq->inr == inr) && |
(irq->claim(irq->instance) == IRQ_ACCEPT)); |
rv = ((irq->inr == inr) && (irq->claim() == IRQ_ACCEPT)); |
} else { |
/* Invoked by irq_find_and_lock(). */ |
rv = ((irq->inr == inr) && (irq->devno == devno)); |
367,7 → 365,7 |
spinlock_lock(&irq->lock); |
if (devno == -1) { |
/* Invoked by irq_dispatch_and_lock() */ |
rv = (irq->claim(irq->instance) == IRQ_ACCEPT); |
rv = (irq->claim() == IRQ_ACCEPT); |
} else { |
/* Invoked by irq_find_and_lock() */ |
rv = (irq->devno == devno); |
/branches/dynload/kernel/generic/src/ddi/ddi.c |
---|
47,7 → 47,7 |
#include <mm/as.h> |
#include <synch/spinlock.h> |
#include <syscall/copy.h> |
#include <adt/list.h> |
#include <adt/btree.h> |
#include <arch.h> |
#include <align.h> |
#include <errno.h> |
55,17 → 55,13 |
/** This lock protects the parea_btree. */ |
SPINLOCK_INITIALIZE(parea_lock); |
/** List with enabled physical memory areas. */ |
static LIST_INITIALIZE(parea_head); |
/** B+tree with enabled physical memory areas. */ |
static btree_t parea_btree; |
/** Physical memory area for devices. */ |
static parea_t dev_area; |
/** Initialize DDI. */ |
void ddi_init(void) |
{ |
hw_area(&dev_area.pbase, &dev_area.frames); |
ddi_parea_register(&dev_area); |
btree_create(&parea_btree); |
} |
/** Enable piece of physical memory for mapping by physmem_map(). |
78,19 → 74,19 |
void ddi_parea_register(parea_t *parea) |
{ |
ipl_t ipl; |
ipl = interrupts_disable(); |
spinlock_lock(&parea_lock); |
/* |
* TODO: we should really check for overlaps here. |
* However, we should be safe because the kernel is pretty sane. |
* However, we should be safe because the kernel is pretty sane and |
* memory of different devices doesn't overlap. |
*/ |
link_initialize(&parea->link); |
list_append(&parea->link, &parea_head); |
btree_insert(&parea_btree, (btree_key_t) parea->pbase, parea, NULL); |
spinlock_unlock(&parea_lock); |
interrupts_restore(ipl); |
interrupts_restore(ipl); |
} |
/** Map piece of physical memory into virtual address space of current task. |
101,16 → 97,16 |
* @param flags Address space area flags for the mapping. |
* |
* @return 0 on success, EPERM if the caller lacks capabilities to use this |
* syscall, ENOENT if there is no task matching the specified ID or the |
* physical address space is not enabled for mapping and ENOMEM if there |
* was a problem in creating address space area. |
* syscall, ENOENT if there is no task matching the specified ID or the |
* physical address space is not enabled for mapping and ENOMEM if there |
* was a problem in creating address space area. |
*/ |
static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, pfn_t pages, int flags) |
static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, count_t pages, int flags) |
{ |
ipl_t ipl; |
cap_t caps; |
mem_backend_data_t backend_data; |
backend_data.base = pf; |
backend_data.frames = pages; |
120,35 → 116,30 |
caps = cap_get(TASK); |
if (!(caps & CAP_MEM_MANAGER)) |
return EPERM; |
ipl = interrupts_disable(); |
/* |
* Check if the physical memory area is enabled for mapping. |
* If the architecture supports virtually indexed caches, intercept |
* attempts to create an illegal address alias. |
*/ |
spinlock_lock(&parea_lock); |
bool fnd = false; |
link_t *cur; |
for (cur = parea_head.next; cur != &parea_head; cur = cur->next) { |
parea_t *parea = list_get_instance(cur, parea_t, link); |
if ((parea->pbase <= pf) && (ADDR2PFN(pf - parea->pbase) + pages <= parea->frames)) { |
fnd = true; |
break; |
} |
} |
spinlock_unlock(&parea_lock); |
if (!fnd) { |
parea_t *parea; |
btree_node_t *nodep; |
parea = (parea_t *) btree_search(&parea_btree, (btree_key_t) pf, &nodep); |
if (!parea || parea->frames < pages || ((flags & AS_AREA_CACHEABLE) && |
!parea->cacheable) || (!(flags & AS_AREA_CACHEABLE) && |
parea->cacheable)) { |
/* |
* Physical memory area cannot be mapped. |
* This physical memory area cannot be mapped. |
*/ |
spinlock_unlock(&parea_lock); |
interrupts_restore(ipl); |
return ENOENT; |
} |
spinlock_unlock(&parea_lock); |
spinlock_lock(&TASK->lock); |
if (!as_area_create(TASK->as, flags, pages * PAGE_SIZE, vp, AS_AREA_ATTR_NONE, |
235,7 → 226,7 |
{ |
return (unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base, |
FRAME_SIZE), ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE), |
(pfn_t) pages, (int) flags); |
(count_t) pages, (int) flags); |
} |
/** Wrapper for SYS_ENABLE_IOSPACE syscall. |
267,13 → 258,13 |
*/ |
unative_t sys_preempt_control(int enable) |
{ |
if (!cap_get(TASK) & CAP_PREEMPT_CONTROL) |
return EPERM; |
if (enable) |
preemption_enable(); |
else |
preemption_disable(); |
return 0; |
if (!cap_get(TASK) & CAP_PREEMPT_CONTROL) |
return EPERM; |
if (enable) |
preemption_enable(); |
else |
preemption_disable(); |
return 0; |
} |
/** @} |
/branches/dynload/kernel/Makefile |
---|
246,6 → 246,7 |
test/atomic/atomic1.c \ |
test/btree/btree1.c \ |
test/avltree/avltree1.c \ |
test/debug/mips1.c \ |
test/fault/fault1.c \ |
test/mm/falloc1.c \ |
test/mm/falloc2.c \ |
252,6 → 253,7 |
test/mm/mapping1.c \ |
test/mm/slab1.c \ |
test/mm/slab2.c \ |
test/mm/purge1.c \ |
test/synch/rwlock1.c \ |
test/synch/rwlock2.c \ |
test/synch/rwlock3.c \ |
263,34 → 265,19 |
test/thread/thread1.c \ |
test/sysinfo/sysinfo1.c |
ifeq ($(KARCH),mips32) |
GENERIC_SOURCES += test/debug/mips1.c |
else |
GENERIC_SOURCES += test/debug/mips1_skip.c |
endif |
ifeq ($(KARCH),ia64) |
GENERIC_SOURCES += test/mm/purge1.c |
else |
GENERIC_SOURCES += test/mm/purge1_skip.c |
endif |
ifeq ($(CONFIG_FPU),y) |
ifeq ($(KARCH),ia32) |
TEST_FPU1 = y |
TEST_SSE1 = y |
GENERIC_SOURCES += test/fpu/fpu1_x86.c |
endif |
ifeq ($(KARCH),amd64) |
TEST_FPU1 = y |
TEST_SSE1 = y |
GENERIC_SOURCES += test/fpu/fpu1_x86.c |
endif |
ifeq ($(KARCH),ia64) |
TEST_FPU1 = y |
GENERIC_SOURCES += test/fpu/fpu1_ia64.c |
endif |
ifeq ($(KARCH),mips32) |
298,7 → 285,9 |
endif |
endif |
ifneq ($(TEST_FPU1),y) |
ifeq ($(TEST_FPU1),y) |
GENERIC_SOURCES += test/fpu/fpu1.c |
else |
GENERIC_SOURCES += test/fpu/fpu1_skip.c |
endif |
/branches/dynload/kernel/arch/sparc64/include/cpu_node.h |
---|
55,5 → 55,4 |
#endif |
/** @} |
*/ |
*/ |
/branches/dynload/kernel/arch/sparc64/include/arch.h |
---|
45,12 → 45,6 |
#define NWINDOWS 8 /** Number of register window sets. */ |
#ifndef __ASM__ |
extern void arch_pre_main(void); |
#endif /* __ASM__ */ |
#endif |
/** @} |
/branches/dynload/kernel/arch/sparc64/include/asm.h |
---|
44,25 → 44,25 |
#include <arch/stack.h> |
#include <arch/barrier.h> |
static inline void pio_write_8(ioport_t port, uint8_t v) |
static inline void outb(ioport_t port, uint8_t v) |
{ |
*((volatile uint8_t *)(port)) = v; |
memory_barrier(); |
} |
static inline void pio_write_16(ioport_t port, uint16_t v) |
static inline void outw(ioport_t port, uint16_t v) |
{ |
*((volatile uint16_t *)(port)) = v; |
memory_barrier(); |
} |
static inline void pio_write_32(ioport_t port, uint32_t v) |
static inline void outl(ioport_t port, uint32_t v) |
{ |
*((volatile uint32_t *)(port)) = v; |
memory_barrier(); |
} |
static inline uint8_t pio_read_8(ioport_t port) |
static inline uint8_t inb(ioport_t port) |
{ |
uint8_t rv; |
72,7 → 72,7 |
return rv; |
} |
static inline uint16_t pio_read_16(ioport_t port) |
static inline uint16_t inw(ioport_t port) |
{ |
uint16_t rv; |
82,7 → 82,7 |
return rv; |
} |
static inline uint32_t pio_read_32(ioport_t port) |
static inline uint32_t inl(ioport_t port) |
{ |
uint32_t rv; |
/branches/dynload/kernel/arch/sparc64/include/mm/frame.h |
---|
73,7 → 73,6 |
typedef union frame_address frame_address_t; |
extern uintptr_t last_frame; |
extern uintptr_t end_frame; |
extern void frame_arch_init(void); |
#define physmem_print() |
/branches/dynload/kernel/arch/sparc64/include/cpu_family.h |
---|
79,5 → 79,4 |
#endif |
/** @} |
*/ |
*/ |
/branches/dynload/kernel/arch/sparc64/src/console.c |
---|
141,10 → 141,32 |
{ |
thread_detach(THREAD); |
if (kbd_type != KBD_SGCN) |
#ifdef CONFIG_Z8530 |
if (kbd_type == KBD_Z8530) { |
/* |
* The z8530 driver is interrupt-driven. |
*/ |
return; |
} |
#endif |
#ifdef CONFIG_NS16550 |
#ifdef CONFIG_NS16550_INTERRUPT_DRIVEN |
if (kbd_type == KBD_NS16550) { |
/* |
* The ns16550 driver is interrupt-driven. |
*/ |
return; |
} |
#endif |
#endif |
while (1) { |
#ifdef CONFIG_NS16550 |
#ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
if (kbd_type == KBD_NS16550) |
ns16550_poll(); |
#endif |
#endif |
#ifdef CONFIG_SGCN |
if (kbd_type == KBD_SGCN) |
sgcn_poll(); |
/branches/dynload/kernel/arch/sparc64/src/sparc64.c |
---|
103,6 → 103,7 |
{ |
static thread_t *t = NULL; |
if (!t) { |
/* |
* Create thread that polls keyboard. |
/branches/dynload/kernel/arch/sparc64/src/drivers/sgcn.c |
---|
161,10 → 161,19 |
chardev_t sgcn_io; |
/** |
* Set some sysinfo values (SRAM address and SRAM size). |
* Registers the physical area of the SRAM so that the userspace SGCN |
* driver can map it. Moreover, it sets some sysinfo values (SRAM address |
* and SRAM size). |
*/ |
static void register_sram(uintptr_t sram_begin_physical) |
static void register_sram_parea(uintptr_t sram_begin_physical) |
{ |
static parea_t sram_parea; |
sram_parea.pbase = sram_begin_physical; |
sram_parea.vbase = (uintptr_t) sram_begin; |
sram_parea.frames = MAPPED_AREA_SIZE / FRAME_SIZE; |
sram_parea.cacheable = false; |
ddi_parea_register(&sram_parea); |
sysinfo_set_item_val("sram.area.size", NULL, MAPPED_AREA_SIZE); |
sysinfo_set_item_val("sram.address.physical", NULL, |
sram_begin_physical); |
202,7 → 211,7 |
+ *((uint32_t *) iosram_toc->value); |
sram_begin = hw_map(sram_begin_physical, MAPPED_AREA_SIZE); |
register_sram(sram_begin_physical); |
register_sram_parea(sram_begin_physical); |
} |
/** |
310,7 → 319,7 |
/** |
* The driver works in polled mode, so no interrupt should be handled by it. |
*/ |
static irq_ownership_t sgcn_claim(void *instance) |
static irq_ownership_t sgcn_claim(void) |
{ |
return IRQ_DECLINE; |
} |
318,7 → 327,7 |
/** |
* The driver works in polled mode, so no interrupt should be handled by it. |
*/ |
static void sgcn_irq_handler(irq_t *irq) |
static void sgcn_irq_handler(irq_t *irq, void *arg, ...) |
{ |
panic("Not yet implemented, SGCN works in polled mode."); |
} |
/branches/dynload/kernel/arch/sparc64/src/trap/interrupt.c |
---|
86,7 → 86,7 |
/* |
* The IRQ handler was found. |
*/ |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
/* |
* See if there is a clear-interrupt-routine and call it. |
*/ |
/branches/dynload/kernel/arch/sparc64/src/mm/page.c |
---|
147,7 → 147,7 |
physaddr + i * sizemap[order].increment, |
sizemap[order].pagesize_code, true, false); |
#ifdef CONFIG_SMP |
#ifdef CONFIG_SMP |
/* |
* Second, save the information about the mapping for APs. |
*/ |
164,11 → 164,6 |
return virtaddr; |
} |
void hw_area(uintptr_t *physaddr, pfn_t *frames) |
{ |
*physaddr = end_frame; |
*frames = ADDR2PFN(0x7ffffffffff - end_frame); |
} |
/** @} |
*/ |
/branches/dynload/kernel/arch/sparc64/src/mm/frame.c |
---|
41,7 → 41,6 |
#include <macros.h> |
uintptr_t last_frame = NULL; |
uintptr_t end_frame = NULL; |
/** Create memory zones according to information stored in bootinfo. |
* |
81,7 → 80,6 |
frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1); |
} |
end_frame = last_frame; |
} |
/** @} |
/branches/dynload/kernel/arch/ia64/include/asm.h |
---|
41,7 → 41,7 |
#define IA64_IOSPACE_ADDRESS 0xE001000000000000ULL |
static inline void pio_write_8(ioport_t port, uint8_t v) |
static inline void outb(ioport_t port, uint8_t v) |
{ |
*((uint8_t *)(IA64_IOSPACE_ADDRESS + |
((port & 0xfff) | ((port >> 2) << 12)))) = v; |
49,7 → 49,7 |
asm volatile ("mf\n" ::: "memory"); |
} |
static inline void pio_write_16(ioport_t port, uint16_t v) |
static inline void outw(ioport_t port, uint16_t v) |
{ |
*((uint16_t *)(IA64_IOSPACE_ADDRESS + |
((port & 0xfff) | ((port >> 2) << 12)))) = v; |
57,7 → 57,7 |
asm volatile ("mf\n" ::: "memory"); |
} |
static inline void pio_write_32(ioport_t port, uint32_t v) |
static inline void outl(ioport_t port, uint32_t v) |
{ |
*((uint32_t *)(IA64_IOSPACE_ADDRESS + |
((port & 0xfff) | ((port >> 2) << 12)))) = v; |
65,7 → 65,7 |
asm volatile ("mf\n" ::: "memory"); |
} |
static inline uint8_t pio_read_8(ioport_t port) |
static inline uint8_t inb(ioport_t port) |
{ |
asm volatile ("mf\n" ::: "memory"); |
73,7 → 73,7 |
((port & 0xfff) | ((port >> 2) << 12)))); |
} |
static inline uint16_t pio_read_16(ioport_t port) |
static inline uint16_t inw(ioport_t port) |
{ |
asm volatile ("mf\n" ::: "memory"); |
81,7 → 81,7 |
((port & 0xffE) | ((port >> 2) << 12)))); |
} |
static inline uint32_t pio_read_32(ioport_t port) |
static inline uint32_t inl(ioport_t port) |
{ |
asm volatile ("mf\n" ::: "memory"); |
/branches/dynload/kernel/arch/ia64/include/drivers/i8042.h |
---|
47,22 → 47,22 |
static inline void i8042_data_write(uint8_t data) |
{ |
pio_write_8(i8042_DATA, data); |
outb(i8042_DATA, data); |
} |
static inline uint8_t i8042_data_read(void) |
{ |
return pio_read_8(i8042_DATA); |
return inb(i8042_DATA); |
} |
static inline uint8_t i8042_status_read(void) |
{ |
return pio_read_8(i8042_STATUS); |
return inb(i8042_STATUS); |
} |
static inline void i8042_command_write(uint8_t command) |
{ |
pio_write_8(i8042_STATUS, command); |
outb(i8042_STATUS, command); |
} |
#endif |
/branches/dynload/kernel/arch/ia64/include/mm/frame.h |
---|
44,7 → 44,6 |
#include <arch/types.h> |
extern uintptr_t last_frame; |
extern uintptr_t end_frame; |
extern void frame_arch_init(void); |
#define physmem_print() |
/branches/dynload/kernel/arch/ia64/include/arch.h |
---|
39,8 → 39,6 |
#include <arch/ski/ski.h> |
extern void arch_pre_main(void); |
#endif |
/** @} |
/branches/dynload/kernel/arch/ia64/src/ia64.c |
---|
148,13 → 148,36 |
{ |
} |
#ifdef I460GX |
#define POLL_INTERVAL 50000 /* 50 ms */ |
/** Kernel thread for polling keyboard. */ |
static void i8042_kkbdpoll(void *arg) |
{ |
while (1) { |
#ifdef CONFIG_NS16550 |
#ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
ns16550_poll(); |
#endif |
#else |
#ifndef CONFIG_I8042_INTERRUPT_DRIVEN |
i8042_poll(); |
#endif |
#endif |
thread_usleep(POLL_INTERVAL); |
} |
} |
#endif |
void arch_post_smp_init(void) |
{ |
thread_t *t; |
/* |
* Create thread that polls keyboard. |
*/ |
#ifdef SKI |
thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); |
t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); |
if (!t) |
panic("Cannot create kkbdpoll."); |
thread_ready(t); |
169,6 → 192,10 |
devno_t mouse = device_assign_devno(); |
i8042_init(kbd, IRQ_KBD, mouse, IRQ_MOUSE); |
#endif |
t = thread_create(i8042_kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); |
if (!t) |
panic("Cannot create kkbdpoll."); |
thread_ready(t); |
#endif |
sysinfo_set_item_val("ia64_iospace", NULL, true); |
249,7 → 276,7 |
void arch_reboot(void) |
{ |
pio_write_8(0x64, 0xfe); |
outb(0x64, 0xfe); |
while (1) |
; |
} |
/branches/dynload/kernel/arch/ia64/src/ski/ski.c |
---|
186,7 → 186,7 |
* |
* @return Always IRQ_DECLINE. |
*/ |
static irq_ownership_t ski_kbd_claim(void *instance) |
static irq_ownership_t ski_kbd_claim(void) |
{ |
return IRQ_DECLINE; |
} |
/branches/dynload/kernel/arch/ia64/src/interrupt.c |
---|
266,7 → 266,7 |
case INTERRUPT_TIMER: |
irq = irq_dispatch_and_lock(ivr.vector); |
if (irq) { |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
spinlock_unlock(&irq->lock); |
} else { |
panic("Unhandled Internal Timer Interrupt (%d).", |
283,7 → 283,7 |
/* Send EOI before processing the interrupt */ |
end_of_local_irq(); |
} |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
if (!irq->preack) |
end_of_local_irq(); |
spinlock_unlock(&irq->lock); |
/branches/dynload/kernel/arch/ia64/src/mm/frame.c |
---|
51,7 → 51,6 |
#define MINCONF 1 |
uintptr_t last_frame = 0; |
uintptr_t end_frame = 0; |
void frame_arch_init(void) |
{ |
/branches/dynload/kernel/arch/ia64/src/mm/page.c |
---|
274,11 → 274,5 |
return PA2KA(physaddr); |
} |
void hw_area(uintptr_t *physaddr, pfn_t *frames) |
{ |
*physaddr = end_frame; |
*frames = ADDR2PFN(0x7fffffffffffffffUL - end_frame); |
} |
/** @} |
*/ |
/branches/dynload/kernel/arch/ia64/src/drivers/it.c |
---|
56,8 → 56,8 |
static irq_t it_irq; |
static irq_ownership_t it_claim(void *); |
static void it_interrupt(irq_t *irq); |
static irq_ownership_t it_claim(void); |
static void it_interrupt(irq_t *irq, void *arg, ...); |
/** Initialize Interval Timer. */ |
void it_init(void) |
104,13 → 104,13 |
* |
* @return Always IRQ_ACCEPT. |
*/ |
irq_ownership_t it_claim(void *instance) |
irq_ownership_t it_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
/** Process Interval Timer interrupt. */ |
void it_interrupt(irq_t *irq) |
void it_interrupt(irq_t *irq, void *arg, ...) |
{ |
int64_t c; |
int64_t m; |
/branches/dynload/kernel/arch/arm32/include/asm.h |
---|
46,14 → 46,15 |
{ |
} |
static inline void pio_write_8(ioport_t port, uint8_t v) |
/** No I/O port address space on ARM. */ |
static inline void outb(ioport_t port, uint8_t v) |
{ |
/* XXX */ |
} |
static inline uint8_t pio_read_8(ioport_t port) |
/** No I/O port address space on ARM. */ |
static inline uint8_t inb(ioport_t port) |
{ |
return 0; /* XXX */ |
return 0; |
} |
/** Return base address of current stack. |
/branches/dynload/kernel/arch/arm32/include/machine.h |
---|
102,7 → 102,7 |
extern uintptr_t machine_get_fb_address(void); |
#ifdef MACHINE_gxemul |
#ifdef MACHINE_GXEMUL_TESTARM |
#define machine_console_init(devno) gxemul_console_init(devno) |
#define machine_grab_console gxemul_grab_console |
#define machine_release_console gxemul_release_console |
/branches/dynload/kernel/arch/arm32/include/mm/frame.h |
---|
51,7 → 51,6 |
#define BOOT_PAGE_TABLE_SIZE_IN_FRAMES (BOOT_PAGE_TABLE_SIZE >> FRAME_WIDTH) |
extern uintptr_t last_frame; |
extern uintptr_t end_frame; |
extern void frame_arch_init(void); |
extern void boot_page_table_free(void); |
/branches/dynload/kernel/arch/arm32/include/asm/boot.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup arm32 |
/** @addtogroup arm32 |
* @{ |
*/ |
/** @file |
39,7 → 39,24 |
/** Size of a temporary stack used for initial kernel start. */ |
#define TEMP_STACK_SIZE 0x100 |
#ifndef __ASM__ |
/** Kernel entry point. |
* |
* Implemented in assembly. Copies boot_bootinfo (declared as bootinfo in |
* boot/arch/arm32/loader/main.c) to #bootinfo struct. Then jumps to |
* #arch_pre_main and #main_bsp. |
* |
* @param entry Entry point address (not used). |
* @param boot_bootinfo Struct holding information about loaded tasks. |
* @param bootinfo_size Size of the bootinfo structure. |
*/ |
extern void kernel_image_start(void *entry, void *boot_bootinfo, |
unsigned int bootinfo_size); |
#endif |
#endif |
/** @} |
*/ |
/branches/dynload/kernel/arch/arm32/include/boot.h |
---|
0,0 → 1,76 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup arm32 |
* @{ |
*/ |
/** @file |
* @brief Bootinfo declarations. |
* |
* Reflects boot/arch/arm32/loader/main.h. |
*/ |
#ifndef KERN_arm32_BOOT_H_ |
#define KERN_arm32_BOOT_H_ |
#include <arch/types.h> |
/** Maximum number of tasks in the #bootinfo_t struct. */ |
#define TASKMAP_MAX_RECORDS 32 |
/** Struct holding information about single loaded uspace task. */ |
typedef struct { |
/** Address where the task was placed. */ |
uintptr_t addr; |
/** Size of the task's binary. */ |
uint32_t size; |
} utask_t; |
/** Struct holding information about loaded uspace tasks. */ |
typedef struct { |
/** Number of loaded tasks. */ |
uint32_t cnt; |
/** Array of loaded tasks. */ |
utask_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
/** Bootinfo that is filled in #kernel_image_start. */ |
extern bootinfo_t bootinfo; |
#endif |
/** @} |
*/ |
/branches/dynload/kernel/arch/arm32/include/arch.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup arm32 |
/** @addtogroup arm32 |
* @{ |
*/ |
/** @file |
36,23 → 36,6 |
#ifndef KERN_arm32_ARCH_H_ |
#define KERN_arm32_ARCH_H_ |
#define TASKMAP_MAX_RECORDS 32 |
#define CPUMAP_MAX_RECORDS 32 |
#include <typedefs.h> |
typedef struct { |
uintptr_t addr; |
uint32_t size; |
} utask_t; |
typedef struct { |
uint32_t cnt; |
utask_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
extern void arch_pre_main(void *entry, bootinfo_t *bootinfo); |
#endif |
/** @} |
/branches/dynload/kernel/arch/arm32/Makefile.inc |
---|
35,11 → 35,14 |
TARGET = arm-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/arm |
KERNEL_LOAD_ADDRESS = 0x80200000 |
DMACHINE = MACHINE_GXEMUL_TESTARM |
ATSIGN = % |
GCC_CFLAGS += -fno-zero-initialized-in-bss |
DEFS += -D__32_BITS__ |
DEFS += -D__32_BITS__ -DKERNEL_LOAD_ADDRESS=$(KERNEL_LOAD_ADDRESS) -D$(DMACHINE) |
ARCH_SOURCES = \ |
arch/$(KARCH)/src/start.S \ |
/branches/dynload/kernel/arch/arm32/src/arm32.c |
---|
34,6 → 34,7 |
*/ |
#include <arch.h> |
#include <arch/boot.h> |
#include <config.h> |
#include <arch/console.h> |
#include <ddi/device.h> |
47,19 → 48,22 |
#include <arch/regutils.h> |
#include <arch/machine.h> |
#include <userspace.h> |
#include <macros.h> |
/** Information about loaded tasks. */ |
bootinfo_t bootinfo; |
/** Performs arm32 specific initialization before main_bsp() is called. */ |
void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo) |
void arch_pre_main(void) |
{ |
unsigned int i; |
init.cnt = bootinfo.cnt; |
for (i = 0; i < bootinfo.cnt; ++i) { |
init.tasks[i].addr = bootinfo.tasks[i].addr; |
init.tasks[i].size = bootinfo.tasks[i].size; |
} |
init.cnt = bootinfo->cnt; |
for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); ++i) { |
init.tasks[i].addr = bootinfo->tasks[i].addr; |
init.tasks[i].size = bootinfo->tasks[i].size; |
} |
} |
/** Performs arm32 specific initialization before mm is initialized. */ |
/branches/dynload/kernel/arch/arm32/src/drivers/gxemul.c |
---|
184,8 → 184,9 |
/** Process keyboard interrupt. |
* |
* @param irq IRQ information. |
* @param arg Not used. |
*/ |
static void gxemul_irq_handler(irq_t *irq) |
static void gxemul_irq_handler(irq_t *irq, void *arg, ...) |
{ |
if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) { |
ipc_irq_send_notif(irq); |
203,7 → 204,7 |
} |
} |
static irq_ownership_t gxemul_claim(void *instance) |
static irq_ownership_t gxemul_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
265,7 → 266,7 |
*((uint32_t*) gxemul_hw_map.rtc_freq) = frequency; |
} |
static irq_ownership_t gxemul_timer_claim(void *instance) |
static irq_ownership_t gxemul_timer_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
275,7 → 276,7 |
* @param irq Interrupt information. |
* @param arg Not used. |
*/ |
static void gxemul_timer_irq_handler(irq_t *irq) |
static void gxemul_timer_irq_handler(irq_t *irq, void *arg, ...) |
{ |
/* |
* We are holding a lock which prevents preemption. |
369,7 → 370,7 |
irq_t *irq = irq_dispatch_and_lock(i); |
if (irq) { |
/* The IRQ handler was found. */ |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
spinlock_unlock(&irq->lock); |
} else { |
/* Spurious interrupt.*/ |
/branches/dynload/kernel/arch/arm32/src/mm/page.c |
---|
106,11 → 106,5 |
return virtaddr; |
} |
void hw_area(uintptr_t *physaddr, pfn_t *frames) |
{ |
*physaddr = end_frame; |
*frames = ADDR2PFN(0xffffffff - end_frame); |
} |
/** @} |
*/ |
/branches/dynload/kernel/arch/arm32/src/mm/frame.c |
---|
41,7 → 41,6 |
/** Address of the last frame in the memory. */ |
uintptr_t last_frame = 0; |
uintptr_t end_frame = 0; |
/** Creates memory zones. */ |
void frame_arch_init(void) |
50,8 → 49,7 |
zone_create(0, ADDR2PFN(machine_get_memory_size()), |
BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0); |
last_frame = machine_get_memory_size(); |
end_frame = last_frame; |
/* blacklist boot page table */ |
frame_mark_unavailable(BOOT_PAGE_TABLE_START_FRAME, |
BOOT_PAGE_TABLE_SIZE_IN_FRAMES); |
/branches/dynload/kernel/arch/arm32/src/start.S |
---|
40,12 → 40,30 |
mrs r3, cpsr |
bic r3, r3, #0x1f |
orr r3, r3, #0x13 |
msr cpsr_c, r3 |
msr cpsr_c, r3 |
ldr sp, =temp_stack |
cmp r2, #0 |
beq bootinfo_end |
ldr r3, =bootinfo |
bootinfo_loop: |
ldr r4, [r1] |
str r4, [r3] |
add r1, r1, #4 |
add r3, r3, #4 |
add r2, r2, #-4 |
cmp r2, #0 |
bne bootinfo_loop |
bootinfo_end: |
bl arch_pre_main |
bl main_bsp |
.space TEMP_STACK_SIZE |
56,3 → 74,4 |
supervisor_sp: |
.space 4 |
/branches/dynload/kernel/arch/arm32/_link.ld.in |
---|
1,16 → 1,15 |
/* |
* ARM linker script |
* |
* ARM linker script |
* |
* kernel text |
* kernel data |
* |
* |
*/ |
#define KERNEL_LOAD_ADDRESS 0x80200000 |
OUTPUT_ARCH(arm) |
ENTRY(kernel_image_start) |
ENTRY(kernel_image_start) |
SECTIONS { |
. = KERNEL_LOAD_ADDRESS; |
.text : { |
20,29 → 19,29 |
} |
.data : { |
kdata_start = .; |
*(.data); /* initialized data */ |
*(.data); /* initialized data */ |
hardcoded_ktext_size = .; |
LONG(ktext_end - ktext_start); |
LONG(ktext_end - ktext_start); |
hardcoded_kdata_size = .; |
LONG(kdata_end - kdata_start); |
hardcoded_load_address = .; |
LONG(KERNEL_LOAD_ADDRESS); |
*(.bss); /* uninitialized static variables */ |
*(COMMON); /* global variables */ |
*(.bss); /* uninitialized static variables */ |
*(COMMON); /* global variables */ |
*(.rodata*); |
*(.sdata); |
*(.reginfo); |
symbol_table = .; |
*(symtab.*); |
*(symtab.*); |
} |
.sbss : { |
*(.sbss); |
*(.scommon); |
} |
kdata_end = .; |
/DISCARD/ : { |
*(.mdebug*); |
*(.pdr); |
49,4 → 48,5 |
*(.comment); |
*(.note); |
} |
} |
/branches/dynload/kernel/arch/ppc32/include/asm.h |
---|
149,14 → 149,15 |
extern void userspace_asm(uintptr_t uspace_uarg, uintptr_t stack, uintptr_t entry); |
static inline void pio_write_8(ioport_t port, uint8_t v) |
/** No I/O port address space on PowerPC. */ |
static inline void outb(ioport_t port, uint8_t v) |
{ |
/* XXX */ |
} |
static inline uint8_t pio_read_8(ioport_t port) |
/** No I/O port address space on PowerPC. */ |
static inline uint8_t inb(ioport_t port) |
{ |
return 0; /* XXX */ |
return 0; |
} |
#endif |
/branches/dynload/kernel/arch/ppc32/include/boot/boot.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup ppc32 |
/** @addtogroup ppc32 |
* @{ |
*/ |
/** @file |
35,13 → 35,13 |
#ifndef KERN_ppc32_BOOT_H_ |
#define KERN_ppc32_BOOT_H_ |
#define BOOT_OFFSET 0x8000 |
#define BOOT_OFFSET 0x8000 |
/* Temporary stack size for boot process */ |
#define TEMP_STACK_SIZE 0x1000 |
#define TEMP_STACK_SIZE 0x1000 |
#define TASKMAP_MAX_RECORDS 32 |
#define MEMMAP_MAX_RECORDS 32 |
#define TASKMAP_MAX_RECORDS 32 |
#define MEMMAP_MAX_RECORDS 32 |
#ifndef __ASM__ |
/branches/dynload/kernel/arch/ppc32/include/mm/frame.h |
---|
41,10 → 41,9 |
#ifdef KERNEL |
#ifndef __ASM__ |
#include <arch/types.h> |
#include <arch/types.h> |
extern uintptr_t last_frame; |
extern uintptr_t end_frame; |
extern void frame_arch_init(void); |
extern void physmem_print(void); |
/branches/dynload/kernel/arch/ppc32/include/arch.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup ppc32 |
/** @addtogroup ppc32 |
* @{ |
*/ |
/** @file |
35,7 → 35,7 |
#ifndef KERN_ppc32_ARCH_H_ |
#define KERN_ppc32_ARCH_H_ |
extern void arch_pre_main(void); |
#include <arch/drivers/cuda.h> |
#endif |
/branches/dynload/kernel/arch/ppc32/src/ppc32.c |
---|
45,19 → 45,19 |
#include <ddi/device.h> |
#include <ddi/irq.h> |
#include <arch/drivers/pic.h> |
#include <macros.h> |
#define IRQ_COUNT 64 |
#define IRQ_COUNT 64 |
bootinfo_t bootinfo; |
void arch_pre_main(void) |
{ |
/* Setup usermode */ |
init.cnt = bootinfo.taskmap.count; |
uint32_t i; |
for (i = 0; i < min3(bootinfo.taskmap.count, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) { |
for (i = 0; i < bootinfo.taskmap.count; i++) { |
init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); |
init.tasks[i].size = bootinfo.taskmap.tasks[i].size; |
} |
/branches/dynload/kernel/arch/ppc32/src/mm/page.c |
---|
63,11 → 63,5 |
return virtaddr; |
} |
void hw_area(uintptr_t *physaddr, pfn_t *frames) |
{ |
*physaddr = end_frame; |
*frames = ADDR2PFN(0xffffffff - end_frame); |
} |
/** @} |
*/ |
/branches/dynload/kernel/arch/ppc32/src/mm/frame.c |
---|
40,7 → 40,6 |
#include <print.h> |
uintptr_t last_frame = 0; |
uintptr_t end_frame = 0; |
void physmem_print(void) |
{ |
75,9 → 74,7 |
if (last_frame < ALIGN_UP(bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE)) |
last_frame = ALIGN_UP(bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE); |
} |
end_frame = last_frame; |
/* First is exception vector, second is 'implementation specific', |
third and fourth is reserved, other contain real mode code */ |
frame_mark_unavailable(0, 8); |
/branches/dynload/kernel/arch/ppc32/src/interrupt.c |
---|
73,7 → 73,7 |
ack = true; |
} |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
spinlock_unlock(&irq->lock); |
} else { |
/* |
/branches/dynload/kernel/arch/ppc32/src/drivers/cuda.c |
---|
249,7 → 249,7 |
return -1; |
} |
static void cuda_irq_handler(irq_t *irq) |
static void cuda_irq_handler(irq_t *irq, void *arg, ...) |
{ |
if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) |
ipc_irq_send_notif(irq); |
264,7 → 264,7 |
} |
} |
static irq_ownership_t cuda_claim(void *instance) |
static irq_ownership_t cuda_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
/branches/dynload/kernel/arch/ppc32/src/boot/boot.S |
---|
33,7 → 33,7 |
.global kernel_image_start |
kernel_image_start: |
# load temporal kernel stack |
lis sp, kernel_stack@ha |
52,7 → 52,7 |
beq bootinfo_end |
addis r3, r3, 0x8000 |
lis r31, bootinfo@ha |
addi r31, r31, bootinfo@l # r31 = bootinfo |
/branches/dynload/kernel/arch/amd64/include/mm/frame.h |
---|
44,7 → 44,6 |
#ifndef __ASM__ |
extern uintptr_t last_frame; |
extern uintptr_t end_frame; |
extern void frame_arch_init(void); |
extern void physmem_print(void); |
#endif /* __ASM__ */ |
/branches/dynload/kernel/arch/amd64/include/interrupt.h |
---|
71,6 → 71,7 |
/** This is passed to interrupt handlers */ |
typedef struct { |
uint64_t rax; |
uint64_t rbx; |
uint64_t rcx; |
uint64_t rdx; |
uint64_t rsi; |
79,6 → 80,11 |
uint64_t r9; |
uint64_t r10; |
uint64_t r11; |
uint64_t r12; |
uint64_t r13; |
uint64_t r14; |
uint64_t r15; |
uint64_t rbp; |
uint64_t error_word; |
uint64_t rip; |
uint64_t cs; |
/branches/dynload/kernel/arch/amd64/include/asm.h |
---|
73,7 → 73,7 |
* @param port Port to read from |
* @return Value read |
*/ |
static inline uint8_t pio_read_8(uint16_t port) |
static inline uint8_t inb(uint16_t port) |
{ |
uint8_t val; |
88,7 → 88,7 |
* @param port Port to write to |
* @param val Value to write |
*/ |
static inline void pio_write_8(uint16_t port, uint8_t val) |
static inline void outb(uint16_t port, uint8_t val) |
{ |
asm volatile ("outb %b0, %w1\n" : : "a" (val), "d" (port)); |
} |
/branches/dynload/kernel/arch/amd64/src/debugger.c |
---|
64,6 → 64,8 |
.argc = 0, |
}; |
#ifndef CONFIG_DEBUG_AS_WATCHPOINT |
static int cmd_del_breakpoint(cmd_arg_t *argv); |
static cmd_arg_t del_argv = { |
.type = ARG_TYPE_INT |
99,6 → 101,7 |
.argv = &addw_argv |
}; |
#endif /* CONFIG_DEBUG_AS_WATCHPOINT */ |
#endif /* CONFIG_KCONSOLE */ |
/* Setup DR register according to table */ |
317,6 → 320,7 |
if (!cmd_register(&bkpts_info)) |
printf("Cannot register command %s\n", bkpts_info.name); |
#ifndef CONFIG_DEBUG_AS_WATCHPOINT |
cmd_initialize(&delbkpt_info); |
if (!cmd_register(&delbkpt_info)) |
printf("Cannot register command %s\n", delbkpt_info.name); |
328,6 → 332,7 |
cmd_initialize(&addwatchp_info); |
if (!cmd_register(&addwatchp_info)) |
printf("Cannot register command %s\n", addwatchp_info.name); |
#endif /* CONFIG_DEBUG_AS_WATCHPOINT */ |
#endif /* CONFIG_KCONSOLE */ |
exc_register(VECTOR_DEBUG, "debugger", debug_exception); |
373,6 → 378,8 |
return 1; |
} |
#ifndef CONFIG_DEBUG_AS_WATCHPOINT |
/** Remove breakpoint from table */ |
int cmd_del_breakpoint(cmd_arg_t *argv) |
{ |
405,6 → 412,7 |
return 1; |
} |
#endif /* CONFIG_DEBUG_AS_WATCHPOINT */ |
#endif /* CONFIG_KCONSOLE */ |
/** @} |
/branches/dynload/kernel/arch/amd64/src/interrupt.c |
---|
80,6 → 80,12 |
istate->rdi, istate->r8); |
printf("%%r9=%#llx, %%r10=%#llx, %%r11=%#llx\n", istate->r9, |
istate->r10, istate->r11); |
#ifdef CONFIG_DEBUG_ALLREGS |
printf("%%r12=%#llx, %%r13=%#llx, %%r14=%#llx\n", istate->r12, |
istate->r13, istate->r14); |
printf("%%r15=%#llx, %%rbx=%#llx, %%rbp=%#llx\n", istate->r15, |
istate->rbx, &istate->rbp); |
#endif |
printf("%%rsp=%#llx\n", &istate->stack[0]); |
} |
173,7 → 179,7 |
trap_virtual_eoi(); |
ack = true; |
} |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
spinlock_unlock(&irq->lock); |
} else { |
/* |
/branches/dynload/kernel/arch/amd64/src/mm/page.c |
---|
214,11 → 214,5 |
return virtaddr; |
} |
void hw_area(uintptr_t *physaddr, pfn_t *frames) |
{ |
*physaddr = end_frame; |
*frames = ADDR2PFN(0xfffffffffffff - end_frame); |
} |
/** @} |
*/ |
/branches/dynload/kernel/arch/amd64/src/asm_utils.S |
---|
26,17 → 26,23 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
#define IREGISTER_SPACE 72 |
#define IREGISTER_SPACE 120 |
#define IOFFSET_RAX 0x0 |
#define IOFFSET_RCX 0x8 |
#define IOFFSET_RDX 0x10 |
#define IOFFSET_RSI 0x18 |
#define IOFFSET_RDI 0x20 |
#define IOFFSET_R8 0x28 |
#define IOFFSET_R9 0x30 |
#define IOFFSET_R10 0x38 |
#define IOFFSET_R11 0x40 |
#define IOFFSET_RAX 0x0 |
#define IOFFSET_RBX 0x8 |
#define IOFFSET_RCX 0x10 |
#define IOFFSET_RDX 0x18 |
#define IOFFSET_RSI 0x20 |
#define IOFFSET_RDI 0x28 |
#define IOFFSET_R8 0x30 |
#define IOFFSET_R9 0x38 |
#define IOFFSET_R10 0x40 |
#define IOFFSET_R11 0x48 |
#define IOFFSET_R12 0x50 |
#define IOFFSET_R13 0x58 |
#define IOFFSET_R14 0x60 |
#define IOFFSET_R15 0x68 |
#define IOFFSET_RBP 0x70 |
# Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word |
# and 1 means interrupt with error word |
167,7 → 173,7 |
rdmsr |
ret |
# Push all volatile general purpose registers on stack |
# Push all general purpose registers on stack except %rbp, %rsp |
.macro save_all_gpr |
movq %rax, IOFFSET_RAX(%rsp) |
movq %rcx, IOFFSET_RCX(%rsp) |
178,6 → 184,14 |
movq %r9, IOFFSET_R9(%rsp) |
movq %r10, IOFFSET_R10(%rsp) |
movq %r11, IOFFSET_R11(%rsp) |
#ifdef CONFIG_DEBUG_ALLREGS |
movq %rbx, IOFFSET_RBX(%rsp) |
movq %rbp, IOFFSET_RBP(%rsp) |
movq %r12, IOFFSET_R12(%rsp) |
movq %r13, IOFFSET_R13(%rsp) |
movq %r14, IOFFSET_R14(%rsp) |
movq %r15, IOFFSET_R15(%rsp) |
#endif |
.endm |
.macro restore_all_gpr |
190,9 → 204,21 |
movq IOFFSET_R9(%rsp), %r9 |
movq IOFFSET_R10(%rsp), %r10 |
movq IOFFSET_R11(%rsp), %r11 |
#ifdef CONFIG_DEBUG_ALLREGS |
movq IOFFSET_RBX(%rsp), %rbx |
movq IOFFSET_RBP(%rsp), %rbp |
movq IOFFSET_R12(%rsp), %r12 |
movq IOFFSET_R13(%rsp), %r13 |
movq IOFFSET_R14(%rsp), %r14 |
movq IOFFSET_R15(%rsp), %r15 |
#endif |
.endm |
#define INTERRUPT_ALIGN 128 |
#ifdef CONFIG_DEBUG_ALLREGS |
# define INTERRUPT_ALIGN 256 |
#else |
# define INTERRUPT_ALIGN 128 |
#endif |
## Declare interrupt handlers |
# |
/branches/dynload/kernel/arch/amd64/src/proc/scheduler.c |
---|
39,6 → 39,7 |
#include <arch.h> |
#include <arch/context.h> /* SP_DELTA */ |
#include <arch/asm.h> |
#include <arch/debugger.h> |
#include <print.h> |
#include <arch/pm.h> |
#include <arch/ddi/ddi.h> |
67,6 → 68,13 |
/* TLS support - set FS to thread local storage */ |
write_msr(AMD_MSR_FS, THREAD->arch.tls); |
#ifdef CONFIG_DEBUG_AS_WATCHPOINT |
/* Set watchpoint on AS to ensure that nobody sets it to zero */ |
if (CPU->id < BKPOINTS_MAX) |
breakpoint_add(&((the_t *) THREAD->kstack)->as, |
BKPOINT_WRITE | BKPOINT_CHECK_ZERO, CPU->id); |
#endif |
} |
void after_thread_ran_arch(void) |
/branches/dynload/kernel/arch/mips32/include/context_offset.h |
---|
76,17 → 76,26 |
#define EOFFSET_T5 0x30 |
#define EOFFSET_T6 0x34 |
#define EOFFSET_T7 0x38 |
#define EOFFSET_T8 0x3c |
#define EOFFSET_T9 0x40 |
#define EOFFSET_GP 0x44 |
#define EOFFSET_SP 0x48 |
#define EOFFSET_RA 0x4c |
#define EOFFSET_LO 0x50 |
#define EOFFSET_HI 0x54 |
#define EOFFSET_STATUS 0x58 |
#define EOFFSET_EPC 0x5c |
#define EOFFSET_K1 0x60 |
#define REGISTER_SPACE 100 |
#define EOFFSET_S0 0x3c |
#define EOFFSET_S1 0x40 |
#define EOFFSET_S2 0x44 |
#define EOFFSET_S3 0x48 |
#define EOFFSET_S4 0x4c |
#define EOFFSET_S5 0x50 |
#define EOFFSET_S6 0x54 |
#define EOFFSET_S7 0x58 |
#define EOFFSET_T8 0x5c |
#define EOFFSET_T9 0x60 |
#define EOFFSET_GP 0x64 |
#define EOFFSET_SP 0x68 |
#define EOFFSET_S8 0x6c |
#define EOFFSET_RA 0x70 |
#define EOFFSET_LO 0x74 |
#define EOFFSET_HI 0x78 |
#define EOFFSET_STATUS 0x7c |
#define EOFFSET_EPC 0x80 |
#define EOFFSET_K1 0x84 |
#define REGISTER_SPACE 136 |
#ifdef __ASM__ |
/branches/dynload/kernel/arch/mips32/include/asm.h |
---|
55,11 → 55,7 |
{ |
uintptr_t v; |
asm volatile ( |
"and %0, $29, %1\n" |
: "=r" (v) |
: "r" (~(STACK_SIZE-1)) |
); |
asm volatile ("and %0, $29, %1\n" : "=r" (v) : "r" (~(STACK_SIZE-1))); |
return v; |
} |
67,22 → 63,22 |
extern void cpu_halt(void); |
extern void asm_delay_loop(uint32_t t); |
extern void userspace_asm(uintptr_t ustack, uintptr_t uspace_uarg, |
uintptr_t entry); |
uintptr_t entry); |
extern ipl_t interrupts_disable(void); |
extern ipl_t interrupts_enable(void); |
extern void interrupts_restore(ipl_t ipl); |
extern ipl_t interrupts_read(void); |
extern void asm_delay_loop(uint32_t t); |
static inline void pio_write_8(ioport_t port, uint8_t v) |
/** No I/O port address space on MIPS. */ |
static inline void outb(ioport_t port, uint8_t v) |
{ |
/* XXX */ |
} |
static inline uint8_t pio_read_8(ioport_t port) |
/** No I/O port address space on MIPS. */ |
static inline uint8_t inb(ioport_t port) |
{ |
return 0; /* XXX */ |
return 0; |
} |
#endif |
/branches/dynload/kernel/arch/mips32/include/mm/frame.h |
---|
35,19 → 35,15 |
#ifndef KERN_mips32_FRAME_H_ |
#define KERN_mips32_FRAME_H_ |
#define FRAME_WIDTH 14 /* 16K */ |
#define FRAME_SIZE (1 << FRAME_WIDTH) |
#define FRAME_WIDTH 14 /* 16K */ |
#define FRAME_SIZE (1 << FRAME_WIDTH) |
#ifdef KERNEL |
#ifndef __ASM__ |
#include <typedefs.h> |
extern void frame_arch_init(void); |
extern void physmem_print(void); |
extern uintptr_t end_frame; |
#endif /* __ASM__ */ |
#endif /* KERNEL */ |
/branches/dynload/kernel/arch/mips32/include/atomic.h |
---|
35,14 → 35,14 |
#ifndef KERN_mips32_ATOMIC_H_ |
#define KERN_mips32_ATOMIC_H_ |
#define atomic_inc(x) ((void) atomic_add(x, 1)) |
#define atomic_dec(x) ((void) atomic_add(x, -1)) |
#define atomic_inc(x) ((void) atomic_add(x, 1)) |
#define atomic_dec(x) ((void) atomic_add(x, -1)) |
#define atomic_postinc(x) (atomic_add(x, 1) - 1) |
#define atomic_postdec(x) (atomic_add(x, -1) + 1) |
#define atomic_postinc(x) (atomic_add(x, 1) - 1) |
#define atomic_postdec(x) (atomic_add(x, -1) + 1) |
#define atomic_preinc(x) atomic_add(x, 1) |
#define atomic_predec(x) atomic_add(x, -1) |
#define atomic_preinc(x) atomic_add(x, 1) |
#define atomic_predec(x) atomic_add(x, -1) |
/* Atomic addition of immediate value. |
* |
54,37 → 54,19 |
static inline long atomic_add(atomic_t *val, int i) |
{ |
long tmp, v; |
asm volatile ( |
"1:\n" |
" ll %0, %1\n" |
" addu %0, %0, %3\n" /* same as addi, but never traps on overflow */ |
" move %2, %0\n" |
" addu %0, %0, %3\n" /* same as addi, but never traps on overflow */ |
" move %2, %0\n" |
" sc %0, %1\n" |
" beq %0, %4, 1b\n" /* if the atomic operation failed, try again */ |
" beq %0, %4, 1b\n" /* if the atomic operation failed, try again */ |
" nop\n" |
: "=&r" (tmp), "+m" (val->count), "=&r" (v) |
: "r" (i), "i" (0) |
); |
return v; |
} |
); |
static inline uint32_t test_and_set(atomic_t *val) { |
uint32_t tmp, v; |
asm volatile ( |
"1:\n" |
" ll %2, %1\n" |
" bnez %2, 2f\n" |
" li %0, %3\n" |
" sc %0, %1\n" |
" beqz %0, 1b\n" |
"2:\n" |
: "=&r" (tmp), "+m" (val->count), "=&r" (v) |
: "i" (1) |
); |
return v; |
} |
/branches/dynload/kernel/arch/mips32/include/smp/dorder.h |
---|
File deleted |
/branches/dynload/kernel/arch/mips32/include/smp/order.h |
---|
0,0 → 1,34 |
/* |
* Copyright (c) 2007 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef KERN_mips32_ORDER_H_ |
#define KERN_mips32_ORDER_H_ |
extern void ipi_broadcast_arch(int ipi); |
#endif |
/branches/dynload/kernel/arch/mips32/include/interrupt.h |
---|
38,11 → 38,9 |
#include <typedefs.h> |
#include <arch/exception.h> |
#define IVT_ITEMS 32 |
#define IVT_FIRST 0 |
#define IVT_ITEMS 32 |
#define IVT_FIRST 0 |
#define VECTOR_TLB_SHOOTDOWN_IPI EXC_Int |
extern function virtual_timer_fnc; |
extern uint32_t count_hi; |
/branches/dynload/kernel/arch/mips32/include/exception.h |
---|
73,10 → 73,19 |
uint32_t t5; |
uint32_t t6; |
uint32_t t7; |
uint32_t s0; |
uint32_t s1; |
uint32_t s2; |
uint32_t s3; |
uint32_t s4; |
uint32_t s5; |
uint32_t s6; |
uint32_t s7; |
uint32_t t8; |
uint32_t t9; |
uint32_t gp; |
uint32_t sp; |
uint32_t s8; |
uint32_t ra; |
uint32_t lo; |
/branches/dynload/kernel/arch/mips32/include/cpu.h |
---|
42,7 → 42,7 |
uint32_t imp_num; |
uint32_t rev_num; |
} cpu_arch_t; |
#endif |
/** @} |
/branches/dynload/kernel/arch/mips32/include/asm/boot.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup mips32 |
/** @addtogroup mips32 |
* @{ |
*/ |
/** @file |
/branches/dynload/kernel/arch/mips32/include/boot.h |
---|
0,0 → 1,48 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef KERN_mips32_BOOT_H_ |
#define KERN_mips32_BOOT_H_ |
#define TASKMAP_MAX_RECORDS 32 |
#include <arch/types.h> |
typedef struct { |
uintptr_t addr; |
uint32_t size; |
} utask_t; |
typedef struct { |
uint32_t cnt; |
utask_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
extern bootinfo_t bootinfo; |
#endif |
/branches/dynload/kernel/arch/mips32/include/arch.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup mips32 |
/** @addtogroup mips32 |
* @{ |
*/ |
/** @file |
35,26 → 35,6 |
#ifndef KERN_mips32_ARCH_H_ |
#define KERN_mips32_ARCH_H_ |
#define TASKMAP_MAX_RECORDS 32 |
#define CPUMAP_MAX_RECORDS 32 |
#include <typedefs.h> |
extern count_t cpu_count; |
typedef struct { |
uintptr_t addr; |
uint32_t size; |
} utask_t; |
typedef struct { |
uint32_t cpumap; |
uint32_t cnt; |
utask_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
extern void arch_pre_main(void *entry, bootinfo_t *bootinfo); |
#endif |
/** @} |
/branches/dynload/kernel/arch/mips32/Makefile.inc |
---|
33,9 → 33,11 |
TARGET = mipsel-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/mipsel |
KERNEL_LOAD_ADDRESS = 0x80100000 |
GCC_CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss |
DEFS += -D__32_BITS__ |
DEFS += -D__32_BITS__ -D$(MACHINE) -DKERNEL_LOAD_ADDRESS=$(KERNEL_LOAD_ADDRESS) |
## Accepted MACHINEs |
# |
72,6 → 74,7 |
arch/$(KARCH)/src/context.S \ |
arch/$(KARCH)/src/panic.S \ |
arch/$(KARCH)/src/mips32.c \ |
arch/$(KARCH)/src/dummy.S \ |
arch/$(KARCH)/src/console.c \ |
arch/$(KARCH)/src/asm.S \ |
arch/$(KARCH)/src/exception.c \ |
87,5 → 90,4 |
arch/$(KARCH)/src/ddi/ddi.c \ |
arch/$(KARCH)/src/drivers/msim.c \ |
arch/$(KARCH)/src/drivers/serial.c \ |
arch/$(KARCH)/src/smp/dorder.c \ |
arch/$(KARCH)/src/smp/smp.c |
arch/$(KARCH)/src/smp/order.c |
/branches/dynload/kernel/arch/mips32/src/asm.S |
---|
27,7 → 27,7 |
# |
#include <arch/asm/regname.h> |
.text |
.macro cp0_read reg |
46,11 → 46,6 |
.set noreorder |
.set nomacro |
.global asm_delay_loop |
asm_delay_loop: |
j $31 |
nop |
.global cpu_halt |
cpu_halt: |
j cpu_halt |
/branches/dynload/kernel/arch/mips32/src/mips32.c |
---|
33,6 → 33,7 |
*/ |
#include <arch.h> |
#include <arch/boot.h> |
#include <arch/cp0.h> |
#include <arch/exception.h> |
#include <mm/as.h> |
57,39 → 58,34 |
#include <arch/asm/regname.h> |
/* Size of the code jumping to the exception handler code |
* - J+NOP |
/* Size of the code jumping to the exception handler code |
* - J+NOP |
*/ |
#define EXCEPTION_JUMP_SIZE 8 |
#define EXCEPTION_JUMP_SIZE 8 |
#define TLB_EXC ((char *) 0x80000000) |
#define NORM_EXC ((char *) 0x80000180) |
#define CACHE_EXC ((char *) 0x80000100) |
#define TLB_EXC ((char *) 0x80000000) |
#define NORM_EXC ((char *) 0x80000180) |
#define CACHE_EXC ((char *) 0x80000100) |
/* Why the linker moves the variable 64K away in assembler |
* when not in .text section? |
* when not in .text section ???????? |
*/ |
uintptr_t supervisor_sp __attribute__ ((section (".text"))); |
/* Stack pointer saved when entering user mode */ |
uintptr_t supervisor_sp __attribute__ ((section (".text"))); |
/* TODO: How do we do it on SMP system???? */ |
bootinfo_t bootinfo __attribute__ ((section (".text"))); |
count_t cpu_count = 0; |
void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo) |
void arch_pre_main(void) |
{ |
/* Setup usermode */ |
init.cnt = bootinfo->cnt; |
init.cnt = bootinfo.cnt; |
count_t i; |
for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) { |
init.tasks[i].addr = bootinfo->tasks[i].addr; |
init.tasks[i].size = bootinfo->tasks[i].size; |
} |
uint32_t i; |
for (i = 0; i < CPUMAP_MAX_RECORDS; i++) { |
if ((bootinfo->cpumap & (1 << i)) != 0) |
cpu_count++; |
for (i = 0; i < bootinfo.cnt; i++) { |
init.tasks[i].addr = bootinfo.tasks[i].addr; |
init.tasks[i].size = bootinfo.tasks[i].size; |
} |
} |
141,19 → 137,19 |
fb_init(&gxemul_prop); |
#endif |
#ifdef MACHINE_msim |
#ifdef msim |
sysinfo_set_item_val("machine.msim", NULL, 1); |
#endif |
#ifdef MACHINE_simics |
#ifdef simics |
sysinfo_set_item_val("machine.simics", NULL, 1); |
#endif |
#ifdef MACHINE_bgxemul |
#ifdef bgxemul |
sysinfo_set_item_val("machine.bgxemul", NULL, 1); |
#endif |
#ifdef MACHINE_lgxemul |
#ifdef lgxemul |
sysinfo_set_item_val("machine.lgxemul", NULL, 1); |
#endif |
} |
170,10 → 166,6 |
{ |
} |
void calibrate_delay_loop(void) |
{ |
} |
void userspace(uspace_arg_t *kernel_uarg) |
{ |
/* EXL = 1, UM = 1, IE = 1 */ |
/branches/dynload/kernel/arch/mips32/src/mm/frame.c |
---|
65,9 → 65,7 |
static count_t phys_regions_count = 0; |
static phys_region_t phys_regions[MAX_REGIONS]; |
uintptr_t end_frame = 0; |
/** Check whether frame is available |
* |
* Returns true if given frame is generally available for use. |
77,7 → 75,7 |
*/ |
static bool frame_available(pfn_t frame) |
{ |
#ifdef MACHINE_msim |
#ifdef msim |
/* MSIM device (dprinter) */ |
if (frame == (KA2PA(MSIM_VIDEORAM) >> ZERO_PAGE_WIDTH)) |
return false; |
87,13 → 85,13 |
return false; |
#endif |
#ifdef MACHINE_simics |
#ifdef simics |
/* Simics device (serial line) */ |
if (frame == (KA2PA(SERIAL_ADDRESS) >> ZERO_PAGE_WIDTH)) |
return false; |
#endif |
#if defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul) |
#if defined(lgxemul) || defined(bgxemul) |
/* gxemul devices */ |
if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE, |
0x10000000, MB2SIZE(256))) |
238,10 → 236,8 |
} |
} |
end_frame = frame; |
frame_add_region(start_frame, frame); |
frame_add_region(start_frame, end_frame); |
/* Blacklist interrupt vector frame */ |
frame_mark_unavailable(0, 1); |
/branches/dynload/kernel/arch/mips32/src/mm/tlb.c |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup mips32mm |
/** @addtogroup mips32mm |
* @{ |
*/ |
/** @file |
41,7 → 41,7 |
#include <panic.h> |
#include <arch.h> |
#include <symtab.h> |
#include <synch/mutex.h> |
#include <synch/spinlock.h> |
#include <print.h> |
#include <debug.h> |
#include <align.h> |
92,15 → 92,15 |
uintptr_t badvaddr; |
pte_t *pte; |
int pfrc; |
badvaddr = cp0_badvaddr_read(); |
mutex_lock(&AS->lock); |
spinlock_lock(&AS->lock); |
asid = AS->asid; |
mutex_unlock(&AS->lock); |
spinlock_unlock(&AS->lock); |
page_table_lock(AS, true); |
pte = find_mapping_and_check(badvaddr, PF_ACCESS_READ, istate, &pfrc); |
if (!pte) { |
switch (pfrc) { |
/branches/dynload/kernel/arch/mips32/src/mm/page.c |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup mips32mm |
/** @addtogroup mips32mm |
* @{ |
*/ |
/** @file |
35,7 → 35,6 |
#include <arch/mm/page.h> |
#include <genarch/mm/page_pt.h> |
#include <mm/page.h> |
#include <mm/frame.h> |
void page_arch_init(void) |
{ |
51,11 → 50,5 |
return physaddr + 0xa0000000; |
} |
void hw_area(uintptr_t *physaddr, pfn_t *frames) |
{ |
*physaddr = end_frame; |
*frames = ADDR2PFN(0xffffffff - end_frame); |
} |
/** @} |
*/ |
/branches/dynload/kernel/arch/mips32/src/drivers/msim.c |
---|
41,6 → 41,7 |
#include <sysinfo/sysinfo.h> |
#include <ddi/ddi.h> |
static parea_t msim_parea; |
static chardev_t console; |
static irq_t msim_irq; |
93,7 → 94,7 |
} |
/** Process keyboard interrupt. */ |
static void msim_irq_handler(irq_t *irq) |
static void msim_irq_handler(irq_t *irq, void *arg, ...) |
{ |
if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) |
ipc_irq_send_notif(irq); |
109,7 → 110,7 |
} |
} |
static irq_ownership_t msim_claim(void *instance) |
static irq_ownership_t msim_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
155,6 → 156,12 |
sysinfo_set_item_val("kbd.inr", NULL, MSIM_KBD_IRQ); |
sysinfo_set_item_val("kbd.address.virtual", NULL, MSIM_KBD_ADDRESS); |
msim_parea.pbase = KA2PA(MSIM_VIDEORAM); |
msim_parea.vbase = MSIM_VIDEORAM; |
msim_parea.frames = 1; |
msim_parea.cacheable = false; |
ddi_parea_register(&msim_parea); |
sysinfo_set_item_val("fb", NULL, true); |
sysinfo_set_item_val("fb.kind", NULL, 3); |
sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(MSIM_VIDEORAM)); |
/branches/dynload/kernel/arch/mips32/src/drivers/serial.c |
---|
112,7 → 112,7 |
} |
/** Process keyboard interrupt. Does not work in simics? */ |
static void serial_irq_handler(irq_t *irq) |
static void serial_irq_handler(irq_t *irq, void *arg, ...) |
{ |
if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) |
ipc_irq_send_notif(irq); |
120,7 → 120,7 |
serial_handler(); |
} |
static irq_ownership_t serial_claim(void *instance) |
static irq_ownership_t serial_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
/branches/dynload/kernel/arch/mips32/src/exception.c |
---|
144,7 → 144,7 |
int i; |
/* decode interrupt number and process the interrupt */ |
cause = (cp0_cause_read() >> 8) & 0xff; |
cause = (cp0_cause_read() >> 8) &0xff; |
for (i = 0; i < 8; i++) { |
if (cause & (1 << i)) { |
153,7 → 153,7 |
/* |
* The IRQ handler was found. |
*/ |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
spinlock_unlock(&irq->lock); |
} else { |
/* |
160,8 → 160,7 |
* Spurious interrupt. |
*/ |
#ifdef CONFIG_DEBUG |
printf("cpu%u: spurious interrupt (inum=%d)\n", |
CPU->id, i); |
printf("cpu%u: spurious interrupt (inum=%d)\n", CPU->id, i); |
#endif |
} |
} |
/branches/dynload/kernel/arch/mips32/src/debugger.c |
---|
162,7 → 162,7 |
for (i = 0; i < BKPOINTS_MAX; i++) { |
if (breakpoints[i].address == (uintptr_t)argv->intval) { |
printf("Duplicate breakpoint %d.\n", i); |
spinlock_unlock(&bkpoint_lock); |
spinlock_unlock(&bkpoints_lock); |
return 0; |
} else if (breakpoints[i].address == (uintptr_t)argv->intval + |
sizeof(unative_t) || breakpoints[i].address == |
169,10 → 169,10 |
(uintptr_t)argv->intval - sizeof(unative_t)) { |
printf("Adjacent breakpoints not supported, conflict " |
"with %d.\n", i); |
spinlock_unlock(&bkpoint_lock); |
spinlock_unlock(&bkpoints_lock); |
return 0; |
} |
} |
for (i = 0; i < BKPOINTS_MAX; i++) |
/branches/dynload/kernel/arch/mips32/src/interrupt.c |
---|
41,9 → 41,8 |
#include <ipc/sysipc.h> |
#include <ddi/device.h> |
#define IRQ_COUNT 8 |
#define TIMER_IRQ 7 |
#define DORDER_IRQ 5 |
#define IRQ_COUNT 8 |
#define TIMER_IRQ 7 |
function virtual_timer_fnc = NULL; |
static irq_t timer_irq; |
101,12 → 100,12 |
cp0_compare_write(nextcount); |
} |
static irq_ownership_t timer_claim(void *instance) |
static irq_ownership_t timer_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
static void timer_irq_handler(irq_t *irq) |
static void timer_irq_handler(irq_t *irq, void *arg, ...) |
{ |
unsigned long drift; |
/branches/dynload/kernel/arch/mips32/src/start.S |
---|
31,7 → 31,7 |
#include <arch/asm/boot.h> |
#include <arch/context_offset.h> |
#include <arch/stack.h> |
.text |
.set noat |
75,6 → 75,18 |
mfhi $at |
sw $at, EOFFSET_HI(\r) |
#ifdef CONFIG_DEBUG_ALLREGS |
sw $s0, EOFFSET_S0(\r) |
sw $s1, EOFFSET_S1(\r) |
sw $s2, EOFFSET_S2(\r) |
sw $s3, EOFFSET_S3(\r) |
sw $s4, EOFFSET_S4(\r) |
sw $s5, EOFFSET_S5(\r) |
sw $s6, EOFFSET_S6(\r) |
sw $s7, EOFFSET_S7(\r) |
sw $s8, EOFFSET_S8(\r) |
#endif |
sw $gp, EOFFSET_GP(\r) |
sw $ra, EOFFSET_RA(\r) |
sw $k1, EOFFSET_K1(\r) |
120,6 → 132,17 |
lw $t8, EOFFSET_T8(\r) |
lw $t9, EOFFSET_T9(\r) |
#ifdef CONFIG_DEBUG_ALLREGS |
lw $s0, EOFFSET_S0(\r) |
lw $s1, EOFFSET_S1(\r) |
lw $s2, EOFFSET_S2(\r) |
lw $s3, EOFFSET_S3(\r) |
lw $s4, EOFFSET_S4(\r) |
lw $s5, EOFFSET_S5(\r) |
lw $s6, EOFFSET_S6(\r) |
lw $s7, EOFFSET_S7(\r) |
lw $s8, EOFFSET_S8(\r) |
#endif |
lw $gp, EOFFSET_GP(\r) |
lw $ra, EOFFSET_RA(\r) |
lw $k1, EOFFSET_K1(\r) |
152,9 → 175,9 |
ori $k0, $k0, %lo(supervisor_sp) |
# Move $k0 (superveisor_sp) |
lw $k0, 0($k0) |
1: |
1: |
.endm |
.org 0x0 |
kernel_image_start: |
/* Load temporary stack */ |
161,12 → 184,31 |
lui $sp, %hi(end_stack) |
ori $sp, $sp, %lo(end_stack) |
/* Not sure about this, but might |
be needed for PIC code */ |
/* $a1 contains physical address of bootinfo_t */ |
/* $a2 contains size of bootinfo_t */ |
beq $a2, $0, bootinfo_end |
/* Not sure about this, but might be needed for PIC code???? */ |
lui $gp, 0x8000 |
/* $a1 contains physical address of bootinfo_t */ |
lui $a3, %hi(bootinfo) |
ori $a3, $a3, %lo(bootinfo) |
bootinfo_loop: |
lw $v0, 0($a1) |
sw $v0, 0($a3) |
addi $a1, $a1, 4 |
addi $a3, $a3, 4 |
addi $a2, $a2, -4 |
bgtz $a2, bootinfo_loop |
nop |
bootinfo_end: |
jal arch_pre_main |
nop |
186,8 → 228,8 |
exception_entry: |
j exception_handler |
nop |
nop |
exception_handler: |
KERNEL_STACK_TO_K0 |
sub $k0, REGISTER_SPACE |
196,17 → 238,17 |
mfc0 $k0, $cause |
sra $k0, $k0, 0x2 # cp0_exc_cause() part 1 |
andi $k0, $k0, 0x1f # cp0_exc_cause() part 2 |
sub $k0, 8 # 8 = SYSCALL |
sra $k0, $k0, 0x2 # cp0_exc_cause() part 1 |
andi $k0, $k0, 0x1f # cp0_exc_cause() part 2 |
sub $k0, 8 # 8 = SYSCALL |
beqz $k0, syscall_shortcut |
add $k0, 8 # Revert $k0 back to correct exc number |
add $k0, 8 # Revert $k0 back to correct exc number |
REGISTERS_STORE_AND_EXC_RESET $sp |
move $a1, $sp |
jal exc_dispatch # exc_dispatch(excno, register_space) |
jal exc_dispatch # exc_dispatch(excno, register_space) |
move $a0, $k0 |
REGISTERS_LOAD $sp |
/branches/dynload/kernel/arch/mips32/src/smp/dorder.c |
---|
File deleted |
/branches/dynload/kernel/arch/mips32/src/smp/smp.c |
---|
File deleted |
/branches/dynload/kernel/arch/mips32/src/smp/order.c |
---|
0,0 → 1,45 |
/* |
* Copyright (c) 2007 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup mips32 |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/smp/order.h> |
#define MSIM_ORDER_ADDRESS 0xB0000004 |
void ipi_broadcast_arch(int ipi) |
{ |
*((volatile unsigned int *) MSIM_ORDER_ADDRESS) = 0x7FFFFFFF; |
} |
/** @} |
*/ |
/branches/dynload/kernel/arch/mips32/src/dummy.S |
---|
0,0 → 1,41 |
# |
# Copyright (c) 2003-2004 Jakub Jermar |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions |
# are met: |
# |
# - Redistributions of source code must retain the above copyright |
# notice, this list of conditions and the following disclaimer. |
# - Redistributions in binary form must reproduce the above copyright |
# notice, this list of conditions and the following disclaimer in the |
# documentation and/or other materials provided with the distribution. |
# - The name of the author may not be used to endorse or promote products |
# derived from this software without specific prior written permission. |
# |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
.text |
.set noat |
.global calibrate_delay_loop |
.global asm_delay_loop |
.global dummy |
calibrate_delay_loop: |
asm_delay_loop: |
dummy: |
j $31 |
nop |
/branches/dynload/kernel/arch/mips32/_link.ld.in |
---|
1,17 → 1,15 |
/* |
* MIPS32 linker script |
* |
* MIPS32 linker script |
* |
* kernel text |
* kernel data |
* |
* |
*/ |
#undef mips |
#define mips mips |
#define KERNEL_LOAD_ADDRESS 0x80100000 |
OUTPUT_ARCH(mips) |
OUTPUT_ARCH(mips) |
ENTRY(kernel_image_start) |
SECTIONS { |
23,9 → 21,9 |
} |
.data : { |
kdata_start = .; |
*(.data); /* initialized data */ |
*(.data); /* initialized data */ |
hardcoded_ktext_size = .; |
LONG(ktext_end - ktext_start); |
LONG(ktext_end - ktext_start); |
hardcoded_kdata_size = .; |
LONG(kdata_end - kdata_start); |
hardcoded_load_address = .; |
35,21 → 33,21 |
*(.reginfo); |
*(.sbss); |
*(.scommon); |
*(.bss); /* uninitialized static variables */ |
*(COMMON); /* global variables */ |
*(.bss); /* uninitialized static variables */ |
*(COMMON); /* global variables */ |
symbol_table = .; |
*(symtab.*); |
*(symtab.*); |
} |
_gp = . + 0x8000; |
.lit8 : { *(.lit8) } |
.lit4 : { *(.lit4) } |
kdata_end = .; |
/DISCARD/ : { |
*(.mdebug*); |
*(.pdr); |
*(.comment); |
*(.note); |
*(.mdebug*); |
*(.pdr); |
*(.comment); |
*(.note); |
} |
} |
/branches/dynload/kernel/arch/ia32/include/drivers/i8042.h |
---|
47,22 → 47,22 |
static inline void i8042_data_write(uint8_t data) |
{ |
pio_write_8(i8042_DATA, data); |
outb(i8042_DATA, data); |
} |
static inline uint8_t i8042_data_read(void) |
{ |
return pio_read_8(i8042_DATA); |
return inb(i8042_DATA); |
} |
static inline uint8_t i8042_status_read(void) |
{ |
return pio_read_8(i8042_STATUS); |
return inb(i8042_STATUS); |
} |
static inline void i8042_command_write(uint8_t command) |
{ |
pio_write_8(i8042_STATUS, command); |
outb(i8042_STATUS, command); |
} |
#endif |
/branches/dynload/kernel/arch/ia32/include/mm/frame.h |
---|
44,7 → 44,6 |
#include <arch/types.h> |
extern uintptr_t last_frame; |
extern uintptr_t end_frame; |
extern void frame_arch_init(void); |
extern void physmem_print(void); |
/branches/dynload/kernel/arch/ia32/include/barrier.h |
---|
69,7 → 69,7 |
#endif |
} |
#if defined(CONFIG_FENCES_P4) |
#ifdef CONFIG_FENCES_P4 |
# define memory_barrier() asm volatile ("mfence\n" ::: "memory") |
# define read_barrier() asm volatile ("lfence\n" ::: "memory") |
# ifdef CONFIG_WEAK_MEMORY |
77,7 → 77,7 |
# else |
# define write_barrier() asm volatile( "" ::: "memory"); |
# endif |
#elif defined(CONFIG_FENCES_P3) |
#elif CONFIG_FENCES_P3 |
# define memory_barrier() cpuid_serialization() |
# define read_barrier() cpuid_serialization() |
# ifdef CONFIG_WEAK_MEMORY |
/branches/dynload/kernel/arch/ia32/include/asm.h |
---|
105,7 → 105,7 |
* @param port Port to write to |
* @param val Value to write |
*/ |
static inline void pio_write_8(uint16_t port, uint8_t val) |
static inline void outb(uint16_t port, uint8_t val) |
{ |
asm volatile ("outb %b0, %w1\n" : : "a" (val), "d" (port) ); |
} |
117,7 → 117,7 |
* @param port Port to write to |
* @param val Value to write |
*/ |
static inline void pio_write_16(uint16_t port, uint16_t val) |
static inline void outw(uint16_t port, uint16_t val) |
{ |
asm volatile ("outw %w0, %w1\n" : : "a" (val), "d" (port) ); |
} |
129,7 → 129,7 |
* @param port Port to write to |
* @param val Value to write |
*/ |
static inline void pio_write_32(uint16_t port, uint32_t val) |
static inline void outl(uint16_t port, uint32_t val) |
{ |
asm volatile ("outl %l0, %w1\n" : : "a" (val), "d" (port) ); |
} |
141,7 → 141,7 |
* @param port Port to read from |
* @return Value read |
*/ |
static inline uint8_t pio_read_8(uint16_t port) |
static inline uint8_t inb(uint16_t port) |
{ |
uint8_t val; |
156,7 → 156,7 |
* @param port Port to read from |
* @return Value read |
*/ |
static inline uint16_t pio_read_16(uint16_t port) |
static inline uint16_t inw(uint16_t port) |
{ |
uint16_t val; |
171,7 → 171,7 |
* @param port Port to read from |
* @return Value read |
*/ |
static inline uint32_t pio_read_32(uint16_t port) |
static inline uint32_t inl(uint16_t port) |
{ |
uint32_t val; |
/branches/dynload/kernel/arch/ia32/include/interrupt.h |
---|
72,6 → 72,10 |
uint32_t eax; |
uint32_t ecx; |
uint32_t edx; |
uint32_t esi; |
uint32_t edi; |
uint32_t ebp; |
uint32_t ebx; |
uint32_t gs; |
uint32_t fs; |
/branches/dynload/kernel/arch/ia32/src/smp/smp.c |
---|
122,8 → 122,8 |
* Save 0xa to address 0xf of the CMOS RAM. |
* BIOS will not do the POST after the INIT signal. |
*/ |
pio_write_8(0x70, 0xf); |
pio_write_8(0x71, 0xa); |
outb(0x70, 0xf); |
outb(0x71, 0xa); |
pic_disable_irqs(0xffff); |
apic_init(); |
/branches/dynload/kernel/arch/ia32/src/smp/apic.c |
---|
132,12 → 132,12 |
#endif |
} |
static irq_ownership_t l_apic_timer_claim(void *instance) |
static irq_ownership_t l_apic_timer_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
static void l_apic_timer_irq_handler(irq_t *irq) |
static void l_apic_timer_irq_handler(irq_t *irq, void *arg __attribute__((unused)), ...) |
{ |
/* |
* Holding a spinlock could prevent clock() from preempting |
/branches/dynload/kernel/arch/ia32/src/mm/page.c |
---|
93,12 → 93,6 |
return virtaddr; |
} |
void hw_area(uintptr_t *physaddr, pfn_t *frames) |
{ |
*physaddr = end_frame; |
*frames = ADDR2PFN(0xffffffff - end_frame); |
} |
void page_fault(int n __attribute__((unused)), istate_t *istate) |
{ |
uintptr_t page; |
108,7 → 102,7 |
if (istate->error_word & PFERR_CODE_RSVD) |
panic("Reserved bit set in page directory."); |
if (istate->error_word & PFERR_CODE_RW) |
access = PF_ACCESS_WRITE; |
else |
/branches/dynload/kernel/arch/ia32/src/mm/frame.c |
---|
50,7 → 50,6 |
size_t hardcoded_unmapped_kdata_size = 0; |
uintptr_t last_frame = 0; |
uintptr_t end_frame = 0; |
static void init_e820_memory(pfn_t minconf) |
{ |
74,10 → 73,8 |
e820table[i].size, FRAME_SIZE)) |
last_frame = |
ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE); |
} |
} |
} |
end_frame = last_frame; |
} |
static char *e820names[] = { |
116,14 → 113,16 |
if (config.cpu_active == 1) { |
minconf = 1; |
#ifdef CONFIG_SMP |
minconf = max(minconf, |
ADDR2PFN(AP_BOOT_OFFSET + hardcoded_unmapped_ktext_size + |
hardcoded_unmapped_kdata_size)); |
#endif |
#ifdef CONFIG_SIMICS_FIX |
minconf = max(minconf, ADDR2PFN(0x10000)); |
#endif |
init_e820_memory(minconf); |
/* Reserve frame 0 (BIOS data) */ |
frame_mark_unavailable(0, 1); |
132,7 → 131,12 |
frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, |
(hardcoded_unmapped_ktext_size + |
hardcoded_unmapped_kdata_size) >> FRAME_WIDTH); |
#ifdef CONFIG_SIMICS_FIX |
/* Don't know why, but these addresses help */ |
frame_mark_unavailable(0xd000 >> FRAME_WIDTH, 3); |
#endif |
#endif |
} |
} |
/branches/dynload/kernel/arch/ia32/src/interrupt.c |
---|
77,6 → 77,9 |
printf("ERROR_WORD=%#lx\n", istate->error_word); |
printf("%%cs=%#lx,flags=%#lx\n", istate->cs, istate->eflags); |
printf("%%eax=%#lx, %%ecx=%#lx, %%edx=%#lx, %%esp=%p\n", istate->eax, istate->ecx, istate->edx, &istate->stack[0]); |
#ifdef CONFIG_DEBUG_ALLREGS |
printf("%%esi=%#lx, %%edi=%#lx, %%ebp=%#lx, %%ebx=%#lx\n", istate->esi, istate->edi, istate->ebp, istate->ebx); |
#endif |
printf("stack: %#lx, %#lx, %#lx, %#lx\n", istate->stack[0], istate->stack[1], istate->stack[2], istate->stack[3]); |
printf(" %#lx, %#lx, %#lx, %#lx\n", istate->stack[4], istate->stack[5], istate->stack[6], istate->stack[7]); |
} |
188,7 → 191,7 |
trap_virtual_eoi(); |
ack = true; |
} |
irq->handler(irq); |
irq->handler(irq, irq->arg); |
spinlock_unlock(&irq->lock); |
} else { |
/* |
/branches/dynload/kernel/arch/ia32/src/drivers/i8259.c |
---|
49,28 → 49,28 |
void i8259_init(void) |
{ |
/* ICW1: this is ICW1, ICW4 to follow */ |
pio_write_8(PIC_PIC0PORT1, PIC_ICW1 | PIC_NEEDICW4); |
outb(PIC_PIC0PORT1, PIC_ICW1 | PIC_NEEDICW4); |
/* ICW2: IRQ 0 maps to INT IRQBASE */ |
pio_write_8(PIC_PIC0PORT2, IVT_IRQBASE); |
outb(PIC_PIC0PORT2, IVT_IRQBASE); |
/* ICW3: pic1 using IRQ IRQ_PIC1 */ |
pio_write_8(PIC_PIC0PORT2, 1 << IRQ_PIC1); |
outb(PIC_PIC0PORT2, 1 << IRQ_PIC1); |
/* ICW4: i8086 mode */ |
pio_write_8(PIC_PIC0PORT2, 1); |
outb(PIC_PIC0PORT2, 1); |
/* ICW1: ICW1, ICW4 to follow */ |
pio_write_8(PIC_PIC1PORT1, PIC_ICW1 | PIC_NEEDICW4); |
outb(PIC_PIC1PORT1, PIC_ICW1 | PIC_NEEDICW4); |
/* ICW2: IRQ 8 maps to INT (IVT_IRQBASE + 8) */ |
pio_write_8(PIC_PIC1PORT2, IVT_IRQBASE + 8); |
outb(PIC_PIC1PORT2, IVT_IRQBASE + 8); |
/* ICW3: pic1 is known as IRQ_PIC1 */ |
pio_write_8(PIC_PIC1PORT2, IRQ_PIC1); |
outb(PIC_PIC1PORT2, IRQ_PIC1); |
/* ICW4: i8086 mode */ |
pio_write_8(PIC_PIC1PORT2, 1); |
outb(PIC_PIC1PORT2, 1); |
/* |
* Register interrupt handler for the PIC spurious interrupt. |
94,12 → 94,12 |
uint8_t x; |
if (irqmask & 0xff) { |
x = pio_read_8(PIC_PIC0PORT2); |
pio_write_8(PIC_PIC0PORT2, (uint8_t) (x & (~(irqmask & 0xff)))); |
x = inb(PIC_PIC0PORT2); |
outb(PIC_PIC0PORT2, (uint8_t) (x & (~(irqmask & 0xff)))); |
} |
if (irqmask >> 8) { |
x = pio_read_8(PIC_PIC1PORT2); |
pio_write_8(PIC_PIC1PORT2, (uint8_t) (x & (~(irqmask >> 8)))); |
x = inb(PIC_PIC1PORT2); |
outb(PIC_PIC1PORT2, (uint8_t) (x & (~(irqmask >> 8)))); |
} |
} |
108,19 → 108,19 |
uint8_t x; |
if (irqmask & 0xff) { |
x = pio_read_8(PIC_PIC0PORT2); |
pio_write_8(PIC_PIC0PORT2, (uint8_t) (x | (irqmask & 0xff))); |
x = inb(PIC_PIC0PORT2); |
outb(PIC_PIC0PORT2, (uint8_t) (x | (irqmask & 0xff))); |
} |
if (irqmask >> 8) { |
x = pio_read_8(PIC_PIC1PORT2); |
pio_write_8(PIC_PIC1PORT2, (uint8_t) (x | (irqmask >> 8))); |
x = inb(PIC_PIC1PORT2); |
outb(PIC_PIC1PORT2, (uint8_t) (x | (irqmask >> 8))); |
} |
} |
void pic_eoi(void) |
{ |
pio_write_8(0x20, 0x20); |
pio_write_8(0xa0, 0x20); |
outb(0x20, 0x20); |
outb(0xa0, 0x20); |
} |
void pic_spurious(int n __attribute__((unused)), istate_t *istate __attribute__((unused))) |
/branches/dynload/kernel/arch/ia32/src/drivers/i8254.c |
---|
61,12 → 61,12 |
static irq_t i8254_irq; |
static irq_ownership_t i8254_claim(void *instance) |
static irq_ownership_t i8254_claim(void) |
{ |
return IRQ_ACCEPT; |
} |
static void i8254_irq_handler(irq_t *irq) |
static void i8254_irq_handler(irq_t *irq, void *arg __attribute__((unused)), ...) |
{ |
/* |
* This IRQ is responsible for kernel preemption. |
94,10 → 94,10 |
void i8254_normal_operation(void) |
{ |
pio_write_8(CLK_PORT4, 0x36); |
outb(CLK_PORT4, 0x36); |
pic_disable_irqs(1 << IRQ_CLK); |
pio_write_8(CLK_PORT1, (CLK_CONST / HZ) & 0xf); |
pio_write_8(CLK_PORT1, (CLK_CONST / HZ) >> 8); |
outb(CLK_PORT1, (CLK_CONST / HZ) & 0xf); |
outb(CLK_PORT1, (CLK_CONST / HZ) >> 8); |
pic_enable_irqs(1 << IRQ_CLK); |
} |
114,36 → 114,36 |
* One-shot timer. Count-down from 0xffff at 1193180Hz |
* MAGIC_NUMBER is the magic value for 1ms. |
*/ |
pio_write_8(CLK_PORT4, 0x30); |
pio_write_8(CLK_PORT1, 0xff); |
pio_write_8(CLK_PORT1, 0xff); |
outb(CLK_PORT4, 0x30); |
outb(CLK_PORT1, 0xff); |
outb(CLK_PORT1, 0xff); |
do { |
/* will read both status and count */ |
pio_write_8(CLK_PORT4, 0xc2); |
not_ok = (uint8_t) ((pio_read_8(CLK_PORT1) >> 6) & 1); |
t1 = pio_read_8(CLK_PORT1); |
t1 |= pio_read_8(CLK_PORT1) << 8; |
outb(CLK_PORT4, 0xc2); |
not_ok = (uint8_t) ((inb(CLK_PORT1) >> 6) & 1); |
t1 = inb(CLK_PORT1); |
t1 |= inb(CLK_PORT1) << 8; |
} while (not_ok); |
asm_delay_loop(LOOPS); |
pio_write_8(CLK_PORT4, 0xd2); |
t2 = pio_read_8(CLK_PORT1); |
t2 |= pio_read_8(CLK_PORT1) << 8; |
outb(CLK_PORT4, 0xd2); |
t2 = inb(CLK_PORT1); |
t2 |= inb(CLK_PORT1) << 8; |
/* |
* We want to determine the overhead of the calibrating mechanism. |
*/ |
pio_write_8(CLK_PORT4, 0xd2); |
o1 = pio_read_8(CLK_PORT1); |
o1 |= pio_read_8(CLK_PORT1) << 8; |
outb(CLK_PORT4, 0xd2); |
o1 = inb(CLK_PORT1); |
o1 |= inb(CLK_PORT1) << 8; |
asm_fake_loop(LOOPS); |
pio_write_8(CLK_PORT4, 0xd2); |
o2 = pio_read_8(CLK_PORT1); |
o2 |= pio_read_8(CLK_PORT1) << 8; |
outb(CLK_PORT4, 0xd2); |
o2 = inb(CLK_PORT1); |
o2 |= inb(CLK_PORT1) << 8; |
CPU->delay_loop_const = |
((MAGIC_NUMBER * LOOPS) / 1000) / ((t1 - t2) - (o1 - o2)) + |
/branches/dynload/kernel/arch/ia32/src/asm.S |
---|
268,6 → 268,14 |
pushl %fs |
pushl %gs |
#ifdef CONFIG_DEBUG_ALLREGS |
pushl %ebx |
pushl %ebp |
pushl %edi |
pushl %esi |
#else |
subl $16, %esp |
#endif |
pushl %edx |
pushl %ecx |
pushl %eax |
289,6 → 297,14 |
popl %eax |
popl %ecx |
popl %edx |
#ifdef CONFIG_DEBUG_ALLREGS |
popl %esi |
popl %edi |
popl %ebp |
popl %ebx |
#else |
addl $16, %esp |
#endif |
popl %gs |
popl %fs |
/branches/dynload/kernel/arch/ia32/src/proc/scheduler.c |
---|
38,6 → 38,7 |
#include <proc/thread.h> |
#include <arch.h> |
#include <arch/context.h> /* SP_DELTA */ |
#include <arch/debugger.h> |
#include <arch/pm.h> |
#include <arch/asm.h> |
#include <arch/ddi/ddi.h> |
69,6 → 70,15 |
/* Set up TLS in GS register */ |
set_tls_desc(THREAD->arch.tls); |
#ifdef CONFIG_DEBUG_AS_WATCHPOINT |
/* Set watchpoint on AS to ensure that nobody sets it to zero */ |
if (CPU->id < BKPOINTS_MAX) { |
the_t *the = THE; |
breakpoint_add(&((the_t *) the->thread->kstack)->as, |
BKPOINT_WRITE | BKPOINT_CHECK_ZERO, the->cpu->id); |
} |
#endif |
} |
void after_thread_ran_arch(void) |
/branches/dynload/tools/config.py |
---|
54,7 → 54,7 |
inf.close() |
def check_condition(text, defaults, ask_names): |
"Check that the condition specified on input line is True (only CNF and DNF is supported)" |
"Check for condition" |
ctype = 'cnf' |
83,7 → 83,7 |
return False |
def check_inside(text, defaults, ctype): |
"Check for condition" |
"Check that the condition specified on input line is True (only CNF is supported)" |
if (ctype == 'cnf'): |
conds = text.split('|') |
257,8 → 257,8 |
outmc.write('/* %s */\n#define %s\n\n' % (name, varname)) |
outdf.write(' -D%s' % varname) |
else: |
outmc.write('/* %s */\n#define %s %s\n#define %s_%s\n\n' % (name, varname, default, varname, default)) |
outdf.write(' -D%s=%s -D%s_%s' % (varname, default, varname, default)) |
outmc.write('/* %s */\n#define %s %s\n\n' % (name, varname, default)) |
outdf.write(' -D%s=%s' % (varname, default)) |
outmk.write('REVISION = %s\n' % revision) |
outmk.write('TIMESTAMP = %s\n' % timestamp) |
300,11 → 300,6 |
selname = None |
while True: |
# Cancel out all defaults which have to be deduced |
for varname, vartype, name, choices, cond in ask_names: |
if (vartype == 'y'): |
defaults[varname] = None |
options = [] |
opt2row = {} |
position = None |
/branches/dynload/uspace/app/tetris/input.c |
---|
114,7 → 114,7 |
if (!getchar_inprog) { |
cons_phone = get_cons_phone(); |
getchar_inprog = async_send_2(cons_phone, |
CONSOLE_GETKEY, 0, 0, &charcall); |
CONSOLE_GETCHAR, 0, 0, &charcall); |
} |
if (!s) |
async_wait_for(getchar_inprog, &rc); |
127,7 → 127,7 |
if (rc) { |
stop("end of file, help"); |
} |
lastchar = IPC_GET_ARG4(charcall); |
lastchar = IPC_GET_ARG1(charcall); |
} |
if (tvp) { |
/* since there is input, we may not have timed out */ |
/branches/dynload/uspace/app/trace/trace.c |
---|
519,7 → 519,7 |
int rc; |
/* Spawn a program loader */ |
ldr = loader_connect(); |
ldr = loader_spawn(path); |
if (ldr == NULL) |
return 0; |
623,7 → 623,7 |
V_INTEGER, |
V_INTEGER, |
V_INTEGER, |
V_INTEGER |
V_INTEGER |
}; |
next_thread_id = 1; |
658,10 → 658,9 |
proto_register(SERVICE_VFS, p); |
p = proto_new("console"); |
resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; |
resp_def[2] = V_INTEGER; resp_def[3] = V_CHAR; |
o = oper_new("getkey", 0, arg_def, V_ERRNO, 4, resp_def); |
proto_add_oper(p, CONSOLE_GETKEY, o); |
resp_def[0] = V_CHAR; |
o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def); |
proto_add_oper(p, CONSOLE_GETCHAR, o); |
arg_def[0] = V_CHAR; |
o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def); |
/branches/dynload/uspace/lib/libc/include/kbd/kbd.h |
---|
File deleted |
/branches/dynload/uspace/lib/libc/include/kbd/keycode.h |
---|
File deleted |
/branches/dynload/uspace/lib/libc/include/ipc/console.h |
---|
38,7 → 38,7 |
#include <ipc/ipc.h> |
typedef enum { |
CONSOLE_GETKEY = IPC_FIRST_USER_METHOD, |
CONSOLE_GETCHAR = IPC_FIRST_USER_METHOD, |
CONSOLE_PUTCHAR, |
CONSOLE_CLEAR, |
CONSOLE_GOTO, |
/branches/dynload/uspace/lib/libc/include/ipc/services.h |
---|
38,8 → 38,7 |
#define LIBIPC_SERVICES_H_ |
typedef enum { |
SERVICE_LOAD = 1, |
SERVICE_PCI, |
SERVICE_PCI = 1, |
SERVICE_KEYBOARD, |
SERVICE_VIDEO, |
SERVICE_CONSOLE, |
/branches/dynload/uspace/lib/libc/include/loader/loader.h |
---|
44,8 → 44,7 |
int phone_id; |
} loader_t; |
extern int loader_spawn(const char *); |
extern loader_t *loader_connect(void); |
extern loader_t *loader_spawn(const char *name); |
extern int loader_get_task_id(loader_t *, task_id_t *); |
extern int loader_set_pathname(loader_t *, const char *); |
extern int loader_set_args(loader_t *, char *const []); |
/branches/dynload/uspace/lib/libc/Makefile |
---|
84,7 → 84,6 |
generic/time.c \ |
generic/err.c \ |
generic/stdlib.c \ |
generic/kbd.c \ |
generic/mman.c \ |
generic/udebug.c \ |
generic/vfs/vfs.c \ |
/branches/dynload/uspace/lib/libc/generic/kbd.c |
---|
File deleted |
/branches/dynload/uspace/lib/libc/generic/io/stream.c |
---|
43,7 → 43,6 |
#include <ipc/fb.h> |
#include <ipc/services.h> |
#include <ipc/console.h> |
#include <kbd/kbd.h> |
#include <unistd.h> |
#include <async.h> |
#include <sys/types.h> |
59,17 → 58,13 |
{ |
open_console(); |
if (console_phone >= 0) { |
kbd_event_t ev; |
int rc; |
ipcarg_t r0, r1; |
size_t i = 0; |
while (i < count) { |
do { |
rc = kbd_get_event(&ev); |
if (rc < 0) return -1; |
} while (ev.c == 0 || ev.type == KE_RELEASE); |
((char *) buf)[i++] = ev.c; |
if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0, &r1) < 0) |
return -1; |
((char *) buf)[i++] = r0; |
} |
return i; |
} else { |
/branches/dynload/uspace/lib/libc/generic/loader.c |
---|
34,7 → 34,6 |
#include <ipc/ipc.h> |
#include <ipc/loader.h> |
#include <ipc/services.h> |
#include <libc.h> |
#include <task.h> |
#include <string.h> |
51,27 → 50,33 |
* @return Pointer to the loader connection structure (should be |
* de-allocated using free() after use). |
*/ |
int loader_spawn(const char *name) |
loader_t *loader_spawn(const char *name) |
{ |
return __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER, |
(sysarg_t) name, strlen(name)); |
} |
loader_t *loader_connect(void) |
{ |
int phone_id, rc; |
loader_t *ldr; |
int phone_id; |
phone_id = ipc_connect_me_to(PHONE_NS, SERVICE_LOAD, 0, 0); |
if (phone_id < 0) |
/* |
* Ask kernel to spawn a new loader task. |
*/ |
rc = __SYSCALL3(SYS_PROGRAM_SPAWN_LOADER, (sysarg_t) &phone_id, |
(sysarg_t) name, strlen(name)); |
if (rc != 0) |
return NULL; |
/* |
* Say hello so that the loader knows the incoming connection's |
* phone hash. |
*/ |
rc = async_req_0_0(phone_id, LOADER_HELLO); |
if (rc != EOK) |
return NULL; |
ldr = malloc(sizeof(loader_t)); |
if (ldr == NULL) |
return NULL; |
ldr->phone_id = phone_id; |
return ldr; |
return ldr; |
} |
/** Get ID of the new task. |
/branches/dynload/uspace/lib/libc/generic/task.c |
---|
63,8 → 63,8 |
task_id_t task_id; |
int rc; |
/* Connect to a program loader. */ |
ldr = loader_connect(); |
/* Spawn a program loader. */ |
ldr = loader_spawn(path); |
if (ldr == NULL) |
return 0; |
89,6 → 89,7 |
goto error; |
/* Run it. */ |
/* Load the program. */ |
rc = loader_run(ldr); |
if (rc != EOK) |
goto error; |
/branches/dynload/uspace/srv/kbd/layout/us_qwerty.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/layout/us_dvorak.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/ctl/pc.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/ctl/stty.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/ctl/sun.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/ctl/gxe_fb.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/msim.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/i8042.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/z8530.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/sgcn.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/dummy.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/i8042.h |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/gxemul.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/port/ns16550.c |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/Makefile |
---|
46,72 → 46,53 |
generic/kbd.c \ |
generic/key_buffer.c |
ARCH_SOURCES = |
GENARCH_SOURCES = |
ARCH_SOURCES = \ |
arch/$(UARCH)/src/kbd.c |
ifeq ($(KBD_LAYOUT), us_qwerty) |
GENARCH_SOURCES += layout/us_qwerty.c |
endif |
ifeq ($(KBD_LAYOUT), us_dvorak) |
GENARCH_SOURCES += layout/us_dvorak.c |
endif |
ifeq ($(UARCH), amd64) |
GENARCH_SOURCES += \ |
port/i8042.c \ |
ctl/pc.c |
endif |
ifeq ($(UARCH), arm32) |
GENARCH_SOURCES += \ |
port/gxemul.c |
ifeq ($(CONFIG_FB), y) |
GENARCH_SOURCES += \ |
ctl/gxe_fb.c |
else |
GENARCH_SOURCES += \ |
ctl/stty.c |
endif |
endif |
ifeq ($(UARCH), ia32) |
GENARCH_SOURCES += \ |
port/i8042.c \ |
ctl/pc.c |
ARCH_SOURCES += \ |
arch/$(UARCH)/src/mouse.c \ |
arch/$(UARCH)/src/scanc.c |
GENARCH_SOURCES = \ |
genarch/src/kbd.c |
CFLAGS += -DMOUSE_ENABLED |
endif |
ifeq ($(UARCH), ia64) |
GENARCH_SOURCES += \ |
port/dummy.c \ |
ctl/stty.c |
ARCH_SOURCES += \ |
arch/$(UARCH)/src/mouse.c \ |
arch/$(UARCH)/src/scanc.c \ |
arch/$(UARCH)/src/lkbd.c |
GENARCH_SOURCES = \ |
genarch/src/kbd.c |
CFLAGS += -DMOUSE_ENABLED |
endif |
ifeq ($(MACHINE), msim) |
GENARCH_SOURCES += \ |
port/msim.c \ |
ctl/stty.c |
ifeq ($(UARCH), amd64) |
ARCH_SOURCES += \ |
arch/$(UARCH)/src/mouse.c \ |
arch/$(UARCH)/src/scanc.c |
GENARCH_SOURCES = \ |
genarch/src/kbd.c |
CFLAGS += -DMOUSE_ENABLED |
endif |
ifeq ($(MACHINE), lgxemul) |
GENARCH_SOURCES += \ |
port/gxemul.c |
ifeq ($(CONFIG_FB), y) |
GENARCH_SOURCES += \ |
ctl/gxe_fb.c |
else |
GENARCH_SOURCES += \ |
ctl/stty.c |
endif |
ifeq ($(UARCH), sparc64) |
ARCH_SOURCES += \ |
arch/$(UARCH)/src/scanc.c \ |
arch/$(UARCH)/src/sgcn.c |
GENARCH_SOURCES = \ |
genarch/src/kbd.c \ |
genarch/src/nofb.c |
endif |
ifeq ($(MACHINE), bgxemul) |
GENARCH_SOURCES += \ |
port/gxemul.c \ |
ctl/stty.c |
ifeq ($(UARCH), arm32) |
ARCH_SOURCES += \ |
arch/$(UARCH)/src/kbd_gxemul.c |
endif |
ifeq ($(UARCH), ppc32) |
ifeq ($(UARCH), mips32) |
GENARCH_SOURCES += \ |
port/dummy.c \ |
ctl/stty.c |
genarch/src/nofb.c |
endif |
ifeq ($(UARCH), sparc64) |
ifeq ($(UARCH), mips32eb) |
GENARCH_SOURCES += \ |
port/z8530.c \ |
ctl/sun.c |
genarch/src/nofb.c |
endif |
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) |
/branches/dynload/uspace/srv/kbd/arch/ia64/src/kbd.c |
---|
0,0 → 1,392 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia64 ia64 |
* @brief HelenOS ia64 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/kbd.h> |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <align.h> |
#include <async.h> |
#include <ipc/ipc.h> |
#include <errno.h> |
#include <stdio.h> |
#include <ddi.h> |
#include <sysinfo.h> |
#include <as.h> |
#include <ipc/fb.h> |
#include <ipc/ipc.h> |
#include <ipc/ns.h> |
#include <ipc/services.h> |
#include <libarch/ddi.h> |
extern int lkbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call); |
extern int lkbd_arch_init(void); |
#define KEY_F1 0x504f1b |
#define KEY_F2 0x514f1b |
#define KEY_F3 0x524f1b |
#define KEY_F4 0x534f1b |
#define KEY_F5 0x7e35315b1b |
#define KEY_F6 0x7e37315b1b |
#define KEY_F7 0x7e38315b1b |
#define KEY_F8 0x7e39315b1b |
#define KEY_F9 0x7e30325b1b |
#define KEY_F10 0x7e31325b1b |
#define KEY_F11 0x7e33325b1b |
#define KEY_F12 0x7e34325b1b |
#define NSKEY_F1 0x415b5b1b |
#define NSKEY_F2 0x425b5b1b |
#define NSKEY_F3 0x435b5b1b |
#define NSKEY_F4 0x445b5b1b |
#define NSKEY_F5 0x455b5b1b |
#define NSKEY_F6 0x37315b1b |
#define NSKEY_F7 0x38315b1b |
#define NSKEY_F8 0x39315b1b |
#define NSKEY_F9 0x30325b1b |
#define NSKEY_F10 0x31325b1b |
#define NSKEY_F11 0x33325b1b |
#define NSKEY_F12 0x34325b1b |
#define FUNCTION_KEYS 0x100 |
#define KBD_SKI 1 |
#define KBD_LEGACY 2 |
#define KBD_NS16550 3 |
/* NS16550 registers */ |
#define RBR_REG 0 /** Receiver Buffer Register. */ |
#define IER_REG 1 /** Interrupt Enable Register. */ |
#define IIR_REG 2 /** Interrupt Ident Register (read). */ |
#define FCR_REG 2 /** FIFO control register (write). */ |
#define LCR_REG 3 /** Line Control register. */ |
#define MCR_REG 4 /** Modem Control Register. */ |
#define LSR_REG 5 /** Line Status Register. */ |
irq_cmd_t ns16550_cmds[1] = { |
{ CMD_PORT_READ_1, 0, 0, 2 }, |
}; |
irq_code_t ns16550_kbd = { |
1, |
ns16550_cmds |
}; |
uint16_t ns16550_port; |
int kbd_type; |
int kbd_arch_init(void) |
{ |
if (sysinfo_value("kbd")) { |
kbd_type=sysinfo_value("kbd.type"); |
if (kbd_type == KBD_LEGACY) |
return lkbd_arch_init(); |
if (kbd_type == KBD_NS16550) { |
ns16550_kbd.cmds[0].addr = (void *) (sysinfo_value("kbd.port") + RBR_REG); |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ns16550_kbd); |
iospace_enable(task_get_id(), ns16550_port = sysinfo_value("kbd.port"), 8); |
} |
return 0; |
} |
return 1; |
} |
/* |
* Please preserve this code (it can be used to determine scancodes) |
* |
int to_hex(int v) |
{ |
return "0123456789ABCDEF"[v]; |
} |
*/ |
#define LSR_DATA_READY 0x01 |
int kbd_ns16550_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
static unsigned long buf = 0; |
static int count = 0, esc_count=0; |
int scan_code = IPC_GET_ARG2(*call); |
if (scan_code == 0x1b) { |
esc_count++; |
if (esc_count == 3) { |
__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); |
} |
} else { |
esc_count = 0; |
} |
if (scan_code == 0x0d) |
return 1; /* Delete CR */ |
if (scan_code == 0x7f) |
scan_code='\b'; /* Convert backspace */ |
if(scan_code == 0x7e) { |
switch (buf) { |
case NSKEY_F6: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 6); |
buf = count = 0; |
return 1; |
case NSKEY_F7: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 7); |
buf = count = 0; |
return 1; |
case NSKEY_F8: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 8); |
buf = count = 0; |
return 1; |
case NSKEY_F9: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 9); |
buf = count = 0; |
return 1; |
case NSKEY_F10: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 10); |
buf = count = 0; |
return 1; |
case NSKEY_F11: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 11); |
buf = count = 0; |
return 1; |
case NSKEY_F12: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 12); |
buf = count = 0; |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
keybuffer_push(keybuffer, (buf >> 16) &0xff); |
keybuffer_push(keybuffer, (buf >> 24) &0xff); |
keybuffer_push(keybuffer, scan_code); |
buf = count = 0; |
return 1; |
} |
} |
buf |= ((unsigned long) scan_code)<<(8*(count++)); |
if((buf & 0xff) != (NSKEY_F1 & 0xff)) { |
keybuffer_push(keybuffer, buf); |
buf = count = 0; |
return 1; |
} |
if (count <= 1) |
return 1; |
if ((buf & 0xffff) != (NSKEY_F1 & 0xffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 2) |
return 1; |
if ((buf & 0xffffff) != (NSKEY_F1 & 0xffffff) |
&& (buf & 0xffffff) != (NSKEY_F6 & 0xffffff) |
&& (buf & 0xffffff) != (NSKEY_F9 & 0xffffff) ) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
keybuffer_push(keybuffer, (buf >> 16) &0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 3) |
return 1; |
switch (buf) { |
case NSKEY_F1: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 1); |
buf = count = 0; |
return 1; |
case NSKEY_F2: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 2); |
buf = count = 0; |
return 1; |
case NSKEY_F3: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 3); |
buf = count = 0; |
return 1; |
case NSKEY_F4: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 4); |
buf = count = 0; |
return 1; |
case NSKEY_F5: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 5); |
buf = count = 0; |
return 1; |
} |
switch (buf) { |
case NSKEY_F6: |
case NSKEY_F7: |
case NSKEY_F8: |
case NSKEY_F9: |
case NSKEY_F10: |
case NSKEY_F11: |
case NSKEY_F12: |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
keybuffer_push(keybuffer, (buf >> 16) &0xff); |
keybuffer_push(keybuffer, (buf >> 24) &0xff); |
buf = count = 0; |
return 1; |
} |
return 1; |
} |
int kbd_ski_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
static unsigned long long buf = 0; |
static int count = 0; |
static int esc_count = 0; |
int scan_code = IPC_GET_ARG2(*call); |
/* |
* Please preserve this code (it can be used to determine scancodes) |
*/ |
//keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
//keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
//keybuffer_push(keybuffer, ' '); |
//keybuffer_push(keybuffer, ' '); |
//*/ |
if (scan_code) { |
buf |= (unsigned long long) scan_code<<(8*(count++)); |
} else { |
if (buf == 0x1b) { |
esc_count++; |
if (esc_count == 3) { |
__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); |
} |
} else { |
esc_count = 0; |
} |
if (!(buf & 0xff00)) { |
keybuffer_push(keybuffer, buf); |
} else { |
switch (buf) { |
case KEY_F1: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 1); |
break; |
case KEY_F2: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 2); |
break; |
case KEY_F3: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 3); |
break; |
case KEY_F4: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 4); |
break; |
case KEY_F5: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 5); |
break; |
case KEY_F6: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 6); |
break; |
case KEY_F7: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 7); |
break; |
case KEY_F8: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 8); |
break; |
case KEY_F9: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 9); |
break; |
case KEY_F10: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 10); |
break; |
case KEY_F11: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 11); |
break; |
case KEY_F12: |
keybuffer_push(keybuffer, FUNCTION_KEYS | 12); |
break; |
} |
} |
buf = count = 0; |
} |
return 1; |
} |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
printf("KBD Key pressed: %x(%c)\n",IPC_GET_ARG2(*call),IPC_GET_ARG2(*call)); |
if (kbd_type == KBD_SKI) |
return kbd_ski_process(keybuffer, call); |
if (kbd_type == KBD_NS16550) |
return kbd_ns16550_process(keybuffer,call); |
if (kbd_type == KBD_LEGACY) |
return lkbd_arch_process(keybuffer,call); |
} |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia64/src/scanc.c |
---|
0,0 → 1,202 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia32 |
* @brief Scancodes for PC keyboards. |
* @{ |
*/ |
/** @file |
* @ingroup kbdamd64 |
*/ |
#include <genarch/scanc.h> |
/** Primary meaning of scancodes. */ |
int sc_primary_map[] = { |
SPECIAL, /* 0x00 */ |
SPECIAL, /* 0x01 - Esc */ |
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', |
'\b', /* 0x0e - Backspace */ |
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', |
SPECIAL, /* 0x1d - LCtrl */ |
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', |
'`', |
SPECIAL, /* 0x2a - LShift */ |
'\\', |
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', |
SPECIAL, /* 0x36 - RShift */ |
'*', |
SPECIAL, /* 0x38 - LAlt */ |
' ', |
SPECIAL, /* 0x3a - CapsLock */ |
(FUNCTION_KEYS | 1), /* 0x3b - F1 */ |
(FUNCTION_KEYS | 2), /* 0x3c - F2 */ |
(FUNCTION_KEYS | 3), /* 0x3d - F3 */ |
(FUNCTION_KEYS | 4), /* 0x3e - F4 */ |
(FUNCTION_KEYS | 5), /* 0x3f - F5 */ |
(FUNCTION_KEYS | 6), /* 0x40 - F6 */ |
(FUNCTION_KEYS | 7), /* 0x41 - F7 */ |
(FUNCTION_KEYS | 8), /* 0x42 - F8 */ |
(FUNCTION_KEYS | 9), /* 0x43 - F9 */ |
(FUNCTION_KEYS | 10), /* 0x44 - F10 */ |
SPECIAL, /* 0x45 - NumLock */ |
SPECIAL, /* 0x46 - ScrollLock */ |
'7', '8', '9', '-', |
'4', '5', '6', '+', |
'1', '2', '3', |
'0', '.', |
SPECIAL, /* 0x54 - Alt-SysRq */ |
SPECIAL, /* 0x55 - F11/F12/PF1/FN */ |
SPECIAL, /* 0x56 - unlabelled key next to LAlt */ |
(FUNCTION_KEYS | 11), /* 0x57 - F11 */ |
(FUNCTION_KEYS | 12), /* 0x58 - F12 */ |
SPECIAL, /* 0x59 */ |
SPECIAL, /* 0x5a */ |
SPECIAL, /* 0x5b */ |
SPECIAL, /* 0x5c */ |
SPECIAL, /* 0x5d */ |
SPECIAL, /* 0x5e */ |
SPECIAL, /* 0x5f */ |
SPECIAL, /* 0x60 */ |
SPECIAL, /* 0x61 */ |
SPECIAL, /* 0x62 */ |
SPECIAL, /* 0x63 */ |
SPECIAL, /* 0x64 */ |
SPECIAL, /* 0x65 */ |
SPECIAL, /* 0x66 */ |
SPECIAL, /* 0x67 */ |
SPECIAL, /* 0x68 */ |
SPECIAL, /* 0x69 */ |
SPECIAL, /* 0x6a */ |
SPECIAL, /* 0x6b */ |
SPECIAL, /* 0x6c */ |
SPECIAL, /* 0x6d */ |
SPECIAL, /* 0x6e */ |
SPECIAL, /* 0x6f */ |
SPECIAL, /* 0x70 */ |
SPECIAL, /* 0x71 */ |
SPECIAL, /* 0x72 */ |
SPECIAL, /* 0x73 */ |
SPECIAL, /* 0x74 */ |
SPECIAL, /* 0x75 */ |
SPECIAL, /* 0x76 */ |
SPECIAL, /* 0x77 */ |
SPECIAL, /* 0x78 */ |
SPECIAL, /* 0x79 */ |
SPECIAL, /* 0x7a */ |
SPECIAL, /* 0x7b */ |
SPECIAL, /* 0x7c */ |
SPECIAL, /* 0x7d */ |
SPECIAL, /* 0x7e */ |
SPECIAL, /* 0x7f */ |
}; |
/** Secondary meaning of scancodes. */ |
int sc_secondary_map[] = { |
SPECIAL, /* 0x00 */ |
0x1b, /* 0x01 - Esc */ |
'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', |
SPECIAL, /* 0x0e - Backspace */ |
'\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', |
SPECIAL, /* 0x1d - LCtrl */ |
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', |
'~', |
SPECIAL, /* 0x2a - LShift */ |
'|', |
'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', |
SPECIAL, /* 0x36 - RShift */ |
'*', |
SPECIAL, /* 0x38 - LAlt */ |
' ', |
SPECIAL, /* 0x3a - CapsLock */ |
SPECIAL, /* 0x3b - F1 */ |
SPECIAL, /* 0x3c - F2 */ |
SPECIAL, /* 0x3d - F3 */ |
SPECIAL, /* 0x3e - F4 */ |
SPECIAL, /* 0x3f - F5 */ |
SPECIAL, /* 0x40 - F6 */ |
SPECIAL, /* 0x41 - F7 */ |
SPECIAL, /* 0x42 - F8 */ |
SPECIAL, /* 0x43 - F9 */ |
SPECIAL, /* 0x44 - F10 */ |
SPECIAL, /* 0x45 - NumLock */ |
SPECIAL, /* 0x46 - ScrollLock */ |
'7', '8', '9', '-', |
'4', '5', '6', '+', |
'1', '2', '3', |
'0', '.', |
SPECIAL, /* 0x54 - Alt-SysRq */ |
SPECIAL, /* 0x55 - F11/F12/PF1/FN */ |
SPECIAL, /* 0x56 - unlabelled key next to LAlt */ |
SPECIAL, /* 0x57 - F11 */ |
SPECIAL, /* 0x58 - F12 */ |
SPECIAL, /* 0x59 */ |
SPECIAL, /* 0x5a */ |
SPECIAL, /* 0x5b */ |
SPECIAL, /* 0x5c */ |
SPECIAL, /* 0x5d */ |
SPECIAL, /* 0x5e */ |
SPECIAL, /* 0x5f */ |
SPECIAL, /* 0x60 */ |
SPECIAL, /* 0x61 */ |
SPECIAL, /* 0x62 */ |
SPECIAL, /* 0x63 */ |
SPECIAL, /* 0x64 */ |
SPECIAL, /* 0x65 */ |
SPECIAL, /* 0x66 */ |
SPECIAL, /* 0x67 */ |
SPECIAL, /* 0x68 */ |
SPECIAL, /* 0x69 */ |
SPECIAL, /* 0x6a */ |
SPECIAL, /* 0x6b */ |
SPECIAL, /* 0x6c */ |
SPECIAL, /* 0x6d */ |
SPECIAL, /* 0x6e */ |
SPECIAL, /* 0x6f */ |
SPECIAL, /* 0x70 */ |
SPECIAL, /* 0x71 */ |
SPECIAL, /* 0x72 */ |
SPECIAL, /* 0x73 */ |
SPECIAL, /* 0x74 */ |
SPECIAL, /* 0x75 */ |
SPECIAL, /* 0x76 */ |
SPECIAL, /* 0x77 */ |
SPECIAL, /* 0x78 */ |
SPECIAL, /* 0x79 */ |
SPECIAL, /* 0x7a */ |
SPECIAL, /* 0x7b */ |
SPECIAL, /* 0x7c */ |
SPECIAL, /* 0x7d */ |
SPECIAL, /* 0x7e */ |
SPECIAL, /* 0x7f */ |
}; |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia64/src/mouse.c |
---|
0,0 → 1,117 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <ipc/ipc.h> |
#include <async.h> |
#include <kbd.h> |
#include <keys.h> |
#define i8042_MOUSE_DATA 0x20 |
#define BUFSIZE 3 |
typedef struct { |
union { |
unsigned char data[BUFSIZE]; |
struct { |
unsigned leftbtn : 1; |
unsigned rightbtn : 1; |
unsigned middlebtn : 1; |
unsigned isone : 1; /* Always one */ |
unsigned xsign : 1; |
unsigned ysign : 1; |
unsigned xovfl : 1; |
unsigned yovfl : 1; |
unsigned char x; |
unsigned char y; |
} val; |
}u; |
}ps2packet_t; |
static ps2packet_t buf; |
static int bufpos = 0; |
static int leftbtn = 0; |
static int rightbtn = 0; |
static int middlebtn = 0; |
/** Convert 9-bit 2-complement signed number to integer */ |
static int bit9toint(int sign, unsigned char data) |
{ |
int tmp; |
if (!sign) |
return data; |
tmp = ((unsigned char)~data) + 1; |
return -tmp; |
} |
/** Process mouse data |
* |
* @return True if mouse command was recognized and processed |
*/ |
int mouse_arch_process(int phoneid, ipc_call_t *call) |
{ |
int status = IPC_GET_ARG1(*call); |
int data = IPC_GET_ARG2(*call); |
int x,y; |
if (!(status & i8042_MOUSE_DATA)) |
return 0; |
/* Check that we have not lost synchronization */ |
if (bufpos == 0 && !(data & 0x8)) |
return 1; /* Synchro lost, ignore byte */ |
buf.u.data[bufpos++] = data; |
if (bufpos == BUFSIZE) { |
bufpos = 0; |
if (phoneid != -1) { |
if (buf.u.val.leftbtn ^ leftbtn) { |
leftbtn = buf.u.val.leftbtn; |
async_msg_1(phoneid, KBD_MS_LEFT, leftbtn); |
} |
if (buf.u.val.rightbtn & rightbtn) { |
rightbtn = buf.u.val.middlebtn; |
async_msg_1(phoneid, KBD_MS_RIGHT, rightbtn); |
} |
if (buf.u.val.rightbtn & rightbtn) { |
middlebtn = buf.u.val.middlebtn; |
async_msg_1(phoneid, KBD_MS_MIDDLE, middlebtn); |
} |
x = bit9toint(buf.u.val.xsign, buf.u.val.x); |
y = bit9toint(buf.u.val.ysign, buf.u.val.y); |
if (x || y) |
async_msg_2(phoneid, KBD_MS_MOVE, (ipcarg_t)x, |
(ipcarg_t)(-y)); |
} |
} |
return 1; |
} |
/branches/dynload/uspace/srv/kbd/arch/ia64/src/lkbd.c |
---|
0,0 → 1,166 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia64 ia64 |
* @brief HelenOS ia64 |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
* @ingroup kbdia64 |
*/ |
#include <arch/lkbd.h> |
#include <ipc/ipc.h> |
#include <unistd.h> |
#include <kbd.h> |
#include <keys.h> |
#include <genarch/kbd.h> |
#include <sysinfo.h> |
/* Interesting bits for status register */ |
#define i8042_OUTPUT_FULL 0x1 |
#define i8042_INPUT_FULL 0x2 |
#define i8042_MOUSE_DATA 0x20 |
/* Command constants */ |
#define i8042_CMD_KBD 0x60 |
#define i8042_CMD_MOUSE 0xd4 |
/* Keyboard cmd byte */ |
#define i8042_KBD_IE 0x1 |
#define i8042_MOUSE_IE 0x2 |
#define i8042_KBD_DISABLE 0x10 |
#define i8042_MOUSE_DISABLE 0x20 |
#define i8042_KBD_TRANSLATE 0x40 |
/* Mouse constants */ |
#define MOUSE_OUT_INIT 0xf4 |
#define MOUSE_ACK 0xfa |
#define KEY_RELEASE 0x80 |
static volatile int keyflags; /**< Tracking of multiple keypresses. */ |
static volatile int lockflags; /**< Tracking of multiple keys lockings. */ |
irq_cmd_t i8042_cmds[2] = { |
{ CMD_PORT_READ_1, (void *) 0x64, 0, 1 }, |
{ CMD_PORT_READ_1, (void *) 0x60, 0, 2 } |
}; |
irq_code_t i8042_kbd = { |
2, |
i8042_cmds |
}; |
static void wait_ready(void) { |
while (i8042_status_read() & i8042_INPUT_FULL) |
; |
} |
/** Register uspace irq handler |
* @return |
*/ |
int lkbd_arch_init(void) |
{ |
int i; |
int mouseenabled = 0; |
iospace_enable(task_get_id(), (void *) i8042_DATA, 5); |
/* Disable kbd, enable mouse */ |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_data_write(i8042_KBD_DISABLE); |
wait_ready(); |
/* Flush all current IO */ |
while (i8042_status_read() & i8042_OUTPUT_FULL) |
i8042_data_read(); |
/* Initialize mouse */ |
i8042_command_write(i8042_CMD_MOUSE); |
wait_ready(); |
i8042_data_write(MOUSE_OUT_INIT); |
wait_ready(); |
int mouseanswer = 0; |
for (i=0;i < 1000; i++) { |
int status = i8042_status_read(); |
if (status & i8042_OUTPUT_FULL) { |
int data = i8042_data_read(); |
if (status & i8042_MOUSE_DATA) { |
mouseanswer = data; |
break; |
} |
} |
usleep(1000); |
} |
if (mouseanswer == MOUSE_ACK) { |
/* enable mouse */ |
mouseenabled = 1; |
ipc_register_irq(sysinfo_value("mouse.inr"), sysinfo_value("mouse.devno"), 0, &i8042_kbd); |
} |
/* Enable kbd */ |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &i8042_kbd); |
int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE; |
if (mouseenabled) |
newcontrol |= i8042_MOUSE_IE; |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_data_write(newcontrol); |
wait_ready(); |
return 0; |
} |
/** Process keyboard & mouse events */ |
int lkbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int status = IPC_GET_ARG1(*call); |
if ((status & i8042_MOUSE_DATA)) |
return 0; |
int scan_code = IPC_GET_ARG2(*call); |
if (scan_code & KEY_RELEASE) |
key_released(keybuffer, scan_code ^ KEY_RELEASE); |
else |
key_pressed(keybuffer, scan_code); |
return 1; |
} |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia64/include/lkbd.h |
---|
0,0 → 1,76 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdamd64 amd64 |
* @brief HelenOS ia32 / amd64 arch dependent parts of uspace keyboard and mouse handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
* @ingroup kbdia32 |
*/ |
#ifndef KBD_ia32_KBD_H_ |
#define KBD_ia32_KBD_H_ |
#include <ddi.h> |
#include <libarch/ddi.h> |
#define i8042_DATA 0x60 |
#define i8042_STATUS 0X64 |
typedef unsigned char u8; |
typedef short u16; |
static inline void i8042_data_write(u8 data) |
{ |
outb(i8042_DATA, data); |
} |
static inline u8 i8042_data_read(void) |
{ |
return inb(i8042_DATA); |
} |
static inline u8 i8042_status_read(void) |
{ |
return inb(i8042_STATUS); |
} |
static inline void i8042_command_write(u8 command) |
{ |
outb(i8042_STATUS, command); |
} |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia64/include/scanc.h |
---|
0,0 → 1,59 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia32 |
* @{ |
*/ |
/** @file |
* @ingroup kbdamd64 |
*/ |
#ifndef KBD_ia32_SCANC_H_ |
#define KBD_ia32_SCANC_H_ |
/** Scancodes. */ |
#define SC_ESC 0x01 |
#define SC_BACKSPACE 0x0e |
#define SC_LSHIFT 0x2a |
#define SC_RSHIFT 0x36 |
#define SC_CAPSLOCK 0x3a |
#define SC_SPEC_ESCAPE 0xe0 |
#define SC_LEFTARR 0x4b |
#define SC_RIGHTARR 0x4d |
#define SC_UPARR 0x48 |
#define SC_DOWNARR 0x50 |
#define SC_DELETE 0x53 |
#define SC_HOME 0x47 |
#define SC_END 0x4f |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia64/include/kbd.h |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia64 ia64 |
* @brief HelenOS ia64 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_ia64_KBD_H_ |
#define KBD_ia64_KBD_H_ |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ppc32/src/kbd.c |
---|
0,0 → 1,203 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdppc32 ppc32 |
* @brief HelenOS ppc32 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/kbd.h> |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
#define SPECIAL 255 |
#define FUNCTION_KEYS 0x100 |
static int lchars[0x80] = { |
'a', |
's', |
'd', |
'f', |
'h', |
'g', |
'z', |
'x', |
'c', |
'v', |
SPECIAL, |
'b', |
'q', |
'w', |
'e', |
'r', |
'y', |
't', |
'1', |
'2', |
'3', |
'4', |
'6', |
'5', |
'=', |
'9', |
'7', |
'-', |
'8', |
'0', |
']', |
'o', |
'u', |
'[', |
'i', |
'p', |
'\n', /* Enter */ |
'l', |
'j', |
'\'', |
'k', |
';', |
'\\', |
',', |
'/', |
'n', |
'm', |
'.', |
'\t', /* Tab */ |
' ', |
'`', |
'\b', /* Backspace */ |
SPECIAL, |
SPECIAL, /* Escape */ |
SPECIAL, /* Ctrl */ |
SPECIAL, /* Alt */ |
SPECIAL, /* Shift */ |
SPECIAL, /* Caps-Lock */ |
SPECIAL, /* RAlt */ |
SPECIAL, /* Left */ |
SPECIAL, /* Right */ |
SPECIAL, /* Down */ |
SPECIAL, /* Up */ |
SPECIAL, |
SPECIAL, |
'.', /* Keypad . */ |
SPECIAL, |
'*', /* Keypad * */ |
SPECIAL, |
'+', /* Keypad + */ |
SPECIAL, |
SPECIAL, /* NumLock */ |
SPECIAL, |
SPECIAL, |
SPECIAL, |
'/', /* Keypad / */ |
'\n', /* Keypad Enter */ |
SPECIAL, |
'-', /* Keypad - */ |
SPECIAL, |
SPECIAL, |
SPECIAL, |
'0', /* Keypad 0 */ |
'1', /* Keypad 1 */ |
'2', /* Keypad 2 */ |
'3', /* Keypad 3 */ |
'4', /* Keypad 4 */ |
'5', /* Keypad 5 */ |
'6', /* Keypad 6 */ |
'7', /* Keypad 7 */ |
SPECIAL, |
'8', /* Keypad 8 */ |
'9', /* Keypad 9 */ |
SPECIAL, |
SPECIAL, |
SPECIAL, |
(FUNCTION_KEYS | 5), /* F5 */ |
(FUNCTION_KEYS | 6), /* F6 */ |
(FUNCTION_KEYS | 7), /* F7 */ |
(FUNCTION_KEYS | 3), /* F3 */ |
(FUNCTION_KEYS | 8), /* F8 */ |
(FUNCTION_KEYS | 9), /* F9 */ |
SPECIAL, |
(FUNCTION_KEYS | 11), /* F11 */ |
SPECIAL, |
(FUNCTION_KEYS | 13), /* F13 */ |
SPECIAL, |
SPECIAL, /* ScrollLock */ |
SPECIAL, |
(FUNCTION_KEYS | 10), /* F10 */ |
SPECIAL, |
(FUNCTION_KEYS | 12), /* F12 */ |
SPECIAL, |
SPECIAL, /* Pause */ |
SPECIAL, /* Insert */ |
SPECIAL, /* Home */ |
SPECIAL, /* PageUp */ |
SPECIAL, /* Delete */ |
(FUNCTION_KEYS | 4), /* F4 */ |
SPECIAL, /* End */ |
(FUNCTION_KEYS | 2), /* F2 */ |
SPECIAL, /* PageDown */ |
(FUNCTION_KEYS | 1) /* F1 */ |
}; |
int kbd_arch_init(void) |
{ |
if (!sysinfo_value("kbd")) |
return 0; |
return ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, 0); |
} |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int param = IPC_GET_ARG2(*call); |
if (param != -1) { |
uint8_t scancode = (uint8_t) param; |
if ((scancode & 0x80) != 0x80) { |
int key = lchars[scancode & 0x7f]; |
if (key != SPECIAL) |
keybuffer_push(keybuffer, key); |
} |
} |
return 1; |
} |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ppc32/include/kbd.h |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdppc32 ppc32 |
* @brief HelenOS ppc32 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_ppc32_KBD_H_ |
#define KBD_ppc32_KBD_H_ |
#endif |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/sparc64/include/sgcn.h |
---|
0,0 → 1,46 |
/* |
* Copyright (c) 2008 Pavel Rimsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdsparc64 sparc64 |
* @brief Serengeti-specific parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_sparc64_SGCN_H_ |
#define KBD_sparc64_SGCN_H_ |
void sgcn_init(void); |
void sgcn_key_pressed(void); |
#endif |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/sparc64/include/kbd.h |
---|
0,0 → 1,43 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdsparc64 sparc64 |
* @brief HelenOS sparc64 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_sparc64_KBD_H_ |
#define KBD_sparc64_KBD_H_ |
#endif |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/sparc64/include/scanc.h |
---|
0,0 → 1,57 |
/* |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup genarch |
* @{ |
*/ |
/** |
* @file |
* @brief Scan codes for sun keyboards. |
*/ |
#ifndef KBD_SCANC_SUN_H_ |
#define KBD_SCANC_SUN_H_ |
#define SC_ESC 0x1d |
#define SC_BACKSPACE 0x2b |
#define SC_LSHIFT 0x63 |
#define SC_RSHIFT 0x6e |
#define SC_CAPSLOCK 0x77 |
#define SC_SPEC_ESCAPE 0xe0 /* ??? */ |
#define SC_LEFTARR 0x18 |
#define SC_RIGHTARR 0x1c |
#define SC_UPARR 0x14 |
#define SC_DOWNARR 0x1b |
#define SC_DELETE 0x42 |
#define SC_HOME 0x34 |
#define SC_END 0x4a |
#endif |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/sparc64/src/kbd.c |
---|
0,0 → 1,127 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdsparc64 sparc64 |
* @brief HelenOS sparc64 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/kbd.h> |
#include <arch/sgcn.h> |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <genarch/kbd.h> |
#define KBD_KEY_RELEASE 0x80 |
#define KBD_ALL_KEYS_UP 0x7f |
/** Top-half pseudocode for z8530. */ |
irq_cmd_t z8530_cmds[] = { |
{ |
CMD_MEM_READ_1, |
0, /**< Address. Will be patched in run-time. */ |
0, /**< Value. Not used. */ |
1 /**< Arg 1 will contain the result. */ |
} |
}; |
irq_code_t z8530_kbd = { |
1, |
z8530_cmds |
}; |
/** Top-half pseudocode for ns16550. */ |
irq_cmd_t ns16550_cmds[] = { |
{ |
CMD_MEM_READ_1, |
0, /**< Address. Will be patched in run-time. */ |
0, /**< Value. Not used. */ |
1 /**< Arg 1 will contain the result. */ |
} |
}; |
irq_code_t ns16550_kbd = { |
1, |
ns16550_cmds |
}; |
#define KBD_Z8530 1 |
#define KBD_NS16550 2 |
#define KBD_SGCN 3 |
int kbd_arch_init(void) |
{ |
int type = sysinfo_value("kbd.type"); |
switch (type) { |
case KBD_Z8530: |
z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") + 6; |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &z8530_kbd); |
break; |
case KBD_NS16550: |
ns16550_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual"); |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ns16550_kbd); |
break; |
case KBD_SGCN: |
sgcn_init(); |
break; |
default: |
break; |
} |
return 0; |
} |
/** Process keyboard events */ |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
if (sysinfo_value("kbd.type") == KBD_SGCN) { |
sgcn_key_pressed(); |
return 1; |
} |
int scan_code = IPC_GET_ARG1(*call); |
if (scan_code == KBD_ALL_KEYS_UP) |
return 1; |
if (scan_code & KBD_KEY_RELEASE) |
key_released(keybuffer, scan_code ^ KBD_KEY_RELEASE); |
else |
key_pressed(keybuffer, scan_code); |
return 1; |
} |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/sparc64/src/sgcn.c |
---|
0,0 → 1,147 |
/* |
* Copyright (c) 2008 Pavel Rimsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdsparc64 sparc64 |
* @brief Serengeti-specific parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/sgcn.h> |
#include <as.h> |
#include <ddi.h> |
#include <ipc/ipc.h> |
#include <kbd.h> |
#include <genarch/nofb.h> |
#include <genarch/kbd.h> |
#include <sysinfo.h> |
#include <stdio.h> |
#include <futex.h> |
/** |
* SGCN buffer header. It is placed at the very beginning of the SGCN |
* buffer. |
*/ |
typedef struct { |
/** hard-wired to "CON" */ |
char magic[4]; |
/** we don't need this */ |
char unused[8]; |
/** offset within the SGCN buffer of the input buffer start */ |
uint32_t in_begin; |
/** offset within the SGCN buffer of the input buffer end */ |
uint32_t in_end; |
/** offset within the SGCN buffer of the input buffer read pointer */ |
uint32_t in_rdptr; |
/** offset within the SGCN buffer of the input buffer write pointer */ |
uint32_t in_wrptr; |
} __attribute__ ((packed)) sgcn_buffer_header_t; |
/* |
* Returns a pointer to the object of a given type which is placed at the given |
* offset from the console buffer beginning. |
*/ |
#define SGCN_BUFFER(type, offset) \ |
((type *) (sram_virt_addr + sram_buffer_offset + (offset))) |
/** Returns a pointer to the console buffer header. */ |
#define SGCN_BUFFER_HEADER (SGCN_BUFFER(sgcn_buffer_header_t, 0)) |
extern keybuffer_t keybuffer; |
/** |
* Virtual address mapped to SRAM. |
*/ |
static uintptr_t sram_virt_addr; |
/** |
* SGCN buffer offset within SGCN. |
*/ |
static uintptr_t sram_buffer_offset; |
/** |
* Initializes the SGCN driver. |
* Maps the physical memory (SRAM) and registers the interrupt. |
*/ |
void sgcn_init(void) |
{ |
sram_virt_addr = (uintptr_t) as_get_mappable_page( |
sysinfo_value("sram.area.size")); |
int result = physmem_map( |
(void *) sysinfo_value("sram.address.physical"), |
(void *) sram_virt_addr, |
sysinfo_value("sram.area.size") / PAGE_SIZE, |
AS_AREA_READ | AS_AREA_WRITE |
); |
if (result != 0) { |
printf("SGCN: uspace driver could not map physical memory."); |
} |
sram_buffer_offset = sysinfo_value("sram.buffer.offset"); |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), |
0, (void *) 0); |
} |
/** |
* Handler of the "key pressed" event. Reads codes of all the pressed keys from |
* the buffer. |
*/ |
void sgcn_key_pressed(void) |
{ |
char c; |
uint32_t begin = SGCN_BUFFER_HEADER->in_begin; |
uint32_t end = SGCN_BUFFER_HEADER->in_end; |
uint32_t size = end - begin; |
volatile char *buf_ptr = (volatile char *) |
SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); |
volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr); |
volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr); |
while (*in_rdptr_ptr != *in_wrptr_ptr) { |
c = *buf_ptr; |
*in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; |
buf_ptr = (volatile char *) |
SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); |
if (c == '\r') { |
c = '\n'; |
} |
kbd_process_no_fb(&keybuffer, c); |
} |
} |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/sparc64/src/scanc.c |
---|
0,0 → 1,304 |
/* |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup genarch |
* @{ |
*/ |
/** |
* @file |
* @brief Scan codes for Sun keyboards. |
*/ |
#include <genarch/scanc.h> |
/** Primary meaning of scancodes. */ |
int sc_primary_map[] = { |
[0x00] = SPECIAL, |
[0x01] = SPECIAL, |
[0x02] = SPECIAL, |
[0x03] = SPECIAL, |
[0x04] = SPECIAL, |
[0x05] = FUNCTION_KEYS + 1, /* F1 */ |
[0x06] = FUNCTION_KEYS + 2, /* F2 */ |
[0x07] = FUNCTION_KEYS + 10, /* F10 */ |
[0x08] = FUNCTION_KEYS + 3, /* F3 */ |
[0x09] = FUNCTION_KEYS + 11, /* F11 */ |
[0x0a] = FUNCTION_KEYS + 4, /* F4 */ |
[0x0b] = FUNCTION_KEYS + 12, /* F12 */ |
[0x0c] = FUNCTION_KEYS + 5, /* F5 */ |
[0x0d] = SPECIAL, /* RAlt */ |
[0x0e] = FUNCTION_KEYS + 6, /* F6 */ |
[0x0f] = SPECIAL, |
[0x10] = FUNCTION_KEYS + 7, /* F7 */ |
[0x11] = FUNCTION_KEYS + 8, /* F8 */ |
[0x12] = FUNCTION_KEYS + 9, /* F9 */ |
[0x13] = SPECIAL, /* LAlt */ |
[0x14] = SPECIAL, /* Up Arrow */ |
[0x15] = SPECIAL, /* Pause */ |
[0x16] = SPECIAL, |
[0x17] = SPECIAL, /* Scroll Lock */ |
[0x18] = SPECIAL, /* Left Arrow */ |
[0x19] = SPECIAL, |
[0x1a] = SPECIAL, |
[0x1b] = SPECIAL, /* Down Arrow */ |
[0x1c] = SPECIAL, /* Right Arrow */ |
[0x1d] = SPECIAL, /* Esc */ |
[0x1e] = '1', |
[0x1f] = '2', |
[0x20] = '3', |
[0x21] = '4', |
[0x22] = '5', |
[0x23] = '6', |
[0x24] = '7', |
[0x25] = '8', |
[0x26] = '9', |
[0x27] = '0', |
[0x28] = '-', |
[0x29] = '=', |
[0x2a] = '`', |
[0x2b] = '\b', /* Backspace */ |
[0x2c] = SPECIAL, /* Insert */ |
[0x2d] = SPECIAL, |
[0x2e] = '/', /* numeric keypad */ |
[0x2f] = '*', /* numeric keypad */ |
[0x30] = SPECIAL, |
[0x31] = SPECIAL, |
[0x32] = '.', /* numeric keypad */ |
[0x33] = SPECIAL, |
[0x34] = SPECIAL, /* Home */ |
[0x35] = '\t', /* Tab */ |
[0x36] = 'q', |
[0x37] = 'w', |
[0x38] = 'e', |
[0x39] = 'r', |
[0x3a] = 't', |
[0x3b] = 'y', |
[0x3c] = 'u', |
[0x3d] = 'i', |
[0x3e] = 'o', |
[0x3f] = 'p', |
[0x40] = '[', |
[0x41] = ']', |
[0x42] = SPECIAL, /* Del */ |
[0x43] = SPECIAL, |
[0x44] = '7', /* numeric keypad */ |
[0x45] = '8', /* numeric keypad */ |
[0x46] = '9', /* numeric keypad */ |
[0x47] = '-', /* numeric keypad */ |
[0x48] = SPECIAL, |
[0x49] = SPECIAL, |
[0x4a] = SPECIAL, /* End */ |
[0x4b] = SPECIAL, |
[0x4c] = SPECIAL, /* Control */ |
[0x4d] = 'a', |
[0x4e] = 's', |
[0x4f] = 'd', |
[0x50] = 'f', |
[0x51] = 'g', |
[0x52] = 'h', |
[0x53] = 'j', |
[0x54] = 'k', |
[0x55] = 'l', |
[0x56] = ';', |
[0x57] = '\'', |
[0x58] = '\\', |
[0x59] = '\n', /* Enter */ |
[0x5a] = '\n', /* Enter on numeric keypad */ |
[0x5b] = '4', /* numeric keypad */ |
[0x5c] = '5', /* numeric keypad */ |
[0x5d] = '6', /* numeric keypad */ |
[0x5e] = '0', /* numeric keypad */ |
[0x5f] = SPECIAL, |
[0x60] = SPECIAL, /* Page Up */ |
[0x61] = SPECIAL, |
[0x62] = SPECIAL, /* Num Lock */ |
[0x63] = SPECIAL, /* LShift */ |
[0x64] = 'z', |
[0x65] = 'x', |
[0x66] = 'c', |
[0x67] = 'v', |
[0x68] = 'b', |
[0x69] = 'n', |
[0x6a] = 'm', |
[0x6b] = ',', |
[0x6c] = '.', |
[0x6d] = '/', |
[0x6e] = SPECIAL, /* RShift */ |
[0x6f] = SPECIAL, |
[0x70] = '1', /* numeric keypad */ |
[0x71] = '2', /* numeric keypad */ |
[0x72] = '3', /* numeric keypad */ |
[0x73] = SPECIAL, |
[0x74] = SPECIAL, |
[0x75] = SPECIAL, |
[0x76] = SPECIAL, |
[0x77] = SPECIAL, /* Caps Lock */ |
[0x78] = SPECIAL, |
[0x79] = ' ', |
[0x7a] = SPECIAL, |
[0x7b] = SPECIAL, /* Page Down */ |
[0x7c] = SPECIAL, |
[0x7d] = '+', /* numeric key pad */ |
[0x7e] = SPECIAL, |
[0x7f] = SPECIAL |
}; |
/** Secondary meaning of scancodes. */ |
int sc_secondary_map[] = { |
[0x00] = SPECIAL, |
[0x01] = SPECIAL, |
[0x02] = SPECIAL, |
[0x03] = SPECIAL, |
[0x04] = SPECIAL, |
[0x05] = SPECIAL, /* F1 */ |
[0x06] = SPECIAL, /* F2 */ |
[0x07] = SPECIAL, /* F10 */ |
[0x08] = SPECIAL, /* F3 */ |
[0x09] = SPECIAL, /* F11 */ |
[0x0a] = SPECIAL, /* F4 */ |
[0x0b] = SPECIAL, /* F12 */ |
[0x0c] = SPECIAL, /* F5 */ |
[0x0d] = SPECIAL, /* RAlt */ |
[0x0e] = SPECIAL, /* F6 */ |
[0x0f] = SPECIAL, |
[0x10] = SPECIAL, /* F7 */ |
[0x11] = SPECIAL, /* F8 */ |
[0x12] = SPECIAL, /* F9 */ |
[0x13] = SPECIAL, /* LAlt */ |
[0x14] = SPECIAL, /* Up Arrow */ |
[0x15] = SPECIAL, /* Pause */ |
[0x16] = SPECIAL, |
[0x17] = SPECIAL, /* Scroll Lock */ |
[0x18] = SPECIAL, /* Left Arrow */ |
[0x19] = SPECIAL, |
[0x1a] = SPECIAL, |
[0x1b] = SPECIAL, /* Down Arrow */ |
[0x1c] = SPECIAL, /* Right Arrow */ |
[0x1d] = SPECIAL, /* Esc */ |
[0x1e] = '!', |
[0x1f] = '@', |
[0x20] = '#', |
[0x21] = '$', |
[0x22] = '%', |
[0x23] = '^', |
[0x24] = '&', |
[0x25] = '*', |
[0x26] = '(', |
[0x27] = ')', |
[0x28] = '_', |
[0x29] = '+', |
[0x2a] = '~', |
[0x2b] = SPECIAL, /* Backspace */ |
[0x2c] = SPECIAL, /* Insert */ |
[0x2d] = SPECIAL, |
[0x2e] = '/', /* numeric keypad */ |
[0x2f] = '*', /* numeric keypad */ |
[0x30] = SPECIAL, |
[0x31] = SPECIAL, |
[0x32] = '.', /* numeric keypad */ |
[0x33] = SPECIAL, |
[0x34] = SPECIAL, /* Home */ |
[0x35] = SPECIAL, /* Tab */ |
[0x36] = 'Q', |
[0x37] = 'W', |
[0x38] = 'E', |
[0x39] = 'R', |
[0x3a] = 'T', |
[0x3b] = 'Y', |
[0x3c] = 'U', |
[0x3d] = 'I', |
[0x3e] = 'O', |
[0x3f] = 'P', |
[0x40] = '{', |
[0x41] = '}', |
[0x42] = SPECIAL, /* Del */ |
[0x43] = SPECIAL, |
[0x44] = '7', /* numeric keypad */ |
[0x45] = '8', /* numeric keypad */ |
[0x46] = '9', /* numeric keypad */ |
[0x47] = '-', /* numeric keypad */ |
[0x48] = SPECIAL, |
[0x49] = SPECIAL, |
[0x4a] = SPECIAL, /* End */ |
[0x4b] = SPECIAL, |
[0x4c] = SPECIAL, /* Control */ |
[0x4d] = 'A', |
[0x4e] = 'S', |
[0x4f] = 'D', |
[0x50] = 'F', |
[0x51] = 'G', |
[0x52] = 'H', |
[0x53] = 'J', |
[0x54] = 'K', |
[0x55] = 'L', |
[0x56] = ':', |
[0x57] = '"', |
[0x58] = '|', |
[0x59] = SPECIAL, /* Enter */ |
[0x5a] = SPECIAL, /* Enter on numeric keypad */ |
[0x5b] = '4', /* numeric keypad */ |
[0x5c] = '5', /* numeric keypad */ |
[0x5d] = '6', /* numeric keypad */ |
[0x5e] = '0', /* numeric keypad */ |
[0x5f] = SPECIAL, |
[0x60] = SPECIAL, /* Page Up */ |
[0x61] = SPECIAL, |
[0x62] = SPECIAL, /* Num Lock */ |
[0x63] = SPECIAL, /* LShift */ |
[0x64] = 'Z', |
[0x65] = 'X', |
[0x66] = 'C', |
[0x67] = 'V', |
[0x68] = 'B', |
[0x69] = 'N', |
[0x6a] = 'M', |
[0x6b] = '<', |
[0x6c] = '>', |
[0x6d] = '?', |
[0x6e] = SPECIAL, /* RShift */ |
[0x6f] = SPECIAL, |
[0x70] = '1', /* numeric keypad */ |
[0x71] = '2', /* numeric keypad */ |
[0x72] = '3', /* numeric keypad */ |
[0x73] = SPECIAL, |
[0x74] = SPECIAL, |
[0x75] = SPECIAL, |
[0x76] = SPECIAL, |
[0x77] = SPECIAL, /* Caps Lock */ |
[0x78] = SPECIAL, |
[0x79] = ' ', |
[0x7a] = SPECIAL, |
[0x7b] = SPECIAL, /* Page Down */ |
[0x7c] = SPECIAL, |
[0x7d] = '+', /* numeric key pad */ |
[0x7e] = SPECIAL, |
[0x7f] = SPECIAL |
}; |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/mips32/src/kbd.c |
---|
0,0 → 1,238 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdmips32 mips32 |
* @brief HelenOS mips32 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/kbd.h> |
#include <genarch/nofb.h> |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
#define MSIM_KEY_F1 0x504f1bL |
#define MSIM_KEY_F2 0x514f1bL |
#define MSIM_KEY_F3 0x524f1bL |
#define MSIM_KEY_F4 0x534f1bL |
#define MSIM_KEY_F5 0x35315b1bL |
#define MSIM_KEY_F6 0x37315b1bL |
#define MSIM_KEY_F7 0x38315b1bL |
#define MSIM_KEY_F8 0x39315b1bL |
#define MSIM_KEY_F9 0x30325b1bL |
#define MSIM_KEY_F10 0x31325b1bL |
#define MSIM_KEY_F11 0x33325b1bL |
#define MSIM_KEY_F12 0x34325b1bL |
#define GXEMUL_KEY_F1 0x504f5b1bL |
#define GXEMUL_KEY_F2 0x514f5b1bL |
#define GXEMUL_KEY_F3 0x524f5b1bL |
#define GXEMUL_KEY_F4 0x534f5b1bL |
#define GXEMUL_KEY_F5 0x35315b1bL |
#define GXEMUL_KEY_F6 0x37315b1bL |
#define GXEMUL_KEY_F7 0x38315b1bL |
#define GXEMUL_KEY_F8 0x39315b1bL |
#define GXEMUL_KEY_F9 0x38325b1bL |
#define GXEMUL_KEY_F10 0x39325b1bL |
#define GXEMUL_KEY_F11 0x33325b1bL |
#define GXEMUL_KEY_F12 0x34325b1bL |
#define FUNCTION_KEYS 0x100 |
irq_cmd_t msim_cmds[1] = { |
{ CMD_MEM_READ_1, (void *) 0, 0, 2 } |
}; |
irq_code_t msim_kbd = { |
1, |
msim_cmds |
}; |
static int msim,gxemul; |
static int fb_fb; |
int kbd_arch_init(void) |
{ |
fb_fb = (sysinfo_value("fb.kind") == 1); |
msim_cmds[0].addr = sysinfo_value("kbd.address.virtual"); |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &msim_kbd); |
return 0; |
} |
/* |
//* |
//* Please preserve this code (it can be used to determine scancodes) |
//* |
int to_hex(int v) |
{ |
return "0123456789ABCDEF"[v]; |
} |
*/ |
static int kbd_arch_process_fb(keybuffer_t *keybuffer, int scan_code) |
{ |
static unsigned long buf = 0; |
static int count = 0; |
/* Please preserve this code (it can be used to determine scancodes) |
keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
keybuffer_push(keybuffer, ' '); |
keybuffer_push(keybuffer, ' '); |
return 1; |
*/ |
if (scan_code == '\r') |
scan_code = '\n'; |
buf |= ((unsigned long) scan_code)<<(8*(count++)); |
if ((buf & 0xff) != (GXEMUL_KEY_F1 & 0xff)) { |
keybuffer_push(keybuffer, buf); |
buf = count = 0; |
return 1; |
} |
if (count <= 1) |
return 1; |
if ((buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 2) |
return 1; |
if ((buf & 0xffffff) != (GXEMUL_KEY_F1 & 0xffffff) |
&& (buf & 0xffffff) != (GXEMUL_KEY_F5 & 0xffffff) |
&& (buf & 0xffffff) != (GXEMUL_KEY_F9 & 0xffffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) & 0xff); |
keybuffer_push(keybuffer, (buf >> 16) & 0xff); |
buf = count = 0; |
return 1; |
} |
if ( count <= 3 ) |
return 1; |
switch (buf) { |
case GXEMUL_KEY_F1: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 1 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F2: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 2 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F3: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 3 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F4: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 4 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F5: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 5 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F6: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 6 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F7: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 7 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F8: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 8 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F9: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 9 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F10: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 10 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F11: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 11 ); |
buf=count=0; |
return 1; |
case GXEMUL_KEY_F12: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 12 ); |
buf=count=0; |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff ); |
keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
keybuffer_push(keybuffer, (buf >> 16) &0xff ); |
keybuffer_push(keybuffer, (buf >> 24) &0xff ); |
buf=count=0; |
return 1; |
} |
return 1; |
} |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
static int esc_count=0; |
if (scan_code == 0x1b) { |
esc_count++; |
if (esc_count == 3) |
__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); |
} else { |
esc_count=0; |
} |
if (fb_fb) |
return kbd_arch_process_fb(keybuffer, scan_code); |
return kbd_process_no_fb(keybuffer, scan_code); |
} |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/mips32/include/kbd.h |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdmips32 mips32 |
* @brief HelenOS mips32 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_mips32_KBD_H_ |
#define KBD_mips32_KBD_H_ |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia32/src/mouse.c |
---|
0,0 → 1,117 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <ipc/ipc.h> |
#include <async.h> |
#include <kbd.h> |
#include <keys.h> |
#define i8042_MOUSE_DATA 0x20 |
#define BUFSIZE 3 |
typedef struct { |
union { |
unsigned char data[BUFSIZE]; |
struct { |
unsigned leftbtn : 1; |
unsigned rightbtn : 1; |
unsigned middlebtn : 1; |
unsigned isone : 1; /* Always one */ |
unsigned xsign : 1; |
unsigned ysign : 1; |
unsigned xovfl : 1; |
unsigned yovfl : 1; |
unsigned char x; |
unsigned char y; |
} val; |
}u; |
}ps2packet_t; |
static ps2packet_t buf; |
static int bufpos = 0; |
static int leftbtn = 0; |
static int rightbtn = 0; |
static int middlebtn = 0; |
/** Convert 9-bit 2-complement signed number to integer */ |
static int bit9toint(int sign, unsigned char data) |
{ |
int tmp; |
if (!sign) |
return data; |
tmp = ((unsigned char)~data) + 1; |
return -tmp; |
} |
/** Process mouse data |
* |
* @return True if mouse command was recognized and processed |
*/ |
int mouse_arch_process(int phoneid, ipc_call_t *call) |
{ |
int status = IPC_GET_ARG1(*call); |
int data = IPC_GET_ARG2(*call); |
int x,y; |
if (!(status & i8042_MOUSE_DATA)) |
return 0; |
/* Check that we have not lost synchronization */ |
if (bufpos == 0 && !(data & 0x8)) |
return 1; /* Synchro lost, ignore byte */ |
buf.u.data[bufpos++] = data; |
if (bufpos == BUFSIZE) { |
bufpos = 0; |
if (phoneid != -1) { |
if (buf.u.val.leftbtn ^ leftbtn) { |
leftbtn = buf.u.val.leftbtn; |
async_msg_1(phoneid, KBD_MS_LEFT, leftbtn); |
} |
if (buf.u.val.rightbtn & rightbtn) { |
rightbtn = buf.u.val.middlebtn; |
async_msg_1(phoneid, KBD_MS_RIGHT, rightbtn); |
} |
if (buf.u.val.rightbtn & rightbtn) { |
middlebtn = buf.u.val.middlebtn; |
async_msg_1(phoneid, KBD_MS_MIDDLE, middlebtn); |
} |
x = bit9toint(buf.u.val.xsign, buf.u.val.x); |
y = bit9toint(buf.u.val.ysign, buf.u.val.y); |
if (x || y) |
async_msg_2(phoneid, KBD_MS_MOVE, (ipcarg_t)x, |
(ipcarg_t)(-y)); |
} |
} |
return 1; |
} |
/branches/dynload/uspace/srv/kbd/arch/ia32/src/kbd.c |
---|
0,0 → 1,166 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia32 ia32 |
* @brief HelenOS ia32 / amd64 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
* @ingroup kbdamd64 |
*/ |
#include <arch/kbd.h> |
#include <ipc/ipc.h> |
#include <unistd.h> |
#include <kbd.h> |
#include <keys.h> |
#include <genarch/kbd.h> |
#include <sysinfo.h> |
/* Interesting bits for status register */ |
#define i8042_OUTPUT_FULL 0x1 |
#define i8042_INPUT_FULL 0x2 |
#define i8042_MOUSE_DATA 0x20 |
/* Command constants */ |
#define i8042_CMD_KBD 0x60 |
#define i8042_CMD_MOUSE 0xd4 |
/* Keyboard cmd byte */ |
#define i8042_KBD_IE 0x1 |
#define i8042_MOUSE_IE 0x2 |
#define i8042_KBD_DISABLE 0x10 |
#define i8042_MOUSE_DISABLE 0x20 |
#define i8042_KBD_TRANSLATE 0x40 |
/* Mouse constants */ |
#define MOUSE_OUT_INIT 0xf4 |
#define MOUSE_ACK 0xfa |
#define KEY_RELEASE 0x80 |
static volatile int keyflags; /**< Tracking of multiple keypresses. */ |
static volatile int lockflags; /**< Tracking of multiple keys lockings. */ |
irq_cmd_t i8042_cmds[2] = { |
{ CMD_PORT_READ_1, (void *) 0x64, 0, 1 }, |
{ CMD_PORT_READ_1, (void *) 0x60, 0, 2 } |
}; |
irq_code_t i8042_kbd = { |
2, |
i8042_cmds |
}; |
static void wait_ready(void) { |
while (i8042_status_read() & i8042_INPUT_FULL) |
; |
} |
/** Register uspace irq handler |
* @return |
*/ |
int kbd_arch_init(void) |
{ |
int i; |
int mouseenabled = 0; |
iospace_enable(task_get_id(), (void *) i8042_DATA, 5); |
/* Disable kbd, enable mouse */ |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_data_write(i8042_KBD_DISABLE); |
wait_ready(); |
/* Flush all current IO */ |
while (i8042_status_read() & i8042_OUTPUT_FULL) |
i8042_data_read(); |
/* Initialize mouse */ |
i8042_command_write(i8042_CMD_MOUSE); |
wait_ready(); |
i8042_data_write(MOUSE_OUT_INIT); |
wait_ready(); |
int mouseanswer = 0; |
for (i=0;i < 1000; i++) { |
int status = i8042_status_read(); |
if (status & i8042_OUTPUT_FULL) { |
int data = i8042_data_read(); |
if (status & i8042_MOUSE_DATA) { |
mouseanswer = data; |
break; |
} |
} |
usleep(1000); |
} |
if (mouseanswer == MOUSE_ACK) { |
/* enable mouse */ |
mouseenabled = 1; |
ipc_register_irq(sysinfo_value("mouse.inr"), sysinfo_value("mouse.devno"), 0, &i8042_kbd); |
} |
/* Enable kbd */ |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &i8042_kbd); |
int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE; |
if (mouseenabled) |
newcontrol |= i8042_MOUSE_IE; |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_data_write(newcontrol); |
wait_ready(); |
return 0; |
} |
/** Process keyboard & mouse events */ |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int status = IPC_GET_ARG1(*call); |
if ((status & i8042_MOUSE_DATA)) |
return 0; |
int scan_code = IPC_GET_ARG2(*call); |
if (scan_code & KEY_RELEASE) |
key_released(keybuffer, scan_code ^ KEY_RELEASE); |
else |
key_pressed(keybuffer, scan_code); |
return 1; |
} |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia32/src/scanc.c |
---|
0,0 → 1,202 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia32 |
* @brief Scancodes for PC keyboards. |
* @{ |
*/ |
/** @file |
* @ingroup kbdamd64 |
*/ |
#include <genarch/scanc.h> |
/** Primary meaning of scancodes. */ |
int sc_primary_map[] = { |
SPECIAL, /* 0x00 */ |
SPECIAL, /* 0x01 - Esc */ |
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', |
'\b', /* 0x0e - Backspace */ |
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', |
SPECIAL, /* 0x1d - LCtrl */ |
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', |
'`', |
SPECIAL, /* 0x2a - LShift */ |
'\\', |
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', |
SPECIAL, /* 0x36 - RShift */ |
'*', |
SPECIAL, /* 0x38 - LAlt */ |
' ', |
SPECIAL, /* 0x3a - CapsLock */ |
(FUNCTION_KEYS | 1), /* 0x3b - F1 */ |
(FUNCTION_KEYS | 2), /* 0x3c - F2 */ |
(FUNCTION_KEYS | 3), /* 0x3d - F3 */ |
(FUNCTION_KEYS | 4), /* 0x3e - F4 */ |
(FUNCTION_KEYS | 5), /* 0x3f - F5 */ |
(FUNCTION_KEYS | 6), /* 0x40 - F6 */ |
(FUNCTION_KEYS | 7), /* 0x41 - F7 */ |
(FUNCTION_KEYS | 8), /* 0x42 - F8 */ |
(FUNCTION_KEYS | 9), /* 0x43 - F9 */ |
(FUNCTION_KEYS | 10), /* 0x44 - F10 */ |
SPECIAL, /* 0x45 - NumLock */ |
SPECIAL, /* 0x46 - ScrollLock */ |
'7', '8', '9', '-', |
'4', '5', '6', '+', |
'1', '2', '3', |
'0', '.', |
SPECIAL, /* 0x54 - Alt-SysRq */ |
SPECIAL, /* 0x55 - F11/F12/PF1/FN */ |
SPECIAL, /* 0x56 - unlabelled key next to LAlt */ |
(FUNCTION_KEYS | 11), /* 0x57 - F11 */ |
(FUNCTION_KEYS | 12), /* 0x58 - F12 */ |
SPECIAL, /* 0x59 */ |
SPECIAL, /* 0x5a */ |
SPECIAL, /* 0x5b */ |
SPECIAL, /* 0x5c */ |
SPECIAL, /* 0x5d */ |
SPECIAL, /* 0x5e */ |
SPECIAL, /* 0x5f */ |
SPECIAL, /* 0x60 */ |
SPECIAL, /* 0x61 */ |
SPECIAL, /* 0x62 */ |
SPECIAL, /* 0x63 */ |
SPECIAL, /* 0x64 */ |
SPECIAL, /* 0x65 */ |
SPECIAL, /* 0x66 */ |
SPECIAL, /* 0x67 */ |
SPECIAL, /* 0x68 */ |
SPECIAL, /* 0x69 */ |
SPECIAL, /* 0x6a */ |
SPECIAL, /* 0x6b */ |
SPECIAL, /* 0x6c */ |
SPECIAL, /* 0x6d */ |
SPECIAL, /* 0x6e */ |
SPECIAL, /* 0x6f */ |
SPECIAL, /* 0x70 */ |
SPECIAL, /* 0x71 */ |
SPECIAL, /* 0x72 */ |
SPECIAL, /* 0x73 */ |
SPECIAL, /* 0x74 */ |
SPECIAL, /* 0x75 */ |
SPECIAL, /* 0x76 */ |
SPECIAL, /* 0x77 */ |
SPECIAL, /* 0x78 */ |
SPECIAL, /* 0x79 */ |
SPECIAL, /* 0x7a */ |
SPECIAL, /* 0x7b */ |
SPECIAL, /* 0x7c */ |
SPECIAL, /* 0x7d */ |
SPECIAL, /* 0x7e */ |
SPECIAL, /* 0x7f */ |
}; |
/** Secondary meaning of scancodes. */ |
int sc_secondary_map[] = { |
SPECIAL, /* 0x00 */ |
0x1b, /* 0x01 - Esc */ |
'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', |
SPECIAL, /* 0x0e - Backspace */ |
'\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', |
SPECIAL, /* 0x1d - LCtrl */ |
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', |
'~', |
SPECIAL, /* 0x2a - LShift */ |
'|', |
'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', |
SPECIAL, /* 0x36 - RShift */ |
'*', |
SPECIAL, /* 0x38 - LAlt */ |
' ', |
SPECIAL, /* 0x3a - CapsLock */ |
SPECIAL, /* 0x3b - F1 */ |
SPECIAL, /* 0x3c - F2 */ |
SPECIAL, /* 0x3d - F3 */ |
SPECIAL, /* 0x3e - F4 */ |
SPECIAL, /* 0x3f - F5 */ |
SPECIAL, /* 0x40 - F6 */ |
SPECIAL, /* 0x41 - F7 */ |
SPECIAL, /* 0x42 - F8 */ |
SPECIAL, /* 0x43 - F9 */ |
SPECIAL, /* 0x44 - F10 */ |
SPECIAL, /* 0x45 - NumLock */ |
SPECIAL, /* 0x46 - ScrollLock */ |
'7', '8', '9', '-', |
'4', '5', '6', '+', |
'1', '2', '3', |
'0', '.', |
SPECIAL, /* 0x54 - Alt-SysRq */ |
SPECIAL, /* 0x55 - F11/F12/PF1/FN */ |
SPECIAL, /* 0x56 - unlabelled key next to LAlt */ |
SPECIAL, /* 0x57 - F11 */ |
SPECIAL, /* 0x58 - F12 */ |
SPECIAL, /* 0x59 */ |
SPECIAL, /* 0x5a */ |
SPECIAL, /* 0x5b */ |
SPECIAL, /* 0x5c */ |
SPECIAL, /* 0x5d */ |
SPECIAL, /* 0x5e */ |
SPECIAL, /* 0x5f */ |
SPECIAL, /* 0x60 */ |
SPECIAL, /* 0x61 */ |
SPECIAL, /* 0x62 */ |
SPECIAL, /* 0x63 */ |
SPECIAL, /* 0x64 */ |
SPECIAL, /* 0x65 */ |
SPECIAL, /* 0x66 */ |
SPECIAL, /* 0x67 */ |
SPECIAL, /* 0x68 */ |
SPECIAL, /* 0x69 */ |
SPECIAL, /* 0x6a */ |
SPECIAL, /* 0x6b */ |
SPECIAL, /* 0x6c */ |
SPECIAL, /* 0x6d */ |
SPECIAL, /* 0x6e */ |
SPECIAL, /* 0x6f */ |
SPECIAL, /* 0x70 */ |
SPECIAL, /* 0x71 */ |
SPECIAL, /* 0x72 */ |
SPECIAL, /* 0x73 */ |
SPECIAL, /* 0x74 */ |
SPECIAL, /* 0x75 */ |
SPECIAL, /* 0x76 */ |
SPECIAL, /* 0x77 */ |
SPECIAL, /* 0x78 */ |
SPECIAL, /* 0x79 */ |
SPECIAL, /* 0x7a */ |
SPECIAL, /* 0x7b */ |
SPECIAL, /* 0x7c */ |
SPECIAL, /* 0x7d */ |
SPECIAL, /* 0x7e */ |
SPECIAL, /* 0x7f */ |
}; |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia32/include/kbd.h |
---|
0,0 → 1,76 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdamd64 amd64 |
* @brief HelenOS ia32 / amd64 arch dependent parts of uspace keyboard and mouse handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
* @ingroup kbdia32 |
*/ |
#ifndef KBD_ia32_KBD_H_ |
#define KBD_ia32_KBD_H_ |
#include <ddi.h> |
#include <libarch/ddi.h> |
#define i8042_DATA 0x60 |
#define i8042_STATUS 0X64 |
typedef unsigned char u8; |
typedef short u16; |
static inline void i8042_data_write(u8 data) |
{ |
outb(i8042_DATA, data); |
} |
static inline u8 i8042_data_read(void) |
{ |
return inb(i8042_DATA); |
} |
static inline u8 i8042_status_read(void) |
{ |
return inb(i8042_STATUS); |
} |
static inline void i8042_command_write(u8 command) |
{ |
outb(i8042_STATUS, command); |
} |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/ia32/include/scanc.h |
---|
0,0 → 1,59 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdia32 |
* @{ |
*/ |
/** @file |
* @ingroup kbdamd64 |
*/ |
#ifndef KBD_ia32_SCANC_H_ |
#define KBD_ia32_SCANC_H_ |
/** Scancodes. */ |
#define SC_ESC 0x01 |
#define SC_BACKSPACE 0x0e |
#define SC_LSHIFT 0x2a |
#define SC_RSHIFT 0x36 |
#define SC_CAPSLOCK 0x3a |
#define SC_SPEC_ESCAPE 0xe0 |
#define SC_LEFTARR 0x4b |
#define SC_RIGHTARR 0x4d |
#define SC_UPARR 0x48 |
#define SC_DOWNARR 0x50 |
#define SC_DELETE 0x53 |
#define SC_HOME 0x47 |
#define SC_END 0x4f |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/arm32/include/kbd.h |
---|
0,0 → 1,42 |
/* |
* Copyright (c) 2007 Michal Kebrt |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdarm32 |
* @{ |
*/ |
/** @file |
* @brief Empty. |
*/ |
#ifndef KBD_arm32_KBD_H_ |
#define KBD_arm32_KBD_H_ |
#endif |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/arm32/src/kbd.c |
---|
0,0 → 1,40 |
/* |
* Copyright (c) 2007 Michal Kebrt |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdarm32 arm32 |
* @brief HelenOS arm32 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
* @brief Empty, required by generic Makefile. |
*/ |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/arm32/src/kbd_gxemul.c |
---|
0,0 → 1,424 |
/* |
* Copyright (c) 2007 Michal Kebrt |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdarm32gxemul GXemul |
* @brief HelenOS arm32 GXEmul uspace keyboard handler. |
* @ingroup kbdarm32 |
* @{ |
*/ |
/** @file |
* @brief GXemul uspace keyboard handler. |
*/ |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
#include <bool.h> |
/* GXemul key codes in no-framebuffer mode. */ |
#define GXEMUL_KEY_F1 0x504f1bL |
#define GXEMUL_KEY_F2 0x514f1bL |
#define GXEMUL_KEY_F3 0x524f1bL |
#define GXEMUL_KEY_F4 0x534f1bL |
#define GXEMUL_KEY_F5 0x35315b1bL |
#define GXEMUL_KEY_F6 0x37315b1bL |
#define GXEMUL_KEY_F7 0x38315b1bL |
#define GXEMUL_KEY_F8 0x39315b1bL |
#define GXEMUL_KEY_F9 0x30325b1bL |
#define GXEMUL_KEY_F10 0x31325b1bL |
#define GXEMUL_KEY_F11 0x33325d1bL |
#define GXEMUL_KEY_F12 0x34325b1bL |
/** Start code of F5-F12 keys. */ |
#define GXEMUL_KEY_F5_F12_START_CODE 0x7e |
/* GXemul key codes in framebuffer mode. */ |
#define GXEMUL_FB_KEY_F1 0x504f5b1bL |
#define GXEMUL_FB_KEY_F2 0x514f5b1bL |
#define GXEMUL_FB_KEY_F3 0x524f5b1bL |
#define GXEMUL_FB_KEY_F4 0x534f5b1bL |
#define GXEMUL_FB_KEY_F5 0x35315b1bL |
#define GXEMUL_FB_KEY_F6 0x37315b1bL |
#define GXEMUL_FB_KEY_F7 0x38315b1bL |
#define GXEMUL_FB_KEY_F8 0x39315b1bL |
#define GXEMUL_FB_KEY_F9 0x38325b1bL |
#define GXEMUL_FB_KEY_F10 0x39325b1bL |
#define GXEMUL_FB_KEY_F11 0x33325b1bL |
#define GXEMUL_FB_KEY_F12 0x34325b1bL |
/** Function keys start code (F1=0x101) */ |
#define FUNCTION_KEYS 0x100 |
static irq_cmd_t gxemul_cmds[] = { |
{ |
CMD_MEM_READ_1, |
(void *) 0, |
0, |
2 |
} |
}; |
static irq_code_t gxemul_kbd = { |
1, |
gxemul_cmds |
}; |
/** Framebuffer switched on. */ |
static bool fb; |
/* |
// Please preserve this code (it can be used to determine scancodes) |
int to_hex(int v) |
{ |
return "0123456789ABCDEF"[v]; |
} |
*/ |
/** Process data sent when a key is pressed (in no-framebuffer mode). |
* |
* @param keybuffer Buffer of pressed key. |
* @param scan_code Scan code. |
* |
* @return Always 1. |
*/ |
static int gxemul_kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code) |
{ |
// holds at most 4 latest scan codes |
static unsigned long buf = 0; |
// number of scan codes in #buf |
static int count = 0; |
/* |
// Preserve for detecting scan codes. |
keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
keybuffer_push(keybuffer, 'X'); |
keybuffer_push(keybuffer, 'Y'); |
return 1; |
*/ |
if (scan_code == '\r') { |
scan_code = '\n'; |
} |
if (scan_code == GXEMUL_KEY_F5_F12_START_CODE) { |
switch (buf) { |
case GXEMUL_KEY_F5: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 5); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F6: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 6); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F7: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 7); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F8: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 8); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F9: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 9); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F10: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 10); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F11: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 11); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F12: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 12); |
buf = count = 0; |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) & 0xff); |
keybuffer_push(keybuffer, (buf >> 16) & 0xff); |
keybuffer_push(keybuffer, (buf >> 24) & 0xff); |
keybuffer_push(keybuffer, scan_code); |
buf = count = 0; |
return 1; |
} |
} |
// add to buffer |
buf |= ((unsigned long) scan_code) << (8 * (count++)); |
if ((buf & 0xff) != (GXEMUL_KEY_F1 & 0xff)) { |
keybuffer_push(keybuffer, buf); |
buf = count = 0; |
return 1; |
} |
if (count <= 1) { |
return 1; |
} |
if ((buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff) |
&& (buf & 0xffff) != (GXEMUL_KEY_F5 & 0xffff) ) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 2) { |
return 1; |
} |
switch (buf) { |
case GXEMUL_KEY_F1: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 1); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F2: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 2); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F3: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 3); |
buf = count = 0; |
return 1; |
case GXEMUL_KEY_F4: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 4); |
buf = count = 0; |
return 1; |
} |
if ((buf & 0xffffff) != (GXEMUL_KEY_F5 & 0xffffff) |
&& (buf & 0xffffff) != (GXEMUL_KEY_F9 & 0xffffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) & 0xff); |
keybuffer_push(keybuffer, (buf >> 16) & 0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 3) { |
return 1; |
} |
switch (buf) { |
case GXEMUL_KEY_F5: |
case GXEMUL_KEY_F6: |
case GXEMUL_KEY_F7: |
case GXEMUL_KEY_F8: |
case GXEMUL_KEY_F9: |
case GXEMUL_KEY_F10: |
case GXEMUL_KEY_F11: |
case GXEMUL_KEY_F12: |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) & 0xff); |
keybuffer_push(keybuffer, (buf >> 16) & 0xff); |
keybuffer_push(keybuffer, (buf >> 24) & 0xff); |
buf = count = 0; |
return 1; |
} |
return 1; |
} |
/** Process data sent when a key is pressed (in framebuffer mode). |
* |
* @param keybuffer Buffer of pressed keys. |
* @param scan_code Scan code. |
* |
* @return Always 1. |
*/ |
static int gxemul_kbd_process_fb(keybuffer_t *keybuffer, int scan_code) |
{ |
// holds at most 4 latest scan codes |
static unsigned long buf = 0; |
// number of scan codes in #buf |
static int count = 0; |
/* |
// Please preserve this code (it can be used to determine scancodes) |
keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
keybuffer_push(keybuffer, ' '); |
keybuffer_push(keybuffer, ' '); |
return 1; |
*/ |
if (scan_code == '\r') { |
scan_code = '\n'; |
} |
// add to buffer |
buf |= ((unsigned long) scan_code) << (8*(count++)); |
if ((buf & 0xff) != (GXEMUL_FB_KEY_F1 & 0xff)) { |
keybuffer_push(keybuffer, buf); |
buf = count = 0; |
return 1; |
} |
if (count <= 1) { |
return 1; |
} |
if ((buf & 0xffff) != (GXEMUL_FB_KEY_F1 & 0xffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 2) { |
return 1; |
} |
if ((buf & 0xffffff) != (GXEMUL_FB_KEY_F1 & 0xffffff) |
&& (buf & 0xffffff) != (GXEMUL_FB_KEY_F5 & 0xffffff) |
&& (buf & 0xffffff) != (GXEMUL_FB_KEY_F9 & 0xffffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) & 0xff); |
keybuffer_push(keybuffer, (buf >> 16) & 0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 3) { |
return 1; |
} |
switch (buf) { |
case GXEMUL_FB_KEY_F1: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 1 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F2: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 2 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F3: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 3 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F4: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 4 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F5: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 5 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F6: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 6 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F7: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 7 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F8: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 8 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F9: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 9 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F10: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 10 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F11: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 11 ); |
buf = count = 0; |
return 1; |
case GXEMUL_FB_KEY_F12: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 12 ); |
buf = count = 0; |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff ); |
keybuffer_push(keybuffer, (buf >> 8) & 0xff); |
keybuffer_push(keybuffer, (buf >> 16) & 0xff); |
keybuffer_push(keybuffer, (buf >> 24) & 0xff); |
buf = count = 0; |
return 1; |
} |
return 1; |
} |
/** Initializes keyboard handler. */ |
int kbd_arch_init(void) |
{ |
fb = (sysinfo_value("fb.kind") == 1); |
gxemul_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual"); |
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &gxemul_kbd); |
return 0; |
} |
/** Process data sent when a key is pressed. |
* |
* @param keybuffer Buffer of pressed keys. |
* @param call IPC call. |
* |
* @return Always 1. |
*/ |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
if (fb) { |
return gxemul_kbd_process_fb(keybuffer, scan_code); |
} else { |
return gxemul_kbd_process_no_fb(keybuffer, scan_code); |
} |
} |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/arch/amd64 |
---|
0,0 → 1,0 |
link ia32 |
Property changes: |
Added: svn:special |
+* |
\ No newline at end of property |
/branches/dynload/uspace/srv/kbd/arch/mips32eb |
---|
0,0 → 1,0 |
link mips32 |
Property changes: |
Added: svn:special |
+* |
\ No newline at end of property |
/branches/dynload/uspace/srv/kbd/genarch/src/nofb.c |
---|
0,0 → 1,190 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdmips32 mips32 |
* @brief HelenOS mips32 arch dependent parts of uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <genarch/nofb.h> |
#include <stdio.h> // DELETE!!! |
#define KEY_F1 0x504f1bL |
#define KEY_F2 0x514f1bL |
#define KEY_F3 0x524f1bL |
#define KEY_F4 0x534f1bL |
#define KEY_F5 0x35315b1bL |
#define KEY_F6 0x37315b1bL |
#define KEY_F7 0x38315b1bL |
#define KEY_F8 0x39315b1bL |
#define KEY_F9 0x30325b1bL |
#define KEY_F10 0x31325b1bL |
#define KEY_F11 0x33325b1bL |
#define KEY_F12 0x34325b1bL |
/** |
* Processes the key pressed - pushes the key code into the key buffer. |
* Used in MSIM and Serengeti, i.e. non-framebuffer consoles. |
*/ |
int kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code) |
{ |
static unsigned long buf = 0; |
static int count = 0; |
if (scan_code == '\r') |
scan_code = '\n'; |
if (scan_code == 0x7e) { |
switch (buf) { |
case KEY_F5: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 5); |
buf = count = 0; |
return 1; |
case KEY_F6: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 6); |
buf = count = 0; |
return 1; |
case KEY_F7: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 7); |
buf = count = 0; |
return 1; |
case KEY_F8: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 8); |
buf = count = 0; |
return 1; |
case KEY_F9: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 9); |
buf = count = 0; |
return 1; |
case KEY_F10: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 10); |
buf = count = 0; |
return 1; |
case KEY_F11: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 11); |
buf = count = 0; |
return 1; |
case KEY_F12: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 12); |
buf = count = 0; |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
keybuffer_push(keybuffer, (buf >> 16) &0xff); |
keybuffer_push(keybuffer, (buf >> 24) &0xff); |
keybuffer_push(keybuffer, scan_code); |
buf = count = 0; |
return 1; |
} |
} |
buf |= ((unsigned long) scan_code)<<(8*(count++)); |
if((buf & 0xff) != (KEY_F1 & 0xff)) { |
keybuffer_push(keybuffer, buf); |
buf = count = 0; |
return 1; |
} |
if (count <= 1) |
return 1; |
if ((buf & 0xffff) != (KEY_F1 & 0xffff) |
&& (buf & 0xffff) != (KEY_F5 & 0xffff) ) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
buf = count = 0; |
return 1; |
} |
if (count <= 2) |
return 1; |
switch (buf) { |
case KEY_F1: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 1); |
buf = count = 0; |
return 1; |
case KEY_F2: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 2); |
buf = count = 0; |
return 1; |
case KEY_F3: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 3); |
buf = count = 0; |
return 1; |
case KEY_F4: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 4); |
buf = count = 0; |
return 1; |
} |
if((buf & 0xffffff) != (KEY_F5 & 0xffffff) |
&& (buf & 0xffffff) != (KEY_F9 & 0xffffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) & 0xff); |
keybuffer_push(keybuffer, (buf >> 16) & 0xff); |
buf=count=0; |
return 1; |
} |
if (count <= 3) |
return 1; |
switch (buf) { |
case KEY_F5: |
case KEY_F6: |
case KEY_F7: |
case KEY_F8: |
case KEY_F9: |
case KEY_F10: |
case KEY_F11: |
case KEY_F12: |
return 1; |
default: |
keybuffer_push(keybuffer, buf & 0xff); |
keybuffer_push(keybuffer, (buf >> 8) &0xff); |
keybuffer_push(keybuffer, (buf >> 16) &0xff); |
keybuffer_push(keybuffer, (buf >> 24) &0xff); |
buf = count = 0; |
return 1; |
} |
return 1; |
} |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/genarch/src/kbd.c |
---|
0,0 → 1,113 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbd |
* @brief Handling of keyboard IRQ notifications for several architectures. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <key_buffer.h> |
#include <arch/scanc.h> |
#include <genarch/scanc.h> |
#include <genarch/kbd.h> |
#include <libc.h> |
#define PRESSED_SHIFT (1<<0) |
#define PRESSED_CAPSLOCK (1<<1) |
#define LOCKED_CAPSLOCK (1<<0) |
static volatile int keyflags; /**< Tracking of multiple keypresses. */ |
static volatile int lockflags; /**< Tracking of multiple keys lockings. */ |
void key_released(keybuffer_t *keybuffer, unsigned char key) |
{ |
switch (key) { |
case SC_LSHIFT: |
case SC_RSHIFT: |
keyflags &= ~PRESSED_SHIFT; |
break; |
case SC_CAPSLOCK: |
keyflags &= ~PRESSED_CAPSLOCK; |
if (lockflags & LOCKED_CAPSLOCK) |
lockflags &= ~LOCKED_CAPSLOCK; |
else |
lockflags |= LOCKED_CAPSLOCK; |
break; |
default: |
break; |
} |
} |
void key_pressed(keybuffer_t *keybuffer, unsigned char key) |
{ |
int *map = sc_primary_map; |
int ascii = sc_primary_map[key]; |
int shift, capslock; |
int letter = 0; |
static int esc_count = 0; |
if (key == SC_ESC) { |
esc_count++; |
if (esc_count == 3) |
__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); |
} else { |
esc_count = 0; |
} |
switch (key) { |
case SC_LSHIFT: |
case SC_RSHIFT: |
keyflags |= PRESSED_SHIFT; |
break; |
case SC_CAPSLOCK: |
keyflags |= PRESSED_CAPSLOCK; |
break; |
case SC_SPEC_ESCAPE: |
break; |
default: |
letter = ((ascii >= 'a') && (ascii <= 'z')); |
capslock = (keyflags & PRESSED_CAPSLOCK) || (lockflags & LOCKED_CAPSLOCK); |
shift = keyflags & PRESSED_SHIFT; |
if (letter && capslock) |
shift = !shift; |
if (shift) |
map = sc_secondary_map; |
if (map[key] != SPECIAL) |
keybuffer_push(keybuffer, map[key]); |
break; |
} |
} |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/genarch/include/nofb.h |
---|
0,0 → 1,48 |
/* |
* Copyright (c) 2008 Pavel Rimsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_genarch_NOFB_H_ |
#define KBD_genarch_NOFB_H_ |
#include <key_buffer.h> |
#include <genarch/scanc.h> |
extern int kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code); |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/genarch/include/kbd.h |
---|
0,0 → 1,47 |
/* |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_genarch_KBD_H_ |
#define KBD_genarch_KBD_H_ |
#include <key_buffer.h> |
extern void key_released(keybuffer_t *keybuffer, unsigned char key); |
extern void key_pressed(keybuffer_t *keybuffer, unsigned char key); |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/genarch/include/scanc.h |
---|
0,0 → 1,50 |
/* |
* Copyright (c) 2001-2004 Jakub Jermar |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KBD_SCANC_H_ |
#define KBD_SCANC_H_ |
#define FUNCTION_KEYS 0x100 |
#define SPECIAL 255 |
extern int sc_primary_map[]; |
extern int sc_secondary_map[]; |
#endif |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/generic/kbd.c |
---|
42,16 → 42,13 |
#include <stdlib.h> |
#include <stdio.h> |
#include <ipc/ns.h> |
#include <async.h> |
#include <errno.h> |
#include <arch/kbd.h> |
#include <kbd.h> |
#include <libadt/fifo.h> |
#include <kbd/kbd.h> |
#include <kbd.h> |
#include <key_buffer.h> |
#include <kbd_port.h> |
#include <kbd_ctl.h> |
#include <layout.h> |
#include <async.h> |
#include <keys.h> |
#define NAME "kbd" |
59,51 → 56,31 |
int phone2cons = -1; |
keybuffer_t keybuffer; |
void kbd_push_scancode(int scancode) |
static void irq_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
printf("scancode: 0x%x\n", scancode); |
kbd_ctl_parse_scancode(scancode); |
} |
int chr; |
#include <kbd/keycode.h> |
void kbd_push_ev(int type, unsigned int key, unsigned int mods) |
{ |
kbd_event_t ev; |
#ifdef MOUSE_ENABLED |
if (mouse_arch_process(phone2cons, call)) |
return; |
#endif |
kbd_arch_process(&keybuffer, call); |
printf("type: %d\n", type); |
printf("mods: 0x%x\n", mods); |
printf("keycode: %u\n", key); |
if (cons_connected && phone2cons != -1) { |
/* |
* recode to ASCII - one interrupt can produce more than one |
* code so result is stored in fifo |
*/ |
while (!keybuffer_empty(&keybuffer)) { |
if (!keybuffer_pop(&keybuffer, (int *)&chr)) |
break; |
ev.type = type; |
ev.key = key; |
ev.mods = mods; |
ev.c = layout_parse_ev(&ev); |
async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); |
async_msg_1(phone2cons, KBD_PUSHCHAR, chr); |
} |
} |
} |
//static void irq_handler(ipc_callid_t iid, ipc_call_t *call) |
//{ |
// kbd_event_t ev; |
// |
// kbd_arch_process(&keybuffer, call); |
// |
// if (cons_connected && phone2cons != -1) { |
// /* |
// * One interrupt can produce more than one event so the result |
// * is stored in a FIFO. |
// */ |
// while (!keybuffer_empty(&keybuffer)) { |
// if (!keybuffer_pop(&keybuffer, &ev)) |
// break; |
// |
// async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, |
// ev.mods, ev.c); |
// } |
// } |
//} |
static void console_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
ipc_callid_t callid; |
142,7 → 119,6 |
} |
int main(int argc, char **argv) |
{ |
printf(NAME ": HelenOS Keyboard service\n"); |
149,8 → 125,8 |
ipcarg_t phonead; |
/* Initialize port driver. */ |
if (kbd_port_init()) |
/* Initialize arch dependent parts */ |
if (kbd_arch_init()) |
return -1; |
/* Initialize key buffer */ |
157,8 → 133,8 |
keybuffer_init(&keybuffer); |
async_set_client_connection(console_connection); |
/* Register service at nameserver. */ |
async_set_interrupt_received(irq_handler); |
/* Register service at nameserver */ |
if (ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, 0, &phonead) != 0) |
return -1; |
165,7 → 141,7 |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* Not reached. */ |
/* Never reached */ |
return 0; |
} |
/branches/dynload/uspace/srv/kbd/generic/key_buffer.c |
---|
40,7 → 40,7 |
/** Clear key buffer. |
*/ |
void keybuffer_free(keybuffer_t *keybuffer) |
void keybuffer_free(keybuffer_t *keybuffer) |
{ |
futex_down(&keybuffer_futex); |
keybuffer->head = 0; |
75,18 → 75,15 |
return (keybuffer->items == 0); |
} |
/** Push key event to key buffer. |
* |
* If the buffer is full, the event is ignored. |
* |
* @param keybuffer The keybuffer. |
* @param ev The event to push. |
/** Push key to key buffer. |
* If buffer is full, character is ignored. |
* @param key code of stored key |
*/ |
void keybuffer_push(keybuffer_t *keybuffer, const kbd_event_t *ev) |
void keybuffer_push(keybuffer_t *keybuffer, int key) |
{ |
futex_down(&keybuffer_futex); |
if (keybuffer->items < KEYBUFFER_SIZE) { |
keybuffer->fifo[keybuffer->tail] = *ev; |
keybuffer->fifo[keybuffer->tail] = key; |
keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE; |
keybuffer->items++; |
} |
93,25 → 90,16 |
futex_up(&keybuffer_futex); |
} |
void keybuffer_push0(keybuffer_t *keybuffer, int c) |
{ |
kbd_event_t ev; |
ev.key = c; ev.mods = 0; ev.c = c; |
keybuffer_push(keybuffer, &ev); |
} |
/** Pop event from buffer. |
* |
* @param edst Pointer to where the event should be saved. |
* @return Zero on empty buffer, nonzero otherwise. |
/** Pop character from buffer. |
* @param c pointer to space where to store character from buffer. |
* @return zero on empty buffer, nonzero else |
*/ |
int keybuffer_pop(keybuffer_t *keybuffer, kbd_event_t *edst) |
int keybuffer_pop(keybuffer_t *keybuffer, int *c) |
{ |
futex_down(&keybuffer_futex); |
if (keybuffer->items > 0) { |
keybuffer->items--; |
*edst = (keybuffer->fifo[keybuffer->head]) ; |
*c = (keybuffer->fifo[keybuffer->head]) ; |
keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE; |
futex_up(&keybuffer_futex); |
return 1; |
/branches/dynload/uspace/srv/kbd/include/layout.h |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/include/kbd_port.h |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/include/kbd_ctl.h |
---|
File deleted |
/branches/dynload/uspace/srv/kbd/include/key_buffer.h |
---|
38,25 → 38,23 |
#define __KEY_BUFFER_H__ |
#include <sys/types.h> |
#include <kbd/kbd.h> |
/** Size of buffer for pressed keys */ |
#define KEYBUFFER_SIZE 128 |
typedef struct { |
kbd_event_t fifo[KEYBUFFER_SIZE]; |
int fifo[KEYBUFFER_SIZE]; |
unsigned long head; |
unsigned long tail; |
unsigned long items; |
} keybuffer_t; |
extern void keybuffer_free(keybuffer_t *); |
extern void keybuffer_init(keybuffer_t *); |
extern int keybuffer_available(keybuffer_t *); |
extern int keybuffer_empty(keybuffer_t *); |
extern void keybuffer_push(keybuffer_t *, const kbd_event_t *); |
extern void keybuffer_push0(keybuffer_t *, int c); |
extern int keybuffer_pop(keybuffer_t *, kbd_event_t *); |
void keybuffer_free(keybuffer_t *keybuffer); |
void keybuffer_init(keybuffer_t *keybuffer); |
int keybuffer_available(keybuffer_t *keybuffer); |
int keybuffer_empty(keybuffer_t *keybuffer); |
void keybuffer_push(keybuffer_t *keybuffer, int key); |
int keybuffer_pop(keybuffer_t *keybuffer, int *c); |
#endif |
/branches/dynload/uspace/srv/kbd/include/keys.h |
---|
0,0 → 1,62 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** |
* @addtogroup kbdgen |
* @{ |
*/ |
/** |
* @file |
*/ |
#ifndef _KBD_KEYS_H_ |
#define _KBD_KEYS_H_ |
#define KBD_PUSHCHAR 1024 |
#define KBD_MS_LEFT 1025 |
#define KBD_MS_RIGHT 1026 |
#define KBD_MS_MIDDLE 1027 |
#define KBD_MS_MOVE 1028 |
#define KBD_KEY_F1 0x3b |
#define KBD_KEY_F2 0x3c |
#define KBD_KEY_F3 0x3d |
#define KBD_KEY_F4 0x3e |
#define KBD_KEY_F5 0x3f |
#define KBD_KEY_F6 0x40 |
#define KBD_KEY_F7 0x41 |
#define KBD_KEY_F8 0x42 |
#define KBD_KEY_F9 0x43 |
#define KBD_KEY_F10 0x44 |
#define KBD_KEY_F11 0x45 |
#define KBD_KEY_F12 0x46 |
#endif |
/** @} |
*/ |
/branches/dynload/uspace/srv/kbd/include/kbd.h |
---|
39,15 → 39,10 |
#include <key_buffer.h> |
#define KBD_EVENT 1024 |
#define KBD_MS_LEFT 1025 |
#define KBD_MS_RIGHT 1026 |
#define KBD_MS_MIDDLE 1027 |
#define KBD_MS_MOVE 1028 |
extern int kbd_arch_init(void); |
extern int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call); |
extern int mouse_arch_process(int phoneid, ipc_call_t *call); |
extern void kbd_push_scancode(int); |
extern void kbd_push_ev(int, unsigned int, unsigned int); |
#endif |
/** |
/branches/dynload/uspace/srv/ns/ns.c |
---|
40,7 → 40,6 |
#include <ipc/ns.h> |
#include <ipc/services.h> |
#include <stdio.h> |
#include <bool.h> |
#include <unistd.h> |
#include <stdlib.h> |
#include <errno.h> |
48,7 → 47,6 |
#include <libadt/list.h> |
#include <libadt/hash_table.h> |
#include <sysinfo.h> |
#include <loader/loader.h> |
#include <ddi.h> |
#include <as.h> |
60,11 → 58,6 |
static int connect_to_service(ipcarg_t service, ipc_call_t *call, |
ipc_callid_t callid); |
void register_clonable(ipcarg_t service, ipcarg_t phone, ipc_call_t *call, |
ipc_callid_t callid); |
void connect_to_clonable(ipcarg_t service, ipc_call_t *call, |
ipc_callid_t callid); |
/* Static functions implementing NS hash table operations. */ |
static hash_index_t ns_hash(unsigned long *key); |
static int ns_compare(unsigned long *key, hash_count_t keys, link_t *item); |
91,27 → 84,11 |
static void *clockaddr = NULL; |
static void *klogaddr = NULL; |
/** Request for connection to a clonable service. */ |
typedef struct { |
link_t link; |
ipcarg_t service; |
ipc_call_t call; |
ipc_callid_t callid; |
} cs_req_t; |
/** List of clonable-service connection requests. */ |
static link_t cs_req; |
/** Return true if @a service is clonable. */ |
static bool service_clonable(int service) |
static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, |
void **addr) |
{ |
return service == SERVICE_LOAD; |
} |
void *ph_addr; |
static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr) |
{ |
void *ph_addr; |
if (!*addr) { |
ph_addr = (void *) sysinfo_value(name); |
if (!ph_addr) { |
119,11 → 96,8 |
return; |
} |
*addr = as_get_mappable_page(PAGE_SIZE); |
if (physmem_map(ph_addr, *addr, 1, |
AS_AREA_READ | AS_AREA_CACHEABLE) != 0) { |
ipc_answer_0(callid, ENOENT); |
return; |
} |
physmem_map(ph_addr, *addr, 1, |
AS_AREA_READ | AS_AREA_CACHEABLE); |
} |
ipc_answer_2(callid, EOK, (ipcarg_t) *addr, AS_AREA_READ); |
} |
142,8 → 116,6 |
printf(NAME ": No memory available\n"); |
return ENOMEM; |
} |
list_initialize(&cs_req); |
printf(NAME ": Accepting connections\n"); |
while (1) { |
152,10 → 124,12 |
case IPC_M_SHARE_IN: |
switch (IPC_GET_ARG3(call)) { |
case SERVICE_MEM_REALTIME: |
get_as_area(callid, &call, "clock.faddr", &clockaddr); |
get_as_area(callid, &call, "clock.faddr", |
&clockaddr); |
break; |
case SERVICE_MEM_KLOG: |
get_as_area(callid, &call, "klog.faddr", &klogaddr); |
get_as_area(callid, &call, "klog.faddr", |
&klogaddr); |
break; |
default: |
ipc_answer_0(callid, ENOENT); |
168,27 → 142,15 |
/* |
* Server requests service registration. |
*/ |
if (service_clonable(IPC_GET_ARG1(call))) { |
register_clonable(IPC_GET_ARG1(call), |
IPC_GET_ARG5(call), &call, callid); |
continue; |
} else { |
retval = register_service(IPC_GET_ARG1(call), |
IPC_GET_ARG5(call), &call); |
} |
retval = register_service(IPC_GET_ARG1(call), |
IPC_GET_ARG5(call), &call); |
break; |
case IPC_M_CONNECT_ME_TO: |
/* |
* Client requests to be connected to a service. |
*/ |
if (service_clonable(IPC_GET_ARG1(call))) { |
connect_to_clonable(IPC_GET_ARG1(call), |
&call, callid); |
continue; |
} else { |
retval = connect_to_service(IPC_GET_ARG1(call), |
&call, callid); |
} |
retval = connect_to_service(IPC_GET_ARG1(call), &call, |
callid); |
break; |
default: |
retval = ENOENT; |
205,11 → 167,11 |
/** Register service. |
* |
* @param service Service to be registered. |
* @param phone Phone to be used for connections to the service. |
* @param call Pointer to call structure. |
* @param service Service to be registered. |
* @param phone Phone to be used for connections to the service. |
* @param call Pointer to call structure. |
* |
* @return Zero on success or a value from @ref errno.h. |
* @return Zero on success or a value from @ref errno.h. |
*/ |
int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call) |
{ |
219,7 → 181,7 |
0 |
}; |
hashed_service_t *hs; |
if (hash_table_find(&ns_hash_table, keys)) { |
return EEXISTS; |
} |
240,9 → 202,9 |
/** Connect client to service. |
* |
* @param service Service to be connected to. |
* @param call Pointer to call structure. |
* @param callid Call ID of the request. |
* @param service Service to be connected to. |
* @param call Pointer to call structure. |
* @param callid Call ID of the request. |
* |
* @return Zero on success or a value from @ref errno.h. |
*/ |
251,7 → 213,7 |
unsigned long keys[3] = { service, 0, 0 }; |
link_t *hlp; |
hashed_service_t *hs; |
hlp = hash_table_find(&ns_hash_table, keys); |
if (!hlp) { |
return ENOENT; |
261,82 → 223,6 |
IPC_GET_ARG3(*call), 0, IPC_FF_NONE); |
} |
/** Register clonable service. |
* |
* @param service Service to be registered. |
* @param phone Phone to be used for connections to the service. |
* @param call Pointer to call structure. |
*/ |
void register_clonable(ipcarg_t service, ipcarg_t phone, ipc_call_t *call, |
ipc_callid_t callid) |
{ |
int rc; |
cs_req_t *csr; |
if (list_empty(&cs_req)) { |
/* There was no pending connection request. */ |
printf(NAME ": Unexpected clonable server.\n"); |
ipc_answer_0(callid, EBUSY); |
return; |
} |
csr = list_get_instance(cs_req.next, cs_req_t, link); |
list_remove(&csr->link); |
/* Currently we can only handle a single type of clonable service. */ |
assert(csr->service == SERVICE_LOAD); |
ipc_answer_0(callid, EOK); |
rc = ipc_forward_fast(csr->callid, phone, IPC_GET_ARG2(csr->call), |
IPC_GET_ARG3(csr->call), 0, IPC_FF_NONE); |
free(csr); |
} |
/** Connect client to clonable service. |
* |
* @param service Service to be connected to. |
* @param call Pointer to call structure. |
* @param callid Call ID of the request. |
* |
* @return Zero on success or a value from @ref errno.h. |
*/ |
void connect_to_clonable(ipcarg_t service, ipc_call_t *call, |
ipc_callid_t callid) |
{ |
int rc; |
cs_req_t *csr; |
assert(service == SERVICE_LOAD); |
csr = malloc(sizeof(cs_req_t)); |
if (csr == NULL) { |
ipc_answer_0(callid, ENOMEM); |
return; |
} |
/* Spawn a loader. */ |
rc = loader_spawn("loader"); |
if (rc < 0) { |
free(csr); |
ipc_answer_0(callid, rc); |
return; |
} |
csr->service = service; |
csr->call = *call; |
csr->callid = callid; |
/* |
* We can forward the call only after the server we spawned connects |
* to us. Meanwhile we might need to service more connection requests. |
* Thus we store the call in a queue. |
*/ |
list_append(&csr->link, &cs_req); |
} |
/** Compute hash index into NS hash table. |
* |
* @param key Pointer keys. However, only the first key (i.e. service number) |
/branches/dynload/uspace/srv/console/console.c |
---|
35,8 → 35,7 |
#include <libc.h> |
#include <fb.h> |
#include <ipc/ipc.h> |
#include <kbd.h> |
#include <kbd/keycode.h> |
#include <keys.h> |
#include <ipc/fb.h> |
#include <ipc/services.h> |
#include <errno.h> |
298,7 → 297,7 |
ipc_callid_t callid; |
ipc_call_t call; |
int retval; |
kbd_event_t ev; |
int c; |
connection_t *conn; |
int newcon; |
320,24 → 319,22 |
IPC_GET_ARG2(call)); |
retval = 0; |
break; |
case KBD_EVENT: |
/* Got event from keyboard driver. */ |
case KBD_PUSHCHAR: |
/* got key from keyboard driver */ |
retval = 0; |
ev.type = IPC_GET_ARG1(call); |
ev.key = IPC_GET_ARG2(call); |
ev.mods = IPC_GET_ARG3(call); |
ev.c = IPC_GET_ARG4(call); |
c = IPC_GET_ARG1(call); |
/* switch to another virtual console */ |
conn = &connections[active_console]; |
if ((ev.key >= KC_F1) && (ev.key < KC_F1 + |
CONSOLE_COUNT)) { |
if (ev.key == KC_F12) |
/* |
* if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + |
* CONSOLE_COUNT)) { |
*/ |
if ((c >= 0x101) && (c < 0x101 + CONSOLE_COUNT)) { |
if (c == 0x112) |
change_console(KERNEL_CONSOLE); |
else |
change_console(ev.key - KC_F1); |
change_console(c - 0x101); |
break; |
} |
344,14 → 341,14 |
/* if client is awaiting key, send it */ |
if (conn->keyrequest_counter > 0) { |
conn->keyrequest_counter--; |
ipc_answer_4(fifo_pop(conn->keyrequests), EOK, |
ev.type, ev.key, ev.mods, ev.c); |
ipc_answer_1(fifo_pop(conn->keyrequests), EOK, |
c); |
break; |
} |
keybuffer_push(&conn->keybuffer, &ev); |
keybuffer_push(&conn->keybuffer, c); |
retval = 0; |
break; |
default: |
retval = ENOENT; |
366,7 → 363,7 |
ipc_callid_t callid; |
ipc_call_t call; |
int consnum; |
ipcarg_t arg1, arg2, arg3, arg4; |
ipcarg_t arg1, arg2, arg3; |
connection_t *conn; |
if ((consnum = find_free_connection()) == -1) { |
391,9 → 388,6 |
arg1 = 0; |
arg2 = 0; |
arg3 = 0; |
arg4 = 0; |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
gcons_notify_disconnect(consnum); |
464,7 → 458,7 |
if (consnum == active_console) |
curs_visibility(arg1); |
break; |
case CONSOLE_GETKEY: |
case CONSOLE_GETCHAR: |
if (keybuffer_empty(&conn->keybuffer)) { |
/* buffer is empty -> store request */ |
if (conn->keyrequest_counter < |
480,15 → 474,12 |
} |
continue; |
} |
kbd_event_t ev; |
keybuffer_pop(&conn->keybuffer, &ev); |
arg1 = ev.type; |
arg2 = ev.key; |
arg3 = ev.mods; |
arg4 = ev.c; |
int ch; |
keybuffer_pop(&conn->keybuffer, &ch); |
arg1 = ch; |
break; |
} |
ipc_answer_4(callid, EOK, arg1, arg2, arg3, arg4); |
ipc_answer_2(callid, EOK, arg1, arg2); |
} |
} |
/branches/dynload/uspace/srv/rd/rd.c |
---|
257,7 → 257,7 |
int flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; |
int retval = physmem_map(rd_ph_addr, rd_addr, |
ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags); |
if (retval < 0) { |
printf(NAME ": Error mapping RAM disk\n"); |
return false; |
/branches/dynload/uspace/srv/loader/main.c |
---|
50,7 → 50,6 |
#include <fcntl.h> |
#include <sys/types.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
#include <ipc/loader.h> |
#include <loader/pcb.h> |
#include <errno.h> |
82,8 → 81,6 |
static bool is_dyn_linked; |
/** Used to limit number of connections to one. */ |
static bool connected; |
static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request) |
{ |
308,17 → 305,6 |
ipc_call_t call; |
int retval; |
/* Already have a connection? */ |
if (connected) { |
ipc_answer_0(iid, ELIMIT); |
return; |
} |
connected = true; |
/* Accept the connection */ |
ipc_answer_0(iid, EOK); |
/* Ignore parameters, the connection is already open */ |
(void)iid; (void)icall; |
360,20 → 346,31 |
*/ |
int main(int argc, char *argv[]) |
{ |
ipcarg_t phonead; |
ipc_callid_t callid; |
ipc_call_t call; |
ipcarg_t phone_hash; |
connected = false; |
/* Set a handler of incomming connections. */ |
async_set_client_connection(loader_connection); |
/* The first call only communicates the incoming phone hash */ |
callid = ipc_wait_for_call(&call); |
/* Register at naming service. */ |
if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0) |
return -1; |
if (IPC_GET_METHOD(call) != LOADER_HELLO) { |
if (IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) |
ipc_answer_0(callid, EINVAL); |
return 1; |
} |
ipc_answer_0(callid, EOK); |
phone_hash = call.in_phone_hash; |
/* |
* Up until now async must not be used as it couldn't |
* handle incoming requests. (Which means e.g. printf() |
* cannot be used) |
*/ |
async_new_connection(phone_hash, 0, NULL, loader_connection); |
async_manager(); |
/* Never reached */ |
/* not reached */ |
return 0; |
} |
/branches/dynload/uspace/srv/fb/fb.c |
---|
1671,9 → 1671,8 |
unsigned int fbsize = fb_scanline * fb_height; |
void *fb_addr = as_get_mappable_page(fbsize); |
if (physmem_map(fb_ph_addr + fb_offset, fb_addr, |
ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0) |
return -1; |
physmem_map(fb_ph_addr + fb_offset, fb_addr, |
ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual)) |
return 0; |
/branches/dynload/uspace/srv/fb/ega.c |
---|
373,7 → 373,7 |
scr_width = sysinfo_value("fb.width"); |
scr_height = sysinfo_value("fb.height"); |
if (sysinfo_value("fb.blinking")) { |
if(sysinfo_value("fb.blinking")) { |
ega_normal_color &= 0x77; |
ega_inverted_color &= 0x77; |
} |
385,9 → 385,8 |
sz = scr_width * scr_height * 2; |
scr_addr = as_get_mappable_page(sz); |
if (physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> |
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0) |
return -1; |
physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> |
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
async_set_client_connection(ega_client_connection); |
/branches/dynload/uspace/srv/fb/msim.c |
---|
59,8 → 59,7 |
void *phys_addr = (void *) sysinfo_value("fb.address.physical"); |
virt_addr = (char *) as_get_mappable_page(1); |
if (physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE) != 0) |
return -1; |
physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE); |
serial_console_init(msim_putc, WIDTH, HEIGHT); |
/branches/dynload/uspace/srv/fb/sgcn.c |
---|
121,13 → 121,19 |
*/ |
int sgcn_init(void) |
{ |
sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size")); |
sram_virt_addr = (uintptr_t) as_get_mappable_page( |
sysinfo_value("sram.area.size")); |
int result = physmem_map( |
(void *) sysinfo_value("sram.address.physical"), |
(void *) sram_virt_addr, |
sysinfo_value("sram.area.size") / PAGE_SIZE, |
AS_AREA_READ | AS_AREA_WRITE |
); |
if (result != 0) { |
printf("SGCN: uspace driver couldn't map physical memory: %d\n", |
result); |
} |
if (physmem_map((void *) sysinfo_value("sram.address.physical"), |
(void *) sram_virt_addr, sysinfo_value("sram.area.size") / PAGE_SIZE, |
AS_AREA_READ | AS_AREA_WRITE) != 0) |
return -1; |
serial_console_init(sgcn_putc, WIDTH, HEIGHT); |
sram_buffer_offset = sysinfo_value("sram.buffer.offset"); |
/branches/dynload/HelenOS.config |
---|
48,10 → 48,6 |
! [PLATFORM=mips32] MACHINE (choice) |
% Machine type |
@ "gxemul" GXEmul |
! [PLATFORM=arm32] MACHINE (choice) |
% Machine type |
@ "i460GX" i460GX chipset machine |
@ "ski" Ski ia64 simulator |
! [PLATFORM=ia64] MACHINE (choice) |
142,7 → 138,7 |
% User space architecture |
@ "mips32eb" |
! [PLATFORM=mips32&MACHINE=bgxemul] UARCH (choice) |
! [PLATFORM=mips32&(MACHINE=bgxemul)] UARCH (choice) |
% User space architecture |
@ "ppc32" |
246,11 → 242,8 |
! [PLATFORM=ia32&(MACHINE=athlon-xp|MACHINE=athlon-mp|MACHINE=pentium3)] CONFIG_FENCES_P3 (y) |
% Fences |
! [PLATFORM=ia32&(MACHINE=pentium4|MACHINE=core)] CONFIG_FENCES_P4 (y) |
! [(PLATFORM=ia32&(MACHINE=pentium4|MACHINE=core))|PLATFORM=amd64] CONFIG_FENCES_P4 (y) |
% Fences |
! [PLATFORM=amd64] CONFIG_FENCES_P4 (y) |
% ACPI support |
! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_ACPI (y) |
282,22 → 275,19 |
! [PLATFORM=sparc64] CONFIG_OFW_TREE (y) |
% FPU support |
! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=ia64|PLATFORM=sparc64] CONFIG_FPU (y) |
! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=ia64|PLATFORM=sparc64|(PLATFORM=mips32&(MACHINE=lgxemul|MACHINE=bgxemul))] CONFIG_FPU (y) |
% FPU support |
! [PLATFORM=mips32&(MACHINE=lgxemul|MACHINE=bgxemul)] CONFIG_FPU (y) |
## Kernel features options |
% Support for SMP |
! [(PLATFORM=ia32&MACHINE!=athlon-xp)|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64|(PLATFORM=mips32&MACHINE=msim)] CONFIG_SMP (y/n) |
! [(PLATFORM=ia32&MACHINE!=athlon-xp)|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64] CONFIG_SMP (y/n) |
% Improved support for hyperthreading |
! [PLATFORM=amd64&CONFIG_SMP=y] CONFIG_HT (y/n) |
! [((PLATFORM=ia32&MACHINE!=athlon-xp&MACHINE!=athlon-mp&MACHINE!=pentium3)|PLATFORM=amd64)&CONFIG_SMP=y] CONFIG_HT (y/n) |
% Improved support for hyperthreading |
! [PLATFORM=ia32&MACHINE!=athlon-xp&MACHINE!=athlon-mp&MACHINE!=pentium3&CONFIG_SMP=y] CONFIG_HT (y/n) |
% Simics BIOS AP boot fix |
! [(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_SMP=y] CONFIG_SIMICS_FIX (y/n) |
% Lazy FPU context switching |
! [CONFIG_FPU=y] CONFIG_FPU_LAZY (y/n) |
312,22 → 302,25 |
! [PLATFORM=sparc64] CONFIG_Z8530 (y/n) |
% Support for NS16550 serial port |
! [PLATFORM=sparc64] CONFIG_NS16550 (y/n) |
! [PLATFORM=sparc64|(PLATFORM=ia64&MACHINE!=ski)] CONFIG_NS16550 (n/y) |
% Support for NS16550 serial port |
! [PLATFORM=ia64&MACHINE!=ski] CONFIG_NS16550 (n/y) |
% IOSapic on default address support |
! [PLATFORM=ia64&MACHINE!=ski] CONFIG_IOSAPIC (y/n) |
% Interrupt-driven driver for Legacy Keyboard |
! [CONFIG_NS16550=n&CONFIG_IOSAPIC=y&MACHINE!=ski] CONFIG_I8042_INTERRUPT_DRIVEN (y/n) |
% Interrupt-driven driver for NS16550 |
! [CONFIG_NS16550=y&((PLATFORM!=ia64)|CONFIG_IOSAPIC=y)&MACHINE!=ski] CONFIG_NS16550_INTERRUPT_DRIVEN (y/n) |
% Support for Serengeti console |
! [PLATFORM=sparc64] CONFIG_SGCN (y/n) |
% IOSapic on default address support |
! [PLATFORM=ia64&MACHINE!=ski] CONFIG_IOSAPIC (y/n) |
% Virtually indexed D-cache support |
! [PLATFORM=sparc64] CONFIG_VIRT_IDX_DCACHE (y/n) |
% Support for userspace debuggers |
! CONFIG_UDEBUG (y/n) |
! CONFIG_UDEBUG (n/y) |
% Kernel console support |
! CONFIG_KCONSOLE (y/n) |
338,6 → 331,12 |
% Deadlock detection support for spinlocks |
! [CONFIG_DEBUG=y&CONFIG_SMP=y] CONFIG_DEBUG_SPINLOCK (y/n) |
% Watchpoint on rewriting AS with zero |
! [CONFIG_DEBUG=y&(PLATFORM=amd64|PLATFORM=ia32)] CONFIG_DEBUG_AS_WATCHPOINT (y/n) |
% Save all interrupt registers |
! [CONFIG_DEBUG=y&(PLATFORM=amd64|PLATFORM=mips32|PLATFORM=ia32)] CONFIG_DEBUG_ALLREGS (y/n) |
% Compile kernel tests |
! CONFIG_TEST (y/n) |
345,7 → 344,7 |
## Hardware support |
% Framebuffer support |
! [(PLATFORM=mips32&MACHINE=lgxemul)|(PLATFORM=mips32&MACHINE=bgxemul)|PLATFORM=ia32|PLATFORM=amd64|PLATFORM=arm32|(PLATFORM=sparc64&MACHINE=us3)] CONFIG_FB (y/n) |
! [(PLATFORM=mips32&MACHINE=lgxemul)|(PLATFORM=mips32&MACHINE=bgxemul)|(PLATFORM=ia32)|(PLATFORM=amd64)|(PLATFORM=arm32)|(PLATFORM=sparc64&MACHINE=us3)] CONFIG_FB (y/n) |
% Framebuffer support |
! [PLATFORM=ppc32|(PLATFORM=sparc64&MACHINE=us)] CONFIG_FB (y) |
393,10 → 392,5 |
% External ramdisk |
! [PLATFORM=sparc64] CONFIG_RD_EXTERNAL (y/n) |
% Keyboard layout |
@ "us_qwerty" US QWERTY |
@ "us_dvorak" US Dvorak |
! KBD_LAYOUT (choice) |
% Use shared C library |
! CONFIG_SHARED_LIBC (y/n) |
/branches/dynload/boot/generic/macros.h |
---|
35,18 → 35,15 |
#ifndef BOOT_MACROS_H_ |
#define BOOT_MACROS_H_ |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
#define SIZE2KB(size) ((size) >> 10) |
#define SIZE2MB(size) ((size) >> 20) |
#define SIZE2KB(size) ((size) >> 10) |
#define SIZE2MB(size) ((size) >> 20) |
#define KB2SIZE(kb) ((kb) << 10) |
#define MB2SIZE(mb) ((mb) << 20) |
#define KB2SIZE(kb) ((kb) << 10) |
#define MB2SIZE(mb) ((mb) << 20) |
#define STRING(arg) STRING_ARG(arg) |
#define STRING_ARG(arg) #arg |
#define STRING(arg) STRING_ARG(arg) |
#define STRING_ARG(arg) #arg |
#endif |
/** @} |
/branches/dynload/boot/generic/align.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup generic |
/** @addtogroup generic |
* @{ |
*/ |
/** @file |
/branches/dynload/boot/arch/arm32/loader/main.c |
---|
32,7 → 32,7 |
*/ |
/** @file |
* @brief Bootstrap. |
*/ |
*/ |
#include "main.h" |
39,7 → 39,6 |
#include "asm.h" |
#include "_components.h" |
#include <printf.h> |
#include <align.h> |
#include <macros.h> |
#include "mm.h" |
110,7 → 109,7 |
} |
printf("\nBooting the kernel...\n"); |
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo); |
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo)); |
} |
/** @} |
/branches/dynload/boot/arch/arm32/loader/boot.S |
---|
53,3 → 53,5 |
# make place for PTL0 page table |
page_table: |
.skip PTL0_ENTRIES * PTL0_ENTRY_SIZE |
/branches/dynload/boot/arch/arm32/loader/asm.h |
---|
32,7 → 32,7 |
*/ |
/** @file |
* @brief Functions implemented in assembly. |
*/ |
*/ |
#ifndef BOOT_arm32_ASM_H |
40,10 → 40,10 |
/** Copies cnt bytes from dst to src. |
* |
* |
* @param dst Destination address. |
* @param src Source address. |
* @param cnt Count of bytes to be copied. |
* @param cnt Count of bytes to be copied. |
*/ |
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) |
58,11 → 58,12 |
/** Jumps to the kernel entry point. |
* |
* @param entry Kernel entry point address. |
* @param bootinfo Structure holding information about loaded tasks. |
* |
* @param entry Kernel entry point address. |
* @param bootinfo Structure holding information about loaded tasks. |
* @param bootinfo_size Size of the bootinfo structure. |
*/ |
extern void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn)); |
extern void jump_to_kernel(void *entry, void *bootinfo, |
unsigned int bootinfo_size) __attribute__((noreturn)); |
#endif |
/branches/dynload/boot/arch/arm32/loader/main.h |
---|
32,7 → 32,7 |
*/ |
/** @file |
* @brief Boot related declarations. |
*/ |
*/ |
#ifndef BOOT_arm32_MAIN_H |
39,6 → 39,13 |
#define BOOT_arm32_MAIN_H |
/** Aligns to the nearest higher address. |
* |
* @param addr Address or number to be aligned. |
* @param align Size of alignment, must be power of 2. |
*/ |
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1)) |
/** Maximum number of tasks in the #bootinfo_t struct. */ |
#define TASKMAP_MAX_RECORDS 32 |
67,3 → 74,4 |
/** @} |
*/ |
/branches/dynload/boot/arch/mips32/loader/main.c |
---|
28,7 → 28,6 |
#include "main.h" |
#include <printf.h> |
#include <align.h> |
#include <macros.h> |
#include "msim.h" |
#include "asm.h" |
74,10 → 73,9 |
printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size); |
printf("\nCopying components\n"); |
unsigned int top = 0; |
bootinfo.cnt = 0; |
for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) { |
for (i = 0; i < COMPONENTS; i++) { |
printf(" %s...", components[i].name); |
top = ALIGN_UP(top, PAGE_SIZE); |
memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size); |
90,13 → 88,6 |
printf("done.\n"); |
} |
unsigned int *cpumap = (unsigned int *) CPUMAP; |
bootinfo.cpumap = 0; |
for (i = 0; i < CPUMAP_MAX_RECORDS; i++) { |
if (cpumap[i] != 0) |
bootinfo.cpumap |= (1 << i); |
} |
printf("\nBooting the kernel...\n"); |
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo); |
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo)); |
} |
/branches/dynload/boot/arch/mips32/loader/asm.h |
---|
29,11 → 29,11 |
#ifndef BOOT_mips32_ASM_H_ |
#define BOOT_mips32_ASM_H_ |
#define PAGE_SIZE 16384 |
#define PAGE_WIDTH 14 |
#define PAGE_SIZE 16384 |
#define PAGE_WIDTH 14 |
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) |
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) |
void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn)); |
void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn)); |
#endif |
/branches/dynload/boot/arch/mips32/loader/main.h |
---|
29,15 → 29,15 |
#ifndef BOOT_mips32_MAIN_H_ |
#define BOOT_mips32_MAIN_H_ |
#define CPUMAP 0x80001000 |
#define INITIAL_STACK 0x80002000 |
#define MSIM_DORDER_ADDRESS 0xb0000004 |
/** Align to the nearest higher address. |
* |
* @param addr Address or size to be aligned. |
* @param align Size of alignment, must be power of 2. |
*/ |
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1)) |
#define TASKMAP_MAX_RECORDS 32 |
#define CPUMAP_MAX_RECORDS 32 |
#define TASKMAP_MAX_RECORDS 32 |
#ifndef __ASM__ |
typedef struct { |
void *addr; |
unsigned int size; |
44,7 → 44,6 |
} task_t; |
typedef struct { |
unsigned int cpumap; |
unsigned int cnt; |
task_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
53,5 → 52,3 |
extern void bootstrap(void); |
#endif |
#endif |
/branches/dynload/boot/arch/mips32/loader/boot.S |
---|
27,8 → 27,9 |
# |
#include "regname.h" |
#include "main.h" |
#define INITIAL_STACK 0x80040000 |
.set noat |
.set noreorder |
.set nomacro |
37,82 → 38,8 |
.global start |
start: |
lui $sp, INITIAL_STACK >> 16 |
ori $sp, $sp, INITIAL_STACK & 0xffff |
/* Setup CPU map (on msim this code |
is executed in parallel on all CPUs, |
but it not an issue) */ |
la $a0, CPUMAP |
sw $zero, 0($a0) |
sw $zero, 4($a0) |
sw $zero, 8($a0) |
sw $zero, 12($a0) |
sw $zero, 16($a0) |
sw $zero, 20($a0) |
sw $zero, 24($a0) |
sw $zero, 28($a0) |
sw $zero, 32($a0) |
sw $zero, 36($a0) |
sw $zero, 40($a0) |
sw $zero, 44($a0) |
sw $zero, 48($a0) |
sw $zero, 52($a0) |
sw $zero, 56($a0) |
sw $zero, 60($a0) |
sw $zero, 64($a0) |
sw $zero, 68($a0) |
sw $zero, 72($a0) |
sw $zero, 76($a0) |
sw $zero, 80($a0) |
sw $zero, 84($a0) |
sw $zero, 88($a0) |
sw $zero, 92($a0) |
sw $zero, 96($a0) |
sw $zero, 100($a0) |
sw $zero, 104($a0) |
sw $zero, 108($a0) |
sw $zero, 112($a0) |
sw $zero, 116($a0) |
sw $zero, 120($a0) |
sw $zero, 124($a0) |
lui $a1, 1 |
#ifdef MACHINE_msim |
/* Read dorder value */ |
la $k0, MSIM_DORDER_ADDRESS |
lw $k1, ($k0) |
/* If we are not running on BSP |
then end in an infinite loop */ |
beq $k1, $zero, bsp |
j bootstrap |
nop |
/* Record CPU presence */ |
sll $a2, $k1, 2 |
addu $a2, $a2, $a0 |
sw $a1, ($a2) |
loop: |
j loop |
nop |
#endif |
bsp: |
/* Record CPU presence */ |
sw $a1, ($a0) |
/* Setup initial stack */ |
la $sp, INITIAL_STACK |
j bootstrap |
nop |
/branches/dynload/Makefile |
---|
29,17 → 29,20 |
## Include configuration |
# |
.PHONY: all config distclean clean cscope |
-include Makefile.config |
all: Makefile.config config.h config.defs |
.PHONY: all build config distclean clean cscope |
all: |
tools/config.py HelenOS.config default |
$(MAKE) -C . build |
build: Makefile.config config.h config.defs |
$(MAKE) -C kernel |
$(MAKE) -C uspace |
$(MAKE) -C boot |
Makefile.config config.h config.defs: HelenOS.config |
tools/config.py HelenOS.config default |
config: |
config: HelenOS.config |
tools/config.py HelenOS.config |
distclean: clean |