HelenOS sources
This source file includes following definitions.
- gta02_init
- gta02_timer_irq_start
- gta02_cpu_halt
- gta02_get_memory_extents
- gta02_irq_exception
- gta02_frame_init
- gta02_output_init
- gta02_input_init
- gta02_get_irq_count
- gta02_get_platform_name
- gta02_timer_irq_init
- gta02_timer_irq_claim
- gta02_timer_irq_handler
- gta02_timer_start
#include <arch/exception.h>
#include <arch/mach/gta02/gta02.h>
#include <arch/mm/page.h>
#include <mm/page.h>
#include <mm/km.h>
#include <genarch/fb/fb.h>
#include <abi/fb/visuals.h>
#include <genarch/drivers/s3c24xx/uart.h>
#include <genarch/drivers/s3c24xx/irqc.h>
#include <genarch/drivers/s3c24xx/timer.h>
#include <genarch/srln/srln.h>
#include <sysinfo/sysinfo.h>
#include <interrupt.h>
#include <ddi/ddi.h>
#include <log.h>
#define GTA02_MEMORY_START 0x30000000
#define GTA02_MEMORY_SIZE 0x08000000
#define GTA02_MEMORY_SKIP 0x8000
#define GTA02_SCONS_BASE 0x50008000
#define GTA02_FB_BASE 0x08800000
#define GTA02_TIMER_IRQ S3C24XX_INT_TIMER0
static void gta02_init(void);
static void gta02_timer_irq_start(void);
static void gta02_cpu_halt(void);
static void gta02_get_memory_extents(uintptr_t *start, size_t *size);
static void gta02_irq_exception(unsigned int exc_no, istate_t *istate);
static void gta02_frame_init(void);
static void gta02_output_init(void);
static void gta02_input_init(void);
static size_t gta02_get_irq_count(void);
static const char *gta02_get_platform_name(void);
static void gta02_timer_irq_init(void);
static void gta02_timer_start(void);
static irq_ownership_t gta02_timer_irq_claim(irq_t *irq);
static void gta02_timer_irq_handler(irq_t *irq);
static outdev_t *gta02_scons_dev;
static s3c24xx_irqc_t gta02_irqc;
static s3c24xx_timer_t *gta02_timer;
static irq_t gta02_timer_irq;
struct arm_machine_ops gta02_machine_ops = {
gta02_init,
gta02_timer_irq_start,
gta02_cpu_halt,
gta02_get_memory_extents,
gta02_irq_exception,
gta02_frame_init,
gta02_output_init,
gta02_input_init,
gta02_get_irq_count,
gta02_get_platform_name
};
static void gta02_init(void)
{
s3c24xx_irqc_regs_t *irqc_regs;
gta02_timer = (void *) km_map(S3C24XX_TIMER_ADDRESS, PAGE_SIZE,
PAGE_SIZE, PAGE_NOT_CACHEABLE);
irqc_regs = (void *) km_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE, PAGE_SIZE,
PAGE_NOT_CACHEABLE);
s3c24xx_irqc_init(>a02_irqc, irqc_regs);
}
static void gta02_timer_irq_start(void)
{
gta02_timer_irq_init();
gta02_timer_start();
}
static void gta02_cpu_halt(void)
{
}
static void gta02_get_memory_extents(uintptr_t *start, size_t *size)
{
*start = GTA02_MEMORY_START + GTA02_MEMORY_SKIP;
*size = GTA02_MEMORY_SIZE - GTA02_MEMORY_SKIP;
}
static void gta02_irq_exception(unsigned int exc_no, istate_t *istate)
{
uint32_t inum;
inum = s3c24xx_irqc_inum_get(>a02_irqc);
s3c24xx_irqc_clear(>a02_irqc, inum);
irq_t *irq = irq_dispatch_and_lock(inum);
if (irq) {
irq->handler(irq);
irq_spinlock_unlock(&irq->lock, false);
} else {
log(LF_ARCH, LVL_DEBUG, "cpu%d: spurious interrupt (inum=%d)",
CPU->id, inum);
}
}
static void gta02_frame_init(void)
{
}
static void gta02_output_init(void)
{
#ifdef CONFIG_FB
fb_properties_t prop = {
.addr = GTA02_FB_BASE,
.offset = 0,
.x = 480,
.y = 640,
.scan = 960,
.visual = VISUAL_RGB_5_6_5_LE
};
outdev_t *fb_dev = fb_init(&prop);
if (fb_dev)
stdout_wire(fb_dev);
#endif
gta02_scons_dev =
s3c24xx_uart_init(GTA02_SCONS_BASE, S3C24XX_INT_UART2);
if (gta02_scons_dev) {
stdout_wire(gta02_scons_dev);
}
sysinfo_set_item_val("s3c24xx_uart", NULL, true);
sysinfo_set_item_val("s3c24xx_uart.inr", NULL, S3C24XX_INT_UART2);
sysinfo_set_item_val("s3c24xx_uart.address.physical", NULL,
(uintptr_t) GTA02_SCONS_BASE);
}
static void gta02_input_init(void)
{
s3c24xx_uart_t *scons_inst;
if (gta02_scons_dev) {
scons_inst = (void *) gta02_scons_dev->data;
srln_instance_t *srln_instance = srln_init();
if (srln_instance) {
indev_t *sink = stdin_wire();
indev_t *srln = srln_wire(srln_instance, sink);
s3c24xx_uart_input_wire(scons_inst, srln);
s3c24xx_irqc_src_enable(>a02_irqc,
S3C24XX_INT_UART2);
s3c24xx_irqc_subsrc_enable(>a02_irqc,
S3C24XX_SUBINT_RXD2);
}
}
s3c24xx_irqc_src_enable(>a02_irqc, S3C24XX_INT_ADC);
s3c24xx_irqc_subsrc_enable(>a02_irqc, S3C24XX_SUBINT_ADC_S);
s3c24xx_irqc_subsrc_enable(>a02_irqc, S3C24XX_SUBINT_TC);
}
size_t gta02_get_irq_count(void)
{
return GTA02_IRQ_COUNT;
}
const char *gta02_get_platform_name(void)
{
return "gta02";
}
static void gta02_timer_irq_init(void)
{
irq_initialize(>a02_timer_irq);
gta02_timer_irq.inr = GTA02_TIMER_IRQ;
gta02_timer_irq.claim = gta02_timer_irq_claim;
gta02_timer_irq.handler = gta02_timer_irq_handler;
irq_register(>a02_timer_irq);
}
static irq_ownership_t gta02_timer_irq_claim(irq_t *irq)
{
return IRQ_ACCEPT;
}
static void gta02_timer_irq_handler(irq_t *irq)
{
irq_spinlock_unlock(&irq->lock, false);
clock();
irq_spinlock_lock(&irq->lock, false);
}
static void gta02_timer_start(void)
{
s3c24xx_timer_t *timer = gta02_timer;
#if HZ != 100
#warning Other HZ than 100 not suppored.
#endif
pio_write_32(&timer->tcfg0, 7);
pio_write_32(&timer->tcfg1, 0);
pio_write_32(&timer->tcon, 0);
pio_write_32(&timer->timer[0].cntb, 62500);
pio_write_32(&timer->timer[0].cmpb, 0);
s3c24xx_irqc_src_enable(>a02_irqc, S3C24XX_INT_TIMER0);
pio_write_32(&timer->tcon, TCON_T0_AUTO_RLD | TCON_T0_MUPDATE);
pio_write_32(&timer->tcon, TCON_T0_AUTO_RLD | TCON_T0_START);
}
HelenOS homepage, sources at GitHub