Skip to content

Commit

Permalink
[kernel] Automate detection of QEMU for ftp, ftpd and DF driver
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Mar 30, 2024
1 parent 5231de3 commit bacfd1f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
* 82077AA IBM PS/2 (gen 3) DOR,DIR,CCR PERPENDICULAR,LOCK
*/

#define USE_IMPLIED_SEEK 0 /* =1 for QEMU with 360k/AT stretch floppies (not real hw) */
char USE_IMPLIED_SEEK = 0; /* =1 for QEMU with 360k/AT stretch floppies (not real hw) */
#define CHECK_DIR_REG 1 /* =1 to read and clear DIR DSKCHG when media changed */
#define CHECK_DISK_CHANGE 1 /* =1 to inform kernel of media changed */

Expand Down Expand Up @@ -1474,5 +1474,7 @@ void INITPROC floppy_init(void)
return;
}
blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;
if (!USE_IMPLIED_SEEK)
USE_IMPLIED_SEEK = running_qemu;
config_types();
}
2 changes: 2 additions & 0 deletions elks/include/linuxmt/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#define structof(p,t,m) ((t *) ((char *) (p) - offsetof (t,m)))

extern char running_qemu;

extern void do_exit(int) noreturn;

extern int kill_pg(pid_t,sig_t,int);
Expand Down
7 changes: 7 additions & 0 deletions elks/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <arch/segment.h>
#include <arch/ports.h>
#include <arch/irq.h>
#include <arch/io.h>

/*
* System variable setups
Expand Down Expand Up @@ -45,6 +46,7 @@ struct netif_parms netif_parms[MAX_ETHS] = {
__u16 kernel_cs, kernel_ds;
int tracing;
int nr_ext_bufs, nr_xms_bufs, nr_map_bufs;
char running_qemu;
static int boot_console;
static seg_t membase, memend;
static char bininit[] = "/bin/init";
Expand Down Expand Up @@ -147,6 +149,9 @@ void INITPROC kernel_init(void)
if (buffer_init()) /* also enables xms and unreal mode if configured and possible*/
panic("No buf mem");

outw(0, 0x510);
if (inb(0x511) == 'Q' && inb(0x511) == 'E')
running_qemu = 1;
device_init();

#ifdef CONFIG_SOCKET
Expand Down Expand Up @@ -541,6 +546,8 @@ static void INITPROC finalize_options(void)
/* set ROOTDEV environment variable for rc.sys fsck*/
if (envs < MAX_INIT_ENVS)
envp_init[envs++] = root_dev_name(ROOT_DEV);
if (running_qemu && envs < MAX_INIT_ENVS)
envp_init[envs++] = (char *)"QEMU=1";

#if DEBUG
printk("args: ");
Expand Down
1 change: 0 additions & 1 deletion elkscmd/rootfs_template/bootopts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#init=/bin/init 3 n # muser serial no rc.sys
#init=/bin/sh # singleuser sh
#root=hda1 ro # root hd partition 1 readonly
#QEMU=1 # ftp/ftpd
#kstack
#strace
#root=df0
Expand Down

0 comments on commit bacfd1f

Please sign in to comment.