📄 sysmotvpdalib.s
字号:
/* sysMotVpdALib.s - Motorola PPC VPD assembly routines *//* Copyright 1984-2001 Wind River Systems, Inc. *//* Copyright 1999-2001 Motorola, Inc. All Rights Reserved */ .data .globl copyright_wind_river .long copyright_wind_river/*modification history--------------------01c,12jan01,djs changed sysTimeEdges() to just use the time base register01b,04jan01,scb make sysTimeEdges() immune to static baud out line01a,08dec00,rhv created from 01a,10jun99,rhv*//*DESCRIPTIONThis module contains VPD routines written in assemblylanguage.*/#define _ASMLANGUAGE#include "vxWorks.h"#include "sysLib.h"#include "config.h"#include "regs.h" #include "asm.h"/* defines *//* convert bit numbering from 0=LSB to 31=LSB (standard to PPC) */#define BAUDOUT (31-0)#define DEC_CNT_DELAY_U 0x0010#define DEC_CNT_DELAY_L 0x0000 /* globals */ .globl sysTimeEdges .text .align 3/******************************************************************************** sysTimeEdges - Time BAUDOUT Signal Edges** This function monitors the BAUDOUT signal in the system status register and* reports the number of time-base ticks required for the caller-specified* number of BUADOUT edges to occur. It is used to calculate the processor's* bus speed.** From a C programmers point of view, the routine is defined as follows:** UINT32 sysTimeEdges (UINT32 edges);** INPUTS:* r3 = number of edges to time** OUTPUTS* r3 = number of elapsed time base low register ticks**/sysTimeEdges: mtctr r3 /* move number of edges to counter */ lis r6,HIADJ(LOPEC_SYS_STAT_REG1) /* address of status reg */ addi r6,r6,LO(LOPEC_SYS_STAT_REG1) /* Test BAUDOUT actually wiggling, return 0 if no BAUDOUT wiggle */ lis r7,DEC_CNT_DELAY_U /* decrementer elapsed time max */ addi r7,r7,DEC_CNT_DELAY_L mftb r8 /* snapshot time base low */ isync lbz r5,0(r6) /* read and isolate initial state of BAUDOUT */ rlwinm r5,r5,0,BAUDOUT,BAUDOUTloop0: lbz r4,0(r6) rlwinm r4,r4,0,BAUDOUT,BAUDOUT cmplw r4,r5 bne itwiggles /* No wiggle yet, see if timeout has expired */ mftb r4 subf r4,r8,r4 /* get elapsed time base counts */ cmpl 0,0,r7,r4 /* have we hit the timeout value yet ? */ bc 12,1,loop0 /* branch if we have not */ /* We have exahusted timeout with no BAUDOUT change */ xor r3,r3,r3 /* zero indicates error */ blr /* return */ /* BAUDOUT wiggles, now we can count transitions. */itwiggles: lbz r5,0(r6) /* read and isolate initial state of BAUDOUT */ rlwinm r5,r5,0,BAUDOUT,BAUDOUTloop1: lbz r4,0(r6) /* find an edge */ rlwinm r4,r4,0,BAUDOUT,BAUDOUT cmplw r4,r5 beq loop1 mftb r3 /* found edge, snapshot time base low */loop2: mr r5,r4 /* save new reference state */loop3: lbz r4,0(r6) /* find an edge */ rlwinm r4,r4,0,BAUDOUT,BAUDOUT cmplw r4,r5 beq loop3 bdnz loop2 /* found edge, fall through if last one */ mftb r4 /* snapshot time base low */ subf r3,r3,r4 /* calculate elapsed time */ blr /* return */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -