| #!/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-dump-bootloader (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2 |
| echo "DESCRIPTION" >&2 |
| echo " The ps3-dump-bootloader utility will dump the Other OS binary image from" >&2 |
| echo " PS3 flash memory to stdout." >&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. Takes about 30 seconds to compute." >&2 |
| echo " -h, --help" >&2 |
| echo " Print a help message." >&2 |
| echo " -V, -version" >&2 |
| echo " Display the program version number." >&2 |
| echo "SEE ALSO" >&2 |
| echo " ps3-flash-util(8), md5sum(1)" >&2 |
| echo "Send bug reports to @PACKAGE_BUGREPORT@" >&2 |
| exit 1 |
| } |
| |
| version() { |
| echo "ps3-dump-bootloader (@PACKAGE_NAME@) @PACKAGE_VERSION@" |
| exit 1 |
| } |
| |
| sum= |
| |
| while [ "$#" -gt 0 ]; do |
| case "$1" in |
| --sum | -s) |
| sum="y" |
| ;; |
| --version | -V) |
| version |
| ;; |
| *) |
| usage |
| ;; |
| esac |
| shift |
| done |
| |
| |
| ldr_size=`@prefix@/sbin/ps3-flash-util -s \ |
| | grep 'h\.ldr_size' \ |
| | tr -d ' ' | cut -d':' -f4 | cut -d'(' -f1` |
| |
| if [ ! "$ldr_size" ]; then |
| echo "ERROR: can't dump image" >&2; |
| exit 1; |
| fi |
| |
| ldr_offset=`@prefix@/sbin/ps3-flash-util -s \ |
| | grep 'h\.ldr_area_offset' \ |
| | tr -d ' ' | cut -d':' -f4` |
| |
| if [ ! "ldr_offset" ]; then |
| echo "ERROR: can't dump image" >&2; |
| exit 1; |
| fi |
| |
| ldr_offset=$((512 * ldr_offset)) |
| |
| if [ "$sum" ]; then |
| dd if=/dev/ps3flash bs=1 skip=$ldr_offset count=$ldr_size | md5sum |
| else |
| dd if=/dev/ps3flash bs=1 skip=$ldr_offset count=$ldr_size |
| fi |