Advertisement
ShrewdSpirit

SimpleBootLoader

Oct 24th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1.  
  2. -- bootdevice has been passed to this boot loader from Spirit Loader
  3. local bd = bootdevice
  4.  
  5. bd.gpu.setForeground(0xFFFF00)
  6. bd:clear()
  7. bd:print('Simple boot loader!')
  8. bd:print('')
  9.  
  10. bd.gpu.setForeground(0x00FF00)
  11. bd:print('List of available components:')
  12. bd.gpu.setForeground(0x00FFFF)
  13. for address in bd.ls() do
  14.     local devtype = bd.type(address)
  15.     bd:print(string.format('%s: %s', devtype, address))
  16. end
  17. bd.gpu.setForeground(0xFFFF00)
  18.  
  19. bd:print''
  20. bd:print'Press r to restart / s to shutdown'
  21.  
  22. -- reboot if r is pressed, shutdown if s is pressed
  23. while true do
  24.     e = table.pack(bd:pullsig())
  25.     if e[1] == 'key_up' then
  26.         if string.char(e[3]) == 'r' then
  27.             bd.comp.shutdown(true)
  28.         elseif string.char(e[3]) == 's' then
  29.             bd.comp.shutdown(false)
  30.         end
  31.     end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement