core.lua (f0cb3b6b258df56324123c8732a9b5470a88383c) | core.lua (6d3bcc06e27a9f0c860770442b50dd9650dc8e24) |
---|---|
1-- 2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 3-- All rights reserved. 4-- 5-- Redistribution and use in source and binary forms, with or without 6-- modification, are permitted provided that the following conditions 7-- are met: 8-- 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 33local compose_loader_cmd = function(cmd_name, argstr) 34 if (argstr ~= nil) then 35 cmd_name = cmd_name .. " " .. argstr; 36 end 37 return cmd_name; 38end 39 | 1-- 2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 3-- All rights reserved. 4-- 5-- Redistribution and use in source and binary forms, with or without 6-- modification, are permitted provided that the following conditions 7-- are met: 8-- 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 33local compose_loader_cmd = function(cmd_name, argstr) 34 if (argstr ~= nil) then 35 cmd_name = cmd_name .. " " .. argstr; 36 end 37 return cmd_name; 38end 39 |
40-- Internal function |
|
40-- Parses arguments to boot and returns two values: kernel_name, argstr 41-- Defaults to nil and "" respectively. | 41-- Parses arguments to boot and returns two values: kernel_name, argstr 42-- Defaults to nil and "" respectively. |
42local parse_boot_args = function(argv) | 43-- This will also parse arguments to autoboot, but the with_kernel argument 44-- will need to be explicitly overwritten to false 45local parse_boot_args = function(argv, with_kernel) |
43 if (#argv == 0) then 44 return nil, ""; 45 end | 46 if (#argv == 0) then 47 return nil, ""; 48 end |
49 if (with_kernel == nil) then 50 with_kernel = true; 51 end |
|
46 local kernel_name; 47 local argstr = ""; 48 49 for k, v in ipairs(argv) do | 52 local kernel_name; 53 local argstr = ""; 54 55 for k, v in ipairs(argv) do |
50 if (v:sub(1,1) ~= "-") then | 56 if (with_kernel) and (v:sub(1,1) ~= "-") then |
51 kernel_name = v; 52 else 53 argstr = argstr .. " " .. v; 54 end 55 end | 57 kernel_name = v; 58 else 59 argstr = argstr .. " " .. v; 60 end 61 end |
56 return kernel_name, argstr; | 62 if (with_kernel) then 63 return kernel_name, argstr; 64 else 65 return argstr; 66 end |
57end 58 59-- Globals 60function boot(...) 61 local argv = {...}; 62 local cmd_name = ""; 63 cmd_name, argv = core.popFrontTable(argv); 64 local kernel, argstr = parse_boot_args(argv); 65 if (kernel ~= nil) then 66 loader.perform("unload"); 67 config.selectkernel(kernel); 68 end 69 core.boot(argstr); 70end 71 | 67end 68 69-- Globals 70function boot(...) 71 local argv = {...}; 72 local cmd_name = ""; 73 cmd_name, argv = core.popFrontTable(argv); 74 local kernel, argstr = parse_boot_args(argv); 75 if (kernel ~= nil) then 76 loader.perform("unload"); 77 config.selectkernel(kernel); 78 end 79 core.boot(argstr); 80end 81 |
82function autoboot(...) 83 local argv = {...} 84 local cmd_name = ""; 85 cmd_name, argv = core.popFrontTable(argv); 86 local argstr = parse_boot_args(argv, false); 87 core.autoboot(argstr); 88end 89 |
|
72-- Module exports 73-- Commonly appearing constants 74core.KEY_BACKSPACE = 8; 75core.KEY_ENTER = 13; 76core.KEY_DELETE = 127; 77 78core.KEYSTR_ESCAPE = "\027"; 79 --- 228 unchanged lines hidden --- | 90-- Module exports 91-- Commonly appearing constants 92core.KEY_BACKSPACE = 8; 93core.KEY_ENTER = 13; 94core.KEY_DELETE = 127; 95 96core.KEYSTR_ESCAPE = "\027"; 97 --- 228 unchanged lines hidden --- |