/trunk/kernel/arch/sparc64/_link.ld.in |
---|
6,7 → 6,7 |
* |
*/ |
#define __ASM__ |
#define __LINKER__ |
#include <arch/boot/boot.h> |
ENTRY(kernel_image_start) |
/trunk/kernel/arch/sparc64/include/boot/boot.h |
---|
32,13 → 32,67 |
/** @file |
*/ |
#ifndef __sparc64_BOOT_H__ |
#define __sparc64_BOOT_H__ |
#ifndef KERN_sparc64_BOOT_H_ |
#define KERN_sparc64_BOOT_H_ |
#define VMA 0x400000 |
#define LMA VMA |
#ifndef __LINKER__ |
#include <arch/types.h> |
#include <typedefs.h> |
#define TASKMAP_MAX_RECORDS 32 |
#define MEMMAP_MAX_RECORDS 32 |
typedef struct { |
void * addr; |
uint32_t size; |
} utask_t; |
typedef struct { |
uint32_t count; |
utask_t tasks[TASKMAP_MAX_RECORDS]; |
} taskmap_t; |
typedef struct { |
uintptr_t start; |
uint32_t size; |
} memzone_t; |
typedef struct { |
uint32_t total; |
uint32_t count; |
memzone_t zones[MEMMAP_MAX_RECORDS]; |
} memmap_t; |
typedef struct { |
uintptr_t addr; |
uint32_t width; |
uint32_t height; |
uint32_t bpp; |
uint32_t scanline; |
} screen_t; |
typedef struct { |
uintptr_t addr; |
uint32_t size; |
} keyboard_t; |
typedef struct { |
taskmap_t taskmap; |
memmap_t memmap; |
screen_t screen; |
keyboard_t keyboard; |
} bootinfo_t; |
extern bootinfo_t bootinfo; |
#endif |
#endif |
/** @} |
*/ |
/trunk/kernel/arch/sparc64/include/drivers/tick.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup sparc64 |
/** @addtogroup sparc64 |
* @{ |
*/ |
/** @file |
44,6 → 44,5 |
#endif |
/** @} |
/** @} |
*/ |
/trunk/kernel/arch/sparc64/include/drivers/i8042.h |
---|
37,8 → 37,6 |
#include <arch/types.h> |
#define KBD_PHYS_ADDRESS 0x1fff8904000ULL |
#define STATUS_REG 4 |
#define COMMAND_REG 4 |
#define DATA_REG 6 |
/trunk/kernel/arch/sparc64/include/drivers/fb.h |
---|
35,13 → 35,6 |
#ifndef KERN_sparc64_FB_H_ |
#define KERN_sparc64_FB_H_ |
#define FB_PHYS_ADDRESS 0x1c901000000ULL |
#define FB_X_RES 1152 |
#define FB_Y_RES 900 |
#define FB_COLOR_DEPTH 8 |
#endif |
/** @} |
/trunk/kernel/arch/sparc64/Makefile.inc |
---|
46,8 → 46,6 |
## Own configuration directives |
# |
CONFIG_OFW = y |
## Compile with page hash table support. |
# |
/trunk/kernel/arch/sparc64/src/asm.S |
---|
42,33 → 42,67 |
memcpy: |
memcpy_from_uspace: |
memcpy_to_uspace: |
.register %g2, #scratch |
.register %g3, #scratch |
add %o1, 7, %g1 |
and %g1, -8, %g1 |
cmp %o1, %g1 |
be,pn %xcc, 3f |
add %o0, 7, %g1 |
mov 0, %g3 |
0: |
brz,pn %o2, 2f |
mov 0, %g2 |
1: |
ldub [%g3 + %o1], %g1 |
add %g2, 1, %g2 |
cmp %o2, %g2 |
stb %g1, [%g3 + %o0] |
bne,pt %xcc, 1b |
mov %g2, %g3 |
2: |
jmp %o7 + 8 ! exit point |
mov %o1, %o0 |
3: |
and %g1, -8, %g1 |
cmp %o0, %g1 |
bne,pt %xcc, 0b |
mov 0, %g3 |
srlx %o2, 3, %g4 |
brz,pn %g4, 5f |
mov 0, %g5 |
4: |
sllx %g3, 3, %g2 |
add %g5, 1, %g3 |
ldx [%o1 + %g2], %g1 |
mov %g3, %g5 |
cmp %g4, %g3 |
bne,pt %xcc, 4b |
stx %g1, [%o0 + %g2] |
5: |
and %o2, 7, %o2 |
brz,pn %o2, 2b |
sllx %g4, 3, %g1 |
mov 0, %g2 |
add %g1, %o0, %o0 |
add %g1, %o1, %g4 |
mov 0, %g3 |
6: |
ldub [%g2 + %g4], %g1 |
stb %g1, [%g2 + %o0] |
add %g3, 1, %g2 |
cmp %o2, %g2 |
bne,pt %xcc, 6b |
mov %g2, %g3 |
b _memcpy |
nop |
jmp %o7 + 8 ! exit point |
mov %o1, %o0 |
memcpy_from_uspace_failover_address: |
memcpy_to_uspace_failover_address: |
b memcpy_from_uspace_failover_address |
nop |
jmp %o7 + 8 ! exit point |
mov %g0, %o0 ! return 0 on failure |
memsetb: |
b _memsetb |
nop |
.global ofw |
ofw: |
save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp |
set ofw_cif, %l0 |
ldx [%l0], %l0 |
rdpr %pstate, %l1 |
and %l1, ~PSTATE_AM_BIT, %l2 |
wrpr %l2, 0, %pstate |
jmpl %l0, %o7 |
mov %i0, %o0 |
wrpr %l1, 0, %pstate |
ret |
restore %o0, 0, %o0 |
/trunk/kernel/arch/sparc64/src/console.c |
---|
39,57 → 39,26 |
#include <arch/drivers/fb.h> |
#include <arch/drivers/i8042.h> |
#include <genarch/i8042/i8042.h> |
#include <genarch/ofw/ofw.h> |
#include <console/chardev.h> |
#include <console/console.h> |
#include <arch/asm.h> |
#include <arch/register.h> |
#include <proc/thread.h> |
#include <synch/mutex.h> |
#include <arch/mm/tlb.h> |
#include <arch/boot/boot.h> |
#define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ |
static void ofw_sparc64_putchar(chardev_t *d, const char ch); |
static volatile int ofw_console_active; |
static chardev_t ofw_sparc64_console; |
static chardev_operations_t ofw_sparc64_console_ops = { |
.write = ofw_sparc64_putchar, |
}; |
/** Initialize kernel console to use OpenFirmware services. */ |
void ofw_sparc64_console_init(void) |
{ |
chardev_initialize("ofw_sparc64_console", &ofw_sparc64_console, &ofw_sparc64_console_ops); |
stdin = NULL; |
stdout = &ofw_sparc64_console; |
ofw_console_active = 1; |
} |
/** Initialize kernel console to use framebuffer and keyboard directly. */ |
void standalone_sparc64_console_init(void) |
{ |
ofw_console_active = 0; |
stdin = NULL; |
kbd_init(); |
fb_init(FB_PHYS_ADDRESS, FB_X_RES, FB_Y_RES, FB_COLOR_DEPTH, FB_X_RES * FB_COLOR_DEPTH / 8); |
fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, |
bootinfo.screen.bpp, bootinfo.screen.scanline); |
} |
/** Write one character using OpenFirmware. |
* |
* @param d Character device (ignored). |
* @param ch Character to be written. |
*/ |
void ofw_sparc64_putchar(chardev_t *d, const char ch) |
{ |
if (ch == '\n') |
ofw_putchar('\r'); |
ofw_putchar(ch); |
} |
/** Kernel thread for polling keyboard. |
* |
* @param arg Ignored. |
/trunk/kernel/arch/sparc64/src/sparc64.c |
---|
39,16 → 39,12 |
#include <arch/drivers/tick.h> |
#include <proc/thread.h> |
#include <console/console.h> |
#include <arch/boot/boot.h> |
#include <print.h> |
#include <genarch/ofw/ofw.h> |
#include <arch/asm.h> |
#include <arch/register.h> |
bootinfo_t bootinfo; |
void arch_pre_mm_init(void) |
{ |
interrupts_disable(); |
ofw_sparc64_console_init(); |
trap_init(); |
tick_init(); |
} |
/trunk/kernel/arch/sparc64/src/mm/frame.c |
---|
33,22 → 33,37 |
*/ |
#include <arch/mm/frame.h> |
#include <genarch/ofw/memory_init.h> |
#include <mm/frame.h> |
#include <arch/boot/boot.h> |
#include <config.h> |
#include <align.h> |
/** Create memory zones according to information stored in bootinfo. |
* |
* Walk the bootinfo memory map and create frame zones according to it. |
* The first frame is not blacklisted here as it is done in generic |
* frame_init(). |
*/ |
void frame_arch_init(void) |
{ |
ofw_init_zones(); |
int i; |
pfn_t confdata; |
/* |
* Workaround to prevent slab allocator from allocating frame 0. |
* Frame 0 is |
* a) not mapped by OFW |
* b) would be confused with NULL error return code |
*/ |
frame_mark_unavailable(0, 1); |
for (i = 0; i < bootinfo.memmap.count; i++) { |
/* |
* The memmap is created by HelenOS boot loader. |
* It already contains no holes. |
*/ |
confdata = ADDR2PFN(bootinfo.memmap.zones[i].start); |
if (confdata == 0) |
confdata = 2; |
zone_create(ADDR2PFN(bootinfo.memmap.zones[i].start), |
SIZE2FRAMES(ALIGN_DOWN(bootinfo.memmap.zones[i].size, PAGE_SIZE)), |
confdata, 0); |
} |
} |
/** @} |
/trunk/kernel/arch/sparc64/src/mm/memory_init.c |
---|
33,14 → 33,17 |
*/ |
#include <arch/mm/memory_init.h> |
#include <genarch/ofw/memory_init.h> |
#include <arch/boot/boot.h> |
#include <typedefs.h> |
/** Return total size of available memory in bytes. |
* |
* @return Size of available memory in bytes. |
*/ |
size_t get_memory_size(void) |
{ |
return ofw_get_memory_size(); |
return bootinfo.memmap.total; |
} |
/** @} |
*/ |
/trunk/kernel/arch/sparc64/src/drivers/i8042.c |
---|
34,6 → 34,7 |
#include <arch/drivers/i8042.h> |
#include <genarch/i8042/i8042.h> |
#include <arch/boot/boot.h> |
#include <arch/types.h> |
#include <arch/mm/page.h> |
41,7 → 42,7 |
void kbd_init() |
{ |
kbd_virt_address = (uint8_t *) hw_map(KBD_PHYS_ADDRESS, LAST_REG); |
kbd_virt_address = (uint8_t *) hw_map(bootinfo.keyboard.addr, LAST_REG); |
i8042_init(); |
} |
/trunk/kernel/arch/sparc64/src/start.S |
---|
26,7 → 26,6 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
#include <arch/boot/boot.h> |
#include <arch/regdef.h> |
.register %g2, #scratch |
39,6 → 38,10 |
/* |
* Here is where the kernel is passed control |
* from the boot loader. |
* |
* The registers are expected to be in this state: |
* %o0 bootinfo structure address |
* %o1 bootinfo structure size |
*/ |
.global kernel_image_start |
45,16 → 48,21 |
kernel_image_start: |
flushw ! flush all but the active register window |
/* |
* Disable interrupts and disable 32-bit address masking. |
*/ |
rdpr %pstate, %l0 |
and %l0, ~PSTATE_AM_BIT, %l0 |
and %l0, ~(PSTATE_AM_BIT|PSTATE_IE_BIT), %l0 |
wrpr %l0, 0, %pstate |
set ofw_cif, %l0 |
call ofw_init |
stx %o4, [%l0] |
call ofw_init_memmap |
/* |
* Copy the bootinfo structure passed from the boot loader |
* to the kernel bootinfo structure. |
*/ |
mov %o1, %o2 |
mov %o0, %o1 |
set bootinfo, %o0 |
call memcpy |
nop |
wrpr %r0, 0, %pil |