În 11 iulie 2020 02:15:27 EEST, Mark Kettenis <[email protected]> a scris:
>> Date: Fri, 10 Jul 2020 19:03:58 -0400
>> From: George Koehler <[email protected]>
>> 
>> On Wed, 8 Jul 2020 14:26:02 +0200 (CEST)
>> Mark Kettenis <[email protected]> wrote:
>> 
>> > > From: Paul Irofti <[email protected]>
>> > > Reads OK to me. Please make the adjustments to static functions
>that 
>> > > kettenis@ mentioned in the alpha thread.
>> > 
>> > To add to that:
>> > 
>> > * TC_LAST isn't needed, so kill that
>> > * tc_get_timecount
>> > 
>> > Also in the sparc64 I did an exact copy of the kernel
>implementation
>> > of the functions to read the counter.  I only made them static
>inline.
>> > That makes it easier to verify that they are indeed identical.
>> 
>> Here is the diff for macppc after I drop TC_LAST, recopy usertc.c
>from
>> amd64 (so tc_get_timecount is now static), and copy ppc_mftbl from
>> /sys/arch/powerpc/include/cpu.h
>> 
>> OK to commit?
>> 
>> Index: lib/libc/arch/powerpc/gen/usertc.c
>> ===================================================================
>> RCS file: /cvs/src/lib/libc/arch/powerpc/gen/usertc.c,v
>> retrieving revision 1.1
>> diff -u -p -r1.1 usertc.c
>> --- lib/libc/arch/powerpc/gen/usertc.c       6 Jul 2020 13:33:05 -0000       
>> 1.1
>> +++ lib/libc/arch/powerpc/gen/usertc.c       9 Jul 2020 21:41:47 -0000
>> @@ -1,4 +1,4 @@
>> -/*  $OpenBSD: usertc.c,v 1.1 2020/07/06 13:33:05 pirofti Exp $      */
>> +/*  $OpenBSD: usertc.c,v 1.2 2020/07/08 09:17:48 kettenis Exp $ */
>>  /*
>>   * Copyright (c) 2020 Paul Irofti <[email protected]>
>>   *
>> @@ -18,4 +18,24 @@
>>  #include <sys/types.h>
>>  #include <sys/timetc.h>
>>  
>> -int (*const _tc_get_timecount)(struct timekeep *, u_int *) = NULL;
>> +static __inline u_int32_t
>> +ppc_mftbl (void)
>> +{
>> +    int ret;
>> +    __asm volatile ("mftb %0" : "=r" (ret));
>> +    return ret;
>> +}
>> +
>> +static int
>
>That should be u_int.  I now see that this is broken in the amd64
>version as well.

I don't think this should be u_int. Can you explain why? It is the function 
error status and can return a negative value. It is not the tc. 

>
>Otherwise this is ok kettenis@
>
>> +tc_get_timecount(struct timekeep *tk, u_int *tc)
>> +{
>> +    switch (tk->tk_user) {
>> +    case TC_TB:
>> +            *tc = ppc_mftbl();
>> +            return 0;
>> +    }
>> +
>> +    return -1;
>> +}
>> +
>> +int (*const _tc_get_timecount)(struct timekeep *, u_int *) =
>tc_get_timecount;
>> Index: sys/arch/macppc/include/timetc.h
>> ===================================================================
>> RCS file: /cvs/src/sys/arch/macppc/include/timetc.h,v
>> retrieving revision 1.1
>> diff -u -p -r1.1 timetc.h
>> --- sys/arch/macppc/include/timetc.h 6 Jul 2020 13:33:07 -0000       1.1
>> +++ sys/arch/macppc/include/timetc.h 9 Jul 2020 21:41:48 -0000
>> @@ -18,6 +18,6 @@
>>  #ifndef _MACHINE_TIMETC_H_
>>  #define _MACHINE_TIMETC_H_
>>  
>> -#define     TC_LAST 0
>> +#define     TC_TB   1
>>  
>>  #endif      /* _MACHINE_TIMETC_H_ */
>> Index: sys/arch/macppc/macppc/clock.c
>> ===================================================================
>> RCS file: /cvs/src/sys/arch/macppc/macppc/clock.c,v
>> retrieving revision 1.44
>> diff -u -p -r1.44 clock.c
>> --- sys/arch/macppc/macppc/clock.c   6 Jul 2020 13:33:08 -0000       1.44
>> +++ sys/arch/macppc/macppc/clock.c   9 Jul 2020 21:41:48 -0000
>> @@ -57,7 +57,7 @@ u_int32_t ns_per_tick = 320;
>>  static int32_t ticks_per_intr;
>>  
>>  static struct timecounter tb_timecounter = {
>> -    tb_get_timecount, NULL, 0x7fffffff, 0, "tb", 0, NULL, 0
>> +    tb_get_timecount, NULL, 0x7fffffff, 0, "tb", 0, NULL, TC_TB
>>  };
>>  
>>  /* calibrate the timecounter frequency for the listed models */
>> 

Reply via email to