Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3863 → Rev 3993

/branches/sparc/kernel/arch/sparc64/include/sun4v/asm.h
0,0 → 1,41
/*
* Copyright (c) 2005 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.
*/
 
/** @addtogroup sparc64
* @{
*/
/** @file
*/
 
#ifndef KERN_sparc64_sun4v_ASM_H_
#define KERN_sparc64_sun4v_ASM_H_
 
#endif
 
/** @}
*/
/branches/sparc/kernel/arch/sparc64/include/sun4v/cpu.h
35,9 → 35,29
#ifndef KERN_sparc64_sun4v_CPU_H_
#define KERN_sparc64_sun4v_CPU_H_
 
/* Maximum number of virtual processors. */
#define MAX_NUM_STRANDS 64
 
/*
* Size of pair of pointers (one pointer to kernel stack,
* one to uspace window buffer).
*/
#define KSTACK_WBUF_PTR_SIZE (2 * 8)
 
#ifndef __ASM__
 
/**
* Pair of two pointers, the first one points to the kernel stack of
* a userspace thread, the second one points to the userspace window
* buffer of the userspace thread. For each CPU there exists exactly
* one isntance of this structure.
*/
typedef struct {
uintptr_t kstack;
uintptr_t wbuf;
} __attribute__ ((packed)) kstack_wbuf_ptr ;
 
typedef struct {
uint64_t id; /**< virtual processor ID */
uint32_t mid; // TODO: left here only to keep the code compilable!!!
uint32_t clock_frequency; /**< Processor frequency in Hz. */
46,12 → 66,35
matches this value. */
} cpu_arch_t;
 
/* Maximum number of virtual processors. */
#define MAX_NUM_STRANDS 64
 
#endif
 
#ifdef __ASM__
 
/*
* Computes the pointer to the kstack_wbuf_ptr structure of the current CPU.
*
* Parameters:
* tmpreg1 global register to be used for scratching purposes
* result register where the resulting pointer will be saved
*/
.macro get_kstack_wbuf_ptr tmpreg1, result
! load CPUID to tmpreg1
or %g0, SCRATCHPAD_CPUID, \tmpreg1
ldxa [\tmpreg1] ASI_SCRATCHPAD, \tmpreg1
 
! compute offset within the array of kstack_wbuf_ptr structures (each
! such structure is 16 bytes long)
mulx \tmpreg1, KSTACK_WBUF_PTR_SIZE, \tmpreg1
 
! compute the pointer to the structure for the current CPU
sethi %hi(kstack_wbuf_ptrs), \result
or \result, %lo(kstack_wbuf_ptrs), \result
add \result, \tmpreg1, \result
.endm
 
#endif
 
#endif
 
/** @}
*/