Skip to content

Commit 3dc6eba

Browse files
modload/modunload
1 parent 6a6e6a7 commit 3dc6eba

5 files changed

Lines changed: 31 additions & 3 deletions

File tree

include/basic/peekpoke.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ void poked_statement(struct basic_ctx *ctx);
6464
* @param ctx BASIC context
6565
*/
6666
void pokeq_statement(struct basic_ctx *ctx);
67+
68+
void modload_statement(struct basic_ctx* ctx);
69+
70+
void modunload_statement(struct basic_ctx* ctx);

include/basic/tokenizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@
170170
T(OUTPORTW, STMT) /* 108 */ \
171171
T(OUTPORTD, STMT) /* 109 */ \
172172
T(KGET, STMT) /* 110 */ \
173+
T(MODLOAD, STMT) /* 111 */ \
174+
T(MODUNLOAD, STMT) /* 112 */ \
173175

174176

175177
GENERATE_ENUM_LIST(TOKEN, token_t)

src/basic/peekpoke.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,24 @@ void pokeq_statement(struct basic_ctx* ctx) {
194194
}
195195
*(volatile uint64_t *)(uintptr_t)addr = (uint64_t)val;
196196
}
197+
198+
void modload_statement(struct basic_ctx* ctx) {
199+
accept_or_return(MODLOAD, ctx);
200+
const char* name = str_expr(ctx);
201+
accept_or_return(NEWLINE, ctx);
202+
if (!load_module(name)) {
203+
tokenizer_error_printf(ctx, "Unable to load module '%s'", name);
204+
return;
205+
}
206+
}
207+
208+
void modunload_statement(struct basic_ctx* ctx) {
209+
accept_or_return(MODUNLOAD, ctx);
210+
const char* name = str_expr(ctx);
211+
accept_or_return(NEWLINE, ctx);
212+
if (!unload_module(name)) {
213+
tokenizer_error_printf(ctx, "Unable to unload module '%s'", name);
214+
return;
215+
}
216+
}
217+

src/basic/statement.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ void statement(struct basic_ctx* ctx)
178178
return udpbind_statement(ctx);
179179
case UDPUNBIND:
180180
return udpunbind_statement(ctx);
181+
case MODLOAD:
182+
return modload_statement(ctx);
183+
case MODUNLOAD:
184+
return modunload_statement(ctx);
181185
case NEWLINE:
182186
/* Blank trailing line at end of program, ignore */
183187
return;

src/kernel.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@ void kmain()
2323
preboot_fail("Failed to mount boot drive to VFS!");
2424
}
2525

26-
// TODO: Don't hard code this, give BASIC facility to load it via /programs/init
27-
load_module("e1000");
28-
2926
init_process();
3027
}

0 commit comments

Comments
 (0)