bl-option 2.8 KB

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