Files
OpenCellular/chip/host/system.c
Vic Yang 5007bbc009 Use uintptr_t when converting integer from/to pointer
Perviously we use uint32_t for this, but this doesn't compile for 64-bit
environment (and likely doesn't for 16-bit either.) Use uintptr_t so that
we don't get size mismatch errors.

BUG=chrome-os-partner:19257
TEST=Run host emulated tests
BRANCH=None

Change-Id: I3cd66a745fa171c41a5f142514284ec106586acb
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50358
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-07 20:59:53 -07:00

104 lines
1.7 KiB
C

/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* System module for emulator */
#include <stdlib.h>
#include "host_test.h"
#include "system.h"
#include "persistence.h"
#define SHARED_MEM_SIZE 512 /* bytes */
char __shared_mem_buf[SHARED_MEM_SIZE];
test_mockable void system_reset(int flags)
{
exit(EXIT_CODE_RESET | flags);
}
test_mockable void system_hibernate(uint32_t seconds, uint32_t microseconds)
{
exit(EXIT_CODE_HIBERNATE);
}
test_mockable int system_is_locked(void)
{
return 0;
}
test_mockable int system_jumped_to_this_image(void)
{
return 0;
}
test_mockable uint32_t system_get_reset_flags(void)
{
return RESET_FLAG_POWER_ON;
}
const char *system_get_chip_vendor(void)
{
return "chromeos";
}
const char *system_get_chip_name(void)
{
return "emu";
}
const char *system_get_chip_revision(void)
{
return "";
}
int system_get_vbnvcontext(uint8_t *block)
{
return EC_ERROR_UNIMPLEMENTED;
}
int system_set_vbnvcontext(const uint8_t *block)
{
return EC_ERROR_UNIMPLEMENTED;
}
int system_set_scratchpad(uint32_t value)
{
FILE *f = get_persistent_storage("scratchpad", "w");
fprintf(f, "%lu", value);
release_persistent_storage(f);
return EC_SUCCESS;
}
uint32_t system_get_scratchpad(void)
{
FILE *f = get_persistent_storage("scratchpad", "r");
uint32_t value;
int success;
if (f == NULL)
return 0;
success = fscanf(f, "%lu", &value);
release_persistent_storage(f);
if (success)
return value;
else
return 0;
}
uintptr_t system_usable_ram_end(void)
{
return (uintptr_t)(__shared_mem_buf + SHARED_MEM_SIZE);
}
void system_pre_init(void)
{
/* Nothing */
}