mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
use UART device to print kernel messages
- HermitCore's message buffer isn't longer supported by uhyve
This commit is contained in:
parent
15b5495f31
commit
f11c948347
4 changed files with 13 additions and 16 deletions
|
@ -105,7 +105,7 @@ static inline unsigned char read_from_uart(uint32_t off)
|
|||
{
|
||||
uint8_t c = 0;
|
||||
|
||||
if (uartport)
|
||||
if (!is_uhyve() && uartport)
|
||||
c = inportb(uartport + off);
|
||||
|
||||
return c;
|
||||
|
@ -113,6 +113,9 @@ static inline unsigned char read_from_uart(uint32_t off)
|
|||
|
||||
static inline int is_transmit_empty(void)
|
||||
{
|
||||
if (is_uhyve())
|
||||
return 1;
|
||||
|
||||
if (uartport)
|
||||
return inportb(uartport + UART_LSR) & 0x20;
|
||||
|
||||
|
|
|
@ -1008,7 +1008,7 @@ int load_kernel(uint8_t* mem, char* path)
|
|||
*((uint32_t*) (mem+paddr-GUEST_OFFSET + 0x30)) = 0; // apicid
|
||||
*((uint32_t*) (mem+paddr-GUEST_OFFSET + 0x60)) = 1; // numa nodes
|
||||
*((uint32_t*) (mem+paddr-GUEST_OFFSET + 0x94)) = 1; // announce uhyve
|
||||
|
||||
*((uint64_t*) (mem+paddr-GUEST_OFFSET + 0x98)) = UHYVE_UART_PORT ; // announce uhyve
|
||||
|
||||
char* str = getenv("HERMIT_IP");
|
||||
if (str) {
|
||||
|
@ -1042,7 +1042,8 @@ int load_kernel(uint8_t* mem, char* path)
|
|||
*((uint8_t*) (mem+paddr-GUEST_OFFSET + 0xBB)) = (uint8_t) ip[3];
|
||||
}
|
||||
|
||||
*((uint64_t*) (mem+paddr-GUEST_OFFSET + 0xbc)) = guest_mem;
|
||||
if (verbose)
|
||||
*((uint64_t*) (mem+paddr-GUEST_OFFSET + 0xbc)) = (uint64_t) guest_mem;
|
||||
}
|
||||
*((uint64_t*) (mem+paddr-GUEST_OFFSET + 0x38)) += memsz; // total kernel size
|
||||
}
|
||||
|
|
|
@ -180,16 +180,6 @@ static void uhyve_exit(void* arg)
|
|||
close_fd(&vcpufd);
|
||||
}
|
||||
|
||||
static void dump_log(void)
|
||||
{
|
||||
if (klog && verbose)
|
||||
{
|
||||
fputs("\nDump kernel log:\n", stderr);
|
||||
fputs("================\n", stderr);
|
||||
fprintf(stderr, "%s\n", klog);
|
||||
}
|
||||
}
|
||||
|
||||
static void uhyve_atexit(void)
|
||||
{
|
||||
uhyve_exit(NULL);
|
||||
|
@ -207,8 +197,6 @@ static void uhyve_atexit(void)
|
|||
if (vcpu_fds)
|
||||
free(vcpu_fds);
|
||||
|
||||
dump_log();
|
||||
|
||||
// clean up and close KVM
|
||||
close_fd(&vmfd);
|
||||
close_fd(&kvm);
|
||||
|
@ -321,6 +309,10 @@ static int vcpu_loop(void)
|
|||
|
||||
//printf("port 0x%x\n", run->io.port);
|
||||
switch (port) {
|
||||
case UHYVE_UART_PORT:
|
||||
if (verbose)
|
||||
putc((unsigned char) raddr, stderr);
|
||||
break;
|
||||
case UHYVE_PORT_WRITE: {
|
||||
uhyve_write_t* uhyve_write = (uhyve_write_t*) (guest_mem+raddr);
|
||||
|
||||
|
@ -471,7 +463,6 @@ static int vcpu_loop(void)
|
|||
|
||||
case KVM_EXIT_DEBUG:
|
||||
print_registers();
|
||||
dump_log();
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
default:
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
#define UHYVE_PORT_CMDSIZE 0x740
|
||||
#define UHYVE_PORT_CMDVAL 0x780
|
||||
|
||||
#define UHYVE_UART_PORT 0x800
|
||||
|
||||
#define UHYVE_IRQ 11
|
||||
|
||||
#define kvm_ioctl(fd, cmd, arg) ({ \
|
||||
|
|
Loading…
Add table
Reference in a new issue