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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [infra/] [current/] [tests/] [fc_test.c] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      fc_test.c
4
//
5
//      Test/demonstration of using RedBoot 'fconfig' from eCos
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2003, 2004 Free Software Foundation, Inc.                  
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    gthomas
43
// Contributors: gthomas
44
// Date:         2003-12-22
45
// Purpose:      
46
// Description:  
47
//              
48
//####DESCRIPTIONEND####
49
//
50
//==========================================================================
51
 
52
//
53
// Demonstration of how to use virtual vector interfaces to access/modify
54
// persistent data stored by 'fconfig' command in RedBoot.
55
//
56
// Note: there is currently no support for adding new keys using this
57
// mechanism.  Only existing key/value pairs may be updated.
58
//
59
#include <pkgconf/hal.h>
60
#include <cyg/hal/hal_if.h>
61
#include <cyg/infra/diag.h>
62
 
63
void
64
main(void)
65
{
66
    struct cyg_fconfig fc;
67
    char key[64];
68
    int port;
69
 
70
    diag_printf("fconfig test started\n");
71
    fc.offset = 0;
72
    fc.key = key;
73
    fc.keylen = sizeof(key);
74
    while (CYGACC_CALL_IF_FLASH_CFG_OP2(CYGNUM_CALL_IF_FLASH_CFG_NEXT, &fc)) {
75
        diag_printf("  Offset: %d, key: '%s', type: %d\n", fc.offset, fc.key, fc.type);
76
        fc.keylen = sizeof(key);
77
    }
78
    // Try and update a data value
79
    fc.key = "gdb_port";
80
    fc.val = &port;
81
    fc.type = CYGNUM_FLASH_CFG_TYPE_CONFIG_INT;
82
    if (CYGACC_CALL_IF_FLASH_CFG_OP2(CYGNUM_CALL_IF_FLASH_CFG_GET, &fc)) {
83
        diag_printf("gdb_port = %d\n", port);
84
        port++;
85
        if (CYGACC_CALL_IF_FLASH_CFG_OP2(CYGNUM_CALL_IF_FLASH_CFG_SET, &fc)) {
86
            if (CYGACC_CALL_IF_FLASH_CFG_OP2(CYGNUM_CALL_IF_FLASH_CFG_GET, &fc)) {
87
                diag_printf("now = %d\n", port);
88
            } else {
89
                diag_printf("Can't re-fetch 'gdb_port'\n");
90
                exit(1);
91
            }
92
            port--;
93
            if (!CYGACC_CALL_IF_FLASH_CFG_OP2(CYGNUM_CALL_IF_FLASH_CFG_SET, &fc)) {
94
                diag_printf("Can't update 'gdb_port'\n");
95
                exit(1);
96
            }
97
        } else {
98
            diag_printf("Can't update 'gdb_port'\n");
99
            exit(1);
100
        }
101
    } else {
102
        diag_printf("Fetch 'gdb_port' failed\n");
103
        exit(1);
104
    }
105
    diag_printf("... done\n");
106
    exit(1);
107
}

powered by: WebSVN 2.1.0

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