Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 2612 → Rev 2613

/trunk/kernel/arch/ia32/src/asm.S
28,9 → 28,9
 
## very low and hardware-level functions
 
# Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word
# and 1 means interrupt with error word
#define ERROR_WORD_INTERRUPT_LIST 0x00027D00
# Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error
# word and 1 means interrupt with error word
#define ERROR_WORD_INTERRUPT_LIST 0x00027d00
 
.text
 
74,7 → 74,7
movl MEMCPY_DST(%esp), %edi
movl MEMCPY_SRC(%esp), %esi
rep movsl /* copy as much as possible word by word */
rep movsl /* copy whole words */
 
movl MEMCPY_SIZE(%esp), %ecx
andl $3, %ecx /* size % 4 */
106,7 → 106,8
paging_on:
movl %cr0,%edx
orl $(1<<31),%edx # paging on
andl $~((1<<30)|(1<<29)),%edx # clear Cache Disable and not Write Though
# clear Cache Disable and not Write Though
andl $~((1 << 30) | (1 << 29)), %edx
movl %edx,%cr0
jmp 0f
0:
118,15 → 119,11
# Enable local APIC in MSR.
#
enable_l_apic_in_msr:
push %eax
 
movl $0x1b, %ecx
rdmsr
orl $(1<<11),%eax
orl $(0xfee00000),%eax
wrmsr
 
pop %eax
ret
 
# Clear nested flag
151,17 → 148,25
.macro handler i n
 
.ifeq \i-0x30 # Syscall handler
push %ds
push %es
push %fs
push %gs
pushl %ds
pushl %es
pushl %fs
pushl %gs
 
# Push arguments on stack
push %edi
push %esi
push %edx
push %ecx
push %eax
#
# Push syscall arguments onto the stack
#
# NOTE: The idea behind the order of arguments passed in registers is to
# use all scratch registers first and preserved registers next.
# An optimized libc syscall wrapper can make use of this setup.
#
pushl %eax
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
pushl %ecx
pushl %edx
# we must fill the data segment registers
movw $16,%ax
169,15 → 174,15
movw %ax,%es
sti
call syscall_handler # syscall_handler(ax,cx,dx,si,di)
# syscall_handler(edx, ecx, ebx, esi, edi, ebp, eax)
call syscall_handler
cli
addl $20, %esp # clean-up of parameters
addl $28, %esp # clean-up of parameters
pop %gs
pop %fs
pop %es
pop %ds
popl %gs
popl %fs
popl %es
popl %ds
CLEAR_NT_FLAG
iret
206,22 → 211,22
subl $4, %esp
.endif
push %ds
push %es
push %fs
push %gs
pushl %ds
pushl %es
pushl %fs
pushl %gs
 
#ifdef CONFIG_DEBUG_ALLREGS
push %ebx
push %ebp
push %edi
push %esi
pushl %ebx
pushl %ebp
pushl %edi
pushl %esi
#else
sub $16, %esp
subl $16, %esp
#endif
push %edx
push %ecx
push %eax
pushl %edx
pushl %ecx
pushl %eax
# we must fill the data segment registers
movw $16,%ax
235,22 → 240,22
 
CLEAR_NT_FLAG # Modifies %ecx
pop %eax
pop %ecx
pop %edx
popl %eax
popl %ecx
popl %edx
#ifdef CONFIG_DEBUG_ALLREGS
pop %esi
pop %edi
pop %ebp
pop %ebx
popl %esi
popl %edi
popl %ebp
popl %ebx
#else
add $16, %esp
addl $16, %esp
#endif
pop %gs
pop %fs
pop %es
pop %ds
popl %gs
popl %fs
popl %es
popl %ds
 
addl $4,%esp # Skip error word, no matter whether real or fake.
iret
/trunk/uspace/lib/libc/arch/ia32/Makefile.inc
32,7 → 32,7
TARGET = i686-pc-linux-gnu
TOOLCHAIN_DIR = /usr/local/i686/bin
 
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
arch/$(ARCH)/src/fibril.S \
arch/$(ARCH)/src/tls.c
 
/trunk/uspace/lib/libc/arch/ia32/src/syscall.c
File deleted
/trunk/uspace/lib/libc/arch/ia32/src/fibril.S
74,11 → 74,11
movl %edx,0(%esp) # ctx->pc -> saver's return %eip
 
# Set thread local storage
pushl %edi
movl 24(%eax), %eax # Set arg1 to TLS addr
movl $1, %edi # Syscall 1
pushl %edx
movl 24(%eax), %edx # Set arg1 to TLS addr
movl $1, %eax # Syscall SYS_TLS_SET
int $0x30
popl %edi
popl %edx
xorl %eax,%eax # context_restore returns 0
ret
/trunk/uspace/lib/libc/arch/ia32/src/syscall.S
0,0 → 1,56
#
# Copyright (c) 2007 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.
#
 
.text
 
/** Syscall wrapper.
*
* Mind the order of arguments. First two arguments and the syscall number go to
* scratch registers. An optimized version of this wrapper for fewer arguments
* could benefit from this and not save unused registers on the stack.
*/
.global __syscall
__syscall:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl 20(%esp), %edx # First argument.
movl 24(%esp), %ecx # Second argument.
movl 28(%esp), %ebx # Third argument.
movl 32(%esp), %esi # Fourth argument.
movl 36(%esp), %edi # Fifth argument.
movl 40(%esp), %ebp # Sixth argument.
movl 44(%esp), %eax # Syscall number.
int $0x30
popl %ebp
popl %edi
popl %esi
popl %ebx
ret