Skip to content

Commit

Permalink
Introduction of a new PPC64-only "mach -o" option that dumps the OPAL
Browse files Browse the repository at this point in the history
"Open Power Abstraction Layer" console buffer.
([email protected])
  • Loading branch information
Dave Anderson committed Feb 14, 2017
1 parent 222e784 commit 1a4af84
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 2 deletions.
14 changes: 13 additions & 1 deletion help.c
Original file line number Diff line number Diff line change
Expand Up @@ -2290,14 +2290,15 @@ NULL
char *help_mach[] = {
"mach",
"machine specific data",
"[-m | -c -[xd]]",
"[-m | -c -[xd] | -o]",
" This command displays data specific to a machine type.\n",
" -m Display the physical memory map (x86, x86_64 and ia64 only).",
" -c Display each cpu's cpuinfo structure (x86, x86_64 and ia64 only).",
" Display each cpu's x8664_pda structure (x86_64 only),",
" Display the hwrpb_struct, and each cpu's percpu_struct (alpha only).",
" -x override default output format with hexadecimal format.",
" -d override default output format with decimal format.",
" -o Display the OPAL console log (ppc64 only).",
"\nEXAMPLES",
" %s> mach",
" MACHINE TYPE: i686",
Expand All @@ -2324,6 +2325,17 @@ char *help_mach[] = {
" 00000000fec00000 - 00000000fec90000 E820_RESERVED",
" 00000000fee00000 - 00000000fee10000 E820_RESERVED",
" 00000000ffb00000 - 0000000100000000 E820_RESERVED",
" ",
" Display the OPAL console log:\n",
" %s> mach -o",
" [ 65.219056911,5] SkiBoot skiboot-5.4.0-218-ge0225cc-df9a248 starting...",
" [ 65.219065872,5] initial console log level: memory 7, driver 5",
" [ 65.219068917,6] CPU: P8 generation processor(max 8 threads/core)",
" [ 65.219071681,7] CPU: Boot CPU PIR is 0x0060 PVR is 0x004d0200",
" [ 65.219074685,7] CPU: Initial max PIR set to 0x1fff",
" [ 65.219607955,5] FDT: Parsing fdt @0xff00000",
" [ 494.026291523,7] BT: seq 0x25 netfn 0x0a cmd 0x48: Message sent to host",
" [ 494.027636927,7] BT: seq 0x25 netfn 0x0a cmd 0x48: IPMI MSG done",
NULL
};

Expand Down
102 changes: 101 additions & 1 deletion ppc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "defs.h"
#include <endian.h>
#include <ctype.h>

static int ppc64_kvtop(struct task_context *, ulong, physaddr_t *, int);
static int ppc64_uvtop(struct task_context *, ulong, physaddr_t *, int);
Expand Down Expand Up @@ -64,6 +65,7 @@ static ulong hugepage_dir(ulong pte);
static ulong pgd_page_vaddr_l4(ulong pgd);
static ulong pud_page_vaddr_l4(ulong pud);
static ulong pmd_page_vaddr_l4(ulong pmd);
void opalmsg(void);

static inline int is_hugepage(ulong pte)
{
Expand Down Expand Up @@ -2733,6 +2735,102 @@ ppc64_get_smp_cpus(void)
return get_cpus_online();
}


/*
* Definitions derived from OPAL. These need to track corresponding values in
* https://github.com/open-power/skiboot/blob/master/include/mem-map.h
*/
#define SKIBOOT_CONSOLE_DUMP_START 0x31000000
#define SKIBOOT_CONSOLE_DUMP_SIZE 0x40000
#define SKIBOOT_BASE 0x30000000
#define ASCII_UNLIMITED ((ulong)(-1) >> 1)

void
opalmsg(void)
{
struct memloc {
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint64_t u64;
uint64_t limit64;
};
struct opal {
unsigned long long base;
unsigned long long entry;
} opal;
int i, a;
size_t typesz;
void *location;
char readtype[20];
struct memloc mem;
int displayed, per_line;
int lost;
ulong error_handle;
long count = SKIBOOT_CONSOLE_DUMP_SIZE;
ulonglong addr = SKIBOOT_CONSOLE_DUMP_START;

if (CRASHDEBUG(4))
fprintf(fp, "<addr: %llx count: %ld (%s)>\n",
addr, count, "PHYSADDR");

/*
* OPAL based platform check
* struct opal of BSS section and hence default value will be ZERO(0)
* opal_init() in the kernel initializes this structure based on
* the platform. Use it as a key to determine whether the dump
* was taken on an OPAL based system or not.
*/
if (symbol_exists("opal")) {
get_symbol_data("opal", sizeof(struct opal), &opal);
if (opal.base != SKIBOOT_BASE)
error(FATAL, "dump was captured on non-PowerNV machine");
} else {
error(FATAL, "dump was captured on non-PowerNV machine");
}

BZERO(&mem, sizeof(struct memloc));
lost = typesz = per_line = 0;
location = NULL;

/* ASCII */
typesz = SIZEOF_8BIT;
location = &mem.u8;
sprintf(readtype, "ascii");
per_line = 256;
displayed = 0;

error_handle = FAULT_ON_ERROR;

for (i = a = 0; i < count; i++) {
if (!readmem(addr, PHYSADDR, location, typesz,
readtype, error_handle)) {
addr += typesz;
lost += 1;
continue;
}

if (isprint(mem.u8)) {
if ((a % per_line) == 0) {
if (displayed && i)
fprintf(fp, "\n");
}
fprintf(fp, "%c", mem.u8);
displayed++;
a++;
} else {
if (count == ASCII_UNLIMITED)
return;
a = 0;
}

addr += typesz;
}

if (lost != count)
fprintf(fp, "\n");
}

/*
* Machine dependent command.
*/
Expand All @@ -2741,14 +2839,16 @@ ppc64_cmd_mach(void)
{
int c;

while ((c = getopt(argcnt, args, "cm")) != EOF) {
while ((c = getopt(argcnt, args, "cmo")) != EOF) {
switch(c)
{
case 'c':
case 'm':
fprintf(fp, "PPC64: '-%c' option is not supported\n",
c);
break;
case 'o':
return opalmsg();
default:
argerrs++;
break;
Expand Down

0 comments on commit 1a4af84

Please sign in to comment.