diff options
author | Geoff Levand <geoffrey.levand@am.sony.com> | 2008-01-25 17:54:10 -0800 |
---|---|---|
committer | Geoff Levand <geoffrey.levand@am.sony.com> | 2008-01-25 17:54:10 -0800 |
commit | d1d0312559745aaa7579e5a613ab9b283f98cb53 (patch) | |
tree | 4c5cbf709700fa76314111ea66bf4252ab81eb89 | |
parent | 4403c14bf15616cdac566c6061d491dcb6652803 (diff) | |
download | ps3-utils-d1d0312559745aaa7579e5a613ab9b283f98cb53.tar.gz |
ps3-rtc-init: New utility.
-rw-r--r-- | Makefile.am | 23 | ||||
-rw-r--r-- | lib/flash-db.c | 2 | ||||
-rw-r--r-- | lib/flash.c | 2 | ||||
-rw-r--r-- | ps3-boot-game-os.8 | 4 | ||||
-rw-r--r-- | ps3-boot-game-os.in | 23 | ||||
-rw-r--r-- | ps3-dump-bootloader.8 | 4 | ||||
-rw-r--r-- | ps3-dump-bootloader.in | 25 | ||||
-rw-r--r-- | ps3-flash-util.c | 2 | ||||
-rw-r--r-- | ps3-rtc-init.8 | 71 | ||||
-rw-r--r-- | ps3-rtc-init.in | 117 |
10 files changed, 247 insertions, 26 deletions
diff --git a/Makefile.am b/Makefile.am index dff6327..9ec35c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,19 +32,22 @@ MAINTAINERCLEANFILES = Makefile.in composed_sbin_scripts = \ ps3-boot-game-os \ - ps3-dump-bootloader + ps3-dump-bootloader \ + ps3-rtc-init sbin_SCRIPTS = \ $(composed_sbin_scripts) -bin_PROGRAMS = \ - ps3-video-mode - sbin_PROGRAMS = \ - ps3-flash-util + ps3-flash-util \ + ps3-video-mode -man_MANS = \ - ps3-flash-util.8 +man_MANS = \ + ps3-boot-game-os.8 \ + ps3-dump-bootloader.8 \ + ps3-flash-util.8 \ + ps3-rtc-init.8 \ + ps3-video-mode.8 CLEANFILES = $(composed_sbin_scripts) @@ -91,3 +94,9 @@ ps3-dump-bootloader: Makefile $(srcdir)/ps3-dump-bootloader.in $(edit) $(srcdir)/$@.in >$@.tmp chmod +x $@.tmp mv $@.tmp $@ + +ps3-rtc-init: Makefile $(srcdir)/ps3-rtc-init.in + rm -f $@ $@.tmp + $(edit) $(srcdir)/$@.in >$@.tmp + chmod +x $@.tmp + mv $@.tmp $@ diff --git a/lib/flash-db.c b/lib/flash-db.c index 00952ea..33a7631 100644 --- a/lib/flash-db.c +++ b/lib/flash-db.c @@ -23,7 +23,7 @@ #include "ps3-flash.h" #if defined(DEBUG) -#define DBG(_args...) do {printf(_args);} while(0) +#define DBG(_args...) do {fprintf(stderr, _args);} while(0) #else static inline int __attribute__ ((format (printf, 1, 2))) diff --git a/lib/flash.c b/lib/flash.c index 6dc0128..f6ded23 100644 --- a/lib/flash.c +++ b/lib/flash.c @@ -24,7 +24,7 @@ #include "ps3-flash.h" #if defined(DEBUG) -#define DBG(_args...) do {printf(_args);} while(0) +#define DBG(_args...) do {fprintf(stderr, _args);} while(0) #else static inline int __attribute__ ((format (printf, 1, 2))) diff --git a/ps3-boot-game-os.8 b/ps3-boot-game-os.8 index d4130c2..3ae89f3 100644 --- a/ps3-boot-game-os.8 +++ b/ps3-boot-game-os.8 @@ -37,7 +37,7 @@ .Nm .Op Fl n, -no-reboot | Fl p, -poweroff .Op Fl h, -help -.Op Fl -version +.Op Fl V, -version .\" .Sh DESCRIPTION .\" =========== @@ -57,7 +57,7 @@ Power the system off after setting the boot flag. .It Fl h, -help Print a help message. .\" -.It Fl -version +.It Fl V, -version Display the program version number. .El .Sh SEE ALSO diff --git a/ps3-boot-game-os.in b/ps3-boot-game-os.in index 4cdf436..1a9c3bc 100644 --- a/ps3-boot-game-os.in +++ b/ps3-boot-game-os.in @@ -23,25 +23,35 @@ usage() { echo "ps3-boot-game-os (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2 echo "" >&2 echo "DESCRIPTION" >&2 - echo " Set the PS3 boot flag and reboot to game OS" >&2 + echo " The ps3-boot-game-os utility will set the system boot flag to Game OS and" >&2 + echo " reboot the system. The system will reboot into the Game OS." >&2 echo "" >&2 echo "OPTIONS" >&2 - echo " -h, --help" >&2 - echo " Print a help message." >&2 - echo "" >&2 echo " -n, --no-reboot" >&2 echo " Don't reboot system after setting boot flag." >&2 echo "" >&2 echo " -p, --poweroff" >&2 echo " Poweroff system after setting boot flag." >&2 + echo "" >&2 + echo " -h, --help" >&2 + echo " Print a help message." >&2 + echo "" >&2 + echo " -V, -version" >&2 + echo " Display the program version number." >&2 + echo "" >&2 echo "SEE ALSO" >&2 - echo " ps3-flash-util" >&2 + echo " ps3-flash-util(8)" >&2 echo "" >&2 echo "Send bug reports to @PACKAGE_BUGREPORT@" >&2 echo "" >&2 exit 1 } +version() { + echo "ps3-boot-game-os (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2 + exit 1 +} + cmd="reboot" while [ "$#" -gt 0 ]; do @@ -52,6 +62,9 @@ while [ "$#" -gt 0 ]; do -p | --poweroff) cmd="poweroff" ;; + --version | -V) + version + ;; *) usage ;; diff --git a/ps3-dump-bootloader.8 b/ps3-dump-bootloader.8 index 018f30a..e0656ff 100644 --- a/ps3-dump-bootloader.8 +++ b/ps3-dump-bootloader.8 @@ -37,7 +37,7 @@ .Nm .Op Fl s, -sum .Op Fl h, -help -.Op Fl -version +.Op Fl V, -version .\" .Sh DESCRIPTION .\" =========== @@ -54,7 +54,7 @@ Compute the md5sum of the Other OS image and only print it to stdout. .It Fl h, -help Print a help message. .\" -.It Fl -version +.It Fl V, -version Display the program version number. .El .Sh SEE ALSO diff --git a/ps3-dump-bootloader.in b/ps3-dump-bootloader.in index 3042a8a..ee88869 100644 --- a/ps3-dump-bootloader.in +++ b/ps3-dump-bootloader.in @@ -1,7 +1,5 @@ #!/bin/sh # -# Dump the bootloader from PS3 flash memory to stdout -# # Copyright (C) 2008 Sony Computer Entertainment Inc. # Copyright 2008 Sony Corp. # @@ -23,23 +21,33 @@ usage() { echo "ps3-dump-bootloader (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2 echo "" >&2 echo "DESCRIPTION" >&2 - echo " Dump the bootloader from PS3 flash memory to stdout" >&2 + echo " The ps3-dump-bootloader utility will dump the Other OS binary image from" >&2 + echo " PS3 flash memory to stdout." >&2 echo "" >&2 echo "OPTIONS" >&2 + echo " -s, --sum" >&2 + echo " Compute the md5sum of the Other OS image and only print it to" >&2 + echo " stdout." >&2 + echo "" >&2 echo " -h, --help" >&2 echo " Print a help message." >&2 echo "" >&2 - echo " -s, --sum" >&2 - echo " Compute the md5sum and print it to stdout." >&2 - echo "SEE ALSO" >&2 - echo " ps3-flash-util, md5sum" >&2 + echo " -V, -version" >&2 + echo " Display the program version number." >&2 echo "" >&2 + echo "SEE ALSO" >&2 + echo " ps3-flash-util(8), md5sum(1)" >&2 echo "" >&2 echo "Send bug reports to @PACKAGE_BUGREPORT@" >&2 echo "" >&2 exit 1 } +version() { + echo "ps3-dump-bootloader (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2 + exit 1 +} + sum= while [ "$#" -gt 0 ]; do @@ -47,6 +55,9 @@ while [ "$#" -gt 0 ]; do --sum | -s) sum="y" ;; + --version | -V) + version + ;; *) usage ;; diff --git a/ps3-flash-util.c b/ps3-flash-util.c index 22223d3..cbd5f22 100644 --- a/ps3-flash-util.c +++ b/ps3-flash-util.c @@ -43,7 +43,7 @@ #endif #if defined(DEBUG) -#define DBG(_args...) do {printf(_args);} while(0) +#define DBG(_args...) do {fprintf(stderr, _args);} while(0) #else static inline int __attribute__ ((format (printf, 1, 2))) diff --git a/ps3-rtc-init.8 b/ps3-rtc-init.8 new file mode 100644 index 0000000..e24d471 --- /dev/null +++ b/ps3-rtc-init.8 @@ -0,0 +1,71 @@ +.\" PS3 flash memory utility +.\" +.\" Copyright (C) 2008 Sony Computer Entertainment Inc. +.\" Copyright 2008 Sony Corp. +.\" +.\" This library is free software; you can redistribute it and/or +.\" modify it under the terms of the GNU Library General Public +.\" License as published by the Free Software Foundation; +.\" version 2 of the License. +.\" +.\" This library 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 +.\" Library General Public License for more details. +.\" +.\" You should have received a copy of the GNU Library General Public +.\" License along with this library; if not, write to the Free Software +.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +.\" +.\" Maintainer's Notes: +.\" * For syntax help see the man pages for 'mdoc' and 'mdoc.samples'. +.\" * To check syntax use this: +.\" 'groff -C -mtty-char -Tutf8 -man ps3-rtc-init.8'. +.\" * To check format use this: 'less ps3-rtc-init.8'. +.\" +.Dd "" +.Dt ps3-rtc-init 8 +.Os +.\" +.Sh NAME +.\" ==== +.Nm ps3-rtc-init +.Nd PS3 RTC init utility +.\" +.Sh SYNOPSIS +.\" ======== +.Nm +.Op Fl f, -force +.Op Fl h, -help +.Op Fl V, -version +.\" +.Sh DESCRIPTION +.\" =========== +The ps3-rtc-init utility is used to initialize the Linux RTC diff value +in PS3 flash memory to that currently in use by the Game OS. The default +behavior is to not overwrite an existing value. +.\" +.Sh OPTIONS +.\" ======= +.Bl -tag -width indent +.\" +.It Fl f, -force +Overwrite any existing Linux RTC diff value in flash memory. +.\" +.It Fl h, -help +Print a help message. +.\" +.It Fl V, -version +Display the program version number. +.El +.Sh SEE ALSO +.\" ======== +.Xr ps3-flash-util 8 +.\" +.Sh AUTHOR +.\" ====== +Written by Geoff Levand. +.\" +.Sh REPORTING BUGS +.\" ============== +Report bugs to Geoff Levand <geoffrey.levand@am.sony.com>. diff --git a/ps3-rtc-init.in b/ps3-rtc-init.in new file mode 100644 index 0000000..9fb6173 --- /dev/null +++ b/ps3-rtc-init.in @@ -0,0 +1,117 @@ +#!/bin/sh +# +# Copyright (C) 2008 Sony Computer Entertainment Inc. +# Copyright 2008 Sony Corp. +# +# This program 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; version 2 of the License. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +usage() { + echo "ps3-init-rtc (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2 + echo "" >&2 + echo "DESCRIPTION" >&2 + echo " The ps3-rtc-init utility is used to initialize the Linux RTC diff value" >&2 + echo " in PS3 flash memory to that currently in use by the Game OS. The default" >&2 + echo " behavior is to not overwrite an existing value." >&2 + echo "" >&2 + echo "OPTIONS" >&2 + echo " -f, --force" >&2 + echo " Overwrite any existing Linux RTC diff value in flash memory." >&2 + echo "" >&2 + echo " -h, --help" >&2 + echo " Print a help message." >&2 + echo "" >&2 + echo " -V, -version" >&2 + echo " Display the program version number." >&2 + echo "" >&2 + echo "SEE ALSO" >&2 + echo " ps3-flash-util(8)" >&2 + echo "" >&2 + echo "Send bug reports to @PACKAGE_BUGREPORT@" >&2 + echo "" >&2 + exit 1 +} + +version() { + echo "ps3-init-rtc (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2 + exit 1 +} + +force= + +while [ "$#" -gt 0 ]; do + case "$1" in + --force | -f) + force="y" + ;; + --version | -V) + version + ;; + *) + usage + ;; + esac + shift +done + +game_time=`@prefix@/sbin/ps3-flash-util --game-time` + +if [ $? -ne 0 ]; then + echo "ERROR: Can't read game-time." 2>&1; + exit 1; +fi + +if [ "${force}" ]; then + @prefix@/sbin/ps3-flash-util --db-write-dword 2 1 ${game_time} + + if [ $? -ne 0 ]; then + @prefix@/sbin/ps3-flash-util --db-format + + if [ $? -ne 0 ]; then + echo "ERROR: Can't format flash." 2>&1; + exit 1; + fi + @prefix@/sbin/ps3-flash-util --db-write-dword 2 1 ${game_time} + fi + + if [ $? -ne 0 ]; then + echo "ERROR: Can't set rtc diff." 2>&1; + exit 1; + fi +else + other_time=`@prefix@/sbin/ps3-flash-util --db-print 2 1` + + if [ $? -ne 0 ]; then + echo "ERROR: can't read database. Use -f to re-format." 2>&1; + exit 1; + fi + + other_time=`echo ${other_time} | egrep -o '\([0-9]+\)' | egrep -o '[0-9]+'` + + if [ ${other_time} ]; then + echo "WARNING: rtc diff already set." 2>&1; + exit 1; + fi + + @prefix@/sbin/ps3-flash-util --db-write-dword 2 1 ${game_time} + + if [ $? -ne 0 ]; then + echo "ERROR: can't read database. Use -f to re-format." 2>&1; + exit 1; + fi +fi + +echo "Set rtc diff:${game_time}" 2>&1; + +exit 0
\ No newline at end of file |