[kernel] refresh patches against 2.6.27 final
[openwrt.git] / target / linux / ps3 / base-files / sbin / 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 "" >&2
22 echo "SYNOPSIS" >&2
23 echo " bl-option [OPTION]" >&2
24 echo "" >&2
25 echo "DESCRIPTION" >&2
26 echo " Get and set PS3 bootloader options in flash." >&2
27 echo "" >&2
28 echo "OPTIONS" >&2
29 echo " -m, --get-video-mode" >&2
30 echo " Get the bootloader video mode." >&2
31 echo "" >&2
32 echo " -M, --set-video-mode value" >&2
33 echo " Set the bootloader video mode." >&2
34 echo "" >&2
35 echo " -p, --get-petitboot-default" >&2
36 echo " Get the default Petitboot menu item." >&2
37 echo "" >&2
38 echo " -P, --set-petitboot-default value" >&2
39 echo " Set the default Petitboot menu item." >&2
40 echo "" >&2
41 echo " -t, --get-telnet-enabled" >&2
42 echo " Get the telnet enabled flag." >&2
43 echo "" >&2
44 echo " -T, --set-telnet-enabled value" >&2
45 echo " Set the telnet enabled flag." >&2
46 echo "" >&2
47 echo " -h, --help" >&2
48 echo " Print a help message." >&2
49 echo "" >&2
50 echo "SEE ALSO" >&2
51 echo " ps3-flash-util(8)" >&2
52 echo "" >&2
53 exit 1
54 }
55
56 if [ "$#" -eq 0 ] ; then
57 echo "ERROR: bad arg" >&2;
58 usage
59 fi
60
61 get_flag() {
62 flags=`ps3-flash-util --db-print $1 $2`
63 echo $(( ${flags:-0} & $3 ))
64 }
65
66 set_flag() {
67 flags=`ps3-flash-util --db-print $1 $2`
68
69 if [ $4 -eq 0 ]; then
70 ps3-flash-util --db-write-half $1 $2 $(( ${flags:-0} & ~$3 ))
71 else
72 ps3-flash-util --db-write-half $1 $2 $(( ${flags:-0} | $3 ))
73 fi
74 }
75
76 # owners
77 petitboot="3"
78
79 # keys
80 menu="1"
81 video="2"
82 flags="3"
83
84 # flags
85 telnet="1"
86
87 case "$1" in
88 -m | --get-video-mode)
89 ps3-flash-util --db-print ${petitboot} ${video}
90 ;;
91 -M | --set-video-mode)
92 ps3-flash-util --db-write-half ${petitboot} ${video} $2
93 ;;
94 -p | --get-petitboot-default)
95 ps3-flash-util --db-print ${petitboot} ${menu}
96 ;;
97 -P | --set-petitboot-default)
98 ps3-flash-util --db-write-word ${petitboot} ${menu} $2
99 ;;
100 -t | --get-telnet-enabled)
101 get_flag ${petitboot} ${flags} ${telnet}
102 ;;
103 -T | --set-telnet-enabled)
104 set_flag ${petitboot} ${flags} ${telnet} $2
105 ;;
106 -h | --help)
107 usage
108 ;;
109 *)
110 echo "ERROR: bad arg $1" >&2;
111 usage
112 ;;
113 esac
This page took 0.070719 seconds and 5 git commands to generate.