Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 241 → Rev 242

/SPARTAN/trunk/arch/amd64/include/cpuid.h
0,0 → 1,60
/*
* Copyright (C) 2001-2004 Ondrej Palkovsky
* 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.
*/
 
#ifndef __CPUID_H__
#define __CPUID_H__
 
#include <arch/types.h>
 
struct cpu_info {
__u32 cpuid_eax;
__u32 cpuid_ebx;
__u32 cpuid_ecx;
__u32 cpuid_edx;
} __attribute__ ((packed));
 
extern int has_cpuid(void);
 
static inline void cpuid(__u32 cmd, cpu_info_t *info)
{
__asm__ (
"movl %1, %eax"
"cpuid"
"movl %eax, 0(%0)"
"movl %ebx, 4(%0)"
"movl %ecx, 8(%0)"
"movl %edx, 12(%0)"
: "=m"(info)
: "r"(cmd)
: "%eax","%ebx","%ecx","%edx"
);
}
 
extern __u64 rdtsc(void);
 
#endif
/SPARTAN/trunk/arch/amd64/Makefile.inc
32,4 → 32,5
arch/mm/page.c \
arch/mm/tlb.c \
arch/asm_utils.S \
arch/fmath.c
arch/fmath.c \
arch/mm/memory_init.c
/SPARTAN/trunk/arch/amd64/src/asm_utils.S
44,6 → 44,39
movq $halt, (%rsp)
jmp printf
 
.global has_cpuid
.global rdtsc
 
 
## Determine CPUID support
#
# Return 0 in EAX if CPUID is not support, 1 if supported.
#
has_cpuid:
pushq %rbx
pushfq # store flags
popq %rax # read flags
movq %rax,%rbx # copy flags
btcl $21,%ebx # swap the ID bit
pushq %rbx
popfq # propagate the change into flags
pushfq
popq %rbx # read flags
andl $(1<<21),%eax # interested only in ID bit
andl $(1<<21),%ebx
xorl %ebx,%eax # 0 if not supported, 1 if supported
popq %rbx
ret
 
 
rdtsc:
xorq %rax,%rax
rdtsc
ret
 
# Push all general purpose registers on stack except %rbp, %rsp
.macro push_all_gpr
pushq %rax
/SPARTAN/trunk/arch/amd64/src/boot/memmap.S
File deleted
/SPARTAN/trunk/arch/amd64/src/boot/boot.S
33,7 → 33,7
#include <arch/pm.h>
 
#define START_STACK 0x7c00
#define START_STACK_64 $0xffffffff80007c00
#define START_STACK_64 0xffffffff80007c00
#
# This is where we require any SPARTAN-kernel-compatible boot loader
51,9 → 51,9
xorw %ax,%ax
movw %ax,%ds
movw %ax,%ss # initialize stack segment register
movl START_STACK,%esp # initialize stack pointer
movl $(START_STACK),%esp # initialize stack pointer
# call memmap_arch_init
call memmap_arch_init
movl $0x80000000, %eax
cpuid
116,7 → 116,7
 
.code64
start64:
movq START_STACK_64, %rsp
movq $(START_STACK_64), %rsp
call main_bsp # never returns
1:
/SPARTAN/trunk/arch/amd64/src/amd64.c
38,6 → 38,7
#include <arch/i8259.h>
 
#include <arch/bios/bios.h>
#include <arch/mm/memory_init.h>
 
void arch_pre_mm_init(void)
{
64,3 → 65,21
ega_init(); /* video */
}
}
 
void arch_late_init(void)
{
if (config.cpu_active == 1) {
memory_print_map();
#ifdef __SMP__
acpi_init();
#endif /* __SMP__ */
}
}
 
void calibrate_delay_loop(void)
{
return;
i8254_calibrate_delay_loop();
i8254_normal_operation();
}
/SPARTAN/trunk/arch/amd64/src/dummy.s
34,33 → 34,18
.global cpu_arch_init
.global cpu_sleep
.global cpu_print_report
.global arch_late_init
.global calibrate_delay_loop
.global dummy
.global rdtsc
.global reset_TS_flag
.global fpu_init
.global memory_print_map
.global get_memory_size
 
get_memory_size:
movq $4*1024*1024, %rax
ret
 
rdtsc:
before_thread_runs_arch:
userspace:
calibrate_delay_loop:
cpu_identify:
cpu_arch_init:
cpu_sleep:
cpu_print_report:
arch_late_init:
calibrate_delay_loop:
reset_TS_flag:
fpu_init:
memory_print_map:
dummy:
0: