ps3-bl-option 2.8 KB

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