Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev HEAD → Rev 2606

/trunk/uspace/lib/libc/arch/amd64/src/fibril.S
31,7 → 31,7
.global context_save
.global context_restore
 
#include <kernel/arch/context_offset.h>
#include <libarch/context_offset.h>
 
## Save current CPU context
#
40,10 → 40,17
#
context_save:
movq (%rsp), %rdx # the caller's return %eip
# In %edi is passed 1st argument
CONTEXT_SAVE_ARCH_CORE %rdi %rdx
movq %rdx, OFFSET_PC(%rdi)
movq %rsp, OFFSET_SP(%rdi)
movq %rbx, OFFSET_RBX(%rdi)
movq %rbp, OFFSET_RBP(%rdi)
movq %r12, OFFSET_R12(%rdi)
movq %r13, OFFSET_R13(%rdi)
movq %r14, OFFSET_R14(%rdi)
movq %r15, OFFSET_R15(%rdi)
 
# Save TLS
movq %fs:0, %rax
movq %rax, OFFSET_TLS(%rdi)
59,9 → 66,16
# pointed by the 1st argument. Returns 0 in EAX.
#
context_restore:
movq OFFSET_R15(%rdi), %r15
movq OFFSET_R14(%rdi), %r14
movq OFFSET_R13(%rdi), %r13
movq OFFSET_R12(%rdi), %r12
movq OFFSET_RBP(%rdi), %rbp
movq OFFSET_RBX(%rdi), %rbx
CONTEXT_RESTORE_ARCH_CORE %rdi %rdx
movq OFFSET_SP(%rdi), %rsp # ctx->sp -> %rsp
movq OFFSET_PC(%rdi), %rdx
movq %rdx,(%rsp)
 
# Set thread local storage
/trunk/uspace/lib/libc/arch/amd64/src/entry.s
31,14 → 31,18
.org 0
 
.globl __entry
.globl __entry_driver
 
## User-space task entry point
#
# %rdi contains the PCB pointer
#
__entry:
# %rdi was deliberately chosen as the first argument is also in %rdi
# Pass PCB pointer to __main (no operation)
call __main
call __io_init
call main
call __exit
 
__entry_driver:
call __main
call main
call __exit
/trunk/uspace/lib/libc/arch/amd64/include/types.h
47,9 → 47,6
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
 
typedef int64_t ssize_t;
typedef uint64_t size_t;
 
typedef uint64_t uintptr_t;
 
#endif
/trunk/uspace/lib/libc/arch/amd64/include/atomic.h
38,11 → 38,11
#define LIBC_amd64_ATOMIC_H_
 
static inline void atomic_inc(atomic_t *val) {
asm volatile ("lock incq %0\n" : "+m" (val->count));
asm volatile ("lock incq %0\n" : "=m" (val->count));
}
 
static inline void atomic_dec(atomic_t *val) {
asm volatile ("lock decq %0\n" : "+m" (val->count));
asm volatile ("lock decq %0\n" : "=m" (val->count));
}
 
static inline long atomic_postinc(atomic_t *val)
52,7 → 52,7
asm volatile (
"movq $1, %0\n"
"lock xaddq %0, %1\n"
: "=r" (r), "+m" (val->count)
: "=r" (r), "=m" (val->count)
);
 
return r;
65,14 → 65,14
asm volatile (
"movq $-1, %0\n"
"lock xaddq %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
 
/trunk/uspace/lib/libc/arch/amd64/include/syscall.h
36,8 → 36,6
#ifndef LIBC_amd64_SYSCALL_H_
#define LIBC_amd64_SYSCALL_H_
 
#define LIBARCH_SYSCALL_GENERIC
 
#include <syscall.h>
 
#endif
/trunk/uspace/lib/libc/arch/amd64/include/endian.h
0,0 → 1,49
/*
* Copyright (c) 2006 Josef Cejka
* 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 libcamd64
* @{
*/
/** @file
*/
 
#ifndef LIBC_amd64_ENDIAN_H_
#define LIBC_amd64_ENDIAN_H_
 
#ifndef LIBC_ENDIAN_H_
# error "Never use <libarch/endian.h> directly - use <endian.h> instead."
#endif
 
#define __BYTE_ORDER __LITTLE_ENDIAN
 
#endif
 
/** @}
*/
/trunk/uspace/lib/libc/arch/amd64/include/config.h
36,7 → 36,8
#define LIBC_amd64_CONFIG_H_
 
#define PAGE_WIDTH 12
#define PAGE_SIZE (1 << PAGE_WIDTH)
#define PAGE_SIZE (1<<PAGE_WIDTH)
#define PAGE_COLOR_BITS 0 /* dummy */
 
#endif
 
/trunk/uspace/lib/libc/arch/amd64/include/context_offset.h
0,0 → 1,12
/* This file is automatically generated by gencontext.c. */
#define OFFSET_SP 0x0
#define OFFSET_PC 0x8
#define OFFSET_RBX 0x10
#define OFFSET_RBP 0x18
#define OFFSET_R12 0x20
#define OFFSET_R13 0x28
#define OFFSET_R14 0x30
#define OFFSET_R15 0x38
#define OFFSET_TLS 0x40
/trunk/uspace/lib/libc/arch/amd64/Makefile.inc
30,15 → 30,13
#
 
TARGET = amd64-linux-gnu
TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64/bin
TOOLCHAIN_DIR = /usr/local/amd64/bin
 
ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
arch/$(UARCH)/src/fibril.S \
arch/$(UARCH)/src/tls.c
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
arch/$(ARCH)/src/fibril.S \
arch/$(ARCH)/src/tls.c
 
LFLAGS += -N
 
ENDIANESS = LE
 
BFD_NAME = elf64-x86-64
BFD_ARCH = i386:x86-64
/trunk/uspace/lib/libc/arch/amd64/_link.ld.in
1,4 → 1,4
STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
STARTUP(LIBC_PREFIX/arch/ARCH/src/entry.o)
ENTRY(__entry)
 
PHDRS {
7,9 → 7,9
}
 
SECTIONS {
. = 0x1000 + SIZEOF_HEADERS;
. = 0x1000;
.init : {
.init ALIGN(0x1000) : SUBALIGN(0x1000) {
*(.init);
} :text
.text : {
16,10 → 16,8
*(.text);
*(.rodata*);
} :text
 
. = . + 0x1000;
 
.data : {
.data ALIGN(0x1000) : SUBALIGN(0x1000) {
*(.data);
} :data
.tdata : {
26,11 → 24,13
_tdata_start = .;
*(.tdata);
_tdata_end = .;
} :data
.tbss : {
_tbss_start = .;
*(.tbss);
_tbss_end = .;
} :data
_tls_alignment = ALIGNOF(.tdata);
_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
.bss : {
*(COMMON);
*(.bss);