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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [io/] [serial/] [v2_0/] [tests/] [tty1.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//        tty.c
4
//
5
//        Test TTY driver API
6
//
7
//==========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, 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 version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):     jskov
44
// Contributors:  jskov
45
// Date:          1999-04-08
46
// Description:   Test the TTY driver API.
47
// 
48
//####DESCRIPTIONEND####
49
 
50
#include <pkgconf/system.h>
51
 
52
#include <cyg/infra/testcase.h>         // test macros
53
#include <cyg/infra/cyg_ass.h>          // assertion macros
54
 
55
// Package requirements
56
#if defined(CYGPKG_IO_SERIAL) && defined(CYGPKG_KERNEL)
57
 
58
#include <pkgconf/kernel.h>
59
 
60
// Package option requirements
61
#if defined(CYGFUN_KERNEL_API_C)
62
 
63
#include <cyg/hal/hal_arch.h>           // CYGNUM_HAL_STACK_SIZE_TYPICAL
64
#include <cyg/kernel/kapi.h>
65
unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
66
cyg_thread thread_data;
67
cyg_handle_t thread_handle;
68
 
69
#include "ser_test_protocol.inl"
70
 
71
//---------------------------------------------------------------------------
72
// TTY test main function.
73
 
74
 
75
void
76
tty_api_test(cyg_io_handle_t* handle)
77
{
78
    int res, len;
79
    unsigned char buffer[16];
80
 
81
    // Always return...
82
    if (handle)
83
        return;
84
 
85
    CYG_TEST_FAIL_FINISH("Not reached");
86
 
87
    // read & write
88
    res = cyg_io_read(handle, &buffer[0], &len);
89
    res = cyg_io_write(handle, &buffer[0], &len);
90
 
91
    // cyg_io_get_config
92
    // TTY layer
93
    cyg_io_get_config(handle,
94
                      CYG_IO_GET_CONFIG_TTY_INFO, &buffer[0], &len);
95
    // Call-throughs to serial layer.
96
    cyg_io_get_config(handle,
97
                      CYG_IO_GET_CONFIG_SERIAL_INFO, &buffer[0], &len);
98
    cyg_io_get_config(handle,
99
                      CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, &buffer[0], &len);
100
    cyg_io_get_config(handle,
101
                      CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH, &buffer[0], &len);
102
    cyg_io_get_config(handle,
103
                      CYG_IO_GET_CONFIG_SERIAL_ABORT, &buffer[0], &len);
104
    cyg_io_get_config(handle,
105
                      CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH, &buffer[0], &len);
106
 
107
    // cyg_io_set_config
108
    // TTY layer.
109
    cyg_io_set_config(handle,
110
                      CYG_IO_SET_CONFIG_TTY_INFO, &buffer[0], &len);
111
    // Call-throughs to serial layer.
112
    cyg_io_set_config(handle,
113
                      CYG_IO_SET_CONFIG_SERIAL_INFO, &buffer[0], &len);
114
}
115
 
116
 
117
void
118
tty_test( void )
119
{
120
    cyg_io_handle_t tty_handle;
121
 
122
    test_open_tty(&tty_handle);
123
 
124
    tty_api_test(&tty_handle);
125
 
126
    CYG_TEST_PASS_FINISH("tty1 test OK");
127
}
128
 
129
void
130
cyg_start(void)
131
{
132
    CYG_TEST_INIT();
133
    cyg_thread_create(10,                   // Priority - just a number
134
                      (cyg_thread_entry_t*)tty_test,         // entry
135
                      0,                    // 
136
                      "tty_thread",         // Name
137
                      &stack[0],            // Stack
138
                      CYGNUM_HAL_STACK_SIZE_TYPICAL,           // Size
139
                      &thread_handle,       // Handle
140
                      &thread_data          // Thread data structure
141
        );
142
    cyg_thread_resume(thread_handle);
143
    cyg_scheduler_start();
144
}
145
 
146
#else // CYGFUN_KERNEL_API_C
147
#define N_A_MSG "Needs kernel C API"
148
#endif
149
 
150
#else // CYGPKG_IO_SERIAL && CYGPKG_KERNEL
151
#define N_A_MSG "Needs IO/serial and Kernel"
152
#endif
153
 
154
#ifdef N_A_MSG
155
void
156
cyg_start( void )
157
{
158
    CYG_TEST_INIT();
159
    CYG_TEST_NA( N_A_MSG);
160
}
161
#endif // N_A_MSG
162
// EOF tty1.c

powered by: WebSVN 2.1.0

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