2
2
#![ allow( non_snake_case) ]
3
3
#![ allow( non_upper_case_globals) ]
4
4
5
- use Command_line_shell :: Shell_executable_type ;
5
+ use Executable :: Mount_static_executables ;
6
6
use Executable :: Standard_type ;
7
- use File_system :: { Create_device , Create_file_system , Mode_type } ;
8
- use WASM :: WASM_device_type ;
7
+ use File_system :: { Create_device , Create_file_system } ;
8
+ use Virtual_file_system :: Mount_static_devices ;
9
9
10
10
fn main ( ) {
11
11
// - Initialize the system
@@ -18,18 +18,24 @@ fn main() {
18
18
// - Initialize the graphics manager
19
19
// - - Initialize the graphics driver
20
20
const Resolution : Graphics :: Point_type = Graphics :: Point_type :: New ( 800 , 600 ) ;
21
- let ( Screen , Pointer ) = Drivers :: Native :: Window_screen :: New ( Resolution ) . unwrap ( ) ;
21
+ let ( Screen_device , Pointer_device , Keyboard_device ) =
22
+ Drivers :: Native :: Window_screen :: New ( Resolution ) . unwrap ( ) ;
22
23
// - - Initialize the graphics manager
23
- Graphics :: Initialize ( ) ;
24
- // - - Add a screen
25
- const Buffer_size : usize = Graphics :: Get_recommended_buffer_size ( & Resolution ) ;
26
- let _ = Graphics :: Get_instance ( )
27
- . Create_display :: < Buffer_size > ( Screen , Pointer , true )
24
+ Graphics :: Initialize (
25
+ Screen_device ,
26
+ Pointer_device ,
27
+ Graphics :: Input_type_type :: Pointer ,
28
+ Graphics :: Get_minimal_buffer_size ( & Resolution ) ,
29
+ true ,
30
+ ) ;
31
+
32
+ Graphics :: Get_instance ( )
33
+ . Add_input_device ( Keyboard_device , Graphics :: Input_type_type :: Keypad )
28
34
. unwrap ( ) ;
29
35
30
36
// - Initialize the file system
31
37
// Create a memory device
32
- let Drive = Create_device ! ( Drivers :: Native :: File_drive_device_type :: New ( & "./Drive" ) ) ;
38
+ let Drive = Create_device ! ( Drivers :: Native :: File_drive_device_type :: New ( & "./Drive.img " ) ) ;
33
39
// Mount the file system
34
40
let File_system = match LittleFS :: File_system_type :: New ( Drive . clone ( ) , 256 ) {
35
41
Ok ( File_system ) => File_system ,
@@ -45,50 +51,98 @@ fn main() {
45
51
}
46
52
} ;
47
53
// Initialize the virtual file system
48
- Virtual_file_system :: Initialize ( Create_file_system ! ( File_system ) ) ;
54
+ Virtual_file_system :: Initialize ( Create_file_system ! ( File_system ) ) . unwrap ( ) ;
49
55
50
56
// - - Mount the devices
51
57
let Task = Task :: Get_instance ( ) . Get_current_task_identifier ( ) . unwrap ( ) ;
52
58
53
- Virtual_file_system :: Get_instance ( )
54
- . Mount_static_device ( Task , & "/Shell" , Create_device ! ( Shell_executable_type ) )
55
- . unwrap ( ) ;
59
+ // - - Create the default system hierarchy
60
+ let _ =
61
+ Virtual_file_system :: Create_default_hierarchy ( Virtual_file_system :: Get_instance ( ) , Task ) ;
56
62
57
- Virtual_file_system :: Get_instance ( )
58
- . Mount_static_device ( Task , & "/WASM" , Create_device ! ( WASM_device_type ) )
59
- . unwrap ( ) ;
63
+ // - - Mount the devices
64
+ Virtual_file_system :: Clean_devices ( Virtual_file_system :: Get_instance ( ) ) . unwrap ( ) ;
60
65
61
- let _ = Virtual_file_system :: Get_instance ( ) . Create_directory ( & "/Devices" , Task ) ;
66
+ Mount_static_devices ! (
67
+ Virtual_file_system :: Get_instance ( ) ,
68
+ Task ,
69
+ & [
70
+ (
71
+ & "/Devices/Standard_in" ,
72
+ Drivers :: Native :: Console :: Standard_in_device_type
73
+ ) ,
74
+ (
75
+ & "/Devices/Standard_out" ,
76
+ Drivers :: Native :: Console :: Standard_out_device_type
77
+ ) ,
78
+ (
79
+ & "/Devices/Standard_error" ,
80
+ Drivers :: Native :: Console :: Standard_error_device_type
81
+ ) ,
82
+ ( & "/Devices/Time" , Drivers :: Native :: Time_driver_type ) ,
83
+ ( & "/Devices/Random" , Drivers :: Native :: Random_device_type ) ,
84
+ ( & "/Devices/Null" , Drivers :: Common :: Null_device_type )
85
+ ]
86
+ )
87
+ . unwrap ( ) ;
62
88
63
- Drivers :: Native :: Console :: Mount_devices ( Task , Virtual_file_system :: Get_instance ( ) ) . unwrap ( ) ;
64
89
// Initialize the virtual machine
65
90
Virtual_machine :: Initialize ( & [ & Host_bindings :: Graphics_bindings ] ) ;
66
91
92
+ // Mount static executables
93
+
94
+ let Virtual_file_system = Virtual_file_system :: Get_instance ( ) ;
95
+
96
+ Mount_static_executables ! (
97
+ Virtual_file_system ,
98
+ Task ,
99
+ & [
100
+ (
101
+ & "/Binaries/Graphical_shell" ,
102
+ Graphical_shell :: Shell_executable_type
103
+ ) ,
104
+ (
105
+ & "/Binaries/Command_line_shell" ,
106
+ Command_line_shell :: Shell_executable_type
107
+ ) ,
108
+ (
109
+ & "/Binaries/Terminal" ,
110
+ Terminal :: Terminal_executable_type :: New ( Virtual_file_system :: Get_instance ( ) , Task )
111
+ . unwrap( )
112
+ ) ,
113
+ ( & "/Binaries/WASM" , WASM :: WASM_device_type )
114
+ ]
115
+ )
116
+ . unwrap ( ) ;
117
+
67
118
// - Execute the shell
68
119
// - - Open the standard input, output and error
69
- let Standard_in = Virtual_file_system :: Get_instance ( )
70
- . Open ( & "/Devices/Standard_in" , Mode_type :: Read_only . into ( ) , Task )
71
- . unwrap ( ) ;
120
+ let Standard = Standard_type :: Open (
121
+ & "/Devices/Standard_in" ,
122
+ & "/Devices/Standard_out" ,
123
+ & "/Devices/Standard_error" ,
124
+ Task ,
125
+ Virtual_file_system :: Get_instance ( ) ,
126
+ )
127
+ . unwrap ( ) ;
72
128
73
- let Standard_out = Virtual_file_system :: Get_instance ( )
74
- . Open ( & "/Devices/Standard_out" , Mode_type :: Write_only . into ( ) , Task )
75
- . unwrap ( ) ;
129
+ // - - Create the default user
130
+ let Group_identifier = Users :: Group_identifier_type :: New ( 1000 ) ;
76
131
77
- let Standard_error = Virtual_file_system :: Get_instance ( )
78
- . Open (
79
- & "/Devices/Standard_error" ,
80
- Mode_type :: Write_only . into ( ) ,
81
- Task ,
82
- )
83
- . unwrap ( ) ;
132
+ let _ = Authentication :: Create_group (
133
+ Virtual_file_system :: Get_instance ( ) ,
134
+ "alix_anneraud" ,
135
+ Some ( Group_identifier ) ,
136
+ ) ;
84
137
85
- let Standard = Standard_type :: New (
86
- Standard_in ,
87
- Standard_out ,
88
- Standard_error ,
89
- Task ,
138
+ let _ = Authentication :: Create_user (
90
139
Virtual_file_system :: Get_instance ( ) ,
140
+ "alix_anneraud" ,
141
+ "password" ,
142
+ Group_identifier ,
143
+ None ,
91
144
) ;
145
+
92
146
// - - Set the environment variables
93
147
Task :: Get_instance ( )
94
148
. Set_environment_variable ( Task , "Paths" , "/" )
@@ -98,7 +152,7 @@ fn main() {
98
152
. Set_environment_variable ( Task , "Host" , "xila" )
99
153
. unwrap ( ) ;
100
154
// - - Execute the shell
101
- let _ = Executable :: Execute ( "/Shell " , "" . to_string ( ) , Standard )
155
+ let _ = Executable :: Execute ( "/Binaries/Graphical_shell " , "" . to_string ( ) , Standard )
102
156
. unwrap ( )
103
157
. Join ( )
104
158
. unwrap ( ) ;
0 commit comments