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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [cygmon/] [v2_0/] [misc/] [bsp/] [bsp.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef __BSP_BSP_H__
2
#define __BSP_BSP_H__
3
//==========================================================================
4
//
5
//      bsp.h
6
//
7
//      Public interface to Red Hat BSP.
8
//
9
//==========================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    
46
// Contributors: gthomas
47
// Date:         1999-10-20
48
// Purpose:      Public interface to Red Hat BSP.
49
// Description:  
50
//               
51
//
52
//####DESCRIPTIONEND####
53
//
54
//=========================================================================
55
 
56
 
57
#ifndef __ASSEMBLER__
58
 
59
/* needed for _bsp_vsprintf() */
60
#include <stdarg.h>
61
 
62
/*
63
 * Exception and interrupt handler type.
64
 */
65
#ifndef _BSP_HANDLER_T_DEFINED
66
#define _BSP_HANDLER_T_DEFINED
67
typedef int (*bsp_handler_t)(int __irq_nr, void *__regs);
68
#endif // _BSP_HANDLER_T_DEFINED
69
 
70
/*
71
 *  Vector descriptor. This is needed for chaining vectors. The interfaces use
72
 *  bsp_vec structure pointers instead of direct pointers to handlers. This
73
 *  puts the responsibility for allocating the bsp_vec structures on the
74
 *  caller, rather than the BSP code.
75
 */
76
typedef struct bsp_vec {
77
    bsp_handler_t  handler;     /* pointer to actual ISR */
78
    struct bsp_vec *next;       /* for chaining */
79
} bsp_vec_t;
80
 
81
/*
82
 *  Valid op values for vector install routines.
83
 */
84
#define BSP_VEC_REPLACE     0
85
#define BSP_VEC_CHAIN_FIRST 1
86
#define BSP_VEC_CHAIN_LAST  2
87
 
88
/*
89
 *  Valid kinds of vectors supported by vector install and remove
90
 *  routines.
91
 */
92
#define BSP_VEC_EXCEPTION 0
93
#define BSP_VEC_INTERRUPT 1
94
 
95
/*
96
 * Routine to cause a breakpoint exception.
97
 */
98
extern void bsp_breakpoint(void);
99
 
100
/*
101
 * Dummy function whose address is the address of
102
 * the breakpoint caused by calling bsp_breakpoint().
103
 */
104
extern void bsp_breakinsn(void);
105
 
106
/*
107
 * Enable given irq.
108
 */
109
extern void bsp_enable_irq(int __irq_nr);
110
 
111
/*
112
 * Disable given irq. Returns true if irq was enabled.
113
 */
114
extern int  bsp_disable_irq(int __irq_nr);
115
 
116
/*
117
 * Remove given vector from vector chain.
118
 */
119
extern void bsp_remove_vec(int __vec_kind,
120
                           int __vec_nr,
121
                           bsp_vec_t *__vec);
122
 
123
/*
124
 * Install a vector chain.
125
 *
126
 * vec_kind may be BSP_VEC_EXCEPTION or BSP_VEC_INTERRUPT.
127
 * vec_nr is the exception or interrupt number.
128
 * op may be one of:
129
 *     BSP_VEC_REPLACE - replace existing chain.
130
 *     BSP_VEC_CHAIN_FIRST - install at head of chain.
131
 *     BSP_VEC_CHAIN_LAST  - install at tail of chain.
132
 *
133
 */
134
extern bsp_vec_t *bsp_install_vec(int __vec_kind,
135
                                  int __vec_nr,
136
                                  int __op,
137
                                  bsp_vec_t *__vec);
138
 
139
/*
140
 * Install a debug handler.
141
 * Returns old handler being replaced.
142
 */
143
extern bsp_handler_t bsp_install_dbg_handler(bsp_handler_t __new_handler);
144
 
145
/*
146
 * Sometimes it is desireable to call the debug handler directly. This routine
147
 * accomplishes that. It is the responsibility of the caller to insure that
148
 * interrupts are disabled before calling this routine.
149
 */
150
extern void bsp_invoke_dbg_handler(int __exc_nr, void *__regs);
151
 
152
/*
153
 * Install a 'kill' handler. This handler is called when debugger
154
 * issues a kill command.
155
 * Returns old handler being replaced.
156
 */
157
extern bsp_handler_t bsp_install_kill_handler(bsp_handler_t __new_handler);
158
 
159
/*
160
 * Architecure specific routine to prepare CPU to execute
161
 * a single machine instruction.
162
 */
163
#ifndef USE_ECOS_HAL_SINGLESTEP
164
extern void bsp_singlestep_setup(void *__saved_regs);
165
#endif /* USE_ECOS_HAL_SINGLESTEP */
166
 
167
/*
168
 * Architecure specific routine to cleanup after a single-step
169
 * completes.
170
 */
171
#ifndef USE_ECOS_HAL_SINGLESTEP
172
extern void bsp_singlestep_cleanup(void *__saved_regs);
173
#endif /* USE_ECOS_HAL_SINGLESTEP */
174
 
175
/*
176
 * Architecture specific routine to skip past the current machine instruction.
177
 */
178
#ifndef USE_ECOS_HAL_SINGLESTEP
179
extern void bsp_skip_instruction(void *__saved_regs);
180
#endif /* USE_ECOS_HAL_SINGLESTEP */
181
 
182
/*
183
 * Return byte offset within the saved register area of the
184
 * given register.
185
 */
186
extern int bsp_regbyte(int __regno);
187
 
188
/*
189
 * Return size in bytes of given register.
190
 */
191
extern int bsp_regsize(int __regno);
192
 
193
/*
194
 * Setup the saved registered to establish the given Program Counter.
195
 */
196
#ifndef bsp_set_pc
197
extern void bsp_set_pc(unsigned long __pc, void *__saved_regs);
198
#endif
199
 
200
/*
201
 * Get the current Program Counter from the saved registers.
202
 */
203
#ifndef bsp_get_pc
204
unsigned long bsp_get_pc(void *__saved_regs);
205
#endif
206
 
207
extern int bsp_memory_read(void *__addr,    /* start addr of memory to read */
208
                           int  __asid,     /* address space id */
209
                           int  __rsize,    /* size of individual read ops */
210
                           int  __nreads,   /* number of read operations */
211
                           void *__buf);    /* result buffer */
212
 
213
extern int bsp_memory_write(void *__addr,   /* start addr of memory to write */
214
                            int  __asid,    /* address space id */
215
                            int  __wsize,   /* size of individual write ops */
216
                            int  __nwrites, /* number of write operations */
217
                            void *__buf);   /* source buffer for write data */
218
 
219
/*
220
 * Architecture specific routines to read and write CPU registers.
221
 */
222
extern void bsp_set_register(int __regno, void *__saved_regs, void *__val);
223
extern void bsp_get_register(int __regno, void *__saved_regs, void *__val);
224
 
225
 
226
/*
227
 * Architecture specific conversion of raw exception info into
228
 * a signal value.
229
 */
230
#ifndef bsp_get_signal
231
extern int  bsp_get_signal(int __exc_nr, void *__saved_regs);
232
#endif
233
 
234
/* light-weight bsp printf to console port */
235
extern void bsp_printf(const char *__fmt, ...);
236
 
237
/* light-weight bsp printf to debug port */
238
extern void bsp_dprintf(const char *__fmt, ...);
239
 
240
/* bsp vsprintf */
241
extern int bsp_vsprintf(char *__str, const char *__fmt, va_list __ap);
242
 
243
/* bsp vprintf to console port */
244
extern void bsp_vprintf(const char *__fmt, va_list __ap);
245
 
246
/* bsp vprintf to debug port */
247
extern void bsp_dvprintf(const char *__fmt, va_list __ap);
248
 
249
/* bsp sprintf */
250
extern void bsp_sprintf(char *str, const char *fmt, ...);
251
 
252
#ifdef NDEBUG
253
#define BSP_ASSERT(e)  ((void)0)
254
#else /* NDEBUG */
255
extern void _bsp_assert(const char *, const int, const char *);
256
#define BSP_ASSERT(e)  ((e) ? (void)0 : _bsp_assert(__FILE__, __LINE__, #e))
257
#endif /* NDEBUG */
258
 
259
/*
260
 * Functions for low-level console and debug i/o.
261
 */
262
extern void bsp_console_write(const char *__p, int __len);
263
extern void bsp_console_putc(char __ch);
264
extern int  bsp_console_read(char *__p, int __len);
265
extern int  bsp_console_getc(void);
266
extern void bsp_console_ungetc(char ch);
267
extern void bsp_debug_write(const char *__p, int __len);
268
extern int  bsp_debug_read(char *__p, int __len);
269
extern void bsp_debug_putc(char __ch);
270
extern int  bsp_debug_getc(void);
271
extern void bsp_debug_ungetc(char ch);
272
 
273
/*
274
 * Disable interrupts for debug comm channel.
275
 * Returns true if interrupts were previously enabled,
276
 * false if interrupts were already disabled.
277
 */
278
extern int  bsp_debug_irq_disable(void);
279
extern void bsp_debug_irq_enable(void);
280
 
281
/*
282
 * Cache control functions. May be noops for architectures not
283
 * supporting caches.
284
 *
285
 * The icache flush simply invalidates _at_least_ the range of
286
 * addresses specified.
287
 *
288
 * The dcache flush writes back (if write-back cache) and invalidates
289
 * _at_least_ the range of addresses specified.
290
 *
291
 */
292
extern void bsp_flush_dcache(void *__p, int __nbytes);
293
extern void bsp_flush_icache(void *__p, int __nbytes);
294
 
295
/*
296
 * Reset function. May be noops for architectures not
297
 * supporting software reset.
298
 */
299
extern void bsp_reset(void);
300
 
301
/*
302
 * Generic data (board and CPU specific) handling
303
 */
304
extern void *bsp_cpu_data(void);
305
extern void *bsp_board_data(void);
306
 
307
/*
308
 *  List of board characteristics which can be read queried by BSP clients. These
309
 *  information IDs are passed to:
310
 *
311
 *      int bsp_sysinfo(enum bsp_info_id id, ...);
312
 *
313
 *  Some pieces of information may have more than one instance. For example, the
314
 *  BSP will likely have information on multiple memory regions. In those cases,
315
 *  a particular instance may be accessed using a small integer index argument.
316
 *
317
 *  The following comments indicate what additional arguments are needed
318
 *  to access the specific information.
319
 */
320
enum bsp_info_id {
321
    /*
322
     * CPU and board names.
323
     *
324
     * err = bsp_sysinfo(BSP_INFO_PLATFORM,
325
     *                   struct bsp_platform_info *result)
326
     *
327
     *     err => zero if successful, -1 if unsupported.
328
     */
329
    BSP_INFO_PLATFORM,
330
 
331
    /*
332
     * Data, instruction, and secondary caches.
333
     *
334
     * err = bsp_sysinfo(BSP_INFO_[DIS]CACHE,
335
     *                   struct bsp_cache_info *result)
336
     *
337
     *     err => zero if successful, -1 if unsupported.
338
     *
339
     */
340
    BSP_INFO_DCACHE,
341
    BSP_INFO_ICACHE,
342
    BSP_INFO_SCACHE,
343
 
344
    /*
345
     * Memory region info.
346
     *
347
     * err = bsp_sysinfo(BSP_INFO_MEMORY,
348
     *                   int index,
349
     *                   struct bsp_mem_info *result)
350
     *
351
     *     err => zero if successful, -1 if invalid index.
352
     *
353
     * Caller should start index at zero, then increment index for subsequent
354
     * calls until error return indicates no more memory regions.
355
     */
356
    BSP_INFO_MEMORY,
357
 
358
    /*
359
     * Communication channel info.
360
     *
361
     * err = bsp_sysinfo(BSP_INFO_COMM,
362
     *                   int index,
363
     *                   struct bsp_comm_info *result)
364
     *
365
     *     err => zero if successful, -1 if invalid index.
366
     *
367
     * Caller should start index at zero, then increment index for subsequent
368
     * calls until error return indicates no more comm channels.
369
     */
370
    BSP_INFO_COMM
371
};
372
 
373
 
374
/*
375
 * Platform info.
376
 */
377
struct bsp_platform_info {
378
    const char *cpu;    /* CPU name*/
379
    const char *board;  /* board name */
380
    const char *extra;  /* extra info */
381
};
382
 
383
 
384
/*
385
 * Cache size info.
386
 */
387
struct bsp_cachesize_info {
388
    int   size;         /* total size in bytes */
389
    short linesize;     /* width of cacheline in bytes */
390
    short ways;         /* number of ways per line */
391
};
392
 
393
 
394
/*
395
 * Memory region info.
396
 * The BSP may describe multiple memory regions. For example,
397
 * DRAM may be comprised of several non-contiguous regions.
398
 * ROM and FLASH regions may also be described.
399
 *
400
 */
401
struct bsp_mem_info {
402
    void *phys_start;   /* physical start address */
403
    void *virt_start;   /* virtual start address */
404
    int  virt_asid;     /* some architectures also use an address space id */
405
    long nbytes;        /* length of region in bytes */
406
    int  kind;          /* kind of memory */
407
#define BSP_MEM_RAM    1
408
#define BSP_MEM_FLASH  2
409
#define BSP_MEM_ROM    3
410
};
411
 
412
 
413
struct bsp_comm_info {
414
    char    *name;
415
    short   kind;
416
#define BSP_COMM_SERIAL 1
417
#define BSP_COMM_ENET   2
418
    short   protocol;
419
#define BSP_PROTO_NONE  0
420
#define BSP_PROTO_UDP   1
421
#define BSP_PROTO_TCP   2
422
};
423
 
424
 
425
extern int bsp_sysinfo(enum bsp_info_id __id, ...);
426
 
427
/*
428
 * Set or get active debug and console channels.
429
 * Returns -1 if unsucessful.
430
 * If the passed in __comm_id is -1, then the id of the current channel
431
 * is returned.
432
 */
433
extern int bsp_set_debug_comm(int __comm_id);
434
extern int bsp_set_console_comm(int __comm_id);
435
 
436
/*
437
 * Set or get the current baud rate of a serial comm channel.
438
 * Returns -1 on if unsuccessful.
439
 * If the given baud is -1, then the current baudrate is returned.
440
 */
441
extern int bsp_set_serial_baud(int __comm_id, int baud);
442
 
443
#endif
444
 
445
#endif // __BSP_BSP_H__

powered by: WebSVN 2.1.0

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