summaryrefslogtreecommitdiffstats
path: root/spec/dev/clock/xil-ttc/val/tick-catch-up.yml
blob: d66f088b092c7f895b1e6705432fa9c2a35774ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2024 embedded brains GmbH & Co. KG
enabled-by: bsps/arm/xilinx-zynqmp-rpu
links: []
test-actions:
- action-brief: |
    Synchronize with the clock tick.  Disable interrupts.  Busy wait three
    clock tick intervals.  Enable interrupts.
  action-code: |
    uint32_t              ns_per_tick;
    uint64_t              three_ticks_interval;
    rtems_interrupt_level level;
    rtems_interval        t_0;
    rtems_interval        t_1;
    rtems_interval        t_2;
    uint64_t              m_0;
    uint64_t              m_1;

    ns_per_tick = rtems_configuration_get_nanoseconds_per_tick();
    three_ticks_interval = ( 7 * (uint64_t) nstosbt( ns_per_tick ) ) / 2;
    t_0 = rtems_clock_get_ticks_since_boot();

    /* Synchronize with clock tick */
    do {
      t_1 = rtems_clock_get_ticks_since_boot();
      m_0 = (uint64_t) rtems_clock_get_monotonic_sbintime();
    } while ( t_0 == t_1 );

    rtems_interrupt_local_disable( level );

    do {
      m_1 = (uint64_t) rtems_clock_get_monotonic_sbintime();
    } while ( m_1 - m_0 <= three_ticks_interval );

    rtems_interrupt_local_enable( level );

    /*
     * Make sure the clock interrupt was serviced after the interrupt enable.
     */
    do {
      t_2 = rtems_clock_get_ticks_since_boot();
    } while ( t_1 == t_2 );
  checks:
  - brief: |
      Check that exactly three clock ticks happened once interrupts are enabled
      again.
    code: |
      T_step_eq_u32( ${.:/step}, t_2 - t_1, 3 );
    links:
    - role: validation
      uid: ../req/tick-catch-up-interval
    - role: validation
      uid: ../req/tick-catch-up-ticks
  links: []
test-brief: |
  Tests some Xilinx TTC clock driver functions.
test-context: []
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- sys/time.h
test-local-includes: []
test-setup: null
test-stop: null
test-support: null
test-target: testsuites/validation/tc-dev-clock-xil-ttc.c
test-teardown: null
type: test-case