Path: blob/master/arch/powerpc/platforms/ps3/os-area.c
10818 views
/*1* PS3 flash memory os area.2*3* Copyright (C) 2006 Sony Computer Entertainment Inc.4* Copyright 2006 Sony Corp.5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; version 2 of the License.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/1920#include <linux/kernel.h>21#include <linux/io.h>22#include <linux/workqueue.h>23#include <linux/fs.h>24#include <linux/syscalls.h>25#include <linux/ctype.h>26#include <linux/memblock.h>27#include <linux/of.h>28#include <linux/slab.h>2930#include <asm/prom.h>3132#include "platform.h"3334enum {35OS_AREA_SEGMENT_SIZE = 0X200,36};3738enum os_area_ldr_format {39HEADER_LDR_FORMAT_RAW = 0,40HEADER_LDR_FORMAT_GZIP = 1,41};4243#define OS_AREA_HEADER_MAGIC_NUM "cell_ext_os_area"4445/**46* struct os_area_header - os area header segment.47* @magic_num: Always 'cell_ext_os_area'.48* @hdr_version: Header format version number.49* @db_area_offset: Starting segment number of other os database area.50* @ldr_area_offset: Starting segment number of bootloader image area.51* @ldr_format: HEADER_LDR_FORMAT flag.52* @ldr_size: Size of bootloader image in bytes.53*54* Note that the docs refer to area offsets. These are offsets in units of55* segments from the start of the os area (top of the header). These are56* better thought of as segment numbers. The os area of the os area is57* reserved for the os image.58*/5960struct os_area_header {61u8 magic_num[16];62u32 hdr_version;63u32 db_area_offset;64u32 ldr_area_offset;65u32 _reserved_1;66u32 ldr_format;67u32 ldr_size;68u32 _reserved_2[6];69};7071enum os_area_boot_flag {72PARAM_BOOT_FLAG_GAME_OS = 0,73PARAM_BOOT_FLAG_OTHER_OS = 1,74};7576enum os_area_ctrl_button {77PARAM_CTRL_BUTTON_O_IS_YES = 0,78PARAM_CTRL_BUTTON_X_IS_YES = 1,79};8081/**82* struct os_area_params - os area params segment.83* @boot_flag: User preference of operating system, PARAM_BOOT_FLAG flag.84* @num_params: Number of params in this (params) segment.85* @rtc_diff: Difference in seconds between 1970 and the ps3 rtc value.86* @av_multi_out: User preference of AV output, PARAM_AV_MULTI_OUT flag.87* @ctrl_button: User preference of controller button config, PARAM_CTRL_BUTTON88* flag.89* @static_ip_addr: User preference of static IP address.90* @network_mask: User preference of static network mask.91* @default_gateway: User preference of static default gateway.92* @dns_primary: User preference of static primary dns server.93* @dns_secondary: User preference of static secondary dns server.94*95* The ps3 rtc maintains a read-only value that approximates seconds since96* 2000-01-01 00:00:00 UTC.97*98* User preference of zero for static_ip_addr means use dhcp.99*/100101struct os_area_params {102u32 boot_flag;103u32 _reserved_1[3];104u32 num_params;105u32 _reserved_2[3];106/* param 0 */107s64 rtc_diff;108u8 av_multi_out;109u8 ctrl_button;110u8 _reserved_3[6];111/* param 1 */112u8 static_ip_addr[4];113u8 network_mask[4];114u8 default_gateway[4];115u8 _reserved_4[4];116/* param 2 */117u8 dns_primary[4];118u8 dns_secondary[4];119u8 _reserved_5[8];120};121122#define OS_AREA_DB_MAGIC_NUM "-db-"123124/**125* struct os_area_db - Shared flash memory database.126* @magic_num: Always '-db-'.127* @version: os_area_db format version number.128* @index_64: byte offset of the database id index for 64 bit variables.129* @count_64: number of usable 64 bit index entries130* @index_32: byte offset of the database id index for 32 bit variables.131* @count_32: number of usable 32 bit index entries132* @index_16: byte offset of the database id index for 16 bit variables.133* @count_16: number of usable 16 bit index entries134*135* Flash rom storage for exclusive use by guests running in the other os lpar.136* The current system configuration allocates 1K (two segments) for other os137* use.138*/139140struct os_area_db {141u8 magic_num[4];142u16 version;143u16 _reserved_1;144u16 index_64;145u16 count_64;146u16 index_32;147u16 count_32;148u16 index_16;149u16 count_16;150u32 _reserved_2;151u8 _db_data[1000];152};153154/**155* enum os_area_db_owner - Data owners.156*/157158enum os_area_db_owner {159OS_AREA_DB_OWNER_ANY = -1,160OS_AREA_DB_OWNER_NONE = 0,161OS_AREA_DB_OWNER_PROTOTYPE = 1,162OS_AREA_DB_OWNER_LINUX = 2,163OS_AREA_DB_OWNER_PETITBOOT = 3,164OS_AREA_DB_OWNER_MAX = 32,165};166167enum os_area_db_key {168OS_AREA_DB_KEY_ANY = -1,169OS_AREA_DB_KEY_NONE = 0,170OS_AREA_DB_KEY_RTC_DIFF = 1,171OS_AREA_DB_KEY_VIDEO_MODE = 2,172OS_AREA_DB_KEY_MAX = 8,173};174175struct os_area_db_id {176int owner;177int key;178};179180static const struct os_area_db_id os_area_db_id_empty = {181.owner = OS_AREA_DB_OWNER_NONE,182.key = OS_AREA_DB_KEY_NONE183};184185static const struct os_area_db_id os_area_db_id_any = {186.owner = OS_AREA_DB_OWNER_ANY,187.key = OS_AREA_DB_KEY_ANY188};189190static const struct os_area_db_id os_area_db_id_rtc_diff = {191.owner = OS_AREA_DB_OWNER_LINUX,192.key = OS_AREA_DB_KEY_RTC_DIFF193};194195static const struct os_area_db_id os_area_db_id_video_mode = {196.owner = OS_AREA_DB_OWNER_LINUX,197.key = OS_AREA_DB_KEY_VIDEO_MODE198};199200#define SECONDS_FROM_1970_TO_2000 946684800LL201202/**203* struct saved_params - Static working copies of data from the PS3 'os area'.204*205* The order of preference we use for the rtc_diff source:206* 1) The database value.207* 2) The game os value.208* 3) The number of seconds from 1970 to 2000.209*/210211struct saved_params {212unsigned int valid;213s64 rtc_diff;214unsigned int av_multi_out;215} static saved_params;216217static struct property property_rtc_diff = {218.name = "linux,rtc_diff",219.length = sizeof(saved_params.rtc_diff),220.value = &saved_params.rtc_diff,221};222223static struct property property_av_multi_out = {224.name = "linux,av_multi_out",225.length = sizeof(saved_params.av_multi_out),226.value = &saved_params.av_multi_out,227};228229230static DEFINE_MUTEX(os_area_flash_mutex);231232static const struct ps3_os_area_flash_ops *os_area_flash_ops;233234void ps3_os_area_flash_register(const struct ps3_os_area_flash_ops *ops)235{236mutex_lock(&os_area_flash_mutex);237os_area_flash_ops = ops;238mutex_unlock(&os_area_flash_mutex);239}240EXPORT_SYMBOL_GPL(ps3_os_area_flash_register);241242static ssize_t os_area_flash_read(void *buf, size_t count, loff_t pos)243{244ssize_t res = -ENODEV;245246mutex_lock(&os_area_flash_mutex);247if (os_area_flash_ops)248res = os_area_flash_ops->read(buf, count, pos);249mutex_unlock(&os_area_flash_mutex);250251return res;252}253254static ssize_t os_area_flash_write(const void *buf, size_t count, loff_t pos)255{256ssize_t res = -ENODEV;257258mutex_lock(&os_area_flash_mutex);259if (os_area_flash_ops)260res = os_area_flash_ops->write(buf, count, pos);261mutex_unlock(&os_area_flash_mutex);262263return res;264}265266267/**268* os_area_set_property - Add or overwrite a saved_params value to the device tree.269*270* Overwrites an existing property.271*/272273static void os_area_set_property(struct device_node *node,274struct property *prop)275{276int result;277struct property *tmp = of_find_property(node, prop->name, NULL);278279if (tmp) {280pr_debug("%s:%d found %s\n", __func__, __LINE__, prop->name);281prom_remove_property(node, tmp);282}283284result = prom_add_property(node, prop);285286if (result)287pr_debug("%s:%d prom_set_property failed\n", __func__,288__LINE__);289}290291/**292* os_area_get_property - Get a saved_params value from the device tree.293*294*/295296static void __init os_area_get_property(struct device_node *node,297struct property *prop)298{299const struct property *tmp = of_find_property(node, prop->name, NULL);300301if (tmp) {302BUG_ON(prop->length != tmp->length);303memcpy(prop->value, tmp->value, prop->length);304} else305pr_debug("%s:%d not found %s\n", __func__, __LINE__,306prop->name);307}308309static void dump_field(char *s, const u8 *field, int size_of_field)310{311#if defined(DEBUG)312int i;313314for (i = 0; i < size_of_field; i++)315s[i] = isprint(field[i]) ? field[i] : '.';316s[i] = 0;317#endif318}319320#define dump_header(_a) _dump_header(_a, __func__, __LINE__)321static void _dump_header(const struct os_area_header *h, const char *func,322int line)323{324char str[sizeof(h->magic_num) + 1];325326dump_field(str, h->magic_num, sizeof(h->magic_num));327pr_debug("%s:%d: h.magic_num: '%s'\n", func, line,328str);329pr_debug("%s:%d: h.hdr_version: %u\n", func, line,330h->hdr_version);331pr_debug("%s:%d: h.db_area_offset: %u\n", func, line,332h->db_area_offset);333pr_debug("%s:%d: h.ldr_area_offset: %u\n", func, line,334h->ldr_area_offset);335pr_debug("%s:%d: h.ldr_format: %u\n", func, line,336h->ldr_format);337pr_debug("%s:%d: h.ldr_size: %xh\n", func, line,338h->ldr_size);339}340341#define dump_params(_a) _dump_params(_a, __func__, __LINE__)342static void _dump_params(const struct os_area_params *p, const char *func,343int line)344{345pr_debug("%s:%d: p.boot_flag: %u\n", func, line, p->boot_flag);346pr_debug("%s:%d: p.num_params: %u\n", func, line, p->num_params);347pr_debug("%s:%d: p.rtc_diff %lld\n", func, line, p->rtc_diff);348pr_debug("%s:%d: p.av_multi_out %u\n", func, line, p->av_multi_out);349pr_debug("%s:%d: p.ctrl_button: %u\n", func, line, p->ctrl_button);350pr_debug("%s:%d: p.static_ip_addr: %u.%u.%u.%u\n", func, line,351p->static_ip_addr[0], p->static_ip_addr[1],352p->static_ip_addr[2], p->static_ip_addr[3]);353pr_debug("%s:%d: p.network_mask: %u.%u.%u.%u\n", func, line,354p->network_mask[0], p->network_mask[1],355p->network_mask[2], p->network_mask[3]);356pr_debug("%s:%d: p.default_gateway: %u.%u.%u.%u\n", func, line,357p->default_gateway[0], p->default_gateway[1],358p->default_gateway[2], p->default_gateway[3]);359pr_debug("%s:%d: p.dns_primary: %u.%u.%u.%u\n", func, line,360p->dns_primary[0], p->dns_primary[1],361p->dns_primary[2], p->dns_primary[3]);362pr_debug("%s:%d: p.dns_secondary: %u.%u.%u.%u\n", func, line,363p->dns_secondary[0], p->dns_secondary[1],364p->dns_secondary[2], p->dns_secondary[3]);365}366367static int verify_header(const struct os_area_header *header)368{369if (memcmp(header->magic_num, OS_AREA_HEADER_MAGIC_NUM,370sizeof(header->magic_num))) {371pr_debug("%s:%d magic_num failed\n", __func__, __LINE__);372return -1;373}374375if (header->hdr_version < 1) {376pr_debug("%s:%d hdr_version failed\n", __func__, __LINE__);377return -1;378}379380if (header->db_area_offset > header->ldr_area_offset) {381pr_debug("%s:%d offsets failed\n", __func__, __LINE__);382return -1;383}384385return 0;386}387388static int db_verify(const struct os_area_db *db)389{390if (memcmp(db->magic_num, OS_AREA_DB_MAGIC_NUM,391sizeof(db->magic_num))) {392pr_debug("%s:%d magic_num failed\n", __func__, __LINE__);393return -EINVAL;394}395396if (db->version != 1) {397pr_debug("%s:%d version failed\n", __func__, __LINE__);398return -EINVAL;399}400401return 0;402}403404struct db_index {405uint8_t owner:5;406uint8_t key:3;407};408409struct db_iterator {410const struct os_area_db *db;411struct os_area_db_id match_id;412struct db_index *idx;413struct db_index *last_idx;414union {415uint64_t *value_64;416uint32_t *value_32;417uint16_t *value_16;418};419};420421static unsigned int db_align_up(unsigned int val, unsigned int size)422{423return (val + (size - 1)) & (~(size - 1));424}425426/**427* db_for_each_64 - Iterator for 64 bit entries.428*429* A NULL value for id can be used to match all entries.430* OS_AREA_DB_OWNER_ANY and OS_AREA_DB_KEY_ANY can be used to match all.431*/432433static int db_for_each_64(const struct os_area_db *db,434const struct os_area_db_id *match_id, struct db_iterator *i)435{436next:437if (!i->db) {438i->db = db;439i->match_id = match_id ? *match_id : os_area_db_id_any;440i->idx = (void *)db + db->index_64;441i->last_idx = i->idx + db->count_64;442i->value_64 = (void *)db + db->index_64443+ db_align_up(db->count_64, 8);444} else {445i->idx++;446i->value_64++;447}448449if (i->idx >= i->last_idx) {450pr_debug("%s:%d: reached end\n", __func__, __LINE__);451return 0;452}453454if (i->match_id.owner != OS_AREA_DB_OWNER_ANY455&& i->match_id.owner != (int)i->idx->owner)456goto next;457if (i->match_id.key != OS_AREA_DB_KEY_ANY458&& i->match_id.key != (int)i->idx->key)459goto next;460461return 1;462}463464static int db_delete_64(struct os_area_db *db, const struct os_area_db_id *id)465{466struct db_iterator i;467468for (i.db = NULL; db_for_each_64(db, id, &i); ) {469470pr_debug("%s:%d: got (%d:%d) %llxh\n", __func__, __LINE__,471i.idx->owner, i.idx->key,472(unsigned long long)*i.value_64);473474i.idx->owner = 0;475i.idx->key = 0;476*i.value_64 = 0;477}478return 0;479}480481static int db_set_64(struct os_area_db *db, const struct os_area_db_id *id,482uint64_t value)483{484struct db_iterator i;485486pr_debug("%s:%d: (%d:%d) <= %llxh\n", __func__, __LINE__,487id->owner, id->key, (unsigned long long)value);488489if (!id->owner || id->owner == OS_AREA_DB_OWNER_ANY490|| id->key == OS_AREA_DB_KEY_ANY) {491pr_debug("%s:%d: bad id: (%d:%d)\n", __func__,492__LINE__, id->owner, id->key);493return -1;494}495496db_delete_64(db, id);497498i.db = NULL;499if (db_for_each_64(db, &os_area_db_id_empty, &i)) {500501pr_debug("%s:%d: got (%d:%d) %llxh\n", __func__, __LINE__,502i.idx->owner, i.idx->key,503(unsigned long long)*i.value_64);504505i.idx->owner = id->owner;506i.idx->key = id->key;507*i.value_64 = value;508509pr_debug("%s:%d: set (%d:%d) <= %llxh\n", __func__, __LINE__,510i.idx->owner, i.idx->key,511(unsigned long long)*i.value_64);512return 0;513}514pr_debug("%s:%d: database full.\n",515__func__, __LINE__);516return -1;517}518519static int db_get_64(const struct os_area_db *db,520const struct os_area_db_id *id, uint64_t *value)521{522struct db_iterator i;523524i.db = NULL;525if (db_for_each_64(db, id, &i)) {526*value = *i.value_64;527pr_debug("%s:%d: found %lld\n", __func__, __LINE__,528(long long int)*i.value_64);529return 0;530}531pr_debug("%s:%d: not found\n", __func__, __LINE__);532return -1;533}534535static int db_get_rtc_diff(const struct os_area_db *db, int64_t *rtc_diff)536{537return db_get_64(db, &os_area_db_id_rtc_diff, (uint64_t*)rtc_diff);538}539540#define dump_db(a) _dump_db(a, __func__, __LINE__)541static void _dump_db(const struct os_area_db *db, const char *func,542int line)543{544char str[sizeof(db->magic_num) + 1];545546dump_field(str, db->magic_num, sizeof(db->magic_num));547pr_debug("%s:%d: db.magic_num: '%s'\n", func, line,548str);549pr_debug("%s:%d: db.version: %u\n", func, line,550db->version);551pr_debug("%s:%d: db.index_64: %u\n", func, line,552db->index_64);553pr_debug("%s:%d: db.count_64: %u\n", func, line,554db->count_64);555pr_debug("%s:%d: db.index_32: %u\n", func, line,556db->index_32);557pr_debug("%s:%d: db.count_32: %u\n", func, line,558db->count_32);559pr_debug("%s:%d: db.index_16: %u\n", func, line,560db->index_16);561pr_debug("%s:%d: db.count_16: %u\n", func, line,562db->count_16);563}564565static void os_area_db_init(struct os_area_db *db)566{567enum {568HEADER_SIZE = offsetof(struct os_area_db, _db_data),569INDEX_64_COUNT = 64,570VALUES_64_COUNT = 57,571INDEX_32_COUNT = 64,572VALUES_32_COUNT = 57,573INDEX_16_COUNT = 64,574VALUES_16_COUNT = 57,575};576577memset(db, 0, sizeof(struct os_area_db));578579memcpy(db->magic_num, OS_AREA_DB_MAGIC_NUM, sizeof(db->magic_num));580db->version = 1;581db->index_64 = HEADER_SIZE;582db->count_64 = VALUES_64_COUNT;583db->index_32 = HEADER_SIZE584+ INDEX_64_COUNT * sizeof(struct db_index)585+ VALUES_64_COUNT * sizeof(u64);586db->count_32 = VALUES_32_COUNT;587db->index_16 = HEADER_SIZE588+ INDEX_64_COUNT * sizeof(struct db_index)589+ VALUES_64_COUNT * sizeof(u64)590+ INDEX_32_COUNT * sizeof(struct db_index)591+ VALUES_32_COUNT * sizeof(u32);592db->count_16 = VALUES_16_COUNT;593594/* Rules to check db layout. */595596BUILD_BUG_ON(sizeof(struct db_index) != 1);597BUILD_BUG_ON(sizeof(struct os_area_db) != 2 * OS_AREA_SEGMENT_SIZE);598BUILD_BUG_ON(INDEX_64_COUNT & 0x7);599BUILD_BUG_ON(VALUES_64_COUNT > INDEX_64_COUNT);600BUILD_BUG_ON(INDEX_32_COUNT & 0x7);601BUILD_BUG_ON(VALUES_32_COUNT > INDEX_32_COUNT);602BUILD_BUG_ON(INDEX_16_COUNT & 0x7);603BUILD_BUG_ON(VALUES_16_COUNT > INDEX_16_COUNT);604BUILD_BUG_ON(HEADER_SIZE605+ INDEX_64_COUNT * sizeof(struct db_index)606+ VALUES_64_COUNT * sizeof(u64)607+ INDEX_32_COUNT * sizeof(struct db_index)608+ VALUES_32_COUNT * sizeof(u32)609+ INDEX_16_COUNT * sizeof(struct db_index)610+ VALUES_16_COUNT * sizeof(u16)611> sizeof(struct os_area_db));612}613614/**615* update_flash_db - Helper for os_area_queue_work_handler.616*617*/618619static int update_flash_db(void)620{621const unsigned int buf_len = 8 * OS_AREA_SEGMENT_SIZE;622struct os_area_header *header;623ssize_t count;624int error;625loff_t pos;626struct os_area_db* db;627628/* Read in header and db from flash. */629630header = kmalloc(buf_len, GFP_KERNEL);631if (!header) {632pr_debug("%s: kmalloc failed\n", __func__);633return -ENOMEM;634}635636count = os_area_flash_read(header, buf_len, 0);637if (count < 0) {638pr_debug("%s: os_area_flash_read failed %zd\n", __func__,639count);640error = count;641goto fail;642}643644pos = header->db_area_offset * OS_AREA_SEGMENT_SIZE;645if (count < OS_AREA_SEGMENT_SIZE || verify_header(header) ||646count < pos) {647pr_debug("%s: verify_header failed\n", __func__);648dump_header(header);649error = -EINVAL;650goto fail;651}652653/* Now got a good db offset and some maybe good db data. */654655db = (void *)header + pos;656657error = db_verify(db);658if (error) {659pr_notice("%s: Verify of flash database failed, formatting.\n",660__func__);661dump_db(db);662os_area_db_init(db);663}664665/* Now got good db data. */666667db_set_64(db, &os_area_db_id_rtc_diff, saved_params.rtc_diff);668669count = os_area_flash_write(db, sizeof(struct os_area_db), pos);670if (count < sizeof(struct os_area_db)) {671pr_debug("%s: os_area_flash_write failed %zd\n", __func__,672count);673error = count < 0 ? count : -EIO;674}675676fail:677kfree(header);678return error;679}680681/**682* os_area_queue_work_handler - Asynchronous write handler.683*684* An asynchronous write for flash memory and the device tree. Do not685* call directly, use os_area_queue_work().686*/687688static void os_area_queue_work_handler(struct work_struct *work)689{690struct device_node *node;691int error;692693pr_debug(" -> %s:%d\n", __func__, __LINE__);694695node = of_find_node_by_path("/");696if (node) {697os_area_set_property(node, &property_rtc_diff);698of_node_put(node);699} else700pr_debug("%s:%d of_find_node_by_path failed\n",701__func__, __LINE__);702703error = update_flash_db();704if (error)705pr_warning("%s: Could not update FLASH ROM\n", __func__);706707pr_debug(" <- %s:%d\n", __func__, __LINE__);708}709710static void os_area_queue_work(void)711{712static DECLARE_WORK(q, os_area_queue_work_handler);713714wmb();715schedule_work(&q);716}717718/**719* ps3_os_area_save_params - Copy data from os area mirror to @saved_params.720*721* For the convenience of the guest the HV makes a copy of the os area in722* flash to a high address in the boot memory region and then puts that RAM723* address and the byte count into the repository for retrieval by the guest.724* We copy the data we want into a static variable and allow the memory setup725* by the HV to be claimed by the memblock manager.726*727* The os area mirror will not be available to a second stage kernel, and728* the header verify will fail. In this case, the saved_params values will729* be set from flash memory or the passed in device tree in ps3_os_area_init().730*/731732void __init ps3_os_area_save_params(void)733{734int result;735u64 lpar_addr;736unsigned int size;737struct os_area_header *header;738struct os_area_params *params;739struct os_area_db *db;740741pr_debug(" -> %s:%d\n", __func__, __LINE__);742743result = ps3_repository_read_boot_dat_info(&lpar_addr, &size);744745if (result) {746pr_debug("%s:%d ps3_repository_read_boot_dat_info failed\n",747__func__, __LINE__);748return;749}750751header = (struct os_area_header *)__va(lpar_addr);752params = (struct os_area_params *)__va(lpar_addr753+ OS_AREA_SEGMENT_SIZE);754755result = verify_header(header);756757if (result) {758/* Second stage kernels exit here. */759pr_debug("%s:%d verify_header failed\n", __func__, __LINE__);760dump_header(header);761return;762}763764db = (struct os_area_db *)__va(lpar_addr765+ header->db_area_offset * OS_AREA_SEGMENT_SIZE);766767dump_header(header);768dump_params(params);769dump_db(db);770771result = db_verify(db) || db_get_rtc_diff(db, &saved_params.rtc_diff);772if (result)773saved_params.rtc_diff = params->rtc_diff ? params->rtc_diff774: SECONDS_FROM_1970_TO_2000;775saved_params.av_multi_out = params->av_multi_out;776saved_params.valid = 1;777778memset(header, 0, sizeof(*header));779780pr_debug(" <- %s:%d\n", __func__, __LINE__);781}782783/**784* ps3_os_area_init - Setup os area device tree properties as needed.785*/786787void __init ps3_os_area_init(void)788{789struct device_node *node;790791pr_debug(" -> %s:%d\n", __func__, __LINE__);792793node = of_find_node_by_path("/");794795if (!saved_params.valid && node) {796/* Second stage kernels should have a dt entry. */797os_area_get_property(node, &property_rtc_diff);798os_area_get_property(node, &property_av_multi_out);799}800801if(!saved_params.rtc_diff)802saved_params.rtc_diff = SECONDS_FROM_1970_TO_2000;803804if (node) {805os_area_set_property(node, &property_rtc_diff);806os_area_set_property(node, &property_av_multi_out);807of_node_put(node);808} else809pr_debug("%s:%d of_find_node_by_path failed\n",810__func__, __LINE__);811812pr_debug(" <- %s:%d\n", __func__, __LINE__);813}814815/**816* ps3_os_area_get_rtc_diff - Returns the rtc diff value.817*/818819u64 ps3_os_area_get_rtc_diff(void)820{821return saved_params.rtc_diff;822}823EXPORT_SYMBOL_GPL(ps3_os_area_get_rtc_diff);824825/**826* ps3_os_area_set_rtc_diff - Set the rtc diff value.827*828* An asynchronous write is needed to support writing updates from829* the timer interrupt context.830*/831832void ps3_os_area_set_rtc_diff(u64 rtc_diff)833{834if (saved_params.rtc_diff != rtc_diff) {835saved_params.rtc_diff = rtc_diff;836os_area_queue_work();837}838}839EXPORT_SYMBOL_GPL(ps3_os_area_set_rtc_diff);840841/**842* ps3_os_area_get_av_multi_out - Returns the default video mode.843*/844845enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void)846{847return saved_params.av_multi_out;848}849EXPORT_SYMBOL_GPL(ps3_os_area_get_av_multi_out);850851852