ps3: Make ps3-bl-option executable
[openwrt.git] / target / linux / ps3 / petitboot / base-files / sbin / ps3-bl-option
1 #!/bin/sh
2 #
3 # Copyright (C) 2008 Sony Computer Entertainment Inc.
4 # Copyright 2008 Sony Corp.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # 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 of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #
19
20 usage() {
21 echo -n "
22 SYNOPSIS
23 ps3-bl-option [OPTION]
24 DESCRIPTION
25 Get and set PS3 bootloader options in flash.
26 OPTIONS
27 -m, --get-video-mode
28 Get the bootloader video mode.
29 -M, --set-video-mode value
30 Set the bootloader video mode.
31 -o, --get-bootloader-timeout
32 Get the bootloader timeout in seconds.
33 -O, --set-bootloader-timeout value
34 Set the bootloader timeout in seconds.
35 -p, --get-bootloader-default
36 Get the default bootloader menu item.
37 -P, --set-bootloader-default value
38 Set the default bootloader menu item.
39 -t, --get-telnet-enabled
40 Get the telnet enabled flag.
41 -T, --set-telnet-enabled value
42 Set the telnet enabled flag.
43 -h, --help
44 Print a help message.
45 SEE ALSO
46 ps3-flash-util(8)
47 "
48 }
49
50 bad_arg() {
51 echo "ERROR: bad arg" >&2;
52 usage
53 exit 1
54 }
55
56 if [ "$#" -eq 0 ] ; then
57 bad_arg
58 fi
59
60 get_flag() {
61 flags=`ps3-flash-util --db-print $1 $2`
62 echo $(( ${flags:-0} & $3 ))
63 }
64
65 set_flag() {
66 flags=`ps3-flash-util --db-print $1 $2`
67
68 if [ $4 -eq 0 ]; then
69 ps3-flash-util --db-write-half $1 $2 $(( ${flags:-0} & ~$3 ))
70 else
71 ps3-flash-util --db-write-half $1 $2 $(( ${flags:-0} | $3 ))
72 fi
73 }
74
75 # owners
76 bootloader="3"
77
78 # keys
79 item="1"
80 video="2"
81 flags="3"
82 timeout="4"
83
84 # flags
85 telnet="1"
86
87 case "$1" in
88 -m | --get-video-mode)
89 ps3-flash-util --db-print ${bootloader} ${video}
90 ;;
91 -M | --set-video-mode)
92 ps3-flash-util --db-write-half ${bootloader} ${video} $2
93 ;;
94 -o | --get-bootloader-timeout)
95 ps3-flash-util --db-print ${bootloader} ${timeout}
96 ;;
97 -O | --set-bootloader-timeout)
98 ps3-flash-util --db-write-half ${bootloader} ${timeout} $2
99 ;;
100 -p | --get-bootloader-default)
101 ps3-flash-util --db-print ${bootloader} ${item}
102 ;;
103 -P | --set-bootloader-default)
104 ps3-flash-util --db-write-word ${bootloader} ${item} $2
105 ;;
106 -t | --get-telnet-enabled)
107 get_flag ${bootloader} ${flags} ${telnet}
108 ;;
109 -T | --set-telnet-enabled)
110 set_flag ${bootloader} ${flags} ${telnet} $2
111 ;;
112 -h | --help)
113 usage
114 exit 0
115 ;;
116 *)
117 bad_arg
118 ;;
119 esac
This page took 0.042702 seconds and 5 git commands to generate.