core.lua (6d4ed94d98bbe812805ed6ab71df0badbb8b9101) core.lua (f0cb3b6b258df56324123c8732a9b5470a88383c)
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-- Parses arguments to boot and returns two values: kernel_name, argstr
41-- Defaults to nil and "" respectively.
42local parse_boot_args = function(argv)
43 if (#argv == 0) then
44 return nil, "";
45 end
46 local kernel_name;
47 local argstr = "";
48
49 for k, v in ipairs(argv) do
50 if (v:sub(1,1) ~= "-") then
51 kernel_name = v;
52 else
53 argstr = argstr .. " " .. v;
54 end
55 end
56 return kernel_name, argstr;
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
40-- Module exports
41-- Commonly appearing constants
42core.KEY_BACKSPACE = 8;
43core.KEY_ENTER = 13;
44core.KEY_DELETE = 127;
45
46core.KEYSTR_ESCAPE = "\027";
47

--- 228 unchanged lines hidden ---
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 ---