📄 callout_timer_dec.s
字号:
# # Copyright 2007, QNX Software Systems. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not reproduce, modify or distribute this software except in # compliance with the License. You may obtain a copy of the License # at: http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTIES OF ANY KIND, either express or implied.# # This file may contain contributions from others, either as # contributors under the License or as licensors under other terms. # Please review this entire file for other proprietary rights or license # notices, as well as the QNX Development Suite License Guide at # http://licensing.qnx.com/license-guide/ for other information.# # An entry point for a hardware kernel callout.# It may be called by an interrupt handler.# This code MUST be position independant.# .include "callout.ah" rw_timer: .long 4 patch_timer: add %r3,%r3,%r5 sth %r6,2(%r3) blr ## void timer_load(volatile struct syspage_entry *, struct qtime_entry *qtp)#CALLOUT_START timer_load_dec, rw_timer, patch_timer addi %r3,%r3,0x1234 # get R/W base (patched) lwz %r0,QT_TIMER_LOAD(%r4) mtspr PPC_SPR_DEC,%r0 mfspr %r5,PPC_SPR_TBLR add %r5,%r5,%r0 stw %r5,0(%r3) # save next timer low value blrCALLOUT_END timer_load_dec ## int timer_reload(volatile struct syspage_entry *, struct qtime_entry *qtp)## Reload the PPC_SPR_DEC with the next countdown value. Watch out for skew.#CALLOUT_START timer_reload_dec, rw_timer, patch_timer addi %r3,%r3,0x1234 # get R/W base (patched) lwz %r5,0(%r3) # get next timer low value lwz %r6,QT_TIMER_LOAD(%r4) mfspr %r7, PPC_SPR_TBLR sub. %r8,%r7,%r5 blt- 1f # normal case, time base is beyond what we expected. Make sure # it's not toooo far off. cmplw %r8,%r6 bge 1f sub %r8,%r6,%r8 # adjust the PPC_SPR_DEC countdown appropriately mtspr PPC_SPR_DEC,%r8 add %r5,%r5,%r6 stw %r5,0(%r3) # save next timer low value li %r3,1 blr1: # need to reset the time base mtspr PPC_SPR_DEC,%r6 add %r7,%r7,%r6 stw %r7,0(%r3) # save next timer low value li %r3,1 blrCALLOUT_END timer_reload_dec ## unsigned timer_value(volatile struct syspage_entry *, struct qtime_entry *qtp)## Get the current value of the timer (counting up)#CALLOUT_START timer_value_dec, 0, 0 lwz %r3,QT_TIMER_LOAD(%r4) mfspr %r4,PPC_SPR_DEC sub %r3,%r3,%r4 blrCALLOUT_END timer_value_dec
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -