/branches/network/uspace/lib/libc/arch/ia32/Makefile.inc |
---|
29,8 → 29,12 |
## Toolchain configuration |
# |
ifndef CROSS_PREFIX |
CROSS_PREFIX = /usr/local |
endif |
TARGET = i686-pc-linux-gnu |
TOOLCHAIN_DIR = /usr/local/i686/bin |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/i686/bin |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \ |
arch/$(ARCH)/src/fibril.S \ |
/branches/network/uspace/lib/libc/arch/ia32/include/setjmp.h |
---|
File deleted |
/branches/network/uspace/lib/libc/arch/ia32/include/endian.h |
---|
File deleted |
/branches/network/uspace/lib/libc/arch/ia32/include/config.h |
---|
36,8 → 36,7 |
#define LIBC_ia32_CONFIG_H_ |
#define PAGE_WIDTH 12 |
#define PAGE_SIZE (1<<PAGE_WIDTH) |
#define PAGE_COLOR_BITS 0 /* dummy */ |
#define PAGE_SIZE (1 << PAGE_WIDTH) |
#endif |
/branches/network/uspace/lib/libc/arch/ia32/include/atomic.h |
---|
36,11 → 36,11 |
#define LIBC_ia32_ATOMIC_H_ |
static inline void atomic_inc(atomic_t *val) { |
asm volatile ("lock incl %0\n" : "=m" (val->count)); |
asm volatile ("lock incl %0\n" : "+m" (val->count)); |
} |
static inline void atomic_dec(atomic_t *val) { |
asm volatile ("lock decl %0\n" : "=m" (val->count)); |
asm volatile ("lock decl %0\n" : "+m" (val->count)); |
} |
static inline long atomic_postinc(atomic_t *val) |
50,7 → 50,7 |
asm volatile ( |
"movl $1, %0\n" |
"lock xaddl %0, %1\n" |
: "=r" (r), "=m" (val->count) |
: "=r" (r), "+m" (val->count) |
); |
return r; |
63,14 → 63,14 |
asm volatile ( |
"movl $-1, %0\n" |
"lock xaddl %0, %1\n" |
: "=r" (r), "=m" (val->count) |
: "=r" (r), "+m" (val->count) |
); |
return r; |
} |
#define atomic_preinc(val) (atomic_postinc(val)+1) |
#define atomic_predec(val) (atomic_postdec(val)-1) |
#define atomic_preinc(val) (atomic_postinc(val) + 1) |
#define atomic_predec(val) (atomic_postdec(val) - 1) |
#endif |
/branches/network/uspace/lib/libc/arch/ia32/include/byteorder.h |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 2005 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcia32 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_ia32_BYTEORDER_H_ |
#define LIBC_ia32_BYTEORDER_H_ |
/* IA-32 is little-endian */ |
#define ARCH_IS_LITTLE_ENDIAN |
#endif |
/** @} |
*/ |
/branches/network/uspace/lib/libc/arch/ia32/src/entry.s |
---|
31,10 → 31,10 |
.org 0 |
.globl __entry |
.globl __entry_driver |
## User-space task entry point |
# |
# %ebx contains the PCB pointer |
# |
__entry: |
mov %ss, %ax |
42,19 → 42,9 |
mov %ax, %es |
mov %ax, %fs |
# Do not set %gs, it contains descriptor that can see TLS |
# Pass the PCB pointer to __main as the first argument |
pushl %ebx |
call __main |
call __io_init |
call main |
call __exit |
__entry_driver: |
mov %ss, %ax |
mov %ax, %ds |
mov %ax, %es |
mov %ax, %fs |
# Do not set %gs, it contains descriptor that can see TLS |
call __main |
call main |
call __exit |
/branches/network/uspace/lib/libc/arch/ia32/src/syscall.S |
---|
53,4 → 53,3 |
popl %esi |
popl %ebx |
ret |
/branches/network/uspace/lib/libc/arch/ia32/src/setjmp.S |
---|
26,6 → 26,8 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
#include <kernel/arch/context_offset.h> |
.text |
.global setjmp |
.global longjmp |
32,18 → 34,13 |
.type setjmp,@function |
setjmp: |
movl 0(%esp), %ecx # save current pc |
leal 4(%esp), %edx # save stack pointer |
movl (%edx), %eax # get jmp_buf pointer |
movl 0(%esp),%eax # save pc value into eax |
movl 4(%esp),%edx # address of the jmp_buf structure to save context to |
# Save registers |
movl %ebx, 0(%eax) |
movl %esi, 4(%eax) |
movl %edi, 8(%eax) |
movl %ebp, 12(%eax) |
movl %edx, 16(%eax) |
# save registers to the jmp_buf structure |
CONTEXT_SAVE_ARCH_CORE %edx %eax |
movl %ecx, 20(%eax) # save pc |
xorl %eax,%eax # set_jmp returns 0 |
ret |
.type longjmp,@function |
52,12 → 49,9 |
movl 4(%esp), %ecx # put address of jmp_buf into ecx |
movl 8(%esp), %eax # put return value into eax |
# restore all registers |
movl 0(%ecx), %ebx |
movl 4(%ecx), %esi |
movl 8(%ecx), %edi |
movl 12(%ecx), %ebp |
movl 16(%ecx), %esp |
movl 20(%ecx), %edx # saved return address |
jmp *%edx |
# restore registers from the jmp_buf structure |
CONTEXT_RESTORE_ARCH_CORE %ecx %edx |
movl %edx,0(%esp) # put saved pc on stack |
ret |
/branches/network/uspace/lib/libc/arch/ia32/src/fibril.S |
---|
26,6 → 26,8 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
#include <kernel/arch/context_offset.h> |
.text |
.global context_save |
41,16 → 43,12 |
movl 0(%esp),%eax # the caller's return %eip |
movl 4(%esp),%edx # address of the context variable to save context to |
movl %esp,0(%edx) # %esp -> ctx->sp |
movl %eax,4(%edx) # %eip -> ctx->pc |
movl %ebx,8(%edx) # %ebx -> ctx->ebx |
movl %esi,12(%edx) # %esi -> ctx->esi |
movl %edi,16(%edx) # %edi -> ctx->edi |
movl %ebp,20(%edx) # %ebp -> ctx->ebp |
# save registers to the context structure |
CONTEXT_SAVE_ARCH_CORE %edx %eax |
# Save TLS |
movl %gs:0, %eax |
movl %eax, 24(%edx) # tls -> ctx->tls |
movl %eax, OFFSET_TLS(%edx) # tls -> ctx->tls |
xorl %eax,%eax # context_save returns 1 |
incl %eax |
64,18 → 62,15 |
# |
context_restore: |
movl 4(%esp),%eax # address of the context variable to restore context from |
movl 0(%eax),%esp # ctx->sp -> %esp |
movl 4(%eax),%edx # ctx->pc -> %edx |
movl 8(%eax),%ebx # ctx->ebx -> %ebx |
movl 12(%eax),%esi # ctx->esi -> %esi |
movl 16(%eax),%edi # ctx->edi -> %edi |
movl 20(%eax),%ebp # ctx->ebp -> %ebp |
# restore registers from the context structure |
CONTEXT_RESTORE_ARCH_CORE %eax %edx |
movl %edx,0(%esp) # ctx->pc -> saver's return %eip |
# Set thread local storage |
pushl %edx |
movl 24(%eax), %edx # Set arg1 to TLS addr |
movl OFFSET_TLS(%eax), %edx # Set arg1 to TLS addr |
movl $1, %eax # Syscall SYS_TLS_SET |
int $0x30 |
popl %edx |
/branches/network/uspace/lib/libc/arch/ia32/_link.ld.in |
---|
7,9 → 7,9 |
} |
SECTIONS { |
. = 0x1000; |
. = 0x1000 + SIZEOF_HEADERS; |
.init ALIGN(0x1000) : SUBALIGN(0x1000) { |
.init : { |
*(.init); |
} :text |
.text : { |
16,8 → 16,10 |
*(.text); |
*(.rodata*); |
} :text |
.data ALIGN(0x1000) : SUBALIGN(0x1000) { |
. = . + 0x1000; |
.data : { |
*(.data); |
} :data |
.tdata : { |