OpenCores
URL https://opencores.org/ocsvn/fwrisc/fwrisc/trunk

Subversion Repositories fwrisc

[/] [fwrisc/] [trunk/] [doc/] [fwrisc_zephyr.md] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mballance
# Zephyr Port
2
 
3
The FWRISC Zephyr port consists of SoC and Board files derived from the relevant files for Pulpino and risc-privilege.
4
 
5
The only somewhat-unique aspect of porting Zephyr to FWRISC is that FWRISC does not (currently) support interrupts.
6
As a consequence, measuring time is done by polling the MCYCLE CSR instead of waiting for timer interrupts to occur.
7
This also means that Zephyr does not currently support truly-preemptive multitasking.
8
 
9
 
10
## Porting Tasks
11
 
12
### Creating a dummy Timer Driver
13
Zephyr appears to assume that a timer driver exists. Consequently, a stub fwrisc_timer driver (drivers/timer/fwrisc_timer.c)
14
was created. This is a completely-NOP implementation.
15
 
16
### Implementing the Idle Routine
17
Zephyr applications still need to tell time, so we need an alternative to a timer interrupt. The FWRISC Zephyr port
18
enables keeping time via an implementation of the k_cpu_idle function that issues a clock event every N
19
MCYCLE counts.
20
 
21
```
22
void k_cpu_idle(void)
23
{
24
        u32_t mcycle;
25
 
26
        while (1) {
27
                __asm__ volatile("csrr %0, mcycle" : "=r"(mcycle));
28
 
29
                if ((mcycle-last_mcycle) >= CYCLES_PER_TICK) {
30
                        z_clock_announce(1);
31
                        last_mcycle = mcycle;
32
                        break;
33
                }
34
        }
35
 
36
        // Make a system call to trigger thread rescheduling
37
        __asm__ volatile("ecall");
38
}
39
```
40
 
41
### Boards
42
 
43
The FWRISC port of Zephyr defines two boards:
44
- fwrisc_sim -- A board definition for use with RTL simulation targets. Uses the RAM console, and defines the clock frequency so as to shorten simulation runs.
45
- fwrisc_fpga -- A board definition for use with FPGA platforms. Uses a UART console and defines the clock frequency appropriately
46
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.