Commit 3d93cb64 authored by Kevin Bracey's avatar Kevin Bracey
Browse files

Addition of 1000 base T and fibre magic constant to DCI spec.

Addition of support for HAL timers
Removed a lingering __P in the resolver header file (and while we're
at it all the others).
Added missing open bracket to vn_opn,reported by D.Ellis.

Version 5.45. Tagged as 'TCPIPLibs-5_45'
parent 3e617aeb
/* (5.44)
/* (5.45)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
*
*/
#define Module_MajorVersion_CMHG 5.44
#define Module_MajorVersion_CMHG 5.45
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 30 Sep 2002
#define Module_Date_CMHG 07 Jan 2003
#define Module_MajorVersion "5.44"
#define Module_Version 544
#define Module_MajorVersion "5.45"
#define Module_Version 545
#define Module_MinorVersion ""
#define Module_Date "30 Sep 2002"
#define Module_Date "07 Jan 2003"
#define Module_ApplicationDate2 "30-Sep-02"
#define Module_ApplicationDate4 "30-Sep-2002"
#define Module_ApplicationDate "07-Jan-03"
#define Module_ComponentName "TCPIPLibs"
#define Module_ComponentPath "RiscOS/Sources/Lib/TCPIPLibs"
#define Module_FullVersion "5.44"
#define Module_HelpVersion "5.44 (30 Sep 2002)"
#define Module_LibraryVersionInfo "5:44"
#define Module_FullVersion "5.45"
#define Module_HelpVersion "5.45 (07 Jan 2003)"
#define Module_LibraryVersionInfo "5:45"
......@@ -71,7 +71,7 @@ int kvm_read(kvm_t *, unsigned long, void *, unsigned int);
int kvm_write(kvm_t *, unsigned long, const void *, unsigned int);
/* Comment this out until it can be fixed correctly.
ssize_t kvm_uread
__P((kvm_t *, struct proc *, unsigned long, char *, size_t));
(kvm_t *, struct proc *, unsigned long, char *, size_t);
*/
__END_DECLS
......
......@@ -200,7 +200,7 @@ int __dn_skipname(const u_char *, const u_char *);
void __fp_resstat(struct __res_state *, FILE *);
void __fp_query(const u_char *, FILE *);
void __fp_nquery(const u_char *, int, FILE *);
char *__hostalias __P((const char *));
char *__hostalias(const char *);
void __putlong(u_int32_t, u_char *);
void __putshort(u_int16_t, u_char *);
char *__p_time(u_int32_t);
......
......@@ -301,7 +301,7 @@ MALLOC_DECLARE(M_IFMADDR);
#ifdef KERNEL
#ifndef __riscos
struct proc;
int prison_if __P((struct proc *p, struct sockaddr *sa));
int prison_if(struct proc *p, struct sockaddr *sa);
/* XXX - this should go away soon */
#endif
#include <net/if_var.h>
......
......@@ -65,7 +65,7 @@
#if !defined(__sys_dcistructs_h)
#define __sys_dcistructs_h
#define DCIVERSION 404
#define DCIVERSION 405
/*
* DCI 4 service calls
......@@ -147,7 +147,7 @@
#define SPECIFICOFFSET (0x80)
#define SPECIFICERRORBASE (DCI4ERRORBLOCK + SPECIFICOFFSET)
#if 0
#if 1
# define SETDCI4ERRNO(x, y) ((x) = DCI4ERRORBLOCK + ((y) & 0x7f))
# define REALLYSETDCI4ERRNO(x, y) ((x) = DCI4ERRORBLOCK + ((y) & 0x7f))
#else
......@@ -326,8 +326,8 @@ typedef struct
#define ST_TYPE_ATM155 17
#define ST_TYPE_ATMPLUSRELAY 18
#define ST_TYPE_ATMFLANE 19
#define ST_TYPE_1000BASET 20
#define ST_TYPE_1000BASESX 21
#define ST_TYPE_1000BASESX 20 /* 1000BaseSX Multi-mode Fibre */
#define ST_TYPE_1000BASET 21 /* 1000BaseT 4 pair cat 5 */
/*
* stats. link status bits
......
......@@ -83,7 +83,7 @@ struct ipc_perm {
#define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff)
#define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff))
int ipcperm __P((struct ucred *,struct ipc_perm *,int));
int ipcperm(struct ucred *,struct ipc_perm *,int);
#endif /* KERNEL */
#endif /* !_SYS_IPC_H_ */
......@@ -120,7 +120,7 @@ __dead void boot(int) __dead2;
void tablefull(const char *);
void addlog(const char *, ...);
void log(int, const char *, ...);
void printf(const char *, ...);
int printf(const char *, ...);
void uprintf(const char *, ...);
int sprintf(char *buf, const char *, ...);
void ttyprintf(struct tty *, const char *, ...);
......
......@@ -218,7 +218,7 @@ int b_to_q(char *cp, int cc, struct clist *q);
void catq(struct clist *from, struct clist *to);
void clist_alloc_cblocks(struct clist *q, int ccmax, int ccres);
void clist_free_cblocks(struct clist *q);
/* void clist_init __P((void)); */ /* defined in systm.h for main() */
/* void clist_init(void); */ /* defined in systm.h for main() */
int getc(struct clist *q);
void ndflush(struct clist *q, int cc);
int ndqb(struct clist *q, int flag);
......
......@@ -234,9 +234,9 @@ extern struct vattr va_null; /* predefined null vattr structure */
#define LEASE_READ 0x1 /* Check lease for readers */
#define LEASE_WRITE 0x2 /* Check lease for modifiers */
extern void (*lease_check) __P((struct vnode *vp, struct proc *p,
struct ucred *ucred, int flag));
extern void (*lease_updatetime) __P((int deltat));
extern void (*lease_check) (struct vnode *vp, struct proc *p,
struct ucred *ucred, int flag);
extern void (*lease_updatetime) (int deltat);
#ifdef NFS
#ifdef NQNFS
......@@ -342,7 +342,7 @@ struct vnodeopv_desc {
/*
* A default routine which just returns an error.
*/
int vn_default_error __P((void));
int vn_default_error(void);
/*
* A generic structure.
......@@ -370,7 +370,9 @@ struct vop_generic_args {
/*
* Finally, include the default set of vnode operations.
*/
#ifndef __riscos
#include <vnode_if.h>
#endif
/*
* Public vnode manipulation functions.
......@@ -410,7 +412,7 @@ int vn_close(struct vnode *vp,
int flags, struct ucred *cred, struct proc *p);
int vn_closefile(struct file *fp, struct proc *p);
int vn_ioctl(struct file *fp, int com, caddr_t data, struct proc *p);
int vn_open struct nameidata *ndp, int fmode, int cmode);
int vn_open(struct nameidata *ndp, int fmode, int cmode);
int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base,
int len, off_t offset, enum uio_seg segflg, int ioflg,
struct ucred *cred, int *aresid, struct proc *p);
......
......@@ -24,43 +24,36 @@
* Initial revision
*
*/
#include <sys/time.h>
#include <sys/types.h>
#include <swis.h>
#include <Global/HalEntries.h>
#include "unixlib.h"
#include "asm.h"
#include "stdio.h"
#define secs0070 (((unsigned)86400) * (365 * 70 + 17)) /* less than 2^32 */
typedef struct {unsigned int l,h;} machinetime;
/**********************************************************************/
static long machinetime_to_realtime(machinetime *t, long *csecs)
{
machinetime bt, w, w2;
/* to two 3-byte things - for divide */
w.h = ((t->h & 255) << 8) | (t->l >> 24);
w.l = t->l & 0xffffff;
/* turn csecs to secs */
w2.h = w.h / 100;
w2.l = ((w.h % 100 << 24) | w.l) / 100;
if (csecs)
*csecs = ((w.h % 100L << 24) | w.l) % 100;
/* back to 8 byte binary */
bt.h = w2.h >> 8;
bt.l = (w2.h << 24) | w2.l;
/* normalise to Jan70 instead of Jan00... */
if (bt.l < secs0070) bt.h--;
bt.l -= secs0070;
/*
* if high word is non-zero then date
* is unset/out of unix range...
......@@ -68,82 +61,163 @@ static long machinetime_to_realtime(machinetime *t, long *csecs)
return bt.h ? -1 : bt.l;
}
/**********************************************************************/
static unsigned int t0_divisor; /* Divisor to convert ticks to usecs */
static unsigned int t0_period; /* Timer 0 period */
static void * HAL_TimerReadCountdown_Ptr;
static uint32_t HAL_TimerReadCountdown_SB;
typedef enum
{
timer_NOT_CHECKED,
timer_IOMD,
timer_HAL,
timer_NONE
} timer_type;
/**********************************************************************/
/*
* Return 1 if IOC/IOMD is present (OS_ReadSysInfo 2 reports I/O control
* chip = 0 or 1 - IOC or IOMD).
* Return the type of hardware timer this platform has, and perform
* any necessary initialisation.
*/
static int iomd_present()
static timer_type hw_check()
{
unsigned int hardware;
_kernel_oserror * e;
unsigned int granularity;
if (_swix(OS_ReadSysInfo, _IN(0)|_OUT(0), 2, &hardware))
return 2;
/* Try to get Timer 0 granularity from HAL */
e = _swix(OS_Hardware,
_IN(0) | _INR(8,9) | _OUT(0),
0,
0,
EntryNo_HAL_TimerGranularity,
&granularity);
return (hardware & 0xFF00) <= 0x0100 ? 1 : 2;
/*
* Can only use HAL if this succeeded and granularity is an even
* number of MHz.
*/
if (e == NULL && (granularity % 1000000) == 0)
{
t0_divisor = granularity / 1000000;
/* Try to get Timer 0 period from HAL */
e = _swix(OS_Hardware,
_IN(0) | _INR(8,9) | _OUT(0),
0,
0,
EntryNo_HAL_TimerPeriod,
&t0_period);
if (e == NULL && t0_divisor != 0 && t0_period != 0)
{
/* HAL_TimerReadCountdown counts from (period-1) to 0 */
t0_period--;
/* Try to get HAL_TimerReadCountdown pointer from HAL */
e = _swix(OS_Hardware,
_INR(8,9) | _OUTR(0,1),
1,
EntryNo_HAL_TimerReadCountdown,
&HAL_TimerReadCountdown_Ptr,
&HAL_TimerReadCountdown_SB);
if (e == NULL)
{
/*
* OK so far, now make sure HAL_TimerReadCountdown doesn't
* always return 0.
*/
unsigned long count1, count2;
count1 = _get_hal_t0_count(HAL_TimerReadCountdown_SB, HAL_TimerReadCountdown_Ptr);
_swix(OS_Hardware, _IN(0)|_INR(8,9), 2, 0, EntryNo_HAL_CounterDelay);
count2 = _get_hal_t0_count(HAL_TimerReadCountdown_SB, HAL_TimerReadCountdown_Ptr);
if (count1 != 0 || count2 != 0)
{
/* Everything worked - use HAL */
return timer_HAL;
}
}
}
}
/* Couldn't use HAL, look for IOMD instead */
/* (OS_ReadSysInfo 2 bits 8-15 is I/O chip = 0 or 1 - IOC or IOMD) */
unsigned int hardware;
if (_swix(OS_ReadSysInfo, _IN(0)|_OUT(0), 2, &hardware))
return timer_NONE;
return (hardware & 0xFF00) <= 0x0100 ? timer_IOMD : timer_NONE;
}
/**********************************************************************/
/*
* This function is actully reasonably fast - it's between 7 and 8us
* on a 200MHz StrongARM.
*/
int gettimeofday(struct timeval *tv, struct timezone *tzp)
{
static int iomd_check; /* 0 = not checked, 1 = present, 2 = not present */
static timer_type timer_check = timer_NOT_CHECKED;
machinetime t1, t2;
unsigned long timer_count;
/* Only poke the hardware if we're sure it's there :) */
if (!iomd_check)
iomd_check = iomd_present();
if (timer_check == timer_NOT_CHECKED)
timer_check = hw_check();
t1.l = 3;
t2.l = 3;
if (iomd_check == 1)
if (timer_check != timer_NONE)
{
/* Check initial time */
_kernel_osword(14, (int *) &t1);
/* Read the Timer 0 value - it counts down from 19999 to 0,
* the clock tick occurring as it changes from 0 to 19999.
*/
timer_count = _get_t0_count();
/* Read the Timer 0 value */
if (timer_check == timer_IOMD)
timer_count = _get_t0_count();
else
timer_count = _get_hal_t0_count(HAL_TimerReadCountdown_SB, HAL_TimerReadCountdown_Ptr);
}
/* Check new time */
_kernel_osword(14, (int *) &t2);
tv->tv_sec = machinetime_to_realtime(&t2, &tv->tv_usec);
tv->tv_usec *= 10000;
if (iomd_check == 1 && t1.l == t2.l)
if (timer_check != timer_NONE && t1.l == t2.l)
{
/* Clock didn't tick - add in timer count */
tv->tv_usec += (19999 - timer_count) / 2;
if (timer_check == timer_IOMD)
{
/*
* IOMD timer counts down from 19999 to 0, the clock tick
* occurring as it changes from 0 to 19999.
*/
tv->tv_usec += (19999 - timer_count) / 2;
}
else
{
tv->tv_usec += (t0_period - timer_count) / t0_divisor;
}
}
else
{
/* Clock ticked - let it rest at the 10000us boundary */
}
if ( tzp )
if (tzp)
{
struct tm *t_gmt;
struct tm *t_local;
t_gmt = gmtime( (time_t *)&tv->tv_sec );
t_local = localtime( (time_t *)&tv->tv_sec );
tzp->tz_minuteswest = (int)difftime(mktime(t_gmt),
mktime(t_local)) / 60;
tzp->tz_dsttime = t_local->tm_isdst;
}
return(0);
}
/**********************************************************************/
/* EOF gtimeofday.c */
......@@ -12,4 +12,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
extern unsigned int _get_t0_count(void);
extern unsigned long _get_t0_count(void);
extern unsigned long _get_hal_t0_count(uint32_t hal_sb, void * hal_fn_ptr);
......@@ -18,8 +18,13 @@
GET Hdr:APCS.<APCS>
EXPORT _get_t0_count
EXPORT _get_hal_t0_count
AREA |Asm$$Code|, CODE, READONLY
sb RN 9
SB RN 9
_get_t0_count
MOV ip, lr
[ {CONFIG}<>26
......@@ -45,5 +50,54 @@ _get_t0_count
]
Return ,LinkNotStacked,,ip
; unsigned long _get_hal_t0_count(uint32_t hal_sb, void * hal_fn_ptr);
;
; Call HAL_TimerReadCountdown to get current Timer 0 countdown value.
;
; Static base value in a1
; Pointer to HAL_TimerReadCountdown routine in a2
_get_hal_t0_count ROUT
; Are we in USR mode?
[ {CONFIG} = 26
TST lr, #3 ; Is mode USR26?
|
MRS a3, CPSR
TST a3, #3 ; Is mode USR26 or USR32?
]
BEQ %FT50
; We are in SVC mode already
FunctionEntry sb
MOV sb, a1
MOV a1, #0 ; We want to read timer 0
ADR lr, %FT01
MOV pc, a2 ; Call HAL
01
Return sb
50
; We are in USR mode
[ {CONFIG} = 26
MOV ip, lr
]
SWI XOS_EnterOS ; Enter SVC mode
[ {CONFIG} = 26
STMFD sp!,{sb, ip}
|
STMFD sp!,{a3, sb}
]
MOV sb, a1
MOV a1, #0 ; We want to read timer 0
ADR lr, %FT51
MOV pc, a2 ; Call HAL
51
[ {CONFIG} = 26
Return sb ; Return and restore entry mode
|
LDMFD sp!,{a3, sb}
MSR CPSR_c, a3 ; Restore entry mode
Return ,LinkNotStacked
]
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment