-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from Mellvik/misc
[system] Major synchronization with ELKS updates in header file etc.
- Loading branch information
Showing
60 changed files
with
718 additions
and
749 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
INCLUDES=-I$(TOPDIR)/include -I$(TOPDIR)/libc/include -I$(TOPDIR)/tlvc/include | ||
DEFINES=-D__LIBC__ | ||
|
||
INCS=$(INCLUDES) | ||
SDEFS=$(DEFINES) | ||
CDEFS=$(DEFINES) | ||
|
||
ARCH=-ffreestanding -fno-inline -melks -mtune=i8086 | ||
ifeq "" "$(filter -mcmodel=%,$(MULTILIB))" | ||
ARCH+=-mcmodel=small -mno-segment-relocation-stuff | ||
endif | ||
|
||
CC=ia16-elf-gcc | ||
AS=ia16-elf-as | ||
AR=ia16-elf-ar | ||
LD=ia16-elf-ld | ||
|
||
CFLAGS=$(ARCH) $(INCLUDES) $(CDEFS) -Wall -Os $(MULTILIB) | ||
ASFLAGS=--32-segelf -mtune=i8086 | ||
LDFLAGS=-mtune=i8086 | ||
# This is used in subdirectories to quickly create a library archive without | ||
# a symbol index | ||
ARFLAGS_SUB=cqS | ||
|
||
ifdef MULTISUBDIR | ||
LIBC=$(TOPDIR)/libc/build-ml/$(MULTISUBDIR)/libc.a | ||
CRT0=$(TOPDIR)/libc/build-ml/$(MULTISUBDIR)/crt0.o | ||
endif | ||
LIB_CPU=i86 | ||
LIB_OS=ELKS | ||
|
||
.S.o: | ||
$(CC) -E $(MULTILIB) $(INCS) $(SDEFS) -MD -o $*.tmp $< | ||
$(AS) $(ASFLAGS) -o $*.o $*.tmp | ||
rm -f $*.tmp | ||
|
||
ifdef MULTISUBDIR | ||
$(TOPDIR)/libc/build-ml/$(MULTISUBDIR)/%.o: %.S | ||
$(CC) -E $(MULTILIB) $(INCS) $(SDEFS) -MD -o $@.tmp $< | ||
$(AS) $(ASFLAGS) -o $@ $@.tmp | ||
rm -f $@.tmp | ||
endif | ||
|
||
.s.o: | ||
$(AS) $(ASFLAGS) -o $*.o $< | ||
|
||
.c.o: | ||
$(CC) $(CFLAGS) -c -MD -o $*.o $< | ||
|
||
-include *.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,64 @@ | ||
#include <errno.h> | ||
#include <signal.h> | ||
|
||
typedef sighandler_t Sig; | ||
|
||
extern int _signal (int, __kern_sighandler_t); | ||
#if defined __TINY__ || defined __SMALL__ || defined __COMPACT__ | ||
/* | ||
* If we are building libc for a near-code memory model (tiny, small, or | ||
* compact), then we will arrange for _syscall_signal( ) to be within the | ||
* same near code section as this module. | ||
*/ | ||
extern __attribute__((near_section, stdcall)) | ||
#else | ||
extern __attribute__((stdcall)) | ||
#endif | ||
__far void _syscall_signal (int); | ||
|
||
Sig _sigtable[_NSIG]; | ||
|
||
/* | ||
* Signal handler. | ||
* Signal handling routines. | ||
* | ||
*/ | ||
|
||
/* | ||
* KERNEL INTERFACE: | ||
* It is assumed the kernel will never give us a signal we haven't | ||
* _explicitly_ asked for! | ||
* | ||
* The Kernel need only save space for _one_ function pointer | ||
* (to _syscall_signal) and must deal with SIG_DFL and SIG_IGN | ||
* (to _signal_cbhandler) and must deal with SIG_DFL and SIG_IGN | ||
* in kernel space. | ||
* | ||
* When a signal is required the kernel must set all the registers as if | ||
* returning from a interrupt normally then push the number of the signal | ||
* to be generated, push the current pc value, then set the pc to the | ||
* address of the '_syscall_signal' function. | ||
* When a signal is required to be sent the kernel will setup a specialized | ||
* user stack frame as described in elks/arch/i86/kernel/process.c in the | ||
* arch_setup_sighandler_stack() function. This will look like returning | ||
* from a interrupt normally except the C library kernel signal callback | ||
* routine will be called as _signal_cbhandler(sig), after which a normal | ||
* interrupt return will be executed. | ||
* | ||
* Not all C library routines are safe to call from a C signal handler, | ||
* as the mechanism can be reentrant. | ||
*/ | ||
|
||
sighandler_t _sigtable[_NSIG]; | ||
|
||
#ifdef __GNUC__ | ||
#if defined __TINY__ || defined __SMALL__ || defined __COMPACT__ | ||
/* | ||
* If we are building libc for a near-code memory model (tiny, small, or | ||
* compact), then we will arrange for _signal_cbhandler( ) to be within the | ||
* same near code section as this module. | ||
*/ | ||
extern __attribute__((near_section, __stdcall__)) __far void _signal_cbhandler(int); | ||
#else | ||
extern stdcall __far void _signal_cbhandler(int); | ||
#endif | ||
#endif | ||
|
||
Sig signal(int number, Sig pointer) | ||
#ifdef __WATCOMC__ | ||
extern void stdcall __far _signal_cbhandler(int); /* kernel callback in ASM */ | ||
void __far _signal_wchandler(int sig) /* callback handler calls this */ | ||
{ | ||
Sig old_sig; | ||
int rv; | ||
if( number < 1 || number > _NSIG ) { errno=EINVAL; return SIG_ERR; } | ||
_sigtable[sig-1](sig); | ||
} | ||
#endif | ||
|
||
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" | ||
if( pointer == SIG_DFL || pointer == SIG_IGN ) | ||
rv = _signal(number, (__kern_sighandler_t) (long) (int) pointer); | ||
else | ||
rv = _signal(number, (__kern_sighandler_t) _syscall_signal); | ||
sighandler_t signal(int number, sighandler_t pointer) | ||
{ | ||
sighandler_t old_sig; | ||
int rv; | ||
if (number < 1 || number > _NSIG) { errno = EINVAL; return SIG_ERR; } | ||
|
||
if( rv < 0 ) return SIG_ERR; | ||
if (pointer == SIG_DFL || pointer == SIG_IGN) | ||
rv = _signal(number, (__kern_sighandler_t) (unsigned long)pointer); | ||
else | ||
rv = _signal(number, (__kern_sighandler_t) _signal_cbhandler); | ||
if (rv < 0) return SIG_ERR; | ||
|
||
old_sig = _sigtable[number-1]; | ||
_sigtable[number-1] = pointer; | ||
old_sig = _sigtable[number-1]; | ||
_sigtable[number-1] = pointer; | ||
|
||
return old_sig; | ||
return old_sig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.