Skip to content

Commit

Permalink
[kernel] Enhancements for multiple ROM configuration testing/support
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Dec 6, 2020
1 parent 9a8d1da commit aa16e7d
Show file tree
Hide file tree
Showing 14 changed files with 266 additions and 156 deletions.
10 changes: 10 additions & 0 deletions elks/arch/i86/boot/setup.S
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ start_os:
mov $INITSEG,%ax // DS = setup data segment
mov %ax,%ds

#ifdef CONFIG_ROMCODE
mov %ax,%es // clear setup data segment
xor %di,%di
xor %ax,%ax
mov $256,%cx
cld
rep
stosw
#endif

#ifdef CONFIG_HW_KEYBOARD_BIOS
mov $0x0305,%ax // set the keyboard repeat rate to the max
xor %bx,%bx
Expand Down
17 changes: 9 additions & 8 deletions elks/arch/i86/drivers/block/bioshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static unsigned short int INITPROC bioshd_gethdinfo(void) {
drivep->heads, drivep->sectors);
}
#ifdef CONFIG_IDE_PROBE
if (arch_cpu > 5) { /* Do this only if AT or higher */
if (sys_caps & CAP_HD_IDE) { /* Normally PC/AT or higher */
if (!get_ide_data(drive, drivep)) { /* get CHS from the drive itself */
/* sanity checks already done, accepting data */
printk("bioshd: hd%c IDE CHS %d,%d,%d\n", 'a'+drive, drivep->cylinders,
Expand Down Expand Up @@ -242,18 +242,19 @@ static unsigned short int INITPROC bioshd_getfdinfo(void)
{
register struct drive_infot *drivep = &drive_info[DRIVE_FD0];
int drive, ndrives = 0;
unsigned char equip_flags;

#ifndef CONFIG_ROMCODE
/*
* The INT 13h floppy query will fail on IBM XT v1 BIOS and earlier,
* so default to # drives from the BIOS data area at 0x040:0x0010 (INT 11h).
*/
equip_flags = peekb(0x10, 0x40);
unsigned char equip_flags = peekb(0x10, 0x40);
if (equip_flags & 0x01)
ndrives = (equip_flags >> 6) + 1;
#endif

/* Use INT 13h function 08h only if AT or higher*/
if (arch_cpu > 5) {
/* Use INT 13h function 08h normally if PC/AT or higher*/
if (sys_caps & CAP_DRIVE_PARMS) {
BD_AX = BIOSHD_DRIVE_PARMS;
BD_DX = 0; /* query floppies only*/
BD_ES = BD_DI = BD_SI = 0; /* guard against BIOS bugs*/
Expand All @@ -269,9 +270,9 @@ static unsigned short int INITPROC bioshd_getfdinfo(void)
* If type cannot be determined using BIOSHD_DRIVE_PARMS,
* set drive type to 1.4MM on AT systems, and 360K for XT.
*/
*drivep = fd_types[arch_cpu > 5 ? 3 : 0];
*drivep = fd_types[(sys_caps & CAP_PC_AT) ? 3 : 0];

if (arch_cpu > 5) {
if (sys_caps & CAP_DRIVE_PARMS) {
BD_AX = BIOSHD_DRIVE_PARMS;
BD_DX = drive;
BD_ES = BD_DI = BD_SI = 0; /* guard against BIOS bugs*/
Expand Down Expand Up @@ -547,7 +548,7 @@ int INITPROC bioshd_init(void)
#endif
#ifdef CONFIG_BLK_DEV_BHD
_hd_count = bioshd_gethdinfo();
if (arch_cpu > 5) { /* PC-AT or greater */
if (sys_caps & CAP_PC_AT) { /* PC/AT or greater */
enable_irq(HD_IRQ); /* AT ST506 */
enable_irq(15); /* AHA1542 */
}
Expand Down
2 changes: 1 addition & 1 deletion elks/arch/i86/drivers/char/xt_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void set_leds(void)
{
unsigned char leds;

if (arch_cpu <= 5) return; /* PC/XT doesn't have LEDs */
if (!(sys_caps & CAP_KBD_LEDS)) return; /* PC/XT doesn't have LEDs */

kb_wait(); /* wait for buffer empty */
outb_p(LED_CODE, KEYBD); /* prepare keyboard to accept LED values */
Expand Down
9 changes: 3 additions & 6 deletions elks/arch/i86/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ void enable_irq(unsigned int irq)

static int remap_irq(int irq)
{
if (((unsigned int)irq > 15) || ((irq > 7) && (arch_cpu < 6)))
if ((unsigned int)irq > 15 || (irq > 7 && !(sys_caps & CAP_IRQ8TO15)))
return -EINVAL;
if (irq == 2 && arch_cpu > 5)
if (irq == 2 && (sys_caps & CAP_IRQ2MAP9))
irq = 9; /* Map IRQ 9/2 over */
return irq;
}
Expand Down Expand Up @@ -219,15 +219,12 @@ void INITPROC irq_init(void)
panic("Unable to get timer");

/* Re-start the timer only after irq is set */

enable_timer_tick();

#ifndef CONFIG_ARCH_SIBO
if (arch_cpu > 5) { /* PC-AT or greater */
if (sys_caps & CAP_IRQ2MAP9) { /* PC/AT or greater */
save_flags(flags);
clr_irq();
enable_irq(2); /* Cascade slave PIC */
restore_flags(flags);
}
#endif
}
14 changes: 8 additions & 6 deletions elks/arch/i86/kernel/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <arch/segment.h>


byte_t arch_cpu; // processor number (from setup data)
byte_t sys_caps; /* system capabilities bits */

#ifdef CONFIG_ARCH_SIBO
extern long int basmem;
Expand All @@ -19,13 +19,10 @@ extern long int basmem;
void INITPROC setup_arch(seg_t *start, seg_t *end)
{
#ifdef CONFIG_COMPAQ_FAST

/*
* Switch COMPAQ Deskpro to high speed
*/

outb_p(1,0xcf);

#endif

/*
Expand Down Expand Up @@ -61,8 +58,13 @@ void INITPROC setup_arch(seg_t *start, seg_t *end)
/* Misc */
ROOT_DEV = setupw(0x1fc);

arch_cpu = setupb(0x20);

#ifdef SYS_CAPS
sys_caps = SYS_CAPS; /* custom system capabilities */
#else
byte_t arch_cpu = setupb(0x20);
if (arch_cpu > 5) /* IBM PC/AT capabilities */
sys_caps = CAP_ALL;
#endif
}

/* Stubs for functions needed elsewhere */
Expand Down
2 changes: 1 addition & 1 deletion elks/arch/i86/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void INITPROC mm_stat(seg_t start, seg_t end)
*cp++ = setupb(i++);
if (i == 0x40) {
printk("PC/%cT class machine, %s CPU, %uK base RAM",
arch_cpu > 5 ? 'A' : 'X', proc_name, setupw(0x2a));
(sys_caps & CAP_PC_AT) ? 'A' : 'X', proc_name, setupw(0x2a));
cp = proc_name;
i = 0x50;
}
Expand Down
6 changes: 3 additions & 3 deletions elks/fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ extern struct file_system_type msdos_fs_type;

static struct file_system_type *file_systems[] = {
/* first filesystem is default filesystem for mount w/o -t parm*/
#ifdef CONFIG_MINIX_FS
&minix_fs_type,
#endif
#ifdef CONFIG_ROMFS_FS
&romfs_fs_type,
#endif
#ifdef CONFIG_MINIX_FS
&minix_fs_type,
#endif
#ifdef CONFIG_FS_FAT
&msdos_fs_type,
#endif
Expand Down
2 changes: 1 addition & 1 deletion elks/include/arch/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <linuxmt/types.h>
#include <linuxmt/init.h>

extern byte_t arch_cpu; // processor number (from setup data)
extern byte_t sys_caps; /* system capabilities bits*/

extern void arch_setuptasks(void);
extern void INITPROC setup_arch(seg_t *,seg_t *);
Expand Down
27 changes: 27 additions & 0 deletions elks/include/linuxmt/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,42 @@
#include <autoconf.h>
#include <linuxmt/major.h>

/*
* System capabilities - configurable for ROM or custom installations.
* Normally, all capabilities will be set if arch_cpu > 5 (PC/AT),
* except when SYS_CAPS is defined for custom installations or emulations.
*/
#define CAP_PC_AT 0x01 /* PC/AT capabilities */
#define CAP_DRIVE_PARMS 0x02 /* has INT 13h fn 8 drive parms */
#define CAP_KBD_LEDS 0x04 /* has keyboard LEDs */
#define CAP_HD_IDE 0x08 /* can do hard drive IDE probes */
#define CAP_IRQ8TO15 CAP_PC_AT /* has IRQ 8 through 15 */
#define CAP_IRQ2MAP9 CAP_PC_AT /* map IRQ 2 to 9 */
#define CAP_ALL 0xFF /* all capabilities if PC/AT only */

/* Don't touch these, unless you really know what you are doing. */
#define DEF_INITSEG 0x0100 /* setup data, for netboot use 0x5000 */
#define DEF_SYSSEG 0x1000
#define DEF_SETUPSEG DEF_INITSEG + 0x20
#define DEF_SYSSIZE 0x2F00

#ifdef CONFIG_ROMCODE
#define SYS_CAPS (CAP_PC_AT|CAP_DRIVE_PARMS)
#define SETUP_DATA CONFIG_ROM_SETUP_DATA

#ifdef CONFIG_BLK_DEV_BIOS /* BIOS disk driver*/
#define DMASEG 0x80 /* 0x400 bytes floppy sector buffer */
#ifdef CONFIG_TRACK_CACHE /* floppy track buffer in low mem */
#define DMASEGSZ 0x2400 /* SECTOR_SIZE * 18 (9216) */
#define KERNEL_DATA 0x2C0 /* kernel data segment */
#else
#define DMASEGSZ 0x040 /* BLOCK_SIZE (1024) */
#define KERNEL_DATA 0x0C0 /* kernel data segment */
#endif
#else
#define KERNEL_DATA 0x80 /* kernel data segment */
#endif

#else
#define SETUP_DATA REL_INITSEG

Expand Down
4 changes: 2 additions & 2 deletions emu86-disk.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CONFIG_SMALL_KERNEL=y
CONFIG_SYS_VERSION=y
CONFIG_BOOTOPTS=y
# CONFIG_STRACE is not set
CONFIG_IDLE_HALT=y
# CONFIG_IDLE_HALT is not set
# CONFIG_ROMCODE is not set
CONFIG_EXPERIMENTAL=y
CONFIG_FARTEXT_KERNEL=y
Expand Down Expand Up @@ -84,7 +84,7 @@ CONFIG_BLK_DEV_BFD=y
# CONFIG_BLK_DEV_BFD_HARD is not set
CONFIG_TRACK_CACHE=y
CONFIG_BLK_DEV_BHD=y
# CONFIG_IDE_PROBE is not set
CONFIG_IDE_PROBE=y
# CONFIG_BLK_DEV_FD is not set
# CONFIG_BLK_DEV_HD is not set
# CONFIG_DMA is not set
Expand Down
Loading

0 comments on commit aa16e7d

Please sign in to comment.