Skip to content

Commit

Permalink
Add (some still hacky) changes to offer an installation option
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Zimmermann committed Jan 5, 2025
1 parent 4efb51d commit 72316d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion elks/arch/i86/drivers/block/bioshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct elks_disk_parms {

static int bioshd_initialized = 0;
static int fd_count = 0; /* number of floppy disks */
static int hd_count = 0; /* number of hard disks */
/*global*/ int hd_count = 0; /* number of hard disks */

static int access_count[NUM_DRIVES]; /* device open count */
struct drive_infot drive_info[NUM_DRIVES]; /* operating drive info */
Expand Down
8 changes: 6 additions & 2 deletions elks/arch/i86/drivers/char/ntty.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,16 @@ int tty_select(struct inode *inode, struct file *file, int sel_type)

/*
* Busy wait for a keypress in kernel state
* Only used in mount_root for changing floppies
* Returns key code (ASCII)
*/
int wait_for_keypress(void)
{
set_irq();
return chq_wait_rd(&ttys[0].inq, 0);
int ret = chq_wait_rd(&ttys[0].inq, 0);
if(ret != 0)
halt();

return (chq_getch(&ttys[0].inq));
}

static struct file_operations tty_fops = {
Expand Down
23 changes: 20 additions & 3 deletions elks/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static char *init_command = binshell;
#else
static char *init_command = bininit;
#endif
extern int hd_count;

#ifdef CONFIG_BOOTOPTS
/*
Expand Down Expand Up @@ -252,6 +253,7 @@ static void INITPROC try_exec_process(const char *path)
static void INITPROC do_init_task(void)
{
int num;
int key;
const char *s;

mount_root();
Expand All @@ -276,14 +278,29 @@ static void INITPROC do_init_task(void)
heap_add(&opts, sizeof(opts));
seg_add(DEF_OPTSEG, DMASEG); /* DEF_OPTSEG through REL_INITSEG */

/* pass argc/argv/env array to init_command */

/* unset special sys_wait4() processing if pid 1 not /bin/init*/
if (strcmp(init_command, bininit) != 0)
current->ppid = 1; /* turns off auto-child reaping*/

/* run /bin/init or init= command, normally no return*/
run_init_process_sptr(init_command, (char *)argv_init, argv_slen);
/* pass argc/argv/env array to init or installation command */
if(hd_count > 0 && (ROOT_DEV == DEV_FD0 || ROOT_DEV == DEV_DF0)) {
choice:
/* no return */
printk("\nBoot medium is floppy and a hard disk has been found.\n");
printk("Do you want to [C]ontinue boot or [I]nstall ELKS? with <%s> \n", binshell, argv_init[1]);
key = wait_for_keypress();
if(key == 67 || key == 99)
run_init_process_sptr(bininit, (char *)argv_init, argv_slen);
else if(key == 73 || key == 105)
run_init_process_sptr(binshell, (char *)argv_init, argv_slen);
else
goto choice;
} else {
/* no return */
run_init_process_sptr(bininit, (char *)argv_init, argv_slen);
}

#else
try_exec_process(init_command);
#endif /* CONFIG_BOOTOPTS */
Expand Down

0 comments on commit 72316d9

Please sign in to comment.