Mercurial > ecos
annotate packages/hal/i386/linux/current/src/hal_diag.c @ 44:41bd4f3a90de ecos-sw-1999-10-08
Merge from eCos master repository on 1999-10-08-07:47:04-BST
| author | jlarmour |
|---|---|
| date | Fri, 08 Oct 1999 13:16:25 +0000 |
| parents | 443894e2e912 |
| children | 7a6ac9edc838 |
| rev | line source |
|---|---|
| 2 | 1 //============================================================================= |
| 2 // | |
| 3 // hal_diag.c | |
| 4 // | |
| 5 // HAL diagnostic output code | |
| 6 // | |
| 7 //============================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // October 31, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. | |
| 26 // ------------------------------------------- | |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //============================================================================= | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): proven | |
| 33 // Contributors:proven | |
| 34 // Date: 1998-10-05 | |
| 35 // Purpose: HAL diagnostic output | |
| 36 // Description: Implementations of HAL diagnostic output support. | |
| 37 // | |
| 38 //####DESCRIPTIONEND#### | |
| 39 // | |
| 40 //============================================================================= | |
| 41 | |
| 42 #include <pkgconf/hal.h> | |
| 43 | |
| 44 #include <cyg/infra/cyg_type.h> // base types | |
| 45 | |
| 46 #include <cyg/hal/hal_diag.h> | |
| 47 | |
| 48 //----------------------------------------------------------------------------- | |
| 49 | |
| 50 void hal_diag_init( void ) | |
| 51 { | |
| 52 } | |
| 53 | |
| 54 externC unsigned long cyg_hal_sys_write(int, const void*, long); | |
| 55 externC unsigned long cyg_hal_sys_read(int, void*, long); | |
| 56 | |
| 57 // Write characters to a buffer which is flushed at newline/overflow to | |
| 58 // improve performance. | |
| 59 void hal_diag_write_char(char __c) | |
| 60 { | |
| 61 static cyg_int32 __index = 0; | |
| 62 static cyg_uint8 __buffer[128]; | |
| 63 | |
| 64 __buffer[__index++] = __c; | |
| 65 | |
| 66 if ('\n' == __c || 128 == __index) { | |
| 67 cyg_hal_sys_write(1, &__buffer[0], __index); | |
| 68 __index = 0; | |
| 69 } | |
| 70 } | |
| 71 | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
72 // Hmm... we need the definition of EINTR, which normally lives in |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
73 // <asm/errno.h> on linux. But we can't get at that here, so we just |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
74 // hard-code it. The burden of binary compatibility means x86 linux will |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
75 // never change it. |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
76 #define x86_linux_EINTR 4 |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
77 |
| 2 | 78 void hal_diag_read_char(char *c) |
| 79 { | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
80 int rc; |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
81 |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
82 // The read syscall will get woken up by the itimer alarm, but we don't |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
83 // want to stop reading if that's the case |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
84 do { |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
85 rc = cyg_hal_sys_read(0, c, 1); |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
86 } while (-x86_linux_EINTR == rc); |
| 2 | 87 } |
| 88 | |
| 89 //----------------------------------------------------------------------------- | |
| 90 // End of hal_diag.c |
