1 #ifndef CYGONCE_HAL_HAL_IO_H
2 #define CYGONCE_HAL_HAL_IO_H
4 //=============================================================================
8 // HAL device IO register support.
10 //=============================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 2002 Bart Veer
15 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
17 // eCos is free software; you can redistribute it and/or modify it under
18 // the terms of the GNU General Public License as published by the Free
19 // Software Foundation; either version 2 or (at your option) any later version.
21 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
22 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 // You should have received a copy of the GNU General Public License along
27 // with eCos; if not, write to the Free Software Foundation, Inc.,
28 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
30 // As a special exception, if other files instantiate templates or use macros
31 // or inline functions from this file, or you compile this file and link it
32 // with other works to produce a work based on this file, this file does not
33 // by itself cause the resulting work to be covered by the GNU General Public
34 // License. However the source code for this file must still be made available
35 // in accordance with section (3) of the GNU General Public License.
37 // This exception does not invalidate any other reasons why a work based on
38 // this file might be covered by the GNU General Public License.
40 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
41 // at http://sources.redhat.com/ecos/ecos-license/
42 // -------------------------------------------
43 //####ECOSGPLCOPYRIGHTEND####
44 //=============================================================================
45 //#####DESCRIPTIONBEGIN####
48 // Contributors:nickg, bartv, alunn, jlarmour
50 // Purpose: Define IO register support
51 // Description: The macros defined here provide the HAL APIs for handling
52 // device IO control registers.
54 // For the synthetic target these macros should never
55 // actually be used since the application will run as an
56 // ordinary user application and should not have
57 // permission to access any real hardware. Instead
58 // hardware access should go via the auxiliary. Possibly
59 // the macros should be #pragma poison'd, but some people
60 // may want to run the synthetic target in a way that
61 // does involve accessing real hardware.
63 // The synthetic target provides some additional I/O
64 // facilities in the form of Linux system calls. A useful
65 // subset of these are prototyped here, together with
66 // associated constants. There are also I/O operations to
67 // interact with the auxiliary.
70 // #include <cyg/hal/hal_io.h>
73 //####DESCRIPTIONEND####
75 //=============================================================================
77 #include <cyg/infra/cyg_type.h>
79 #include <cyg/hal/var_io.h> // Variant-specific definitions
81 //-----------------------------------------------------------------------------
82 // IO Register address.
83 // This type is for recording the address of an IO register.
85 typedef volatile CYG_ADDRWORD HAL_IO_REGISTER;
87 //-----------------------------------------------------------------------------
88 // BYTE Register access.
89 // Individual and vectorized access to 8 bit registers.
91 #define HAL_READ_UINT8( _register_, _value_ ) \
93 ((_value_) = *((volatile CYG_BYTE *)(_register_))); \
96 #define HAL_WRITE_UINT8( _register_, _value_ ) \
98 (*((volatile CYG_BYTE *)(_register_)) = (_value_)); \
101 #define HAL_READ_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \
103 cyg_count32 _i_,_j_; \
104 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \
105 (_buf_)[_i_] = ((volatile CYG_BYTE *)(_register_))[_j_]; \
109 #define HAL_WRITE_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \
111 cyg_count32 _i_,_j_; \
112 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \
113 ((volatile CYG_BYTE *)(_register_))[_j_] = (_buf_)[_i_]; \
118 //-----------------------------------------------------------------------------
120 // Individual and vectorized access to 16 bit registers.
122 #define HAL_READ_UINT16( _register_, _value_ ) \
124 ((_value_) = *((volatile CYG_WORD16 *)(_register_))); \
127 #define HAL_WRITE_UINT16( _register_, _value_ ) \
129 (*((volatile CYG_WORD16 *)(_register_)) = (_value_)); \
132 #define HAL_READ_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \
134 cyg_count32 _i_,_j_; \
135 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \
136 (_buf_)[_i_] = ((volatile CYG_WORD16 *)(_register_))[_j_]; \
140 #define HAL_WRITE_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \
142 cyg_count32 _i_,_j_; \
143 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \
144 ((volatile CYG_WORD16 *)(_register_))[_j_] = (_buf_)[_i_]; \
148 //-----------------------------------------------------------------------------
150 // Individual and vectorized access to 32 bit registers.
152 #define HAL_READ_UINT32( _register_, _value_ ) \
154 ((_value_) = *((volatile CYG_WORD32 *)(_register_))); \
157 #define HAL_WRITE_UINT32( _register_, _value_ ) \
159 (*((volatile CYG_WORD32 *)(_register_)) = (_value_)); \
162 #define HAL_READ_UINT32_VECTOR( _register_, _buf_, _count_, _step_ ) \
164 cyg_count32 _i_,_j_; \
165 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \
166 (_buf_)[_i_] = ((volatile CYG_WORD32 *)(_register_))[_j_]; \
170 #define HAL_WRITE_UINT32_VECTOR( _register_, _buf_, _count_, _step_ ) \
172 cyg_count32 _i_,_j_; \
173 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \
174 ((volatile CYG_WORD32 *)(_register_))[_j_] = (_buf_)[_i_]; \
178 // ----------------------------------------------------------------------------
179 // Linux system calls and associated structures and constants. This is
180 // by no means a complete list, but there is enough information for
181 // the needs of the relevant HAL packages. The information needs to be
182 // kept in synch with the Linux header files, but in practice
183 // divergence will be rare because that would imply incompatible
184 // changes in the Linux kernel API.
186 // It may seem tempting to import the Linux header files directly, but
187 // that would prevent cross-compilation and introduce all kinds of
188 // namespace pollution.
190 // The actual implementation lives in variant HAL packages since
191 // typically they involve direct system calls via bits of assembler.
192 // Note that only a subset of system calls are actually implemented,
193 // so the variant HALs may need to be updated if this list needs to
197 #define CYG_HAL_SYS_EINTR 4
198 #define CYG_HAL_SYS_EAGAIN 11
200 // Signal-related information
201 #define CYG_HAL_SYS_SIGHUP 1
202 #define CYG_HAL_SYS_SIGINT 2
203 #define CYG_HAL_SYS_SIGQUIT 3
204 #define CYG_HAL_SYS_SIGILL 4
205 #define CYG_HAL_SYS_SIGTRAP 5
206 #define CYG_HAL_SYS_SIGABRT 6
207 #define CYG_HAL_SYS_SIGBUS 7
208 #define CYG_HAL_SYS_SIGFPE 8
209 #define CYG_HAL_SYS_SIGKILL 9
210 #define CYG_HAL_SYS_SIGUSR1 10
211 #define CYG_HAL_SYS_SIGSEGV 11
212 #define CYG_HAL_SYS_SIGUSR2 12
213 #define CYG_HAL_SYS_SIGPIPE 13
214 #define CYG_HAL_SYS_SIGALRM 14
215 #define CYG_HAL_SYS_SIGTERM 15
216 #define CYG_HAL_SYS_SIGSTKFLT 16
217 #define CYG_HAL_SYS_SIGCHLD 17
218 #define CYG_HAL_SYS_SIGCONT 18
219 #define CYG_HAL_SYS_SIGSTOP 19
220 #define CYG_HAL_SYS_SIGTSTP 20
221 #define CYG_HAL_SYS_SIGTTIN 21
222 #define CYG_HAL_SYS_SIGTTOU 22
223 #define CYG_HAL_SYS_SIGURG 23
224 #define CYG_HAL_SYS_SIGXCPU 24
225 #define CYG_HAL_SYS_SIGXFSZ 25
226 #define CYG_HAL_SYS_SIGVTALRM 26
227 #define CYG_HAL_SYS_SIGPROF 27
228 #define CYG_HAL_SYS_SIGWINCH 28
229 #define CYG_HAL_SYS_SIGIO 29
230 #define CYG_HAL_SYS_SIGPWR 30
231 #define CYG_HAL_SYS_SIGSYS 31
233 #define CYG_HAL_SYS_SA_NOCLDSTOP 0x00000001
234 #define CYG_HAL_SYS_SA_NOCLDWAIT 0x00000002
235 #define CYG_HAL_SYS_SA_SIGINFO 0x00000004
236 #define CYG_HAL_SYS_SA_RESTORER 0x04000000
237 #define CYG_HAL_SYS_SA_RESTART 0x10000000
238 #define CYG_HAL_SYS_SA_NODEFER 0x40000000
240 #define CYG_HAL_SYS_SIG_BLOCK 0
241 #define CYG_HAL_SYS_SIG_UNBLOCK 1
242 #define CYG_HAL_SYS_SIG_SETMASK 2
244 #define CYG_HAL_SYS__NSIG 64
245 #define CYG_HAL_SYS__SIGBITS (8 * sizeof(unsigned long))
246 #define CYG_HAL_SYS__SIGELT(_d_) ((_d_) / CYG_HAL_SYS__SIGBITS)
247 #define CYG_HAL_SYS__SIGMASK(_d_) ((unsigned long)1 << ((_d_) % CYG_HAL_SYS__SIGBITS))
249 typedef struct cyg_hal_sys_sigset_t {
250 unsigned long hal_sig_bits[CYG_HAL_SYS__NSIG / CYG_HAL_SYS__SIGBITS];
251 } cyg_hal_sys_sigset_t;
253 #define CYG_HAL_SYS_SIGFILLSET(_set_) \
256 for (__i = 0; __i < (CYG_HAL_SYS__NSIG / CYG_HAL_SYS__SIGBITS); __i++) { \
257 (_set_)->hal_sig_bits[__i] = ~0; \
261 #define CYG_HAL_SYS_SIGEMPTYSET(_set_) \
264 for (__i = 0; __i < (CYG_HAL_SYS__NSIG / CYG_HAL_SYS__SIGBITS); __i++) { \
265 (_set_)->hal_sig_bits[__i] = 0; \
269 #define CYG_HAL_SYS_SIGADDSET(_set_, _bit_) \
271 (_set_)->hal_sig_bits[CYG_HAL_SYS__SIGELT(_bit_ - 1)] |= CYG_HAL_SYS__SIGMASK(_bit_ - 1); \
274 #define CYG_HAL_SYS_SIGDELSET(_set_, _bit_) \
276 (_set_)->hal_sig_bits[CYG_HAL_SYS__SIGELT(_bit_ - 1)] &= ~CYG_HAL_SYS__SIGMASK(_bit_ - 1); \
279 #define CYG_HAL_SYS_SIGISMEMBER(_set_, _bit_) \
280 (0 != ((_set_)->hal_sig_bits[CYG_HAL_SYS__SIGELT(_bit_ - 1)] & CYG_HAL_SYS__SIGMASK(_bit_ - 1)))
282 // The kernel sigaction structure has changed, to allow for >32
283 // signals. This is the old version, i.e. a struct old_sigaction, for
284 // use with the sigaction() system call rather than rt_sigaction(). It
285 // is preferred to the more modern version because gdb knows about
286 // rt_sigaction() and will start intercepting signals, but it seems to
287 // ignore sigaction().
288 struct cyg_hal_sys_sigaction {
289 void (*hal_handler)(int);
292 void (*hal_restorer)(void);
296 struct cyg_hal_sys_timeval {
301 struct cyg_hal_sys_timezone {
302 int hal_tz_minuteswest;
306 // Select support. Initially this is used only by the idle handler.
307 #define CYG_HAL_SYS_FD_SETSIZE 1024
308 #define CYG_HAL_SYS__NFDBITS (8 * sizeof(unsigned long))
309 #define CYG_HAL_SYS__FDELT(_d_) ((_d_) / CYG_HAL_SYS__NFDBITS)
310 #define CYG_HAL_SYS__FDMASK(_d_) ((unsigned long)1 << ((_d_) % CYG_HAL_SYS__NFDBITS))
312 struct cyg_hal_sys_fd_set {
313 unsigned long hal_fds_bits[CYG_HAL_SYS_FD_SETSIZE / CYG_HAL_SYS__NFDBITS];
315 #define CYG_HAL_SYS_FD_ZERO(_fdsp_) \
319 __i < (CYG_HAL_SYS_FD_SETSIZE / CYG_HAL_SYS__NFDBITS); \
321 (_fdsp_)->hal_fds_bits[__i] = 0; \
325 #define CYG_HAL_SYS_FD_SET(_fd_, _fdsp_) \
327 (_fdsp_)->hal_fds_bits[CYG_HAL_SYS__FDELT(_fd_)] |= CYG_HAL_SYS__FDMASK(_fd_); \
330 #define CYG_HAL_SYS_FD_CLR(_fd_, _fdsp_) \
332 (_fdsp_)->hal_fds_bits[CYG_HAL_SYS__FDELT(_fd_)] &= ~CYG_HAL_SYS__FDMASK(_fd_); \
335 #define CYG_HAL_SYS_FD_ISSET(_fd_, _fdsp_) \
336 (0 != ((_fdsp_)->hal_fds_bits[CYG_HAL_SYS__FDELT(_fd_)] & CYG_HAL_SYS__FDMASK(_fd_)))
338 // Interval timer support, needed for the clock.
339 #define CYG_HAL_SYS_ITIMER_REAL 0
340 #define CYG_HAL_SYS_ITIMER_VIRTUAL 1
341 #define CYG_HAL_SYS_ITIMER_PROF 2
343 struct cyg_hal_sys_itimerval {
344 struct cyg_hal_sys_timeval hal_it_interval;
345 struct cyg_hal_sys_timeval hal_it_value;
348 // System calls and related constants, or rather the subset that is
349 // needed internally.
350 #define CYG_HAL_SYS_R_OK 0x04
351 #define CYG_HAL_SYS_W_OK 0x02
352 #define CYG_HAL_SYS_X_OK 0x01
353 #define CYG_HAL_SYS_F_OK 0x00
355 /* lseek whence flags */
356 #define CYG_HAL_SYS_SEEK_SET 0 /* Seek from beginning of file. */
357 #define CYG_HAL_SYS_SEEK_CUR 1 /* Seek from current position. */
358 #define CYG_HAL_SYS_SEEK_END 2 /* Seek from end of file. */
360 /* open/fcntl flags */
362 #define CYG_HAL_SYS_O_RDONLY 0
363 #define CYG_HAL_SYS_O_WRONLY 01
364 #define CYG_HAL_SYS_O_RDWR 02
365 #define CYG_HAL_SYS_O_CREAT 0100
366 #define CYG_HAL_SYS_O_EXCL 0200
367 #define CYG_HAL_SYS_O_NOCTTY 0400
368 #define CYG_HAL_SYS_O_TRUNC 01000
369 #define CYG_HAL_SYS_O_APPEND 02000
370 #define CYG_HAL_SYS_O_NONBLOCK 04000
371 #define CYG_HAL_SYS_O_NDELAY CYG_HAL_SYS_O_NONBLOCK
372 #define CYG_HAL_SYS_O_SYNC 010000
373 #define CYG_HAL_SYS_O_FSYNC CYG_HAL_SYS_O_SYNC
374 #define CYG_HAL_SYS_O_ASYNC 020000
376 /* open mode flags */
377 #define CYG_HAL_SYS_S_IRUSR 0400
378 #define CYG_HAL_SYS_S_IREAD CYG_HAL_SYS_S_IRUSR
379 #define CYG_HAL_SYS_S_IWUSR 0200
380 #define CYG_HAL_SYS_S_IWRITE CYG_HAL_SYS_S_IWUSR
381 #define CYG_HAL_SYS_S_IXUSR 0100
382 #define CYG_HAL_SYS_S_IEXEC CYG_HAL_SYS_S_IXUSR
383 #define CYG_HAL_SYS_S_IRWXU \
384 (CYG_HAL_SYS_S_IREAD|CYG_HAL_SYS_S_IWRITE|CYG_HAL_SYS_S_IEXEC)
385 #define CYG_HAL_SYS_S_IRWXG (CYG_HAL_SYS_S_IRWXU>>3)
386 #define CYG_HAL_SYS_S_IRGRP (CYG_HAL_SYS_S_IRUSR>>3)
387 #define CYG_HAL_SYS_S_IWGRP (CYG_HAL_SYS_S_IWUSR>>3)
388 #define CYG_HAL_SYS_S_IXGRP (CYG_HAL_SYS_S_IXUSR>>3)
389 #define CYG_HAL_SYS_S_IRWXO (CYG_HAL_SYS_S_IRWXG>>3)
390 #define CYG_HAL_SYS_S_IROTH (CYG_HAL_SYS_S_IRGRP>>3)
391 #define CYG_HAL_SYS_S_IWOTH (CYG_HAL_SYS_S_IWGRP>>3)
392 #define CYG_HAL_SYS_S_IXOTH (CYG_HAL_SYS_S_IXGRP>>3)
395 #define CYG_HAL_SYS_S_IFMT 0170000 /*bitmask for the file type bitfields*/
396 #define CYG_HAL_SYS_S_IFSOCK 0140000 /*socket*/
397 #define CYG_HAL_SYS_S_IFLNK 0120000 /*symbolic link*/
398 #define CYG_HAL_SYS_S_IFREG 0100000 /*regular file*/
399 #define CYG_HAL_SYS_S_IFBLK 0060000 /*block device*/
400 #define CYG_HAL_SYS_S_IFDIR 0040000 /*directory*/
401 #define CYG_HAL_SYS_S_IFCHR 0020000 /*character device*/
402 #define CYG_HAL_SYS_S_IFIFO 0010000 /*fifo*/
403 #define CYG_HAL_SYS_S_ISUID 0004000 /*set UID bit*/
404 #define CYG_HAL_SYS_S_ISGID 0002000 /*set GID bit (see below)*/
405 #define CYG_HAL_SYS_S_ISVTX 0001000 /*sticky bit (see below)*/
407 struct cyg_hal_sys_mmap_args {
413 unsigned long offset;
416 /* Protection flags for mmap */
417 #define CYG_HAL_SYS_PROT_READ 0x1 /* page can be read */
418 #define CYG_HAL_SYS_PROT_WRITE 0x2 /* page can be written */
419 #define CYG_HAL_SYS_PROT_EXEC 0x4 /* page can be executed */
420 #define CYG_HAL_SYS_PROT_NONE 0x0 /* page can not be accessed */
422 /* Sharing types and other flags */
423 #define CYG_HAL_SYS_MAP_SHARED 0x01 /* Share changes. */
424 #define CYG_HAL_SYS_MAP_PRIVATE 0x02 /* Changes are private. */
425 #define CYG_HAL_SYS_MAP_FIXED 0x10 /* Interpret addr exactly. */
427 struct cyg_hal_sys_dirent
431 unsigned short int d_reclen;
435 struct cyg_hal_sys_timespec
438 unsigned int tv_nsec;
441 // NOTE: This corresponds to __old_kernel_stat in the kernel sources
442 // and should be used with cyg_hal_sys_oldstat etc.
444 struct cyg_hal_sys_old_stat
446 unsigned short st_dev; /* device */
447 unsigned short st_ino; /* inode */
448 unsigned short st_mode; /* protection */
449 unsigned short st_nlink; /* number of hard links */
450 unsigned short st_uid; /* user ID of owner */
451 unsigned short st_gid; /* group ID of owner */
452 unsigned short st_rdev; /* device type (if inode device) */
453 unsigned long st_size; /* total size, in bytes */
454 unsigned long st_atime; /* time of last access */
455 unsigned long st_mtime; /* time of last modification */
456 unsigned long st_ctime; /* time of last change */
459 struct cyg_hal_sys_new_stat
461 unsigned long st_dev;
462 unsigned long st_ino;
463 unsigned short st_mode;
464 unsigned short st_nlink;
465 unsigned short st_uid;
466 unsigned short st_gid;
467 unsigned long st_rdev;
468 unsigned long st_size;
469 unsigned long st_blksize;
470 unsigned long st_blocks;
471 unsigned long st_atime;
472 unsigned long st_atime_nsec;
473 unsigned long st_mtime;
474 unsigned long st_mtime_nsec;
475 unsigned long st_ctime;
476 unsigned long st_ctime_nsec;
477 unsigned long __unused4;
478 unsigned long __unused5;
481 // System calls, or rather the subset that is needed internally or by
482 // applications which want to access the host OS.
484 externC unsigned long cyg_hal_sys_write(int, const void*, long);
485 externC unsigned long cyg_hal_sys_read(int, void*, long);
486 externC int cyg_hal_sys_lseek(int, int, int);
487 externC int cyg_hal_sys_open(const char *,int,int);
488 externC int cyg_hal_sys_fdatasync(int);
489 externC int cyg_hal_sys_sigaction(int,
490 const struct cyg_hal_sys_sigaction*,
491 struct cyg_hal_sys_sigaction*);
492 externC int cyg_hal_sys_sigprocmask(int,
493 const cyg_hal_sys_sigset_t*,
494 cyg_hal_sys_sigset_t*);
495 externC int cyg_hal_sys__newselect(int,
496 struct cyg_hal_sys_fd_set*,
497 struct cyg_hal_sys_fd_set*,
498 struct cyg_hal_sys_fd_set*,
499 struct cyg_hal_sys_timeval*);
500 externC int cyg_hal_sys_setitimer(int,
501 const struct cyg_hal_sys_itimerval*,
502 struct cyg_hal_sys_itimerval*);
503 externC int cyg_hal_sys_gettimeofday(struct cyg_hal_sys_timeval*,
504 struct cyg_hal_sys_timezone*);
506 externC int cyg_hal_sys_access(const char*, int);
507 externC int cyg_hal_sys_fork(void);
508 externC int cyg_hal_sys_execve(const char*, const char* [], const char* []);
509 externC int cyg_hal_sys_pipe(int []);
510 externC int cyg_hal_sys_close(int);
511 externC int cyg_hal_sys_dup2(int, int);
513 #define CYG_HAL_SYS_IPCOP_semop 1
514 #define CYG_HAL_SYS_IPCOP_semget 2
515 #define CYG_HAL_SYS_IPCOP_semctl 3
516 #define CYG_HAL_SYS_IPCOP_msgsnd 11
517 #define CYG_HAL_SYS_IPCOP_msgrcv 12
518 #define CYG_HAL_SYS_IPCOP_msgget 13
519 #define CYG_HAL_SYS_IPCOP_msgctl 14
520 #define CYG_HAL_SYS_IPCOP_shmat 21
521 #define CYG_HAL_SYS_IPCOP_shmdt 22
522 #define CYG_HAL_SYS_IPCOP_shmget 23
523 #define CYG_HAL_SYS_IPCOP_shmctl 24
525 /*The ipc system call, which is used by the following shmem
526 functions. These may be unportable*/
528 // Generic system call. Depending on the value of call, it will
529 // perform the following functions.
530 externC int cyg_hal_sys_ipc(int call, int first, int second,
531 int third, void* ptr);
532 //get an identifier for a shared memory segment
533 externC int cyg_hal_sys_shmget (int key, int size, int shmflg);
534 //attach to an shared memory segment
535 externC void * cyg_hal_sys_shmat (int shmid, const void* shmaddr,
537 //detach from it again
538 externC int cyg_hal_sys_shmdt (const void* shmaddr);
540 // Convert a pathname and an identifier into a System V IPC key
541 externC int cyg_hal_sys_ftok(const char* path, int id);
543 // The actual implementation appears to return the new brk() value.
544 externC void* cyg_hal_sys_brk(void*);
546 // Returns the number of characters placed in the buffer or <0 for error,
548 externC int cyg_hal_sys_getcwd(char*, int);
550 // mmap on the "host" system - this may be unportable. This is the
551 // really system call into the kernel which passes one structure
552 // containing all the arguments.
553 externC int cyg_hal_sys_mmapx(struct cyg_hal_sys_mmap_args *);
555 // This is the mmap call that users are used to.
556 externC int cyg_hal_sys_mmap(void *addr,
557 unsigned long length,
563 externC int cyg_hal_sys_readdir(unsigned int fd,
564 struct cyg_hal_sys_dirent *dp,
566 // Old syscall versions
567 externC int cyg_hal_sys_oldlstat(const char* name,
568 struct cyg_hal_sys_old_stat *buf);
569 externC int cyg_hal_sys_oldfstat(int fd, struct cyg_hal_sys_old_stat *buf);
570 externC int cyg_hal_sys_oldstat(const char* name,
571 struct cyg_hal_sys_old_stat *buf);
572 // New syscall versions
573 externC int cyg_hal_sys_newlstat(const char* name,
574 struct cyg_hal_sys_new_stat *buf);
575 externC int cyg_hal_sys_newfstat(int fd, struct cyg_hal_sys_new_stat *buf);
576 externC int cyg_hal_sys_newstat(const char* name,
577 struct cyg_hal_sys_old_stat *buf);
579 externC int cyg_hal_sys_mkdir(const char* path, int mode);
581 // Access to environmental data
582 extern int cyg_hal_sys_argc;
583 extern const char** cyg_hal_sys_argv;
584 extern const char** cyg_hal_sys_environ;
586 // ----------------------------------------------------------------------------
587 // Interaction between the application and the auxiliary.
589 // Is the auxiliary actually in use/available? This flag should be tested by
590 // device drivers prior to attempting any communication with the auxiliary.
591 extern cyg_bool synth_auxiliary_running;
593 // The fundamental I/O operation: sending a request to the auxiliary and
594 // optionally getting back a reply. A null pointer for the response field
595 // indicates that no reply is expected.
596 externC void synth_auxiliary_xchgmsg(int /* devid */, int /* request */,
597 int /* arg1 */, int /* arg2 */,
598 const unsigned char* /* txdata */, int /* txlen */,
600 unsigned char* /* rxdata */, int* /* actual_rxlen */,
603 // Request that the auxiliary instantiates a given device, loading appropriate
604 // support code as required. This function takes the following arguments:
605 // 1) the location of the package that should provide this device, e.g.
607 // 2) the version of that package currently being used, e.g. "current"
608 // 3) the name of the device, e.g. "ethernet". This identifies the
609 // Tcl script that should be loaded to handle requests for this device.
610 // 4) the name of the device instance, e.g. "eth0".
611 // 5) device-specific initialization data.
612 externC int synth_auxiliary_instantiate(const char*, const char*, const char*, const char*, const char*);
614 // Support for generating strings
615 #define SYNTH_MAKESTRING1(a) #a
616 #define SYNTH_MAKESTRING(a) SYNTH_MAKESTRING1(a)
618 //-----------------------------------------------------------------------------
619 #endif // ifndef CYGONCE_HAL_HAL_IO_H