# HG changeset patch # User Pascal Bellard # Date 1613638603 0 # Node ID bc4b94310a29fd365bff4dc532e4ee50900933eb # Parent a1b12ae1c8520ce1beb41da35da37d0c1aa099cf linld: add quick boot switch diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/!COMPILE.BAT --- a/linld/stuff/src/!COMPILE.BAT Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/!COMPILE.BAT Thu Feb 18 08:56:43 2021 +0000 @@ -3,7 +3,8 @@ tasm /h > helptasm.log bcc > helpbcc.log tlink > helptlink.log -bcc @bccopt.opt -S -mt -DISOHOOK -DMOVE_SETUP -DLARGE_IMAGES *.cpp > cpp.log +bcc @bccopt.opt -S -mt -DQUICK_BOOT -DISOHOOK -DMOVE_SETUP *.cpp > cpp.log +#bcc @bccopt.opt -S -mt -DWITH_XMM_ALLOC -DQUICK_BOOT -DISOHOOK -DMOVE_SETUP *.cpp > cpp.log ren LINLD.ASM LINLD.ASO ren LOAD.ASM LOAD.ASO ren HIMEM.ASM HIMEM.ASO @@ -12,5 +13,6 @@ mawk -f pipehole.awk LOAD.ASO > LOAD.ASM mawk -f pipehole.awk HIMEM.ASO > HIMEM.ASM mawk -f pipehole.awk ISO9660.ASO > ISO9660.ASM -tasm /la /m /dISOHOOK /dBIG_CMDLINE /dMOVE_SETUP /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log +tasm /la /m /dQUICK_BOOT /dISOHOOK /dMOVE_SETUP /dNO386 /dLONG_FILENAME *.asm > asm.log +#tasm /la /m /dWITH_XMM_ALLOC /dLARGE_ZIMAGE /dQUICK_BOOT /dISOHOOK /dMOVE_SETUP /dNO386 /dLONG_FILENAME *.asm > asm.log tlink /m /s /t @link.cmd > lnk.log diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/A20.ASM --- a/linld/stuff/src/A20.ASM Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/A20.ASM Thu Feb 18 08:56:43 2021 +0000 @@ -104,7 +104,7 @@ global @moverm$qpus:near @moverm$qpus: push si di - xor di,di + xor di,di ; default setup 9000:0000 extrn _heap_top:word ifdef NO386 mov ax,[_heap_top] @@ -119,7 +119,7 @@ extrn _cpu386:byte test [_cpu386],cl jne @bzimage - mov bx,offset bzimage86 + mov bx,offset bzimage86 ; no himem with 8086 ! @godie: call near die @zimage: @@ -128,7 +128,7 @@ jae @sys@ok xchg ax,cx ; segment min 1000h @sys@ok: - inc ax + inc ax ; first free segment extrn N_LXLSH@4:near call N_LXLSH@4 mov [word ((image_himem bx+4).fallback)],ax @@ -137,20 +137,25 @@ adc dx,[word ((image_himem bx+4).size)+2] ifdef MOVE_SETUP mov di,8000h - sub di,[bx] ; rm_size + sub di,[bx] ; rm_size extrn _rm_offset:word mov [_rm_offset],di - sub ax,di ; -rm_offset + sub ax,di ; -rm_offset sbb dx,cx endif mov cl,12 - shl dx,cl ; last segment - jc @jbe_overflow ; >= 1Mb ? + shl dx,cl ; last sys segment + ifndef LARGE_ZIMAGE + ;jc @jbe_overflow ; >= 1Mb ??? + else + ;jnc @bzimage ; < 1Mb + ;mov dh,-1 + endif @bzimage: extrn _topseg:near call near _topseg mov [word sssp+2],ax - and ch,0 ; vcpi flag + and ch,0 ; vcpi flag org $-1 global _vcpi:byte _vcpi db ? @@ -168,19 +173,19 @@ jae @sys@ok xchg ax,cx ; segment min 1000h @sys@ok: - inc ax + inc ax ; first free segment shl eax,4 mov [(image_himem bx+4).fallback],eax add eax,[(image_himem bx+4).size] ifdef MOVE_SETUP mov di,8000h - sub di,[bx] ; rm_size + sub di,[bx] ; rm_size extrn _rm_offset:word mov [_rm_offset],di - movzx ecx,di ; -rm_offset + movzx ecx,di ; -rm_offset sub eax,ecx endif - shl eax,4 + shr eax,4 mov ch,0 @bzimage: xchg ax,dx @@ -190,8 +195,23 @@ endif add dh,ch ; 60k room for malloc_bufv_or_die cmp ax,dx + ifdef LARGE_ZIMAGE + ja @nooverflow0 + extrn _cmdnum:dword +base_himem = (dword _cmdnum+12) + ifdef NO386 + les cx,[base_himem] + mov [word ((image_himem bx+4).fallback)],cx + mov [word ((image_himem bx+4).fallback)+2],es + else + mov ecx,[base_himem] + mov [(image_himem bx+4).fallback],ecx + endif +@nooverflow0: + endif les cx,[bx] ; rm_size mov si,es ; rm_buf + ifndef LARGE_ZIMAGE @jbe_overflow: ; Oops! We can stomp on our toes... better stop now mov bx,offset overflow @@ -202,6 +222,7 @@ call near die @nooverflow: endif + endif mov es,ax @@move_clear: movsb diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/COMMON.H --- a/linld/stuff/src/COMMON.H Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/COMMON.H Thu Feb 18 08:56:43 2021 +0000 @@ -66,21 +66,20 @@ #define topmem (cmdnum[2]) #define base_himem (cmdnum[3]) #define skip_alloc (* (char *) &cmdnum[4]) +#ifdef QUICK_BOOT +extern u32 cmdnum[7]; +#else extern u32 cmdnum[5]; +#endif -extern _fastcall void memcpy_image(struct image_himem *m); +extern _fastcall void memcpy_image_kernel(); +extern _fastcall void memcpy_image_initrd(); extern _fastcall void storepage(u32 *dst); -#ifdef LARGE_IMAGES extern _fastcall void reset_bufv(unsigned long *p); extern "C" unsigned long* prev_bufv(); extern "C" unsigned long* next_bufv(); #define next(p) p = next_bufv() #define prev(p) p = prev_bufv() -#else -#define reset_bufv(p) -#define next(p) ++p -#define prev(p) --p -#endif extern char vcpi; extern char version_string[]; // External asm helpers @@ -89,7 +88,7 @@ #endif extern "C" u32 memtop(); extern "C" void enable_a20_or_die(); -extern "C" void vm2rm(); +extern "C" void far vm2rm(); extern "C" void hook_int15_88(); // C++ helpers diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/CRTL.ASM Thu Feb 18 08:56:43 2021 +0000 @@ -605,15 +605,13 @@ ;*************************************************************** - ifdef LARGE_IMAGES struc data_himem ;struct data_himem { -first dd ? ; 0 u32 first; -cacheidx dw ? ; 4 int cacheidx; -pageidx dw ? ; 6 int pageidx; +first dd ? ; 0 u32 first; *must* be the first one +cacheidx dw ? ; 4 int cacheidx; quad * +pageidx dw ? ; 6 int pageidx; byte * cache dd 1024 dup(?) ; 8 int cache; page dd 1024 dup(?) ;4104 int page; -ends data_himem ;}; // size=8200 - endif +ends data_himem ;}; ;*************************************************************** ;_fastcall u32* malloc_bufv_or_die(si:struct image_himem *m); @@ -623,48 +621,28 @@ p386 push si - mov bx,si - ifdef LARGE_IMAGES - movzx eax,[word ((image_himem si).size) + 2] - shr ax,4 ; pages index size = size >> 20 - add ax,8+4096+8 + ;mov ecx,[(image_himem si).size] + ;shr ecx,20 ; pages index size = size >> 20 + ;mov ax,cx + ;add ax,size data_himem-4096 + mov ax,size data_himem call malloc_or_die - mov cx,4096+4095 ; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE; + ;mov cx,4096+4095 ; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE; + mov ecx,4096+4095 ; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE; add ecx,[(image_himem si).size] shr ecx,12 mov [curdata],ax - else - mov eax,[(image_himem si).size] - dec eax - shr eax,12 - inc ax ; cnt = (m->size+PAGE_MASK)/PAGE_SIZE; - push ax - inc ax ; cnt+1 - shl ax,2 ; bufv => vcpi => vm86 -; our malloc zeroes allocated mem: bufv[cnt]=0; -; Allocate pages, storing addrs in addrbuf - call malloc_or_die - pop cx - push ax - endif - mov [(image_himem si).bufv],ax + mov [(image_himem si).bufv],ax ; update m->bufv xchg ax,si @@vcpi_alloc: mov ax,0DE04h ; allocate a 4K page => EDX int 67h or ah,ah - stc mov bx,offset vcpi_alloc_err jnz jmpdie ; for (i = cnt-1; i >= 0; i--) - ifdef LARGE_IMAGES mov eax,ecx dec eax - else - mov ax,cx - dec ax - cwde - endif shl eax,12 ; i*_4k ; if (edx < pm.fallback+i*_4k && edx >= pm.fallback) again mov bx,offset _imgs.fallback @@ -677,16 +655,15 @@ jae @@vcpi_alloc @@pmok: ; if (edx >= initrd.fallback+i*_4k && edx < initrd.fallback+initrd.size) again - add eax,[bx-2+2+32] ; +initrd.fallback + add eax,[bx-2+2+size image_himem] ; +initrd.fallback cmp eax,edx ; initrd.fallback+i*_4k > edx ? ja @@initrdok - mov eax,[bx-2+6+32] ; initrd.size - add eax,[bx-2+2+32] ; +initrd.fallback + mov eax,[bx-2+6+size image_himem] ; initrd.size + add eax,[bx-2+2+size image_himem] ; +initrd.fallback cmp eax,edx ; initrd.fallback+initrd.size > edx ? -@@jnc_vcpi_alloc: +@@ja_vcpi_alloc: ja @@vcpi_alloc @@initrdok: - ifdef LARGE_IMAGES cmp [(data_himem si).first],0 jne @@notfirst mov [(data_himem si).first],edx @@ -696,7 +673,7 @@ jae @@nextpage shl bx,2 inc [(data_himem si).cacheidx] - mov [(data_himem bx+si).cache],edx + mov [(data_himem bx+si).cache],edx ; cache[cacheidx++] = edx loopd @@vcpi_alloc mov [(data_himem bx+si).cache],ecx ; last is 0 @@nextpage: @@ -714,15 +691,9 @@ call storepage ; storepage(edx,cx) pop cx or ecx,ecx ; clear C - jnz @@jnc_vcpi_alloc + jnz @@ja_vcpi_alloc mov [dword (data_himem si).cacheidx],ecx xchg ax,si - else - mov [si],edx - lodsd ; si=+4 - loop @@vcpi_alloc - pop ax - endif pop si ret ifdef NO386 @@ -733,14 +704,16 @@ ;*************************************************************** +;_fastcall void memcpy_image_initrd(si:struct image_himem *m); +;_fastcall void memcpy_image_kernel(si:struct image_himem *m); ;_fastcall void memcpy_image(bx:struct image_himem *m); ;*************************************************************** - global memcpy_image_initrd:near -memcpy_image_initrd: - lea bx,[si+32] + global @memcpy_image_initrd$qv:near +@memcpy_image_initrd$qv: + lea bx,[si+size image_himem] db 0A9h ; test ax,imm - global memcpy_image_kernel:near -memcpy_image_kernel: + global @memcpy_image_kernel$qv:near +@memcpy_image_kernel$qv: mov bx,si proc @memcpy_image$qp11image_himem near @@ -749,13 +722,9 @@ mov eax,[(image_himem bx).buf] cmp eax,edx ; if (m->fallback != m->buf) jz @@skip ; memcpy32(m->fallback,0,m->buf,m->size) - ifdef LARGE_IMAGES mov ecx,[(image_himem bx).size] memcpy_imagez: ; memcpy_imagez(edx,eax,ecx) push ecx - else - push [(image_himem bx).size] - endif push eax push 0 call_memcpy32: @@ -763,7 +732,7 @@ else les ax,[dword ((image_himem bx).fallback)] mov dx,es - mov cx,[word ((image_himem bx).buf)] + les cx,[dword ((image_himem bx).buf)] cmp ax,cx ; if (m->fallback != m->buf) jnz @@do cmp dx,[word ((image_himem bx).buf)+2] @@ -771,14 +740,13 @@ @@do: push [word ((image_himem bx).size)+2] push [word ((image_himem bx).size)] - push [word ((image_himem bx).buf)+2] - push cx + push es ; [word ((image_himem bx).buf)+2] + push cx ; [word ((image_himem bx).buf)] xor cx,cx push cx call_memcpy32: push dx ; push dx:ax push ax - ifdef LARGE_IMAGES jmp @@memcpy memcpy_imagez: ; memcpy_imagez(edx,eax,ecx) p386 @@ -789,7 +757,6 @@ ifdef NO386 p8086 endif - endif endif @@memcpy: extrn memcpy32:near @@ -832,7 +799,6 @@ endp @storepage$qpul - ifdef LARGE_IMAGES p386 ;*************************************************************** ;_fastcall void reset_bufv(di:u32 *p); @@ -841,7 +807,7 @@ proc @reset_bufv$qpul near mov [curdata],di - and [dword (data_himem di).cacheidx],0 + and [dword (data_himem di).cacheidx],0 ; and pageidx=0 ret endp @reset_bufv$qpul @@ -858,17 +824,21 @@ db 73h ; jnc _next_bufv: clc + push si mov bx,0 org $-2 curdata dw ? sbb ax,ax cmc adc ax,[(data_himem bx).cacheidx] ; -1/+1 + mov si,3ffh + and si,ax + mov [(data_himem bx).cacheidx],si + shl si,2 xor ecx,ecx test ax,0fc00h - jz @@gotpage - push ax ; FFFF / 0400 - sar ax,8 ; FFFC / 0004 + jz @@gotpage ; FFFF / 0400 + xchg al,ah ; FFFC / 0004 and al,0fch add [(data_himem bx).pageidx],ax mov di,[(data_himem bx).pageidx] @@ -879,29 +849,21 @@ add edx,ecx mov eax,[di] or eax,eax - jnz @@pageok - pop ax - ret -@@pageok: - mov cx,4096 - call memcpy_imagez ; get page - pop ax ; FFFF / 0400 - cbw - shr ax,6 ; 03FF / 0000 + jz @@ret + mov cx,4096 ; get page + call memcpy_imagez ; memcpy_imagez(edx,eax,ecx) @@gotpage: - mov [(data_himem bx).cacheidx],ax - shl ax,2 - xchg ax,di - lea ax,[(data_himem bx+di).cache] - or di,[(data_himem bx).pageidx] ; !pageidx && !cacheidx + lea ax,[(data_himem bx+si).cache] + or si,[(data_himem bx).pageidx] ; !pageidx && !cacheidx jnz @@notfirst2 xchg ax,bx ; &first @@notfirst2: xchg ax,di +@@ret: + pop si ret endp _prev_bufv - endif ifdef NO386 p8086 diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/HIMEM.CPP --- a/linld/stuff/src/HIMEM.CPP Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/HIMEM.CPP Thu Feb 18 08:56:43 2021 +0000 @@ -10,19 +10,26 @@ void load_image(struct image_himem *m) { m->remaining = m->size; + u32* bufv= &himem_buf; +#ifdef WITH_XMM_ALLOC m->buf = m->fallback; // set no_exit btw: die() won't return to DOS - u32* bufv= &himem_buf; if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ? if(vcpi) { bufv = (u32 *)malloc_bufv_or_die(m); // update m->bufv } -#ifdef WITH_XMM_ALLOC else { xmm_alloc(m); // update m->buf } -#endif } himem_buf = m->buf; +#else + *bufv = m->buf = m->fallback; // set no_exit btw: die() won't return to DOS + if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ? + if(vcpi) { + bufv = (u32 *)malloc_bufv_or_die(m); // update m->bufv + } + } +#endif do { u16 size; if(s16(size = read_image(m)) -1 < 0) break; @@ -37,7 +44,8 @@ // Called just before rm->pm void far last_ditch() { asm { - cli + pushf + ;cli push ds push cs pop ds @@ -52,15 +60,17 @@ } vm2rm(); struct image_himem *m = ± +#define KERNEL 0 +#define INITRD 1 u32 *q; - if(((u16 *)&m->fallback)[1] >= 0x10) // >= _1m ? - ((u16 *)&m->fallback)[1] = 0x10; - q = m->bufv; + if(((u16 *)&m[KERNEL].fallback)[1] >= 0x10) // >= _1m ? + ((u16 *)&m[KERNEL].fallback)[1] = 0x10; + q = m[KERNEL].bufv; if(q==0) { // Move kernel - memcpy_image(m); + memcpy_image_kernel(); // Move initrd - memcpy_image(pm2initrd(m)); + memcpy_image_initrd(); } else { //vcpi #if defined(__BORLANDC__) && defined(NO386) #pragma option -3 @@ -71,33 +81,32 @@ // Move kernel // 'Gathering' copy in chunks of PAGE_SIZE // No risk of overlapping: kernel is copied from above to 1m mark - m->size = pm2initrd(m)->size = PAGE_SIZE; + m[KERNEL].size = m[INITRD].size = PAGE_SIZE; #define ADD_PAGE(x) (*(unsigned long *)(((char *)&x)+1)+=PAGE_SIZE/256) #define SUB_PAGE(x) (*(unsigned long *)(((char *)&x)+1)-=PAGE_SIZE/256) reset_bufv(q); do { - m->buf = *q; - memcpy_image(m); - next(q); ADD_PAGE(m->fallback); + m[KERNEL].buf = *q; + memcpy_image_kernel(); + next(q); ADD_PAGE(m[KERNEL].fallback); } while(*q); // Move initrd - m = pm2initrd(m); - if(((u16 *)&m->fallback)[1]) { + if(((u16 *)&m[INITRD].fallback)[1]) { // This is tricky: copy initrd backwards to reduce // risk of overlapping: use the fact that initrd is copied // to the very top of ram // (overlapping still can happen with more than 256mb ram) // (generic solution for this overwrite problem, anyone?) - q=m->bufv; + q=m[INITRD].bufv; reset_bufv(q); do { - next(q); ADD_PAGE(m->fallback); + next(q); ADD_PAGE(m[INITRD].fallback); } while(*q); do { - prev(q); SUB_PAGE(m->fallback); - m->buf = *q; - memcpy_image(m); - } while(q != m->bufv); + prev(q); SUB_PAGE(m[INITRD].fallback); + m[INITRD].buf = *q; + memcpy_image_initrd(); + } while(q != m[INITRD].bufv); } } asm { @@ -110,5 +119,6 @@ popa # endif pop ds + popf } } diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/JUMP.ASM Thu Feb 18 08:56:43 2021 +0000 @@ -23,7 +23,15 @@ macro dos_shutdown xor si,si + ifdef QUICK_BOOT + extrn _cmdnum:dword +quickboot = (word _cmdnum+20) + cmp si,[quickboot] mov ds,si + jne skip_shutdown + else + mov ds,si + endif ifndef NO386 push [dword si+4] ; save step mov [word si+4],offset step19 @@ -56,6 +64,7 @@ xor si,si mov ds,si pop [dword si+4] ; restore step +skip_shutdown: endm macro step19code step19: @@ -148,7 +157,7 @@ push si ; src seg=0 inc cx push cx ; dst ofs hi - push si ; dst ofs lo : 64k + push si ; dst ofs lo : 64k = 0x10000 ; self move extrn gdt_data diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/LINK.CMD --- a/linld/stuff/src/LINK.CMD Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/LINK.CMD Thu Feb 18 08:56:43 2021 +0000 @@ -1,1 +1,1 @@ -_beg.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj linld.obj _end.obj, linld +_beg.obj linld.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj _end.obj, linld diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/LINLD.CPP Thu Feb 18 08:56:43 2021 +0000 @@ -8,7 +8,11 @@ extern char bzimagestr[]; const char* cmdstr[4] = {"auto",bzimagestr,NULL,NULL}; +#ifdef QUICK_BOOT +u32 cmdnum[7]; +#else u32 cmdnum[5]; +#endif inline void syntax() { die("Syntax:" NL @@ -51,7 +55,11 @@ exit(); } if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue; +#ifdef QUICK_BOOT + if (argnum(*argv,"root|vga|mem|-b|-f*|-q*|-v*",&root_dev) >= (int) &base_himem) continue; +#else if (argnum(*argv,"root|vga|mem|-b|-f*",&root_dev) >= (int) &base_himem) continue; +#endif if (fileexist(*argv) != -1) { kernel_name=*argv; continue; diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/MEMCPY32.ASM --- a/linld/stuff/src/MEMCPY32.ASM Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/MEMCPY32.ASM Thu Feb 18 08:56:43 2021 +0000 @@ -156,10 +156,10 @@ cmp esi,edi jae @@do_copy add esi,ecx ;src ;0018 org $-8 global gdt_memcpy:descr -gdt_memcpy descr +gdt_memcpy descr ;null + gdt_abs descriptor gdt_abs ,(data_seg+writable),priv0,is_present,0fffffh,(gran_page+use_32),0 ;Note: code/data segs must be flagged use16 (i.e. use ip/sp, not eip/esp) ;Note: base addrs will be fixed up in prepare_vcpi() @@ -208,7 +209,7 @@ sw2pm_idtr_ptr dw offset idtr,0 sw2pm_ldtr dw 0 ;we don't need it sw2pm_tr dw SEL_TSS ;vcpi thinks we need it... can't set to 0 -sw2pm_jumpaddr dd 0 +sw2pm_jumpaddr dw offset pmode,0 dw SEL_CODE vcpi_pm_entry dd ((640*1024) shr 12) @@ -218,20 +219,6 @@ idt_lim dw 03ffh ;we won't enable ints, idt_base dd 0 ; so let's leave it the same as for rm -;*************************************************************** -switch_to_pm: - assume cs:DGROUP,ds:DGROUP - mov edx,esi - movzx_e si, - org $-4 -sw2pm_addr dd ? - pop [word sw2pm_jumpaddr] ; CS:EIP of protected mode entry-point - ;mov [word sw2pm_jumpaddr+2],0 - ;mov [word sw2pm_jumpaddr+4],SEL_CODE - mov ax,0DE0Ch ; vcpi: switch to pm - cli ; load GDTR LDTR TR need 16 bytes in SS:ESP - int 67h ; EAX, ESI, DS, ES, FS, GS destroyed - ;*************************************************************** ;void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs); @@ -270,14 +257,26 @@ push bx ;\eip push offset vcpi_ret ;/ - call switch_to_pm ; EAX, EDX/ESI, DS, ES, FS, GS destroyed + mov edx,esi +switch_to_pm: + movzx_e si, + org $-4 +sw2pm_addr dd ? + mov ax,0DE0Ch ; vcpi: switch to pm + cli ; load GDTR LDTR TR need 16 bytes in SS:ESP + int 67h ; EAX, ESI, DS, ES, FS, GS destroyed +pmode: assume nothing assume cs:DGROUP ; Now we are in 16-bit protected mode - mov bl,SEL_DATA - mov ss,bx - lea sp,[bp-8-9*4] + push SEL_DATA + pop ss + test bx,bx + jnz vm2rm_end + + ;lea sp,[bp-8-9*4] + lea sp,[bp-9*4] ; Call the routine (bp points to params on stack if any) call do_memcpy_vcpi ; set ds=all_addrspace @@ -287,7 +286,9 @@ cli ; to be safe clts ; ; Go to vm86 mode. Sregs, esp, eflags (IF) restored from IRET stack - jmp [pword cs:vcpi_pm_entry] + call [pword cs:vcpi_pm_entry] + ret + ;jmp [pword cs:vcpi_pm_entry] ;*************************************************************** @@ -335,36 +336,37 @@ ;*************************************************************** ;****** Uses: Flags ;*************************************************************** - global _vm2rm:near - proc _vm2rm near + global _vm2rm:far + proc _vm2rm far assume cs:DGROUP,ds:DGROUP + push ds + ifdef QUICK_BOOT + extrn _cmdnum:dword +v86boot = (byte _cmdnum+24) + cmp [v86boot],0 + jnz @vm2rm_ret + endif + mov bx,offset sssp + mov [bx],sp + ;mov [bx+2],ss extrn sssp:dword ifdef NO386 - p8086 extrn _vcpi:byte - mov bx,offset sssp test [_vcpi],bh - jz vcpi_ret else - p386 smsw ax ;SMSW cannot be trapped! :-) and al,1 ;MSW_PE - jz vcpi_ret - mov bx,offset sssp endif - p386 - pop ax ; convert - push cs ; near call - push ax ; to far call - push ds - mov [bx],sp - ;mov [bx+2],ss - - call switch_to_pm ; EAX, EDX/ESI, DS, ES, FS, GS destroyed + jz @vm2rm_ret + jmp switch_to_pm ; EAX, ESI, DS, ES, FS, GS destroyed +vm2rm_end: assume nothing assume cs:DGROUP + ;push ss + ;pop ds + ; Now we are in 16-bit protected mode ; Black magic here mov eax,cr0 @@ -374,6 +376,7 @@ ; Now we are in rm, but not yet: have to restore sregs: lss sp,[cs:bx] ; SS +@vm2rm_ret: pop ds ; DS retf ; CS diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/XMM.ASM --- a/linld/stuff/src/XMM.ASM Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/XMM.ASM Thu Feb 18 08:56:43 2021 +0000 @@ -6,11 +6,7 @@ %crefref %noincl %nomacs - ifdef NO386 p8086 - else - p386 - endif group DGROUP _TEXT assume cs:DGROUP,ds:DGROUP @@ -23,45 +19,33 @@ global _enable_a20_xmm:near proc _enable_a20_xmm near - mov ah,03h ;global enable a20 + mov ch,03h ;global enable a20 call xmm_driver ; - mov ah,05h ;local enable a20 + mov ch,05h ;local enable a20 ;jmp xmm_driver ; endp _enable_a20_xmm ;*************************************************************** -;Call xmm driver addr or 0 if no xmm +;Call xmm driver addr (success: ax=1) ;void xmm_driver(ah) ;*************************************************************** proc xmm_driver near - push ax ; save cmd + pop bx ; \ + push cs ; fake far call + push bx ; / mov ax,4300h ; installation check in al int 2fh - mov bx,offset @@xmm_fail - push cs - pop es cmp al,80h - jne @@err + jne @@xmm_fail mov ax,4310h ; get driver address in es:bx int 2fh -@@err: - pop ax ; restore cmd + xchg ax,cx ; restore cmd - push cs ; call far - call @@jmp_esbx - dec ax ; Z=1=OK - ret - -@@jmp_esbx: - push es ; \ - push bx ; > jmp far es:bx - retf ; / - + push es ; jmp far es:bx + push bx ; avoid 08h 0Fh 12h and 8Fh functions using bx @@xmm_fail: - xor ax,ax - cwd retf endp xmm_driver @@ -77,33 +61,49 @@ extrn _cmdnum:dword skip_alloc = (byte _cmdnum+16) - cmp [skip_alloc],0 +LARGE_XMM_ALLOC = 1 + ifdef LARGE_XMM_ALLOC + mov ch,89h ;allocate blk of EDX kilobytes + test [skip_alloc],ch ; 89h & ('*'=2Ah) = 08h jne @@err - ifndef NO386 + extrn _cpu386:byte + test [_cpu386],ch + je @@not386 + p386 mov edx,[(image_himem si).size] ; m->size ;dec edx shr edx,10 ; to Kb inc edx - mov ah,89h ;allocate blk of EDX kilobytes + call xmm_driver ; + dec ax ; Z=OK + jz @@gotit +@@not386: + mov cl,16-10 else + mov cl,16-10 + test [skip_alloc],cl ; 06h & ('*'=2Ah) = 02h + jne @@err + endif + p8086 ;mov ax,-1 ;cwd ;add ax,[word (image_himem si).size] ; lo m->size ;adc dx,[word (image_himem si+2).size] ; hi m->size les ax,[dword (image_himem si).size] ; m->size - mov cl,16-10 extrn N_LXLSH@ES:near call N_LXLSH@ES inc dx - mov ah,9h ;allocate blk of DX kilobytes (<64Mb) - endif + mov ch,9h ;allocate blk of DX kilobytes (<64Mb) call xmm_driver ; + dec ax ; Z=OK jnz @@err +@@gotit: ;now: dx=handle of the blk - mov ah,0Ch ;lock blk + mov ch,0Ch ;lock blk call xmm_driver ; ;now: dx:bx=addr of blk - jnz @@err + ;dec ax ; Z=OK + ;jnz @@err mov [word (image_himem si).buf],bx ; lo m->buf mov [word (image_himem si+2).buf],dx ; hi m->buf @@err: diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/_BEG.ASM Thu Feb 18 08:56:43 2021 +0000 @@ -29,7 +29,7 @@ segment _BSS byte public use16 'BSS' - ifdef BIG_CMDLINE + ifdef ISOHOOK extrn _big_cmdline:byte db 254 dup(?) endif @@ -77,7 +77,7 @@ ; Check for oldies push bx ; < 286 : flags[12..15] are forced 1 - popf ; = 286 : flags[12..15] are forced 0 + popf ; = 286 : flags[12..15] are forced 0, cld pushf ; > 286 : only flags[15] is forced 0 pop dx add dh,bh ; NS=386+, S+NC=286, S+C=86/186 @@ -118,15 +118,12 @@ ;*************************************************************** label check_vcpi near p386 - push ds -; Check whether it is safe to call 67h (we trust only known EMM managers) - push si - pop ds - mov ax,[word 67h*4] - or ax,[word 67h*4+2] - pop ds +; Check whether it is safe to call 67h + xor eax,eax + mov es,ax + cmp [dword es:67h*4],eax je no_vcpi - mov ax,0DE00h ; check for vcpi present + mov ah,0DEh ; check for vcpi present int 67h or ah,ah jnz no_vcpi @@ -183,7 +180,7 @@ org $-2 _heap_top dw ? mov si,80h - ifdef BIG_CMDLINE + ifdef ISOHOOK mov bx,offset _big_cmdline cmp [byte si],2 jnb @@user_args @@ -192,7 +189,7 @@ endif lodsb ; size 0..127 cbw - ifdef BIG_CMDLINE + ifdef ISOHOOK inc ax jnz short_cmdline mov si,bx @@ -235,43 +232,6 @@ inc bx dec cx jmp arglp -argdone: - ;mov [word bx+di],0 ; argv[argc] = 0 - lea ax,[bx+di+2] - mov [_heap_top],ax - push di ; argv - shr bx,1 - push bx ; argc - ifndef filearg - mov bx,[di+2] ; argv[1] - extrn openargs:near - call near openargs - jc argend - pop bx ; trash argc, argv >> 1Kb ! - pop cx ; sizemax=argv -read_cmdline: - mov dx,di - push dx - xchg ax,bx - extrn @read$cxdxbx:near ; read(fd=bx,buffer=dx,size=cx) - call near @read$cxdxbx - pop si ; si=buffer=argv - add di,ax - ifndef NO_CLOSE - extrn close:near - call near close - endif - jmp argbuild -argend: - endif - -;*************************************************************** - extrn _main:near - call _main - ;never return - -;*************************************************************** - ;*************************************************************** ;_fastcall void set_cmdline(bx:const char *filename); @@ -308,6 +268,46 @@ endp _topseg endif +;*************************************************************** +argdone: + ;mov [word bx+di],0 ; argv[argc] = 0 + lea ax,[bx+di+2] + mov [_heap_top],ax + ;push di ; argv + ;shr bx,1 + ;push bx ; argc + ifndef filearg + mov bx,[di+2] ; argv[1] + extrn openargs:near + call near openargs + jc argend + ;pop bx ; trash argc, argv >> 1Kb ! + ;pop cx ; sizemax=argv + dec cx ; sizemax=0ffffh +read_cmdline: + mov dx,di + push dx + xchg ax,bx + extrn @read$cxdxbx:near ; read(fd=bx,buffer=dx,size=cx) + call near @read$cxdxbx + pop si ; si=buffer=argv + add di,ax + ifndef NO_CLOSE + extrn close:near + call near close + endif + jmp argbuild +argend: + endif + +;*************************************************************** +; extrn _main:near +; call _main + ;never return + +;*************************************************************** + + ends _TEXT diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/_END.ASM --- a/linld/stuff/src/_END.ASM Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/_END.ASM Thu Feb 18 08:56:43 2021 +0000 @@ -15,14 +15,15 @@ segment _DATA byte public use16 'DATA' ;global _data_end:byte label _data_end byte - ifdef BIG_CMDLINE + ifdef ISOHOOK global _big_cmdline:byte _big_cmdline db 0 endif ends _DATA segment _BSS word public use16 'BSS' -STACK_SIZE = 256 +;STACK_SIZE = 128 +STACK_SIZE = 512 db STACK_SIZE dup(?) global stktop:byte label stktop byte diff -r a1b12ae1c852 -r bc4b94310a29 linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Thu Feb 11 17:59:34 2021 +0000 +++ b/linld/stuff/src/pipehole.awk Thu Feb 18 08:56:43 2021 +0000 @@ -9,37 +9,27 @@ if (file == "" && /debug S/) { file=$3; gsub(/\"/,"",file) } if (/debug S/) print " %PAGESIZE 1000" if (file == "linld.cpp") { - if (/add si,2/) $0=" lodsw ; " $0 + if (/\[si/ || /si,/ || /,si/) sub(/si/,"di") + else if (/\[di/ || /di,/ || /,di/) sub(/di/,"si") if (/add di,2/) $0=" scasw ; " $0 - if (/bx,offset DGROUP:s@\+26/) sub(/mov/,";mov") - if (/bx,si/ || /\[bp-2\]/) next - sub(/\[bx\],0/,"[si],0") + if (/bx,di/ || /\[bp-2\]/) next + sub(/\[bx\],0/,"[di],0") if (islinld==1) { + if (/,word.*/) islinld=0 print "; " $0 - if (!/word ptr/) next - islinld=0 - sub(/,word.*/,",di ; argv") - if (/di,di/) { print "; " $0; next } + next } if (/^_main proc/) islinld=1 - if (/== 0x662F/) islinld=2 - if (islinld==2) { - if (/cpuhaslm/) islinld=0 - if (/bx,word/) { print "; " $0; next } - } if (/image\|initrd/) islinld=3 - if (islinld==3) { - if (/bx,word ptr/) { print "; " $0; next } - } + if (islinld==3 && /bx,word ptr/) { print "; " $0; next } if (/fileexist\$qpxzc/) islinld=4 if (islinld==4) { if (/ax,-1/) { print " inc ax" - print " mov ax,word ptr [si]" + print " mov ax,word ptr [di]" next } if (/ax,word ptr/) next - if (/\[si\]$/) { islinld=0; print "; " $0; next } } if (/buf_cmdline\+1/) { islinld=5 @@ -53,7 +43,7 @@ } if (/bx,word ptr DGROUP:_cmdstr\+6/) next if (/_cmdstr\+6,0/) { - print " mov bx,word ptr [di+6]" + print " mov bx,word ptr [si+6]" $0=" or bx,bx" } } # file == "linld.cpp" @@ -63,7 +53,7 @@ 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/ || /DGROUP:_himem_buf\+2,ax/) sub(/,ax/,",es") + if (/si\+12\],ax/ || /si\+16\],ax/ || /di\+2\],ax/ || /DGROUP:_himem_buf\+2,ax/) sub(/,ax/,",es") if (/dx,dword ptr \[si\+14\]/ || /DGROUP:_himem_buf,dx/) sub(/dx/,"ax") } if (ishimem == 1) { @@ -84,7 +74,7 @@ if (/i\+12/) ishimem=20 } if (ishimem == 20) { - if (/stc/ || /loadfail/) next + if (/loadfail/) next if (/je/) { print " extrn jmploadfailure" $0=" jne short jmploadfailure" @@ -92,27 +82,10 @@ if (/endp/) ishimem=0 } if (/@memcpy_image\$qp11image_himem/) next - if (/far last_ditch/) { - print " extrn memcpy_image_kernel:near" - print " extrn memcpy_image_initrd:near" - ishimem=3 - cpy_initrd=0 - } + if (/far last_ditch/) ishimem=3 if (ishimem == 3) { sub(/DGROUP:_imgs\+4,/,"[si+4],") - if (/bx,di/ || /di,ax/ || /bx,30/) next - if (/mov bx,si/) { - if (cpy_initrd==0) sub(/mov bx,si/, "call memcpy_image_kernel") - else sub(/mov bx,si/, "call memcpy_image_initrd") - cpy_initrd=1-cpy_initrd - } - sub(/lea bx,\[si\+30\]/, "call memcpy_image_initrd") - } - if (/m = pm2initrd/) ishimem=4 - if (ishimem == 4) { - if (/si,30/ || /bx,di/ || /di,ax/) next - sub(/\[si/,"[si+30") - sub(/mov bx,si/, "call memcpy_image_initrd") + if (/bx,di/ || /di,ax/) next } } # file == "himem.cpp" if (file == "load.cpp") { diff -r a1b12ae1c852 -r bc4b94310a29 wpa_supplicant/receipt --- a/wpa_supplicant/receipt Thu Feb 11 17:59:34 2021 +0000 +++ b/wpa_supplicant/receipt Thu Feb 18 08:56:43 2021 +0000 @@ -26,6 +26,12 @@ arm*) BUILD_DEPENDS="openssl-dev libcrypto-dev libnl-dev" ;; esac +current_version() +{ + wget -O - $WEB_SITE 2>/dev/null | \ + sed '/releases\//!d;s|.*/'$PACKAGE'-||;s|.t.*||;q' +} + # Rules to configure and make the package. compile_rules() { @@ -36,6 +42,8 @@ CONFIG_AP=y CONFIG_BGSCAN_SIMPLE=y CONFIG_LIBNL20=y +CONFIG_USIM_SIMULATOR=y +CONFIG_SIM_SIMULATOR=y EOT # Dont use DBUS on ARM arch case "$ARCH" in @@ -86,6 +94,18 @@ # Startup script and cleaned up wpa_empty.conf cp -a $stuff/etc $fs install -m644 -oroot -groot $src/$PACKAGE/wpa_supplicant.conf $fs/etc/wpa + + cat >> $fs/etc/wpa/wpa_supplicant.conf <