Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 266 → Rev 268

/SPARTAN/trunk/arch/amd64/include/boot/boot.h
0,0 → 1,38
/*
* Copyright (C) 2005 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 __amd64_BOOT_H__
#define __amd64_BOOT_H__
 
#define BOOTSTRAP_OFFSET 0x8000
#define BOOT_OFFSET 0x0
 
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
#define MULTIBOOT_HEADER_FLAGS 0x00010003
 
#endif
/SPARTAN/trunk/arch/amd64/include/asm.h
165,6 → 165,24
static inline __u64 read_cr3(void) { __u64 v; __asm__ volatile ("movq %%cr3,%0" : "=r" (v)); return v; }
 
 
/** Enable local APIC
*
* Enable local APIC in MSR.
*/
static inline void enable_l_apic_in_msr()
{
__asm__ volatile (
"movl $0x1b, %%ecx;"
"rdmsr;"
"orl $(1<<11),%%eax;"
"orl $(0xfee00000),%%eax;"
"wrmsr;"
:
:
:"%eax","%ecx","%edx"
);
}
 
extern size_t interrupt_handler_size;
extern void interrupt_handlers(void);
 
/SPARTAN/trunk/arch/amd64/Makefile.inc
5,9 → 5,10
CC=$(AMD64_CC_DIR)/$(AMD64_TARGET)-gcc
AS=$(AMD64_BINUTILS_DIR)/$(AMD64_TARGET)-as
LD=$(AMD64_BINUTILS_DIR)/$(AMD64_TARGET)-ld
OBJCOPY=$(AMD64_BINUTILS_DIR)/$(AMD64_TARGET)-objcopy
BFD_NAME=elf64-x86-64
BFD_ARCH=i386:x86-64
 
 
 
DEFS=-DARCH=$(ARCH)
 
ifdef SMP
46,4 → 47,13
arch/mm/memory_init.c \
arch/cpu/cpu.c \
arch/proc/scheduler.c \
arch/userspace.c
arch/userspace.c \
arch/acpi/acpi.c \
arch/acpi/madt.c
 
ifdef SMP
arch_sources += arch/smp/apic.c \
arch/smp/ipi.c \
arch/smp/mps.c \
arch/smp/smp.c
endif
/SPARTAN/trunk/arch/amd64/src/dummy.s
28,5 → 28,7
 
.text
 
0:
.global ap_boot
ap_boot:
ret
/SPARTAN/trunk/arch/amd64/src/interrupt.c
36,7 → 36,25
#include <arch/asm.h>
#include <mm/tlb.h>
#include <arch.h>
#include <symtab.h>
 
#define PRINT_INFO_ERRCODE(x) { \
char *symbol = get_symtab_entry(stack[1]); \
if (!symbol) \
symbol = ""; \
printf("----------------EXCEPTION OCCURED----------------\n"); \
printf("%%rip: %Q (%s)\n",x[1],symbol); \
printf("ERROR_WORD=%Q\n", x[0]); \
printf("%%rcs=%Q,flags=%Q\n", x[2], x[3]); \
printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",x[-1],x[-2],x[-3]); \
printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",x[-4],x[-5],x[-6]); \
printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",x[-7],x[-8],x[-9]); \
printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",x[-10],x[-11],x[-12]); \
printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",x[-13],x[-14],x); \
printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]); \
printf(" %Q, %Q, %Q\n", x[8], x[9], x[10]); \
}
 
/*
* Interrupt and exception dispatching.
*/
72,6 → 90,7
 
void null_interrupt(__u8 n, __native stack[])
{
printf("----------------EXCEPTION OCCURED----------------\n");
printf("int %d: null_interrupt\n", n);
printf("stack: %L, %L, %L, %L\n", stack[0], stack[1], stack[2], stack[3]);
panic("unserviced interrupt\n");
79,17 → 98,13
 
void gp_fault(__u8 n, __native stack[])
{
printf("ERROR_WORD=%X, %%eip=%X, %%cs=%X, flags=%X\n", stack[0], stack[1], stack[2], stack[3]);
printf("%%eax=%L, %%ebx=%L, %%ecx=%L, %%edx=%L,\n%%edi=%L, %%esi=%L, %%ebp=%L, %%esp=%L\n", stack[-2], stack[-5], stack[-3], stack[-4], stack[-9], stack[-8], stack[-1], stack);
printf("stack: %X, %X, %X, %X\n", stack[4], stack[5], stack[6], stack[7]);
PRINT_INFO_ERRCODE(stack);
panic("general protection fault\n");
}
 
void ss_fault(__u8 n, __native stack[])
{
printf("ERROR_WORD=%X, %%eip=%X, %%cs=%X, flags=%X\n", stack[0], stack[1], stack[2], stack[3]);
printf("%%eax=%L, %%ebx=%L, %%ecx=%L, %%edx=%L,\n%%edi=%L, %%esi=%L, %%ebp=%L, %%esp=%L\n", stack[-2], stack[-5], stack[-3], stack[-4], stack[-9], stack[-8], stack[-1], stack);
printf("stack: %X, %X, %X, %X\n", stack[4], stack[5], stack[6], stack[7]);
PRINT_INFO_ERRCODE(stack);
panic("stack fault\n");
}
 
110,12 → 125,8
 
void page_fault(__u8 n, __native stack[])
{
printf("page fault address: %Q\n", read_cr2());
printf("ERROR_WORD=%Q, %%rip=%Q, %%rcs=%Q, flags=%Q\n", stack[0], stack[1], stack[2], stack[3]);
printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q, %%rdx=%Q,\n%%rsi=%Q, %%rdi=%Q\n",
stack[-1], stack[-2], stack[-3], stack[-4], stack[-5], stack[-6]);
 
printf("stack: %X, %X, %X, %X\n", stack[5], stack[6], stack[7], stack[8]);
PRINT_INFO_ERRCODE(stack);
printf("Page fault address: %Q\n", read_cr2());
panic("page fault\n");
}
 
/SPARTAN/trunk/arch/amd64/_link.ld
31,7 → 31,6
kdata_start = .;
*(.data); /* initialized data */
*(.rodata*); /* string literals */
*(COMMON); /* global variables */
hardcoded_load_address = .;
QUAD(0xffffffff80008000);
hardcoded_ktext_size = .;
38,9 → 37,17
QUAD(ktext_end - ktext_start + (unmapped_ktext_end - unmapped_ktext_start));
hardcoded_kdata_size = .;
QUAD(kdata_end - kdata_start + (unmapped_kdata_end - unmapped_kdata_start));
*(COMMON); /* global variables */
 
 
 
*(.eh_frame);
*(.bss); /* uninitialized static variables */
*(K_DATA_END);
 
symbol_table = .;
*(symtab.*); /* Symbol table, must be LAST symbol!*/
 
kdata_end = .;
}
_map_address = 0xffffffff80000000;