⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 second.s

📁 LINUX lilo-22.7 源代码。
💻 S
📖 第 1 页 / 共 5 页
字号:
	jmp	pwagain		! get password againpwdelch:pop	bx		! at the beginning of the line ?	push	bx	add	bx,#MAX_IMAGE_NAME+1	cmp	si,bx	je	pwloop		! yes -> ignore it	dec	si		! remove one character	sub	cl,#1	jnc	pwloop		! no underflow -> go on	inc	cl		! adjust it	jmp	pwloop		! next characterpwtime:	pop	cx		! drop CX ...	mov	cl,#1		! ... and failpwcr:	call	crlf	pop	bx		! restore the image descriptor	or	cl,cl		! no errors ?	jnz	pwfail		! no -> fail	cmp	byte ptr (si),#0 ! at end ?	je	doboot		! yes -> continue booting#endif	/* CRC_PASSWORDS */pwfail:	mov	bx,#msg_pf	! display an error message	call	say	br	iloop		! get next input! Boot the image BX points todoboot:	mov	byte ptr prechr,#61 ! switch to equal sign	push	bx		! save image descr	mov	bx,#msg_l	! say hi	call	say	pop	bx		! display the image name	push	bx	call	say	pop	si	push	si	add	si,#id_start	! form address	;  Now load the kernel sectors	xor	ax,ax	mov	word ptr (gdt+0x1b),ax ! set GDT to "load low"	mov	byte ptr (gdt+0x1f),al	mov	moff,ax		! map is not loaded yet	lodsw			! address of the first map sector	xchg	cx,ax	lodsw	xchg	dx,ax        lodsb	push	si		! save SI#ifdef DEBUG        push    ax              ;	mov bx,#step0	call say        pop     ax              ;#endif	mov	bx,[map]		! load the first map sector	call	sread#ifdef DEBUG	mov bx,#step0b	call say#endif	mov	bx,#DFLCMD	! load the default command line;BEG_FS;SEG_FS	mov	cx,mt_dflcmd+KEYTABLE+256;SEG_FS	mov	dx,mt_dflcmd+2+KEYTABLE+256;SEG_FS	mov	al,mt_dflcmd+4+KEYTABLE+256;END_FS	call	cread	push	word ptr (DFLCMD) ! push magic number	mov	bx,#DFLCMD	! load the fallback sector	call	load1	pop	ax		! valid magic number ?#ifndef LCF_READONLY	cmp	ax,#DC_MAGIC	je	dclok		! yes -> can write	cmp	ax,#DC_MGOFF	jne	nofbck		! invalid -> must not writedclok:	mov	bx,#DFLCMD	! fallback data present ?	cmp	word ptr (bx),#DC_MAGIC	jne	nofbck		! no -> go on	call	cmd_write	! write out the command linenofbck:#endif#ifdef DEBUG	mov bx,#step1	call say#endif	mov	bx,#DFLCMD	! load the options sector	call	load1	mov	si,cmdbeg	! copy non-options part of command line	mov	di,#PARMLINE	mov	cx,#CL_LENGTH-1	! max number of characters to copycpnocl:	#if DNAME	cmp	si,#cmdline#else	cmp	si,options	! at beginning of options ?#endif	je	cpnodn		! yes -> go on	movsb			! copy one byte	loop	cpnocl		! next one	jmp	cpovfl		! signal overflowcpnodn:	#if DNAME	pop	ax		! get saved pointer	pop	si		! get saved descriptor	push	si	push	axcpdname:	lodsb	or	al,al	jz	cpdname9	stosb	dec	cx	jmp	cpdnamecpdname9:	#endif	mov	si,#DFLCMD	! constant options ?	cmp	byte ptr (si),#0	je	nocopt		! no -> go on	mov	al,#32		! add a space	stosb	dec	cx		! count character	jz	cpovflcpcodsp:#if DEBUG_INITRD	cmp	dword ptr (si),#0x3d647269	! "ird="#else	cmp	dword ptr (si),#0x3d6d656d	! "mem="#endif	jne	cpnotmem	call	getmem		! get the user-provided memory limitcpnotmem:	lodsb			! fetch next byte	cmp	al,#32		! space ?	je	cpcodsp		! yes -> discard itcpcolp:	or	al,al		! NUL ?	jz	cpcodn		! yes -> done	stosb			! store byte	dec	cx		! count character	jz	cpovfl	cmp	al,#32		! a space ?	je	cpcodsp		! yes -> discard next	lodsb			! get next byte	jmp	cpcolpcpcodn:	seg	es	cmp	byte ptr (di-1),#32 ! last was space ?	jne	nocopt		! no -> go on	dec	di		! discard it	inc	cx		; **nocopt:	mov	si,options	! append variable optionscpvalp:	lodsb			! copy one byte	stosb	or	al,al		! NUL ?	jz	cpdone		! done?	loop	cpvalp		! count and loop backcpovfl:	mov	(di),cl		! CX is zero#if DEBUG_NEW	dec	cx		! count 1 more character#endifcpdone:#if DEBUG_NEW	push	cx	mov	bx,#msg_pl	; parameter line message	call	say	pop	cx	mov	ax,#CL_LENGTH-1	sub	ax,cx	call	wout	call	crlf#endif#ifdef DEBUG	mov bx,#step2	call say#endif	mov	es,[initseg]	! load the original boot sector	xor	bx,bx		! load now	call	load1	pop	si		! restore SI	lodsw			! get flags bit map	xchg	bx,ax		! move to BX	lodsw			! copy parameters ... VGA mode ... (done)	cmp	word ptr vgaovr,#VGA_NOCOVR ! VGA mode not overridden on				! command line ?	je	vganorm		! no -> go on	mov	ax,vgaovr	! use that value	jmp	vgasetvganorm:test	bx,#FLAG_VGA	jz	novgavgaset:	seg	es	 mov	[VGA_SET],ax	! magic offset in the boot sectornovga:	push	bx		! use flags (BX) later	test	bx,#FLAG_LOCK	! ... lock target ?	jnz	lockit		! yup -> do it	cmp	byte ptr dolock,#0 ! did user ask to lock new target ?	je	nolock		! no -> go onlockit:#ifndef LCF_READONLY	mov	bx,#lkwbuf	! save the command line	mov	word (bx),#DC_MAGIC	;	push	es	push	si        push    ds                      ;        pop     es                      ;	call	cmd_write		; write out the command line	pop	si	pop	es#endifnolock:#ifdef DEBUG	mov bx,#step3	call say#endif	xor	cx,cx	seg	es	  add	cl,[VSS_NUM];;;	or	cx,cx	jnz	lsetup	mov	cl,#SETUPSECS	! default is to load four sectorslsetup:		mov	es,[setupseg]	! load the setup codes#ifdef MEMORY_CHECK	mov	ax,cx		! number of sectors to AX	shl	ax,#5		! convert to paragraphs (9-4)	mov	bx,es	add	bx,ax	add	bx,#STACK>>4	! allow for stack space in paragraphs	mov	ax,cs		!	cmp	bx,ax	jbe	enough_mem	mov	bx,#msg_mem	! we are very short on memory	call	sayenough_mem:#endif	xor	bx,bx		! other operating system)lsloop:	push	cx	call	loadopt	pop	cx	loop	lsloop#ifdef DEBUG	mov bx,#step4	call say#endif	pop	bx		! get flags	test	bx,#FLAG_MODKRN	! "modern" kernel ?	jz	loadlow		! no -> avoid all patching and such	seg	es		! set loader version	mov	byte ptr (16),#LOADER_VERSION	test	bx,#FLAG_LOADHI	! load kernel high	jz	nohigh		seg	es	mov	ax,word ptr (20+1) ; get start address  00 1000 00	mov	(gdt+0x1b),ax	seg	es	mov	al,byte ptr (20+3) ; get hi-byte of address	mov	(gdt+0x1f),alnohigh:	seg	es		! version >= 1 ?	cmp	word ptr (6),#NEW_HDR_VERSION	jbe	noheap		! no -> do not patch heap	mov	ax,cs	sub	ax,[initseg]	! find no. of paragraphs available	shl	ax,4	add	ax,#SLA_SIZE_DYN	seg	es	mov	word ptr (36),ax	seg	es		! patch flags	or	byte ptr (17),#LFLAG_USE_HEAPnoheap:	pop	si		! restore pointer to DESCR to load	push	[gdt+0x1b]	mov	al,[gdt+0x1f]	push	ax	call	load_initrd	! load the initrd & patch header	pop	ax	mov	[gdt+0x1f],al	pop	bx	mov	[gdt+0x1b],bx	cbw	or	ax,bx		! load low ?	je	loadlow		! yes -> do it	xor	ax,ax		! GDT is already set up ...	mov	es,ax	mov	bx,#gdt#if DEBUG_NEW	push	bx	mov	bx,#msg_high	call	say	pop	bx#endif	call	lfile		! load the system ...	jmp	launch2		! ... and run itloadlow:#if DEBUG_NEW	push	bx	mov	bx,#msg_low	call	say	pop	bx#endif	call	loadfile	! load the systemlaunch2:	jmp	launch		! go !loadfile:	push	#SYSSEG		! load a file at SYSSEG:0000	pop	es	xor	bx,bxlfile:	call	load	jmp	lfile! Load one sector. Issue an error at EOF.load1:	call	loadit		! load the sector	mov	bx,#msg_eof	! we only get here at EOF	call	say	br	restrtloadit:	call	load		! load it	pop	ax		! drop return address of load1	ret! Load one sector. Start the system at EOF.loadopt:call	loadit		! load the sector	jmp	launch		! go! Load one sequence of sectors. Leave outer function at EOF.load:	push	es		! save ES:BX	push	bxlfetch:	mov	si,moff		! get map offset	mov	bx,[map]	mov	cx,(bx+si)	! get address	mov	dx,(bx+si+2)	mov	al,(bx+si+4)	or	cx,cx		! at EOF ?	jnz	noteof		! no -> go on	or	dx,dx	jnz	noteof	pop	bx		! restore ES:BX	pop	es	pop	ax		! pop return address	ret			! return to outer functionnoteof:	add	si,#sa_size	! increment pointer	mov	moff,si	cmp	si,#SECTOR_SIZE - sa_size + 1		! page end ?	jb	near doload	mov	moff,#0		! reset pointer	push	cs		! adjust ES	pop	es        mov     bl,hinib        ; this might get clobbered        push    bx              ; so save it	mov	bx,[map]		! load map page	call	sread        pop     ax              ; restore the hi-nibble	mov     hinib,al        ; 	mov	al,#0x2e	! print a dot	call	display	jmp	lfetch		! try again! Start the kernellaunch:; terminate emulation if CD boot	test	byte ptr [par2_flag2],#FLAG2_EL_TORITO	; a CD?	jz	not_el_torito	mov	si,#Map		! empty command packet	mov	byte ptr (si),#0x13	! size of command packet	mov	ax,#0x4b00	! terminate emulation;;;;	mov	dl,al		! DL is 0	mov	dl,[init_dx]	! terminate boot device	int	0x13not_el_torito:#ifdef MENU	call	menu_exit	! make the menu area vanish#endif	call	crlf		! display a CRLF/* 'outb' was removed in 22.5.5; but the HW stop is required by some BIOSs */	mov	dx,#0x3f2	! stop the floppy motor	xor	ax,ax	outb	mov	dl,al	int	0x13		! reset the FDC  (AH=0)	mov	es,[initseg]	! adjust segment registers	mov	di,#PARMLINE	! set parameter line offset	mov	ax,cs		! find where we are loaded	sub	ax,[initseg]	! find no. of paragraphs available	shl	ax,4		! convert para. to bytes	add	di,ax	seg	es	cmp	dword ptr CL_HEADER_ID,#0x53726448	! "HdrS" (reversed)	je	chkver		! go check header versionmbchain:! it must be the chain loader#ifdef LCF_BDATA	BEG_FS	SEG_FS			! suppress BIOS data collection	or	byte ptr par1_prompt+SSDIFF,#FLAG_NOBD	; suppress BIOS data collection	END_FS#endif			! ES:DI will point at param line (chain.b)	push	ds		; save DS	mov	ds,[setupseg]	; point at chain loader(?) header; DS points at chain loader	cmp	dword [parC_signature],#EX_MAG_HL ;	jne	not_chain	cmp	word [parC_stage],#STAGE_CHAIN	jne	not_chain	cmp	word [parC_version],#VERSION	jne	not_chain	mov	dx,[parC_drive]	; get drive;;;	call	map_device	; map drive -- uses CS to address "devmap"	mov	[parC_drive],dl	; store mapped drive	mov	[parC_devmap],#devmap	; save our drive mapping	mov	[parC_devmap+2],cs	; our DS registernot_chain:	pop	ds	BEG_FS	SEG_FS	mov	dx,[EX_OFF+6]	; pass DX from first stage	END_FS#if DEBUG_NEW	mov	bx,#nohdrs	call	say	jmp	cl_wait#else	br	start_setup2#endifchkver:	mov	bh,[gdt+0x1f]		! check for kernel/initrd conflict	shl	ebx,#8	mov	bx,[gdt+0x1b]		! form kernel final load address	shl	ebx,#8	mov	eax,[rdbeg]		! initrd beg address (0 if none)	or	eax,eax	jz	no_overwrite	sub	eax,ebx	jae	no_overwrite	mov	bx,#msg_confl	br	zzno_overwrite:#if DEBUG_NEW	mov	bx,#hdr1	call	say	seg	es	mov	ax,CL_HDRS_VERSION	call	wout	mov	bx,#hdr2	call	say#endif	seg	es	cmp	word ptr CL_HDRS_VERSION,#NEW_VERSION  ! check for				! new cmdline protocol	jb	protocol201! and now the new protocol	mov	ax,es		! form long address	movzx	edx,ax		! zero extend segment part to EDX	movzx	edi,di		! zero extend offset	shl	edx,4		! make segment into address	add	edx,edi		! form long absolute address	seg	es	mov	CL_POINTER,edx	! and pass the address#if DEBUG_NEW	push	edx			call	dout	jmp	cl_wait#else	jmp	start_setup#endif! the old command line passing protocolprotocol201:	seg	es	mov	CL_MAGIC_ADDR,#CL_MAGIC ! set magic number	seg	es	mov	word ptr CL_OFFSET,di#if DEBUG_NEW	mov	ax,es	call	wout	mov	al,#0x3A	! issue colon    	call	display	mov	ax,di	call	woutcl_wait:	call	crlf	call	crlf	jmp	start_setup#endifstart_setup:			! kernel boot comes here#if DEBUG_NEW && defined(LCF_VIRTUAL)	mov	bx,#msg_real	call	vmtest	jnc	boot_real_msg	mov	bx,#msg_virtualboot_real_msg:	call	say#endif#ifdef LCF_BDATA	mov	bx,#msg_bc	call	say	BEG_FS	SEG_FS		! suppress BIOS data collection?	test	byte ptr par1_prompt+SSDIFF,#FLAG_NOBD	; suppress?	END_FS	jz	start_setup3	mov	bx,#msg_by	call	say	jmp	start_setup2start_setup3:#ifndef LCF_READONLY	or	byte ptr [KEYTABLE+256+mt_flag],#FLAG_NOBD	; suppress#if DEBUG_NEW	call	crlf#endif	call	kt_write#endif#if DEBUG_NEW;;;	call	pause	mov	ah,#2		! get keyboard flags	int	0x16	and	al,#0x70	! Caps, Num, Scroll Lock flags	cmp	al,#0x70	je	near zzz	! fail with all 3 on#endif	BEG_FS	SEG_FS	mov	dx,[EX_OFF+6]	! pass in DX from first stage	END_FS	push	es		; save ES	call	is_prev_mapper	; is there a previous mapper	jz	no_remove	seg es	  mov	word (di),#0	; sterilize itno_remove:	pop	es		; and restore ES	call	io_biosdata	mov	bx,#msg_s	call	say#ifndef LCF_READONLY; if the BIOS data collection was successful, do not suppress it on future boots	and	byte ptr [KEYTABLE+256+mt_flag],#~FLAG_NOBD	;  no suppress	call	kt_write#endif#endif	/* ifdef LCF_BDATA */start_setup2:			! chain loader boot comes here#if DEBUG_NEW	call	pause		! last chance to use the timer#else	mov	ax,#1500/55	! about 1.5 second	call	setto		! set timeoutvpaus1:	test	byte ptr timeout,#-1	jz	vpaus1#endif	call	remto		! free timer interrupt	push	es		! is initseg	pop	ds		! DS = 0x9000 (initseg)#if 0	push	es	pop	fs	push	es	pop	gs#endif	add	sp,#SETUP_STACK_DYN	! increase stack size over this codeif ~*&1					! align to an odd memory location	nopendif	jmpi	0,SETUPSEG		! segment part is a variablesetupseg	=	*-2		!   setupseg is filled in nowinitseg:	.word	INITSEG! Load one sector (called from load)doload:	pop	bx		! restore ES:BX	pop	es! Load a sequence of sectors, possibly moving into "high memory" (> 1 MB)! afterwards.xread:	push	ax		! ES == 0 ?	mov	ax,es	or	ax,ax	pop	ax	jz	rdhigh		! yes -> read into high memory#ifdef DEBUG	br	sread#else	jmp	sread#endifrdhigh:	push	bx		! okay - DS:BX points to GDT in this case	mov	bx,#LOADSEG	! adjust ES:BX	mov	es,bx	xor	bx,bx

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -