Main Page   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

legOS/kernel/systime.c File Reference

system time services. More...


Functions

void systime_handler (void)
system time handler for the 16bit timer OCIA irq. More...

 __asm__ (" .text .align 1 .global _systime_handler .global _systime_tm_return _systime_handler: ; r6 saved by ROM push r0 ; both motors & task ; switcher need this reg. ; increment system timer mov.w @_sys_time+2,r6 ; LSW -> r6 add.b #0x1,r6l ; 16 bit: add 1 addx #0x0,r6h mov.w r6,@_sys_time+2 bcc sys_nohigh ; speedup for 65535 cases mov.w @_sys_time,r6 ; MSW -> r6 add.b #0x1,r6l addx #0x0,r6h mov.w r6,@_sys_time sys_nohigh: " " jsr _dm_handler ; call motor driver " " jsr _dsound_handler ; call sound handler " " mov.w @_lnp_timeout_counter,r6 ; check LNP timeout counter subs #0x1,r6 mov.w r6,r6 ; subs doesn't change flags! bne sys_noreset jsr _lnp_integrity_reset mov.w @_lnp_timeout,r6 ; reset timeout sys_noreset:mov.w r6,@_lnp_timeout_counter " " jsr _dkey_handler " " mov.w @_battery_refresh_counter,r6 subs #0x1,r6 bne batt_norefresh jsr _battery_refresh mov.w @_battery_refresh_period,r6 batt_norefresh:mov.w r6,@_battery_refresh_counter " " mov.b @_vis_refresh_counter,r6l dec r6l bne vis_norefresh jsr _vis_handler mov.b @_vis_refresh_period,r6l vis_norefresh: mov.b r6l,@_vis_refresh_counter " " mov.b @_lcd_refresh_counter,r6l dec r6l bne lcd_norefresh jsr _lcd_refresh_next_byte mov.b @_lcd_refresh_period,r6l lcd_norefresh:mov.b r6l,@_lcd_refresh_counter " " mov.b @_tm_current_slice,r6l dec r6l bne sys_noswitch ; timeslice elapsed? mov.w @_tm_switcher_vector,r6 jsr @r6 ; call task switcher _systime_tm_return: mov.b @_tm_timeslice,r6l ; new timeslice sys_noswitch:mov.b r6l,@_tm_current_slice " " pop r0 bclr #3,@0x91:8 ; reset compare A IRQ flag rts ")
void systime_init (void)
initialize system timer. More...

void systime_shutdown (void)
shutdown system timer. More...

void systime_set_switcher (void* switcher)
set task switcher vector. More...

void systime_set_timeslice (unsigned char slice)
set multitasking timeslice in ms. More...


Variables

volatile time_t sys_time
current system time in ms. More...

unsigned char tm_timeslice
task time slice.

volatile unsigned char tm_current_slice
current time remaining.

void* tm_switcher_vector
pointer to task switcher.


Detailed Description

system time services.

Author(s):
Markus L. Noga <markus@noga.de>

Function Documentation

void systime_handler (void)

system time handler for the 16bit timer OCIA irq.

this is the pulse of the system. task switcher and motor driver calls are initiated here.

__asm__ (".text.align 1.global _systime_handler.global _systime_tm_return_systime_handler:;r6 saved by ROM push r0;both motors &task;switcher need this reg.;increment system timer mov.w@_sys_time+ 2, r6;LSW-, r6 add.b# 0x1, r6l;16 bit:add 1 addx# 0x0, r6h mov. w r6, @_sys_time+2 bcc sys_nohigh;speedup for 65535 cases mov.w@ _sys_time, r6;MSW-, r6 add.b# 0x1, r6l addx# 0x0, r6h mov. w r6, @_sys_time sys_nohigh:""jsr _dm_handler;call motor driver""jsr _dsound_handler;call sound handler""mov.w@ _lnp_timeout_counter, r6;check LNP timeout counter subs# 0x1, r6 mov. w r6, r6;subs doesn't change flags!bne sys_noreset jsr _lnp_integrity_reset mov.w@ _lnp_timeout, r6;reset timeout sys_noreset:mov. w r6, @_lnp_timeout_counter""jsr _dkey_handler""mov.w@ _battery_refresh_counter, r6 subs# 0x1, r6 bne batt_norefresh jsr _battery_refresh mov.w@ _battery_refresh_period, r6batt_norefresh:mov. w r6, @_battery_refresh_counter""mov.b@ _vis_refresh_counter, r6l dec r6l bne vis_norefresh jsr _vis_handler mov.b@ _vis_refresh_period, r6lvis_norefresh:mov. b r6l, @_vis_refresh_counter""mov.b@ _lcd_refresh_counter, r6l dec r6l bne lcd_norefresh jsr _lcd_refresh_next_byte mov.b@ _lcd_refresh_period, r6llcd_norefresh:mov. b r6l, @_lcd_refresh_counter""mov.b@ _tm_current_slice, r6l dec r6l bne sys_noswitch;timeslice elapsed?mov.w@ _tm_switcher_vector, r6 jsr@r6;call task switcher_systime_tm_return:mov.b@ _tm_timeslice, r6l;new timeslice sys_noswitch:mov. b r6l, @_tm_current_slice""pop r0 bclr# 3, @0x91:8;reset compare A IRQ flag rts")

void systime_init (void)

initialize system timer.

task switcher initialized to empty handler motors turned off

void systime_shutdown (void)

shutdown system timer.

will also stop task switching and motors.

void systime_set_switcher (void * switcher)

set task switcher vector.

Parameters:
switcher   the switcher

void systime_set_timeslice (unsigned char slice)

set multitasking timeslice in ms.

Parameters:
slice   the timeslice. must be at least 5ms.

Variable Documentation

volatile time_t sys_time

current system time in ms.

Warning:
This is a 32 bit value which will overflow after 49.7 days of continuous operation.

unsigned char tm_timeslice

task time slice.

volatile unsigned char tm_current_slice

current time remaining.

void* tm_switcher_vector

pointer to task switcher.

legOS-0.2.4 is released under the Mozilla Public License. Original code copyright 1998-1999 by the authors.