Skip to content

Commit

Permalink
Merge pull request #12 from jbruchon/master
Browse files Browse the repository at this point in the history
jb.
  • Loading branch information
marcin-laszewski committed Apr 3, 2020
2 parents 4dda57b + b74f9ca commit 45a0397
Show file tree
Hide file tree
Showing 272 changed files with 3,120 additions and 3,805 deletions.
3 changes: 0 additions & 3 deletions Documentation/historic/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ Fri Nov 01 01:52:44 EET 2002 Harry Kalogirou <harkal@gmx.net>
process.
* Removed FLOAT_HOLES related code from malloc.c
* Stack overflow check for new the new process memory setup.
* Added CONFIG_ADVANCED_MM option to select the inclusion of
growing holes and relocatable code and data segments code.
* Removed CONFIG_EXEC_MINIX. We support minix executables by default
* Rearranged memory manager related config menus
* Added the CONFIG_EXEC_ELKS to control the inclusion of code to
Expand Down Expand Up @@ -1739,7 +1737,6 @@ Mon Aug 13 18:50:50 BST 2001 Riley Williams <rhw@MemAlpha.cx>
ROM_8253_100HZ CONFIG_HW_8253_VALUE_FOR_100HZ
ROM_ADD_BIOS CONFIG_ROM_ADD_BIOS_IMAGE
ROM_BASIS CONFIG_ROM_BASE
ROM_BOGOMIPS CONFIG_BOGOMIPS
ROM_CHECKSUM_SIZE CONFIG_ROM_CHECKSUM_SIZE
ROM_CODE_DEBUG CONFIG_ROM_DEBUG
ROM_CONFIG_8253 CONFIG_HW_8253_SYSTEM_CLOCK
Expand Down
82 changes: 58 additions & 24 deletions bootblocks/boot_sect.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,27 @@
#define ELKS_INITSEG (0x0100)
#define ELKS_SYSSEG (0x1000)

// Whether to copy and modify the BIOS floppy parameter table to allow
// whole-track reads in the bootloader
// Whether to try to do whole-track reads, or read one sector at a time
//
// This is currently disabled because it may clash with setup.S which may
// overwrite the area used by the new table
#undef FROB_DDPT
// Whole-track reads are disabled for the FAT bootloader because we are a
// bit short of code space :-(
#ifndef BOOT_FAT
# define FAST_READ
#else
# undef FAST_READ
#endif

// Macro to restore the original (i.e. BIOS's) Diskette Drive Parameter Table
//
// Note: this clobbers BX and DS, and resets SP! Use it only upon an error
// or just before handing over to /linux
.macro RESTORE_DDPT
mov $-8,%sp
pop %bx
pop %ds
popw (%bx)
popw 2(%bx)
.endm

.code16

Expand All @@ -35,12 +50,10 @@

entry:

#ifdef FROB_DDPT
// Allow the new BIOS floppy parameter table to clobber the first few bytes
// of the boot sector after we are done with them

floppy_table:
#endif

#ifdef BOOT_FAT
jmp entry1
Expand Down Expand Up @@ -68,6 +81,8 @@ entry1:
sub $0x1000,%ax
and $0xF000,%ax
mov %ax,%es
mov %ax,%ss // automatic CLI for next instruction
xor %sp,%sp

xor %di,%di
mov %di,%ds
Expand All @@ -77,12 +92,18 @@ entry1:
rep
movsw

#ifdef FROB_DDPT
// Copy the current BIOS floppy parameter table
// so that we could modify it locally
//
// Keep a pointer to the original table so that RESTORE_DDPT can
// restore it later

mov $0x78,%bx // 0:78h (INT vector 1Eh)
lds (%bx),%si // ds:si = BIOS original table
push %ds
push %si
push %cs
push %bx
.if floppy_table == entry
xor %di,%di
.else
Expand All @@ -99,15 +120,11 @@ entry1:
mov %cx,%ds // CX = 0
popw (%bx)
mov %es,2(%bx)
#endif

// Rebase CS DS ES SS to work in the 64K segment
// Rebase CS DS to work in the 64K segment

push %es
pop %ds
push %es
pop %ss // automatic CLI for next instruction
xor %sp,%sp

push %ss
mov $_next1,%cl // CH = 0
Expand All @@ -125,12 +142,10 @@ _next1:
mov $msg_boot,%bx
call _puts

#ifdef FROB_DDPT
// Set sector count in floppy parameter table

mov sect_max,%al
mov %al,floppy_table + 4
#endif

#ifndef BOOT_FAT
// Load the second sector of the boot block
Expand Down Expand Up @@ -174,7 +189,6 @@ _except:
.global _reboot

_reboot:

mov $msg_reboot,%bx

_reboot1:
Expand All @@ -183,8 +197,7 @@ _reboot1:
xor %ax,%ax // wait for key
int $0x16

int $0x19 // BIOS bootstrap
jmp _reboot
ljmpw $0xffff,$0 // do a cold(er) boot

//------------------------------------------------------------------------------

Expand Down Expand Up @@ -288,13 +301,14 @@ dr_loop:
#endif
div %bx // DL = physical sector number - 1
or %dl,%cl // stash {physical sector number - 1} in CL
inc %cx // base 1 for sector number
mov %al,%dh // DH = physical head number

#ifdef FAST_READ
// Compute number of sectors to read
// First limit the sector count to the end of the track

sub %dl,%bl
inc %cx // base 1 for sector number
mov -4(%bp),%ax
cmp %bx,%ax
jna dr_over
Expand All @@ -318,16 +332,23 @@ dr_over2:
xchg %ax,%bx // AL = number of sectors to read for this round

