# HG changeset patch # User Pascal Bellard # Date 1571044806 -7200 # Node ID 6e3d30b3031f56cc1c43f26d2569be71f7c82e57 # Parent 7f4bf91f0eb95dc734054af2e8889ca34330d5b8 linld: x86 support diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/A20.ASM --- a/linld/stuff/src/A20.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/A20.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -2,6 +2,7 @@ ;****** This file is distributed under GPL ;*************************************************************** ideal + %PAGESIZE 1000 %crefref %noincl %nomacs diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/CRTL.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -2,6 +2,7 @@ ;****** This file is distributed under GPL ;*************************************************************** ideal + %PAGESIZE 1000 %crefref %noincl %nomacs @@ -220,7 +221,7 @@ open: ifdef LONG_FILENAME mov ax,716Ch - push bx di si + push bx si di mov si,bx xor bx,bx ; R/O xor cx,cx ; attributes @@ -228,7 +229,7 @@ cwd ; action = open stc int 21h - pop si di bx + pop di si bx jnc doret endif mov ax,3d00h ; read-only+compatibility @@ -355,8 +356,8 @@ mov ax,[_isostate.fd] global @lseekset2$qipul:near @lseekset2$qipul: - mov dx,[bx] - mov cx,[bx+2] + les dx,[dword bx] + mov cx,es mov bl,0 jmp lseekset @@ -456,9 +457,8 @@ endif cmp [byte bx],'|' je @@test - mov al,0 inc bx - cmp [bx-1],al + cmp [byte bx-1],0 jne @@notopt stc jmp @@nokeyword @@ -543,7 +543,8 @@ global die:near ; die(bx) die: call puts -; global _exit:near + global @exit$qv:near +@exit$qv: _exit: mov al,[_no_exit] or al,al @@ -794,8 +795,8 @@ call_memcpy32: push edx else - mov ax,[word ((image_himem bx).fallback)] - mov dx,[word ((image_himem bx).fallback)+2] + les ax,[dword ((image_himem bx).fallback)] + mov dx,es mov cx,[word ((image_himem bx).buf)] cmp ax,cx ; if (m->fallback != m->buf) jnz @@do @@ -841,8 +842,8 @@ ifndef NO386 mov edx,[bx] else - mov ax,[bx] - mov dx,[bx+2] + les ax,[dword bx] + mov dx,es endif mov cx,offset _xfer_buf storepage: ; storepage(edx,cx) @@ -1097,16 +1098,14 @@ or si,si jz @@end lodsb - mov dx,ax or al,20h - cmp al,'n' ; vga=normal - je @@vga + cmp al,'a' + jb @@notvga + sub al,'n' +@@vgaloop: dec cx - cmp al,'e' ; vga=extended - je @@vga - dec cx - cmp al,'a' ; vga=ask - jne @@notvga + add al,6 + jb @@vgaloop ; vga=normal,extended,ask @@vga: dec cx xchg ax,cx @@ -1114,14 +1113,9 @@ jmp @@popsiret @@notvga: mov cx,10 ; radix - xchg ax,dx - cmp al,'+' - je @@radixskip cmp al,'-' - clc - jne @@radixkeep - stc -@@radixskip: + ja @@radixkeep + cmc ; '+'=2B:C=0 '-'=2D:C=1 lodsb @@radixkeep: pushf @@ -1175,8 +1169,7 @@ @@popsiret: pop si else - push si - push di + push si di xor ax,ax cwd or bx,bx @@ -1184,31 +1177,24 @@ xchg ax,di mov si,bx lodsb - mov bx,ax or al,20h - mov cx,-1 - cmp al,'n' ; vga=normal - je @@vga + cmp al,'a' + jb @@notvga + xor cx,cx + sub al,'n' +@@vgaloop: dec cx - cmp al,'e' ; vga=extended - je @@vga - dec cx - cmp al,'a' ; vga=ask - jne @@notvga + add al,6 + jb @@vgaloop ; vga=normal,extended,ask @@vga: xchg ax,cx @@goend: jmp @@popdisiret @@notvga: mov cx,10 ; radix - xchg ax,bx - cmp al,'+' - je @@radixskip cmp al,'-' - clc - jne @@radixkeep - stc -@@radixskip: + ja @@radixkeep + cmc ; '+'=2B:C=0 '-'=2D:C=1 lodsb @@radixkeep: pushf @@ -1236,21 +1222,19 @@ jae @@endstrtol push ax - push si push dx + xchg ax,bx + mul cx + xchg ax,bx + xchg ax,dx xchg ax,di - mul cx - xchg ax,di - xchg ax,dx - xchg ax,si pop ax mul cx - add ax,si - pop si + add ax,di xchg ax,dx pop ax mov ah,0 - add di,ax + add bx,ax adc dx,0 jmp @@strtollp @@ -1272,14 +1256,13 @@ popf jnc @@end not dx - neg di + neg bx jne @@end inc dx @@end: - xchg ax,di + xchg ax,bx @@popdisiret: - pop di - pop si + pop di si endif strtol_ret: ret diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/CRTL.H --- a/linld/stuff/src/CRTL.H Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/CRTL.H Mon Oct 14 11:20:06 2019 +0200 @@ -48,8 +48,12 @@ #define int3() do { asm { db 0cch } } while(0) #define nop() do { asm { db 90h } } while(0) extern char no_exit; +extern void exit(); extern _fastcall int die(const char* msg); //extern "C" char* malloc_or_die(unsigned size); //extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m); extern _fastcall int malloc_or_die(unsigned size); extern _fastcall int malloc_bufv_or_die(struct image_himem *m); +extern char cpu_features[]; +#define CPUMASKLM (0x20) +#define cpuhaslm() (cpu_features[3]&CPUMASKLM) diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/CRTLX.H --- a/linld/stuff/src/CRTLX.H Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/CRTLX.H Mon Oct 14 11:20:06 2019 +0200 @@ -9,6 +9,3 @@ //extern "C" char *ultoa(unsigned long n); extern _fastcall int ultoa(unsigned long n); extern "C" void try_default_args(); -extern char cpu_features[]; -#define CPUMASKLM (0x20) -#define cpuhaslm() (cpu_features[3]&CPUMASKLM) diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/JUMP.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -2,6 +2,7 @@ ;****** This file is distributed under GPL ;*************************************************************** ideal + %PAGESIZE 1000 %crefref %noincl %nomacs @@ -114,6 +115,7 @@ rep movsb ifdef NO386 + mov bx,ss add bh,9 push bx ; topseg()+0x0900 else diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/LINLD.CPP Mon Oct 14 11:20:06 2019 +0200 @@ -5,9 +5,13 @@ #include "crtl.h" #include "common.h" +const char* cmdline = "auto"; const char* kernel_name = "bzImage"; +#ifdef USE_ARGSTR +const char* initrd_name = NULL; +#else const char* initrd_name; -const char* cmdline = "auto"; +#endif u32 root_dev; u32 vid_mode; // -3 = ask // -2 = Extended VGA @@ -21,6 +25,7 @@ "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline]" NL "vga mode: ask,extended,normal or dec/oct/hex number" NL "-f force" NL + "-64 for cpu64 only" NL "Defaults:" NL "\timage=bzImage" NL "\tinitrd,vga,root=(void)" NL @@ -50,31 +55,29 @@ // Parse command line #ifdef USE_ARGSTR if (!argv[1]) syntax(); - {for (;;) { + for (;;) { const char **clp = &cmdline; - next: argv++; - if (!*argv) { + if (!*argv) goto boot; + if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64 + if (cpuhaslm() == 0) exit(); + } + if ((*(u16 *)*argv|0x2002) == 0x662F) { // -F /f + skip_alloc++; + } + else if (argstr(*argv,"cl|image|initrd",clp) != -1); + else if (fileexist(*argv) != -1) + kernel_name=*argv; + else if (argnum(*argv,"root|vga|mem|-b",&root_dev) != -1); + else { + *clp = (const char *) buf_cmdline + 1; + strcatb((const char *) buf_cmdline,*argv); + boot: puts(*clp); set_cmdline(*clp); puts(load_kernel()); load_initrd(); boot_kernel(); - } - if ((*(u16 *)*argv|0x2002) == 0x662F) { // -F /f - skip_alloc++; - goto next; - } - if (argstr(*argv,"cl|image|initrd",clp) != -1); - else if (fileexist(*argv) != -1) - kernel_name=*argv; - else if (*argv) { - argnum(*argv,"root|vga|mem|-b",&root_dev); - *clp = (const char *) buf_cmdline + 1; - strcatb((const char *) buf_cmdline,*argv); - } - else - break; } } #else @@ -96,6 +99,9 @@ *(u16*)&vid_mode = (u16)strtol(s+7); // support normal, extended & ask } else switch (*(u16 *)s|0x2002) { + case 0x362F: // -64 /64 + if (cpuhaslm() == 0) exit(); + goto next; case 0x662F: // -F /f skip_alloc++; goto next; diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/LOAD.CPP Mon Oct 14 11:20:06 2019 +0200 @@ -191,13 +191,13 @@ // heap_end_ptr appears to be relative to the start of setup (ofs 0x0200) kernelparams->heap_end_ptr = _32k-0x0200; kernelparams->loadflags |= 0x80; // says to rm loader it's ok to use heap - } - // * if we will ever stop moving ourself to 0x90000 - // we must say setup.S how much to move - //kernelparams->setup_move_size = _32k; - if(kernelparams->version >= 0x202) { // starting linux 2.4.0-test3-pre3 - kernelparams->cmd_line_ptr = (((u32)(topseg()+0x0800))<<4); - goto cmd_line_ok; + // * if we will ever stop moving ourself to 0x90000 + // we must say setup.S how much to move + //kernelparams->setup_move_size = _32k; + if(kernelparams->version >= 0x202) { // starting linux 2.4.0-test3-pre3 + kernelparams->cmd_line_ptr = (((u32)(topseg()+0x0800))<<4); + goto cmd_line_ok; + } } } first1k->cl_magic_ofs = 0x8000A33F; diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/MEMCPY32.ASM --- a/linld/stuff/src/MEMCPY32.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/MEMCPY32.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -2,6 +2,7 @@ ;****** This file is distributed under GPL ;*************************************************************** ideal + %PAGESIZE 1000 %crefref %noincl %nomacs diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/MEMTOP.ASM --- a/linld/stuff/src/MEMTOP.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/MEMTOP.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -2,6 +2,7 @@ ;****** This file is distributed under GPL ;*************************************************************** ideal + %PAGESIZE 1000 %crefref %noincl %nomacs diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/VCPI.ASM --- a/linld/stuff/src/VCPI.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/VCPI.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -24,6 +24,7 @@ ideal + %PAGESIZE 1000 %crefref %noincl %nomacs diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/XMM.ASM --- a/linld/stuff/src/XMM.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/XMM.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -2,6 +2,7 @@ ;****** This file is distributed under GPL ;*************************************************************** ideal + %PAGESIZE 1000 %crefref %noincl %nomacs diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/_BEG.ASM Mon Oct 14 11:20:06 2019 +0200 @@ -2,6 +2,7 @@ ;****** This file is distributed under GPL ;*************************************************************** ideal + %PAGESIZE 1000 %crefref %noincl %nomacs @@ -33,10 +34,8 @@ label _bss_start byte db STACK_SIZE-2 dup(?) stktop dw ? - ifdef EXTRA global _cpu_features:dword _cpu_features dd ? - endif ends _BSS segment _TEXT byte public use16 'CODE' @@ -148,7 +147,6 @@ jnz no_vcpi inc [byte bx+_vcpi-msg_badmapping] endcpu386: - ifdef EXTRA pushfd pop dx pop ax @@ -166,7 +164,6 @@ cpuid mov [_cpu_features],edx @@no_cpuid: - endif endcpu86: p8086 diff -r 7f4bf91f0eb9 -r 6e3d30b3031f linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Sat Oct 12 12:08:52 2019 +0200 +++ b/linld/stuff/src/pipehole.awk Mon Oct 14 11:20:06 2019 +0200 @@ -6,16 +6,85 @@ if (/^@.*:$/ || / endp$/) afterjmp=0 if (/^ \.386p$/) is386=1 if (file == "" && /debug S/) { file=$3; gsub(/\"/,"",file) } + if (/debug S/) print " %PAGESIZE 1000" + if (file == "tazboot.cpp") { + if (/add si,2/) $0=" lodsw ; " $0 + if (/add si,4/) { print " lodsw"; $0=" lodsw ; " $0 } + if (/add di,2/) $0=" scasw ; " $0 + } # file == "tazboot.cpp" + if (file == "linld.cpp") { + if (/add si,2/) $0=" lodsw ; " $0 + if (/add di,2/) $0=" scasw ; " $0 + if (/bx,offset DGROUP:s@\+26/) sub(/mov/,";mov") + if (islinld==1) { + print "; " $0 + if (!/word ptr/) next + islinld=0 + sub(/,word.*/,",di ; argv") + if (/di,di/) { print "; " $0; next } + } + if (/^_main proc/) islinld=1 + if (/== 0x662F/) islinld=2 + if (islinld==2) { + if (/cpuhaslm/) islinld=0 + if (/mov/) { print "; " $0; next } + } + if (/image\|initrd/) islinld=3 + if (islinld==3) { + if (/bx,word ptr/) { islinld=0; print "; " $0; next } + } + if (/fileexist\$qpxzc/) islinld=4 + if (islinld==4) { + if (/ax,-1/) print " mov bx,word ptr [si]" + if (/ax,word ptr/) $0=" xchg ax,bx" + if (/\[si\]$/) { islinld=0; print "; " $0; next } + } + } # file == "linld.cpp" if (file == "himem.cpp") { - if (/remaining = m-/) ishimem=1 + if (/void load_image/) ishimem=1 if (ishimem == 1 && is386 == 0) { if (/si\+8\]$/ || /si\+4\]$/ || /si\+16\]$/) next if (/si\+6\]$/ || /si\+2\]$/ || /si\+14\]$/) sub(/mov dx,/,"les dx,d") if (/si\+12\],ax/ || /si\+16\],ax/ || /bp-2\],ax/) sub(/,ax/,",es") - if (/do \{/) ishimem=0 + } + if (ishimem == 1) { + if (/do \{/) ishimem=2 + if (/byte ptr DGROUP:_vcpi,0/) print " mov bx,si" + if (/bx,si/) next + if (/sp,6/) { + print " push si" + print " push si" + next + } + } + if (ishimem == 2) { + if (/movzx/) print " cwde" + if (/bp-6/) next + if (/storepage.bufv/) { + print " inc ax" + print " push ax" + } + if (/buf \+= size;/) { + print " pop ax" + } + if (/Read error/) ishimem=0 } } # file == "himem.cpp" if (file == "load.cpp") { + if (/word ptr \[si\+21\],513$/) isload=11 + if (isload == 12) { # LOAD.LST + if (/cmp/) next + if (/jb/) isload=0 + sub(/jb/,"jcxz") + } + if (isload == 11) { # LOAD.LST + if (/cmp/) { + print " mov cx,513" + $0=" sub cx,word ptr [si+21]" + } + if (/jb/) isload=12 + sub(/jb/,"ja") + } sub(/DGROUP:_imgs\+65534/,"[di-2]") if (/short @1@366$/) isload=10 if (isload == 10) { # LOAD.LST @@ -53,10 +122,7 @@ } if (/\[0\] = m-\>fallback/) isload=6 if (isload == 6) { # LOAD.LST - if (/si\+2/) { - print " inc si" - $0=" inc si" - } + if (/si\+2/) $0=" lodsw" if (/les/) sub(/bx,/,"ax,") if (/bx\+4/ || /es:/) { if (/bx\+4/) isload=0 diff -r 7f4bf91f0eb9 -r 6e3d30b3031f memtest/stuff/bootloader.S --- a/memtest/stuff/bootloader.S Sat Oct 12 12:08:52 2019 +0200 +++ b/memtest/stuff/bootloader.S Mon Oct 14 11:20:06 2019 +0200 @@ -467,7 +467,9 @@ # Assume no error on first track. #ifdef FLOPPY_1440K_ONLY +#ifndef FLOPPY_HAS_2_SIDES #define FLOPPY_HAS_2_SIDES hardcore heads count to 2 +#endif #define FLOPPY_SECTORS 18 /* 18 sectors */ #else #define FLOPPY_HEADS 2 /* 2 heads minimum */