comparison packages/redboot/current/src/syscall.c @ 208:e0c0827131d1 ecos

Merge from eCos master repository on 2002-05-20-20:11:54-BST
author jlarmour
date Mon, 20 May 2002 22:19:26 +0000
parents 353a011b23b8
children d2c90368aeef
comparison
equal deleted inserted replaced
207:74c807ddde34 208:e0c0827131d1
3 // syscall.c 3 // syscall.c
4 // 4 //
5 // Redboot syscall handling for GNUPro bsp support 5 // Redboot syscall handling for GNUPro bsp support
6 // 6 //
7 //========================================================================== 7 //==========================================================================
8 //####COPYRIGHTBEGIN#### 8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // 9 // -------------------------------------------
10 // ------------------------------------------- 10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // The contents of this file are subject to the Red Hat eCos Public License 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Version 1.1 (the "License"); you may not use this file except in 12 //
13 // compliance with the License. You may obtain a copy of the License at 13 // eCos is free software; you can redistribute it and/or modify it under
14 // http://www.redhat.com/ 14 // the terms of the GNU General Public License as published by the Free
15 // 15 // Software Foundation; either version 2 or (at your option) any later version.
16 // Software distributed under the License is distributed on an "AS IS" 16 //
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // License for the specific language governing rights and limitations under 18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // the License. 19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // 20 // for more details.
21 // The Original Code is eCos - Embedded Configurable Operating System, 21 //
22 // released September 30, 1998. 22 // You should have received a copy of the GNU General Public License along
23 // 23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // The Initial Developer of the Original Code is Red Hat. 24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 // Portions created by Red Hat are 25 //
26 // Copyright (C) 2000, 2001, 2002 Red Hat, Inc. 26 // As a special exception, if other files instantiate templates or use macros
27 // All Rights Reserved. 27 // or inline functions from this file, or you compile this file and link it
28 // ------------------------------------------- 28 // with other works to produce a work based on this file, this file does not
29 // 29 // by itself cause the resulting work to be covered by the GNU General Public
30 //####COPYRIGHTEND#### 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####
31 //========================================================================== 40 //==========================================================================
32 //#####DESCRIPTIONBEGIN#### 41 //#####DESCRIPTIONBEGIN####
33 // 42 //
34 // Author(s): msalter 43 // Author(s): msalter
35 // Contributors: msalter 44 // Contributors: msalter
44 #include <cyg/hal/hal_intr.h> 53 #include <cyg/hal/hal_intr.h>
45 #include <cyg/hal/drv_api.h> 54 #include <cyg/hal/drv_api.h>
46 55
47 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS 56 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS
48 57
49 #define EIO 5 /* I/O error */ 58 #define NEWLIB_EIO 5 /* I/O error */
50 59 #define NEWLIB_ENOSYS 88 /* Syscall not supported */
51 // These are required by the ANSI C part of newlib (excluding system() of
52 // course).
53 #define SYS_exit 1
54 #define SYS_open 2
55 #define SYS_close 3
56 #define SYS_read 4
57 #define SYS_write 5
58 #define SYS_lseek 6
59 #define SYS_unlink 7
60 #define SYS_getpid 8
61 #define SYS_kill 9
62 #define SYS_fstat 10
63 //#define SYS_sbrk 11 - not currently a system call, but reserved.
64
65 // ARGV support.
66 #define SYS_argvlen 12
67 #define SYS_argv 13
68
69 // These are extras added for one reason or another.
70 #define SYS_chdir 14
71 #define SYS_stat 15
72 #define SYS_chmod 16
73 #define SYS_utime 17
74 #define SYS_time 18
75 #define SYS_times 20
76
77 #define SYS_interrupt 1000
78 #define SYS_meminfo 1001
79
80 #define __GET_SHARED 0xbaad // 47789 decimal
81
82 60
83 /* 61 /*
84 * Clients of this BSP will need to have access to BSP functions and 62 * Clients of this BSP will need to have access to BSP functions and
85 * data structures. Because, the client and the BSP may not be linked 63 * data structures. Because, the client and the BSP may not be linked
86 * together, a structure of vectors is used to gain this access. A 64 * together, a structure of vectors is used to gain this access. A
108 int __console_interrupt_flag; 86 int __console_interrupt_flag;
109 } __shared_t; 87 } __shared_t;
110 88
111 static __shared_t __shared_data = { 2 }; 89 static __shared_t __shared_data = { 2 };
112 90
91 // this is used by newlib's mode_t so we should match it
92 #ifdef __GNUC__
93 #define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
94 #else
95 #define _ST_INT32
96 #endif
97 typedef unsigned int newlib_mode_t _ST_INT32;
98 typedef short newlib_dev_t;
99 typedef unsigned short newlib_ino_t;
100 typedef unsigned short newlib_nlink_t;
101 typedef long newlib_off_t;
102 typedef unsigned short newlib_uid_t;
103 typedef unsigned short newlib_gid_t;
104 typedef long newlib_time_t;
105 typedef long newlib_long_t;
106
107 struct newlib_stat
108 {
109 newlib_dev_t st_dev;
110 newlib_ino_t st_ino;
111 newlib_mode_t st_mode;
112 newlib_nlink_t st_nlink;
113 newlib_uid_t st_uid;
114 newlib_gid_t st_gid;
115 newlib_dev_t st_rdev;
116 newlib_off_t st_size;
117 // We assume we've been compiled with the same flags as newlib here
118 #if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
119 newlib_time_t st_atime;
120 newlib_time_t st_mtime;
121 newlib_time_t st_ctime;
122 #else
123 newlib_time_t st_atime;
124 newlib_long_t st_spare1;
125 newlib_time_t st_mtime;
126 newlib_long_t st_spare2;
127 newlib_time_t st_ctime;
128 newlib_long_t st_spare3;
129 newlib_long_t st_blksize;
130 newlib_long_t st_blocks;
131 newlib_long_t st_spare4[2];
132 #endif
133 };
134 #define NEWLIB_S_IFCHR 0020000 // character special file
135
113 static inline char __getc(void) 136 static inline char __getc(void)
114 { 137 {
115 char c; 138 char c;
116 hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS(); 139 hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
117 140
134 CYGACC_COMM_IF_PUTC(*__chan, c); 157 CYGACC_COMM_IF_PUTC(*__chan, c);
135 } 158 }
136 } 159 }
137 160
138 161
162 static inline void __flush(void)
163 {
164 hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
165
166 if (__chan == NULL)
167 __chan = CYGACC_CALL_IF_DEBUG_PROCS();
168
169 CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_FLUSH_OUTPUT);
170 }
171
139 // Timer support 172 // Timer support
140 173
141 static cyg_handle_t sys_timer_handle; 174 static cyg_handle_t sys_timer_handle;
142 static cyg_interrupt sys_timer_interrupt; 175 static cyg_interrupt sys_timer_interrupt;
143 static cyg_uint32 sys_timer_ticks = 0; 176 static cyg_uint64 sys_timer_ticks = 0;
177
178 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
179
180 static unsigned int set_period = CYGNUM_HAL_RTC_PERIOD; // The default
181
182 typedef void *callback_func( char *pc, char *sp );
183 static callback_func *timer_callback = 0;
184
185 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
144 186
145 static void 187 static void
146 sys_timer_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data) 188 sys_timer_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
147 { 189 {
148 // do nothing 190 // do nothing
152 static cyg_uint32 194 static cyg_uint32
153 sys_timer_isr(cyg_vector_t vector, cyg_addrword_t data) 195 sys_timer_isr(cyg_vector_t vector, cyg_addrword_t data)
154 { 196 {
155 ++sys_timer_ticks; 197 ++sys_timer_ticks;
156 198
199 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
200 HAL_CLOCK_RESET(CYGNUM_HAL_INTERRUPT_RTC, set_period);
201 #else
157 HAL_CLOCK_RESET(CYGNUM_HAL_INTERRUPT_RTC, CYGNUM_HAL_RTC_PERIOD); 202 HAL_CLOCK_RESET(CYGNUM_HAL_INTERRUPT_RTC, CYGNUM_HAL_RTC_PERIOD);
203 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
158 204
159 cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_RTC); 205 cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_RTC);
160 206
207 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
208 if ( timer_callback ) {
209 char *intrpc = (char *)0;
210 char *intrsp = (char *)0;
211
212 // There may be a number of ways to get the PC and (optional) SP
213 // information out of the HAL. Hence this is conditioned. In some
214 // configurations, a register-set pointer is available as
215 // (invisible) argument 3 to this ISR call.
216
217 #ifdef HAL_GET_PROFILE_INFO
218 HAL_GET_PROFILE_INFO( intrpc, intrsp );
219 #endif // HAL_GET_PROFILE_INFO available
220
221 CYGARC_HAL_SAVE_GP();
222 timer_callback( intrpc, intrsp );
223 CYGARC_HAL_RESTORE_GP();
224 }
225 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
161 return 0; 226 return 0;
162 } 227 }
163 228
164 229
165 static void sys_timer_init(void) 230 static void sys_timer_init(void)
166 { 231 {
232 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
233 HAL_CLOCK_INITIALIZE(set_period);
234 #else
167 HAL_CLOCK_INITIALIZE(CYGNUM_HAL_RTC_PERIOD); 235 HAL_CLOCK_INITIALIZE(CYGNUM_HAL_RTC_PERIOD);
236 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
168 237
169 cyg_drv_interrupt_create( 238 cyg_drv_interrupt_create(
170 CYGNUM_HAL_INTERRUPT_RTC, 239 CYGNUM_HAL_INTERRUPT_RTC,
171 0, // Priority - unused 240 0, // Priority - unused
172 (CYG_ADDRWORD)0, // Data item passed to ISR & DSR 241 (CYG_ADDRWORD)0, // Data item passed to ISR & DSR
179 248
180 cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC); 249 cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC);
181 } 250 }
182 251
183 252
253 #ifndef CYGPKG_HAL_GDB_FILEIO
184 // 254 //
185 // read -- read bytes from the serial port. Ignore fd, since 255 // read -- read bytes from the serial port. Ignore fd, since
186 // we only have stdin. 256 // we only have stdin.
187 static int 257 static int
188 sys_read(int fd, char *buf, int nbytes) 258 sys_read(int fd, char *buf, int nbytes)
217 if (*buf == '\n') 287 if (*buf == '\n')
218 __putc('\r'); 288 __putc('\r');
219 __putc(*buf++); 289 __putc(*buf++);
220 tosend--; 290 tosend--;
221 } 291 }
292 __flush();
222 293
223 return (nbytes); 294 return (nbytes);
224 } 295 }
225 296
226 297
229 // we return an error. 300 // we return an error.
230 // 301 //
231 static int 302 static int
232 sys_open (const char *buf, int flags, int mode) 303 sys_open (const char *buf, int flags, int mode)
233 { 304 {
234 return (-EIO); 305 return (-NEWLIB_EIO);
235 } 306 }
236
237 307
238 // 308 //
239 // close -- We don't need to do anything, but pretend we did. 309 // close -- We don't need to do anything, but pretend we did.
240 // 310 //
241 static int 311 static int
249 // lseek -- Since a serial port is non-seekable, we return an error. 319 // lseek -- Since a serial port is non-seekable, we return an error.
250 // 320 //
251 static int 321 static int
252 sys_lseek(int fd, int offset, int whence) 322 sys_lseek(int fd, int offset, int whence)
253 { 323 {
254 return (-EIO); 324 return (-NEWLIB_EIO);
255 } 325 }
326
327
328 #endif // ifdef CYGPKG_HAL_GDB_FILEIO
256 329
257 #define NS_PER_TICK (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR) 330 #define NS_PER_TICK (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR)
258 #define TICKS_PER_SEC (1000000000L / NS_PER_TICK) 331 #define TICKS_PER_SEC (1000000000ULL / NS_PER_TICK)
259 332
260 // This needs to match newlib HZ which is normally 60. 333 // This needs to match newlib HZ which is normally 60.
261 #define HZ 60 334 #define HZ (60ULL)
262 335
336 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
337 static unsigned int set_freq = TICKS_PER_SEC; // The default
338 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
263 static int 339 static int
264 sys_times(unsigned long *p) 340 sys_times(unsigned long *p)
265 { 341 {
266 static int inited = 0; 342 static int inited = 0;
267 343
270 sys_timer_init(); 346 sys_timer_init();
271 } 347 }
272 348
273 /* target clock runs at CLOCKS_PER_SEC. Convert to HZ */ 349 /* target clock runs at CLOCKS_PER_SEC. Convert to HZ */
274 if (p) 350 if (p)
351 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
352 *p = (sys_timer_ticks * HZ) / (cyg_uint64)set_freq;
353 #else
275 *p = (sys_timer_ticks * HZ) / TICKS_PER_SEC; 354 *p = (sys_timer_ticks * HZ) / TICKS_PER_SEC;
355 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
276 356
277 return 0; 357 return 0;
278 } 358 }
359
360 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
361
362 static void sys_profile_call_back( char *func, char **previous_call_back )
363 {
364 if ( previous_call_back )
365 *previous_call_back = (char *)timer_callback;
366
367 timer_callback = (callback_func *)func;
368
369 // Ensure the timer is started
370 (void)sys_times( (unsigned long *)0 );
371 }
372
373 static void sys_profile_frequency( int freq, int *previous_freq )
374 {
375 // Requested HZ:
376 // 0 => tell me the current value (no change, IMPLEMENTED HERE)
377 // - 1 => tell me the slowest (no change)
378 // - 2 => tell me the default (no change, IMPLEMENTED HERE)
379 // -nnn => tell me what you would choose for nnn (no change)
380 // MIN_INT => tell me the fastest (no change)
381 //
382 // 1 => tell me the slowest (sets the clock)
383 // MAX_INT => tell me the fastest (sets the clock)
384
385 // Ensure the timer is started
386 (void)sys_times( (unsigned long *)0 );
387
388 if ( -2 == freq )
389 freq = TICKS_PER_SEC; // default value
390 else if ( 0 == freq )
391 freq = set_freq; // collect current value
392 else {
393 int do_set_freq = (freq > 0);
394 unsigned int period = CYGNUM_HAL_RTC_PERIOD;
395
396 if ( 0 == (freq ^ -freq) ) // Then it's MIN_INT in local size
397 freq++; // just so that it will negate correctly
398
399 // Then set the timer to that fast - or pass on the enquiry
400 #ifdef HAL_CLOCK_REINITIALIZE
401 // Give the HAL enough info to do the division sum relative to
402 // the default setup, in period and TICKS_PER_SEC.
403 HAL_CLOCK_REINITIALIZE( freq, period, TICKS_PER_SEC );
404 #else
405 freq = TICKS_PER_SEC; // the only choice
406 #endif
407 if ( do_set_freq ) { // update the global variables
408 unsigned int orig = set_freq;
409 set_freq = freq;
410 set_period = period;
411 // We must "correct" sys_timer_ticks for the new scale factor.
412 sys_timer_ticks = sys_timer_ticks * set_freq / orig;
413 }
414 }
415
416 if ( previous_freq ) // Return the current value (new value)
417 *previous_freq = freq;
418 }
419
420 void sys_profile_reset( void )
421 {
422 timer_callback = NULL;
423 // Want to preserve the frequency between runs, for clever GDB users!
424 // sys_profile_frequency( TICKS_PER_SEC, NULL );
425 }
426
427 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
279 428
280 // 429 //
281 // Generic syscall handler. 430 // Generic syscall handler.
282 // 431 //
283 // Returns 0 if syscall number is not handled by this 432 // Returns 0 if syscall number is not handled by this
286 // 435 //
287 CYG_ADDRWORD 436 CYG_ADDRWORD
288 __do_syscall(CYG_ADDRWORD func, // syscall function number 437 __do_syscall(CYG_ADDRWORD func, // syscall function number
289 CYG_ADDRWORD arg1, CYG_ADDRWORD arg2, // up to four args. 438 CYG_ADDRWORD arg1, CYG_ADDRWORD arg2, // up to four args.
290 CYG_ADDRWORD arg3, CYG_ADDRWORD arg4, 439 CYG_ADDRWORD arg3, CYG_ADDRWORD arg4,
291 CYG_ADDRWORD *retval) // syscall return value 440 CYG_ADDRWORD *retval, CYG_ADDRWORD *sig) // syscall return value
292 { 441 {
293 int err = 0; 442 int err = 0;
443 *sig = 0;
294 444
295 switch (func) { 445 switch (func) {
296 446
447 #ifdef CYGPKG_HAL_GDB_FILEIO // File I/O over the GDB remote protocol
448 case SYS_open:
449 {
450 __externC int cyg_hal_gdbfileio_open( const char *name, int flags,
451 int mode, int *sig );
452 err = cyg_hal_gdbfileio_open((const char *)arg1, (int)arg2, (int)arg3,
453 (int *)sig);
454 break;
455 }
456 case SYS_read:
457 {
458 __externC int cyg_hal_gdbfileio_read( int fd, void *buf, size_t count,
459 int *sig );
460 err = cyg_hal_gdbfileio_read((int)arg1, (void *)arg2, (size_t)arg3,
461 (int *)sig);
462 break;
463 }
464 case SYS_write:
465 {
466 __externC int cyg_hal_gdbfileio_write( int fd, const void *buf,
467 size_t count, int *sig );
468 err = cyg_hal_gdbfileio_write((int)arg1, (const void *)arg2,
469 (size_t)arg3, (int *)sig);
470 break;
471 }
472 case SYS_close:
473 {
474 __externC int cyg_hal_gdbfileio_close( int fd, int *sig );
475 err = cyg_hal_gdbfileio_close((int)arg1, (int *)sig);
476 break;
477 }
478 case SYS_lseek:
479 {
480 __externC int cyg_hal_gdbfileio_lseek( int fd, long offset,
481 int whence, int *sig );
482 err = cyg_hal_gdbfileio_lseek((int)arg1, (long)arg2, (int)arg3,
483 (int *)sig);
484 break;
485 }
486 case SYS_stat:
487 {
488 __externC int cyg_hal_gdbfileio_stat( const char *pathname,
489 void *statbuf, int *sig );
490 err = cyg_hal_gdbfileio_stat((const char *)arg1, (void *)arg2,
491 (int *)sig);
492 break;
493 }
494 case SYS_fstat:
495 {
496 __externC int cyg_hal_gdbfileio_fstat( int fd, void *statbuf,
497 int *sig );
498 err = cyg_hal_gdbfileio_fstat((int)arg1, (void *)arg2,
499 (int *)sig);
500 break;
501 }
502 case SYS_rename:
503 {
504 __externC int cyg_hal_gdbfileio_rename( const char *oldpath,
505 const char *newpath,
506 int *sig );
507 err = cyg_hal_gdbfileio_rename((const char *)arg1, (const char *)arg2,
508 (int *)sig);
509 break;
510 }
511 case SYS_unlink:
512 {
513 __externC int cyg_hal_gdbfileio_unlink( const char *pathname,
514 int *sig );
515 err = cyg_hal_gdbfileio_unlink((const char *)arg1, (int *)sig);
516 break;
517 }
518 case SYS_isatty:
519 {
520 __externC int cyg_hal_gdbfileio_isatty( int fd, int *sig );
521 err = cyg_hal_gdbfileio_isatty((int)arg1, (int *)sig);
522 break;
523 }
524 case SYS_system:
525 {
526 __externC int cyg_hal_gdbfileio_system( const char *command,
527 int *sig );
528 err = cyg_hal_gdbfileio_system((const char *)arg1, (int *)sig);
529 break;
530 }
531 case SYS_gettimeofday:
532 {
533 __externC int cyg_hal_gdbfileio_gettimeofday( void *tv, void *tz,
534 int *sig );
535 err = cyg_hal_gdbfileio_gettimeofday((void *)arg1, (void *)arg2,
536 (int *)sig);
537 break;
538 }
539 #else
297 case SYS_read: 540 case SYS_read:
298 err = sys_read((int)arg1, (char *)arg2, (int)arg3); 541 err = sys_read((int)arg1, (char *)arg2, (int)arg3);
299 break; 542 break;
300
301 case SYS_write: 543 case SYS_write:
302 err = sys_write((int)arg1, (char *)arg2, (int)arg3); 544 err = sys_write((int)arg1, (char *)arg2, (int)arg3);
303 break; 545 break;
304
305 case SYS_open: 546 case SYS_open:
306 err = sys_open((const char *)arg1, (int)arg2, (int)arg3); 547 err = sys_open((const char *)arg1, (int)arg2, (int)arg3);
307 break; 548 break;
308
309 case SYS_close: 549 case SYS_close:
310 err = sys_close((int)arg1); 550 err = sys_close((int)arg1);
311 break; 551 break;
312
313 case SYS_lseek: 552 case SYS_lseek:
314 err = sys_lseek((int)arg1, (int)arg2, (int)arg3); 553 err = sys_lseek((int)arg1, (int)arg2, (int)arg3);
315 break; 554 break;
555 case SYS_rename:
556 err = -NEWLIB_ENOSYS;
557 break;
558 case SYS_unlink:
559 err = -NEWLIB_ENOSYS;
560 break;
561 case SYS_isatty:
562 err = 1;
563 break;
564 case SYS_system:
565 err = -1;
566 break;
567 case SYS_gettimeofday:
568 err = 0;
569 break;
570 case SYS_stat:
571 err = -NEWLIB_ENOSYS;
572 break;
573 case SYS_fstat:
574 {
575 struct newlib_stat *st = (struct newlib_stat *)arg2;
576 st->st_mode = NEWLIB_S_IFCHR;
577 st->st_blksize = 4096;
578 err = 0;
579 break;
580 }
581 #endif // !CYGPKG_HAL_GDB_FILEIO
316 582
317 case SYS_utime: 583 case SYS_utime:
318 // FIXME. Some libglosses depend on this behavior. 584 // FIXME. Some libglosses depend on this behavior.
319 err = sys_times((unsigned long *)arg1); 585 err = sys_times((unsigned long *)arg1);
320 break; 586 break;
326 case SYS_meminfo: 592 case SYS_meminfo:
327 err = 1; 593 err = 1;
328 *(unsigned long *)arg1 = (unsigned long)(ram_end-ram_start); 594 *(unsigned long *)arg1 = (unsigned long)(ram_end-ram_start);
329 *(unsigned long *)arg2 = (unsigned long)ram_end; 595 *(unsigned long *)arg2 = (unsigned long)ram_end;
330 break; 596 break;
331 597 #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
598 case SYS_timer_call_back:
599 sys_profile_call_back( (char *)arg1, (char **)arg2 );
600 break;
601
602 case SYS_timer_frequency:
603 sys_profile_frequency( (int)arg1, (unsigned int *)arg2 );
604 break;
605
606 case SYS_timer_reset:
607 sys_profile_reset();
608 break;
609
610 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
332 case __GET_SHARED: 611 case __GET_SHARED:
333 *(__shared_t **)arg1 = &__shared_data; 612 *(__shared_t **)arg1 = &__shared_data;
334 break; 613 break;
335 614
336 default: 615 default: