[platform][vax] add some code to try to sniff the board type

This lets us select the console routines to use.
This commit is contained in:
Travis Geiselbrecht
2019-10-17 23:22:51 -07:00
parent 2760056b4b
commit d5ec654f9a
6 changed files with 90 additions and 9 deletions

View File

@@ -14,6 +14,8 @@
#define LOCAL_TRACE 0
extern uint8_t irq_stack[1024];
void arch_early_init(void) {
// set the top level exception handler
//riscv_csr_write(mtvec, (uintptr_t)&riscv_exception_entry);
@@ -38,8 +40,6 @@ void arch_init(void) {
}
void arch_idle(void) {
// disabled for now, QEMU seems to have some trouble emulating wfi properly
// also have trouble breaking into sifive-e board with openocd when wfi
// __asm__ volatile("wfi");
}

View File

@@ -5,4 +5,6 @@
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <arch/vax/mtpr.h>

View File

@@ -37,18 +37,21 @@ _start:
sobgtr %r2,1b
// branch to our new spot
// TODO: use a REI to make sure the cpu dumps the pipeline
movl $relocated, %r0
jmp (%r0)
relocated:
// set the stack to the end of us
moval stack_end,%sp
moval irq_stack_end,%sp
// branch into main and we're done
calls $0, lk_main
halt
.section .data
// declare bootargs here to make sure it goes in the data segment, since it's
// saved before the bss is zeroed out.
.align 4
.globl bootargs
bootargs:
@@ -57,6 +60,6 @@ bootargs_end:
.section .bss
.align 4
stack:
irq_stack:
.skip 1024
stack_end:
irq_stack_end:

View File

@@ -9,12 +9,24 @@
#include <platform.h>
#include <platform/debug.h>
// todo: move to .S file
unsigned int rom_putchar_addr = 0x20040068;
extern int rom_putchar(int c);
#include "platform_p.h"
// Console io via rom routine
unsigned int rom_putchar_addr;
extern void rom_putchar(int c);
// PR version
void putchar_mtfr(int c) {
// wait until ready
while ((mfpr(PR_TXCS) & 0x80) == 0)
;
// output char
mtpr((char)c, PR_TXDB);
}
// select the above routine
int (*putchar_func)(int c) = &rom_putchar;
void (*putchar_func)(int c);
void platform_dputc(char c) {
if (c == '\n')
@@ -35,5 +47,19 @@ int platform_pgetc(char *c, bool wait) {
return platform_dgetc(c, wait);
}
void platform_early_console_init(void) {
// TODO: decide what type of console to use based on vax machine
// Only understand a few at the moment
switch (vax_boardtype) {
case 0x14000004: // Microvax 3100/40
rom_putchar_addr = 0x20040068;
putchar_func = &rom_putchar;
break;
default:
// default is to use the pr routines
putchar_func = &putchar_mtfr;
}
}

View File

@@ -8,6 +8,39 @@
#include <lk/debug.h>
#include <platform.h>
#include <platform/timer.h>
#include <arch/vax.h>
#include "platform_p.h"
uint32_t vax_cputype;
uint32_t vax_boardtype;
void platform_early_init(void) {
// decode what kind of vax we are so we can make a few platform decisions
// generally follows logic in netbsd sys/arch/vax/...
uint32_t sid = mfpr(PR_SID);
vax_cputype = sid >> 24;
vax_boardtype = vax_cputype << 24;
switch (vax_cputype) {
case 10: // CVAX
case 11: // RIGEL
case 18: // MARIAH
case 19: // NVAX
case 20: { // SOC
uint32_t sie = *(uint32_t *)(0x20040004);
vax_boardtype |= sie >> 24;
break;
}
}
platform_early_console_init();
printf("\n");
printf("VAX: sid %#x\n", sid);
printf("VAX: cputype %#x\n", vax_cputype);
printf("VAX: boardtype %#x\n", vax_boardtype);
}
// stubbed out time
static lk_time_t t = 0;

17
platform/vax/platform_p.h Normal file
View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) 2019 Travis Geiselbrecht
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <lib/cbuf.h>
// super simple cheesy system detection mechanism
// mostly cribbed from netbsd
extern uint32_t vax_cputype;
extern uint32_t vax_boardtype;
void platform_early_console_init(void);