diff options
author | Geoff Levand <geoffrey.levand@am.sony.com> | 2008-01-25 16:06:57 -0800 |
---|---|---|
committer | Geoff Levand <geoffrey.levand@am.sony.com> | 2008-01-25 16:06:57 -0800 |
commit | 4403c14bf15616cdac566c6061d491dcb6652803 (patch) | |
tree | a376e1054c287a8b5c1f5fa5e258deba0a0f051e | |
parent | 1344b790af5662956060b9cec21c965231ea6173 (diff) | |
download | ps3-utils-4403c14bf15616cdac566c6061d491dcb6652803.tar.gz |
ps3-flash-util: Add new option --game-time.
-rw-r--r-- | ps3-flash-util.8 | 4 | ||||
-rw-r--r-- | ps3-flash-util.c | 108 |
2 files changed, 66 insertions, 46 deletions
diff --git a/ps3-flash-util.8 b/ps3-flash-util.8 index b92587e..bae879e 100644 --- a/ps3-flash-util.8 +++ b/ps3-flash-util.8 @@ -40,6 +40,7 @@ .Op Fl w, -write-image Ar image-file .Op Fl g, -set-game-os | Fl o, -set-other-os .Op Fl r, -set-raw | Fl z, -set-gzip +.Op Fl t, -game-time .Op Fl F, -db-format .Op Fl P, -db-print Ar owner Ar key .Op Fl D, -db-write-dword Ar owner Ar key Ar dword @@ -87,6 +88,9 @@ Set the Other OS image compression flag to raw (not compressed). .It Fl z, -set-gzip Set the Other OS image compression flag to gzip compressed. .\" +.It Fl t, -game-time +Print the Game OS RTC diff value. +.\" .It Fl F, -db-format Format (write) an empty Other OS database to flash memory. Any existing data in the flash memory will be lost. diff --git a/ps3-flash-util.c b/ps3-flash-util.c index 8993b13..22223d3 100644 --- a/ps3-flash-util.c +++ b/ps3-flash-util.c @@ -70,6 +70,33 @@ struct db_op_entry { struct db_op_entry *next; }; +static int db_opt_add(struct db_op_entry** list, const struct db_op_entry *e) +{ + struct db_op_entry *p; + + DBG("%s:%d: (%d:%d) = %llu (%llxh)\n", __func__, __LINE__, + (unsigned int)e->id.owner, (unsigned int)e->id.key, + (unsigned long long)e->value, (unsigned long long)e->value); + + if (!*list) { + /* init list */ + *list = malloc(sizeof(struct db_op_entry)); + p = *list; + } else { + /* add to list */ + p = *list; + while(p->next) + p = p->next; + p->next = malloc(sizeof(struct db_op_entry)); + p = p->next; + } + + *p = *e; + p->next = 0; + + return 0; +} + static void print_version(void) { printf(PS3_UTILS_VERSION); @@ -83,8 +110,8 @@ static void print_usage(void) " ps3-flash-util [-d, --device flash-dev] [-s, --show-settings]\n" " [-w, --write-image image-file]\n" " [-g, --set-game-os | -o, --set-other-os]\n" -" [-r, --set-raw | -z, --set-gzip] [-F, --db-format]\n" -" [-P, --db-print owner key]\n" +" [-r, --set-raw | -z, --set-gzip] [-t, --game-time]\n" +" [-F, --db-format] [-P, --db-print owner key]\n" " [-D, --db-write-dword owner key dword]\n" " [-W, --db-write-word owner key word]\n" " [-H, --db-write-half owner key half]\n" @@ -116,6 +143,9 @@ static void print_usage(void) " -z, --set-gzip\n" " Set the Other OS image compression flag to gzip compressed.\n" "\n" +" -t, --game-time\n" +" Print the Game OS RTC diff value.\n" +"\n" " -F, --db-format\n" " Format (write) an empty Other OS database to flash memory. Any\n" " existing data in the flash memory will be lost.\n" @@ -167,6 +197,7 @@ static const struct option long_options[] = { {"set-other-os", no_argument, NULL, 'o'}, {"set-raw", no_argument, NULL, 'r'}, {"set-gzip", no_argument, NULL, 'z'}, + {"game-time", no_argument, NULL, 't'}, {"db-format", no_argument, NULL, 'F'}, {"db-print", required_argument, NULL, 'P'}, {"db-write-dword", required_argument, NULL, 'D'}, @@ -180,7 +211,7 @@ static const struct option long_options[] = { { NULL, 0, NULL, 0}, }; -static const char short_options[] = "d:sw:gorzFP:D:W:H:R:LhvV"; +static const char short_options[] = "d:sw:gorztFP:D:W:H:R:LhvV"; /** * enum opt_value - Tri-state options variables. @@ -197,6 +228,7 @@ struct opts { unsigned int show_version; unsigned int show_help; unsigned int show_settings; + unsigned int show_game_time; unsigned int boot_other_os; unsigned int compressed_image; unsigned int db_format; @@ -206,28 +238,6 @@ struct opts { const char *image; }; -static void opts_dump(const struct opts* opts) -{ - struct db_op_entry *p; - - DBG("verbosity %d\n", opts->verbosity); - DBG("show_version %d\n", opts->show_version); - DBG("show_help %d\n", opts->show_help); - DBG("show_settings %d\n", opts->show_settings); - DBG("boot_other_os %d\n", opts->boot_other_os); - DBG("compressed_image %d\n", opts->compressed_image); - DBG("db_format %d\n", opts->db_format); - DBG("db_list_owners %d\n", opts->db_list_owners); - DBG("device %s\n", opts->device); - DBG("image %s\n", opts->image); - - DBG("db_op_list %p\n", opts->db_op_list); - for (p = opts->db_op_list; p; p = p->next) { - DBG(" %p: type %d, (%d:%d) = %llu\n", p, p->type, p->id.owner, - p->id.key, (unsigned long long)p->value); - } -} - static void show_settings(const struct os_area_header *h, const struct os_area_params *p, const struct os_area_db *db) { @@ -290,11 +300,9 @@ static int pickup_db_op_entry(char *argv[], enum db_op_type type, { int result; struct db_op_entry e; - struct db_op_entry *p; unsigned long long values[3]; unsigned int i; - memset(&e, 0, sizeof(struct db_op_entry)); values[0] = values[1] = values[2] = 0; for (i = 0; i < required; i++) { @@ -333,29 +341,33 @@ static int pickup_db_op_entry(char *argv[], enum db_op_type type, return -1; } + memset(&e, 0, sizeof(struct db_op_entry)); e.type = type; e.id.owner = values[0]; e.id.key = values[1]; e.value = values[2]; - DBG("%s:%d: %s (%d:%d) = %llu (%llxh)\n", __func__, __LINE__, - argv[0], (unsigned int)e.id.owner, (unsigned int)e.id.key, - (unsigned long long)e.value, (unsigned long long)e.value); + db_opt_add(list, &e); + return 0; +} - if (!*list) { - /* init list */ - *list = malloc(sizeof(struct db_op_entry)); - p = *list; - } else { - /* add to list */ - p = *list; - while(p->next) - p = p->next; - p->next = malloc(sizeof(struct db_op_entry)); - p = p->next; - } +static int add_db_op_entry(enum db_op_type type, enum os_area_db_owner owner, + enum os_area_db_key key, const char *optarg, struct db_op_entry** list) +{ + int result; + struct db_op_entry e; + + memset(&e, 0, sizeof(struct db_op_entry)); + e.type = type; + e.id.owner = owner; + e.id.key = key; + result = sscanf(optarg, "%Li", &e.value); - *p = e; + if (result != 1) { + fprintf(stderr, "bad option: at '%s'\n", optarg); + return -1; + } + db_opt_add(list, &e); return 0; } @@ -414,6 +426,10 @@ static int opts_parse(struct opts* opts, int argc, char *argv[]) opts->compressed_image = opt_no; got_work++; break; + case 't': + opts->show_game_time = opt_yes; + got_work++; + break; case 'F': opts->db_format = opt_yes; got_work++; @@ -573,9 +589,6 @@ int main(int argc, char *argv[]) result = opts_parse(&opts, argc, argv); - if (opts.verbosity >= 3) - opts_dump(&opts); - if (result) { print_usage(); DBG("%s:%d: failed.\n", __func__, __LINE__); @@ -621,6 +634,9 @@ int main(int argc, char *argv[]) } } + if (opts.show_game_time) + printf("%llu\n", params.rtc_diff); + found_db = !os_area_db_read(&db, &header, dev); if (opts.show_settings) |