source: rtems/tools/cpu/nios2/clocks.c @ 5f5f681

4.104.115
Last change on this file since 5f5f681 was 5f5f681, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/10/09 at 07:20:06

Whitespace removal.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  Copyright (c) 2006 Kolja Waschk rtemsdev/ixo.de
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10
11#include "ptf.h"
12#include "clocks.h"
13
14#include <stdlib.h>
15
16void add_clock_spec(struct ptf_item *pi, void *arg)
17{
18  clock_desc **clocks = arg;
19  clock_desc *new_clock;
20  unsigned long freq;
21
22  new_clock = (clock_desc*)malloc(sizeof(clock_desc));
23  if(new_clock == NULL) return;
24
25  new_clock->freq = strtoul(pi->item[pi->level]->value, 0, 0);
26
27  new_clock->cfgname = NULL;
28  new_clock->name = pi->item[pi->level-1]->value;
29  new_clock->next = *clocks;
30
31
32  *clocks = new_clock;
33}
34
35void set_clock_cfgname(struct ptf_item *pi, void *arg)
36{
37  clock_desc *clock = arg;
38  clock->cfgname = pi->item[pi->level]->name;
39}
40
41clock_desc *find_clocks( struct ptf *sopc, struct ptf *cfg )
42{
43    clock_desc *clocks, *reverse;
44
45    struct ptf system        = { section, "SYSTEM", 0, 0, 0 };
46    struct ptf wizargs       = { section, "WIZARD_SCRIPT_ARGUMENTS", 0, 0, 0 };
47    struct ptf all           = { section, "CLOCKS", 0, 0, 0 };
48    struct ptf clock         = { section, "CLOCK", 0, 0, 0 };
49    struct ptf freq          = { item,    "frequency", 0, 0, 0 };
50    struct ptf_item clk_spec = { 5, &system, &wizargs, &all, &clock, &freq };
51
52    struct ptf named     = { item, 0, 0, 0, 0 };
53    struct ptf_item clk_cfg = { 2, &all, &named };
54
55    clocks = NULL;
56    ptf_match(sopc, &clk_spec, add_clock_spec, &clocks);
57
58    /* Reverse the linked list and look for configured names */
59
60    reverse = NULL;
61    while(clocks)
62    {
63      clock_desc *tmp = clocks;
64      clocks = clocks->next;
65      tmp->next = reverse;
66      reverse = tmp;
67
68      named.value = tmp->name;
69      ptf_match(cfg, &clk_cfg, set_clock_cfgname, tmp);
70      if(tmp->cfgname == NULL) tmp->cfgname = ptf_defused_name(tmp->name);
71    };
72
73    return reverse;
74}
75
76
77
Note: See TracBrowser for help on using the repository browser.