93 lines
3.1 KiB
C
93 lines
3.1 KiB
C
/* *****************************************************************************
|
|
* p7/dump.c -- p7 information dumping utility.
|
|
* Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of p7utils.
|
|
* p7utils is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* p7utils is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with p7utils; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************** */
|
|
#include "main.h"
|
|
#include <inttypes.h>
|
|
#include <libp7/packetio.h>
|
|
#define numformat "%" PRIuP7INT
|
|
#define addrformat "0x%08" PRIxP7INT
|
|
|
|
/**
|
|
* dump:
|
|
* Dump calculator information.
|
|
*
|
|
* @arg handle the libp7 handle
|
|
* @return the error code (0 if ok).
|
|
*/
|
|
|
|
int dump(p7_handle_t *handle)
|
|
{
|
|
/* get server info */
|
|
const p7_server_t *info = p7_get_info(handle);
|
|
|
|
/* Wiped out things */
|
|
if (info->preprog_rom_wiped)
|
|
log("Warning: Preprogrammed ROM information looks wiped out!\n");
|
|
if (info->bootcode_wiped)
|
|
log("Warning: Bootcode information looks wiped out!\n");
|
|
if (info->os_wiped)
|
|
log("Warning: OS information looks wiped out!\n");
|
|
if (!info->username[0])
|
|
log("Warning: Username is not set.\n");
|
|
|
|
/* main information */
|
|
printf("CPU ID (probably out of date): %s\n", info->cpuid);
|
|
printf("Environnement ID: %s\n", info->hwid);
|
|
printf("Product ID: %s\n", info->product_id);
|
|
|
|
/* Preprogrammed ROM */
|
|
if (!info->preprog_rom_wiped) {
|
|
printf("Preprogrammed ROM version: %02u.%02u",
|
|
info->preprog_rom_version.major, info->preprog_rom_version.minor);
|
|
if (info->preprog_rom_version.rev)
|
|
printf(" (%u)", info->preprog_rom_version.rev);
|
|
printf("\nPreprogrammed ROM capacity: " numformat "o\n",
|
|
info->preprog_rom_capacity);
|
|
}
|
|
|
|
/* ROM and RAM */
|
|
printf("ROM capacity: " numformat "KiB\n", info->flash_rom_capacity / 1024);
|
|
printf("RAM capacity: " numformat "KiB\n", info->ram_capacity / 1024);
|
|
|
|
/* Bootcode */
|
|
if (!info->bootcode_wiped) {
|
|
printf("Bootcode version: %02u.%02u",
|
|
info->bootcode_version.major, info->bootcode_version.minor);
|
|
if (info->bootcode_version.rev)
|
|
printf(" (%u)", info->bootcode_version.rev);
|
|
printf("\nBootcode offset: " addrformat "\n", info->bootcode_offset);
|
|
printf("Bootcode size: " numformat "KiB\n", info->bootcode_size / 1024);
|
|
}
|
|
|
|
/* OS */
|
|
if (!info->os_wiped) {
|
|
printf("OS version: %02u.%02u",
|
|
info->os_version.major, info->os_version.minor);
|
|
if (info->os_version.rev)
|
|
printf(" (%u)", info->os_version.rev);
|
|
printf("\nOS offset: " addrformat "\n", info->os_offset);
|
|
printf("OS size: " numformat "KiB\n", info->os_size / 1024);
|
|
}
|
|
|
|
/* Miscallenous information */
|
|
if (info->username[0])
|
|
printf("Username: %s\n", info->username);
|
|
|
|
return (0);
|
|
}
|