/* $Id: entry.S,v 1.2 2005/06/16 13:46:21 cgoh Exp $
 *
 * entry.s: Setup initial kernel-mode stack, call start_kernel()
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) Equator Technologies
 */

#ifndef __KERNEL__
#define __KERNEL__
#endif

#ifndef _LANGUAGE_ASSEMBLY
#define _LANGUAGE_ASSEMBLY
#endif

#include <asm/page.h>
#include <asm/processor.h>

	.text

	.global _stext
	.global kstart
	.global _L2Start
_stext:
kstart:
_L2Start:

/* 
 * setup initial kernel stack 
 *
 * stack is located as part of 8kB init_task_union.  First part is
 * the task_struct, and rest is kernel-mode stack
 */
	.i0 sethi.32 r16 hi(init_task_union),
	.i1 sethi.32 r16 hi(init_task_union);
	.i0 dincr.32 r16 lo(init_task_union),
	.i1 dincr.32 r16 lo(init_task_union);
	.i0 mnop 4;

/* set stack pointers to init task's kernel stack */
	.i0 sethi.32 r17 hi(KERNEL_STACK_SIZE),
	.i1 sethi.32 r17 hi(KERNEL_STACK_SIZE);
	.i0 dincr.32 r17 lo(KERNEL_STACK_SIZE),
	.i1 dincr.32 r17 lo(KERNEL_STACK_SIZE);
	.i0 add.32   r16 r16 r17,
        .i1 add.32   r16 r16 r17;
	.i0 mnop 4;

/* call start_kernel() C code */
	.i0 sethi.32 r63 hi(start_kernel);
	.i0 dincr.32 r63 lo(start_kernel);
	;
	.i0 sethi.32 r17 hi(eti_early_setup);
	.i0 dincr.32 r17 lo(eti_early_setup);
	;
	.i0 bra r17;
	;
	;

	.data

/* create empty space for linux boot command-line */
	.global boot_cmd_line_start
	.global boot_cmd_line_end
boot_cmd_line_start:

	.word 0xdeadbeef  /* This marker tells us we have an empty cmd line */
	.skip 1020, 0
boot_cmd_line_end:

	.align PAGE_SIZE

/* create space for page stuff */
	.global swapper_pg_dir
swapper_pg_dir:
	.skip PAGE_SIZE, 0

	.global empty_bad_page
empty_bad_page:
	.skip PAGE_SIZE, 0

	.global empty_bad_page_table
empty_bad_page_table:
	.skip PAGE_SIZE, 0

	.global invalid_pte_table
invalid_pte_table:
	.skip PAGE_SIZE, 0

	.global sys_call_table
sys_call_table:
/* Linux */
#define SYS(call, nargs) .word call
#include "syscalls.h"
#undef SYS

/* extra space for ETI specific syscalls */
	.skip 4 * 16, 0