dr_over3:
#endif
mov drive_num,%dl

dr_try:
#ifdef FAST_READ
push %ax
#endif
push %cx
push %dx
push %es
mov -6(%bp),%bx
mov 4(%bp),%es
#ifdef FAST_READ
mov $0x02,%ah // BIOS read disk
#else
mov $0x0201,%ax
#endif
int $0x13
pop %es

Expand All @@ -344,8 +365,10 @@ dr_try:
decb -7(%bp)
pop %dx
pop %cx
#ifdef FAST_READ
pop %ax
mov $1,%al // if retry needed, try reading just _one_ sector...
#endif
jnz dr_try

// TODO: use BIOS returned error
Expand All @@ -364,6 +387,7 @@ dr_cont:

pop %dx
pop %cx
#ifdef FAST_READ
pop %ax

// Update logical sector number and logical count
Expand All @@ -378,6 +402,13 @@ dr_cont:

shl %al // cannot overflow :-)
add %al,-6+1(%bp)
#else
decw -4(%bp)
jz dr_exit
incw -2(%bp)

addb $2,-6+1(%bp)
#endif
jnc dr_next
addb $0x10,4+1(%bp)

Expand Down Expand Up @@ -450,7 +481,6 @@ binfile:
mov drive_num,%dl
xor %dh,%dh

push %ds
mov $LOADSEG,%ax
mov %ax,%ds

Expand All @@ -463,6 +493,7 @@ binfile:

not_elks:

push %cs
pop %ds
mov $ERR_BAD_SYSTEM,%al
jmp _except
Expand All @@ -472,8 +503,6 @@ boot_it:
.error
.endif

pop %ax

// Signify that /linux was loaded as 1 blob
.if ((EF_AS_BLOB|EF_BIOS_DEV_NUM) & 0xff) == 0
orb $(EF_AS_BLOB|EF_BIOS_DEV_NUM)>>8,elks_flags+1
Expand All @@ -482,6 +511,8 @@ boot_it:
.endif
mov %dx,root_dev

RESTORE_DDPT

mov $ELKS_INITSEG,%ax
mov %ax,%ds
mov %ax,%es
Expand Down Expand Up @@ -523,7 +554,8 @@ track_max:
#if defined(CONFIG_IMG_FD360)
.word 40
#elif defined(CONFIG_IMG_FD720) || defined(CONFIG_IMG_FD1200) \
|| defined(CONFIG_IMG_FD1440) || defined(CONFIG_IMG_FD1680)
|| defined(CONFIG_IMG_FD1440) || defined(CONFIG_IMG_FD1680) \
|| defined(CONFIG_IMG_FD2880)
.word 80
#elif defined(CONFIG_IMG_HD)
.word CONFIG_IMG_CYL
Expand All @@ -543,6 +575,8 @@ sect_max:
.byte 18
#elif defined(CONFIG_IMG_FD1680)
.byte 21
#elif defined(CONFIG_IMG_FD2880)
.byte 36
#elif defined(CONFIG_IMG_HD)
.byte CONFIG_IMG_SECT
#else
Expand All @@ -555,7 +589,7 @@ head_max:
#endif
#if defined(CONFIG_IMG_FD360) || defined(CONFIG_IMG_FD720) \
|| defined(CONFIG_IMG_FD1200) || defined(CONFIG_IMG_FD1440) \
|| defined(CONFIG_IMG_FD1680)
|| defined(CONFIG_IMG_FD1680) || defined(CONFIG_IMG_FD2880)
.byte 2
#elif defined(CONFIG_IMG_HD)
.byte CONFIG_IMG_HEAD
Expand Down
1 change: 1 addition & 0 deletions bootblocks/boot_sect_fat.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
// w00t!
mov drive_num,%al
xor %ah,%ah
RESTORE_DDPT
push %es
pop %ds
// Signify that /linux was loaded as 1 blob
Expand Down
4 changes: 0 additions & 4 deletions config-emu86
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ CONFIG_APM=y
#
# Memory manager
#
# CONFIG_MEM_TABLE is not set
CONFIG_MEM_LIST=y
CONFIG_ADVANCED_MM=y
# CONFIG_SWAP is not set
CONFIG_SMALL_KERNEL=y
CONFIG_SYS_VERSION=y
# CONFIG_STRACE is not set
Expand Down
27 changes: 0 additions & 27 deletions config/Configure.help
Original file line number Diff line number Diff line change
Expand Up @@ -303,33 +303,6 @@ High Memory (HMA) Support
contains the last 16 bytes of the first megabyte together with the
HMA and this area is accessible from real mode once set up.

Advanced Memory Manager
CONFIG_ADVANCED_MM
Adds some features to the MM like resizable holes and relocatable
code and data segments for processes. If you are going to use the
ELKS executable format then you better say Y here.
This enlarges the kernel by around 110 bytes.

Swap support (Experimental)
CONFIG_SWAP
Include support for swapping to virtual memory.
This enlarges kernel by about 2KB.

WARNING: This code is VERY experimental at the moment.

Table-based allocator
CONFIG_MEM_TABLE
Track the free & allocated segments in a table within the kernel
data segment. This limits the maximum number of segments but is
compatible with the 286 protected mode.

List-based allocator
CONFIG_MEM_LIST
Track the free & allocated segments in a list scattered over all
the memory. Maximum number of segments is only limited by the
size of the memory, but this allocator is not compatible with
the 286 protected mode.

# Kernel hacking
# ~~~~~~~~~~~~~~

Expand Down
Loading

0 comments on commit 45a0397

Please sign in to comment.