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 |
|
/** @} |
*/ |