initial version
This commit is contained in:
231
Book-Lite/linux-0.12/init/main.c
Normal file
231
Book-Lite/linux-0.12/init/main.c
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* linux/init/main.c
|
||||
*
|
||||
* (C) 1991 Linus Torvalds
|
||||
*/
|
||||
|
||||
#define __LIBRARY__
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
/*
|
||||
* we need this inline - forking from kernel space will result
|
||||
* in NO COPY ON WRITE (!!!), until an execve is executed. This
|
||||
* is no problem, but for the stack. This is handled by not letting
|
||||
* main() use the stack at all after fork(). Thus, no function
|
||||
* calls - which means inline code for fork too, as otherwise we
|
||||
* would use the stack upon exit from 'fork()'.
|
||||
*
|
||||
* Actually only pause and fork are needed inline, so that there
|
||||
* won't be any messing with the stack from main(), but we define
|
||||
* some others too.
|
||||
*/
|
||||
static inline _syscall0(int,fork)
|
||||
static inline _syscall0(int,pause)
|
||||
static inline _syscall1(int,setup,void *,BIOS)
|
||||
static inline _syscall0(int,sync)
|
||||
|
||||
#include <linux/tty.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/head.h>
|
||||
#include <asm/system.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static char printbuf[1024];
|
||||
|
||||
extern char *strcpy();
|
||||
extern int vsprintf();
|
||||
extern void init(void);
|
||||
extern void blk_dev_init(void);
|
||||
extern void chr_dev_init(void);
|
||||
extern void hd_init(void);
|
||||
extern void floppy_init(void);
|
||||
extern void mem_init(long start, long end);
|
||||
extern long rd_init(long mem_start, int length);
|
||||
extern long kernel_mktime(struct tm * tm);
|
||||
|
||||
static int sprintf(char * str, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i = vsprintf(str, fmt, args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is set up by the setup-routine at boot-time
|
||||
*/
|
||||
#define EXT_MEM_K (*(unsigned short *)0x90002)
|
||||
#define CON_ROWS ((*(unsigned short *)0x9000e) & 0xff)
|
||||
#define CON_COLS (((*(unsigned short *)0x9000e) & 0xff00) >> 8)
|
||||
#define DRIVE_INFO (*(struct drive_info *)0x90080)
|
||||
#define ORIG_ROOT_DEV (*(unsigned short *)0x901FC)
|
||||
#define ORIG_SWAP_DEV (*(unsigned short *)0x901FA)
|
||||
|
||||
/*
|
||||
* Yeah, yeah, it's ugly, but I cannot find how to do this correctly
|
||||
* and this seems to work. I anybody has more info on the real-time
|
||||
* clock I'd be interested. Most of this was trial and error, and some
|
||||
* bios-listing reading. Urghh.
|
||||
*/
|
||||
|
||||
#define CMOS_READ(addr) ({ \
|
||||
outb_p(0x80|addr,0x70); \
|
||||
inb_p(0x71); \
|
||||
})
|
||||
|
||||
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
|
||||
|
||||
static void time_init(void)
|
||||
{
|
||||
struct tm time;
|
||||
|
||||
do {
|
||||
time.tm_sec = CMOS_READ(0);
|
||||
time.tm_min = CMOS_READ(2);
|
||||
time.tm_hour = CMOS_READ(4);
|
||||
time.tm_mday = CMOS_READ(7);
|
||||
time.tm_mon = CMOS_READ(8);
|
||||
time.tm_year = CMOS_READ(9);
|
||||
} while (time.tm_sec != CMOS_READ(0));
|
||||
BCD_TO_BIN(time.tm_sec);
|
||||
BCD_TO_BIN(time.tm_min);
|
||||
BCD_TO_BIN(time.tm_hour);
|
||||
BCD_TO_BIN(time.tm_mday);
|
||||
BCD_TO_BIN(time.tm_mon);
|
||||
BCD_TO_BIN(time.tm_year);
|
||||
time.tm_mon--;
|
||||
startup_time = kernel_mktime(&time);
|
||||
}
|
||||
|
||||
static long memory_end = 0;
|
||||
static long buffer_memory_end = 0;
|
||||
static long main_memory_start = 0;
|
||||
static char term[32];
|
||||
|
||||
static char * argv_rc[] = { "/bin/sh", NULL };
|
||||
static char * envp_rc[] = { "HOME=/", NULL ,NULL };
|
||||
|
||||
static char * argv[] = { "-/bin/sh",NULL };
|
||||
static char * envp[] = { "HOME=/usr/root", NULL, NULL };
|
||||
|
||||
struct drive_info { char dummy[32]; } drive_info;
|
||||
|
||||
void main(void) /* This really IS void, no error here. */
|
||||
{ /* The startup routine assumes (well, ...) this */
|
||||
/*
|
||||
* Interrupts are still disabled. Do necessary setups, then
|
||||
* enable them
|
||||
*/
|
||||
ROOT_DEV = ORIG_ROOT_DEV;
|
||||
SWAP_DEV = ORIG_SWAP_DEV;
|
||||
sprintf(term, "TERM=con%dx%d", CON_COLS, CON_ROWS);
|
||||
envp[1] = term;
|
||||
envp_rc[1] = term;
|
||||
drive_info = DRIVE_INFO;
|
||||
memory_end = (1<<20) + (EXT_MEM_K<<10);
|
||||
memory_end &= 0xfffff000;
|
||||
if (memory_end > 16*1024*1024)
|
||||
memory_end = 16*1024*1024;
|
||||
if (memory_end > 12*1024*1024)
|
||||
buffer_memory_end = 4*1024*1024;
|
||||
else if (memory_end > 6*1024*1024)
|
||||
buffer_memory_end = 2*1024*1024;
|
||||
else
|
||||
buffer_memory_end = 1*1024*1024;
|
||||
main_memory_start = buffer_memory_end;
|
||||
#ifdef RAMDISK
|
||||
main_memory_start += rd_init(main_memory_start, RAMDISK*1024);
|
||||
#endif
|
||||
mem_init(main_memory_start,memory_end);
|
||||
trap_init();
|
||||
blk_dev_init();
|
||||
chr_dev_init();
|
||||
tty_init();
|
||||
time_init();
|
||||
sched_init();
|
||||
buffer_init(buffer_memory_end);
|
||||
hd_init();
|
||||
floppy_init();
|
||||
sti();
|
||||
move_to_user_mode();
|
||||
if (!fork()) { /* we count on this going ok */
|
||||
init();
|
||||
}
|
||||
/*
|
||||
* NOTE!! For any other task 'pause()' would mean we have to get a
|
||||
* signal to awaken, but task0 is the sole exception (see 'schedule()')
|
||||
* as task 0 gets activated at every idle moment (when no other tasks
|
||||
* can run). For task0 'pause()' just means we go check if some other
|
||||
* task can run, and if not we return here.
|
||||
*/
|
||||
for(;;)
|
||||
__asm__("int $0x80"::"a" (__NR_pause):"ax");
|
||||
}
|
||||
|
||||
static int printf(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
write(1,printbuf,i=vsprintf(printbuf, fmt, args));
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
void init(void)
|
||||
{
|
||||
int pid,i;
|
||||
|
||||
setup((void *) &drive_info);
|
||||
(void) open("/dev/tty1",O_RDWR,0);
|
||||
(void) dup(0);
|
||||
(void) dup(0);
|
||||
printf("%d buffers = %d bytes buffer space\n\r",NR_BUFFERS,
|
||||
NR_BUFFERS*BLOCK_SIZE);
|
||||
printf("Free mem: %d bytes\n\r",memory_end-main_memory_start);
|
||||
if (!(pid=fork())) {
|
||||
close(0);
|
||||
if (open("/etc/rc",O_RDONLY,0))
|
||||
_exit(1);
|
||||
execve("/bin/sh",argv_rc,envp_rc);
|
||||
_exit(2);
|
||||
}
|
||||
if (pid>0)
|
||||
while (pid != wait(&i))
|
||||
/* nothing */;
|
||||
while (1) {
|
||||
if ((pid=fork())<0) {
|
||||
printf("Fork failed in init\r\n");
|
||||
continue;
|
||||
}
|
||||
if (!pid) {
|
||||
close(0);close(1);close(2);
|
||||
setsid();
|
||||
(void) open("/dev/tty1",O_RDWR,0);
|
||||
(void) dup(0);
|
||||
(void) dup(0);
|
||||
_exit(execve("/bin/sh",argv,envp));
|
||||
}
|
||||
while (1)
|
||||
if (pid == wait(&i))
|
||||
break;
|
||||
printf("\n\rchild %d died with code %04x\n\r",pid,i);
|
||||
sync();
|
||||
}
|
||||
_exit(0); /* NOTE! _exit, not exit() */
|
||||
}
|
||||
551
Book-Lite/linux-0.12/init/main.s
Normal file
551
Book-Lite/linux-0.12/init/main.s
Normal file
@@ -0,0 +1,551 @@
|
||||
.file "init/main.c"
|
||||
gcc_compiled.:
|
||||
.text
|
||||
LC0:
|
||||
.ascii "out of memory\12\15\0"
|
||||
.align 2
|
||||
_sprintf:
|
||||
movl 4(%esp),%edx
|
||||
leal 12(%esp),%eax
|
||||
pushl %eax
|
||||
pushl 12(%esp)
|
||||
pushl %edx
|
||||
call _vsprintf
|
||||
addl $12,%esp
|
||||
ret
|
||||
.align 2
|
||||
_time_init:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $44,%esp
|
||||
L65:
|
||||
movl $128,%eax
|
||||
movl $112,%edx
|
||||
/APP
|
||||
outb %al,%dx
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movl $113,%edx
|
||||
/APP
|
||||
inb %dx,%al
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movb %al,-40(%ebp)
|
||||
movzbl -40(%ebp),%eax
|
||||
movl %eax,-36(%ebp)
|
||||
movl $130,%eax
|
||||
movl $112,%edx
|
||||
/APP
|
||||
outb %al,%dx
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movl $113,%edx
|
||||
/APP
|
||||
inb %dx,%al
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movb %al,-40(%ebp)
|
||||
movzbl -40(%ebp),%eax
|
||||
movl %eax,-32(%ebp)
|
||||
movl $132,%eax
|
||||
movl $112,%edx
|
||||
/APP
|
||||
outb %al,%dx
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movl $113,%edx
|
||||
/APP
|
||||
inb %dx,%al
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movb %al,-40(%ebp)
|
||||
movzbl -40(%ebp),%eax
|
||||
movl %eax,-28(%ebp)
|
||||
movl $135,%eax
|
||||
movl $112,%edx
|
||||
/APP
|
||||
outb %al,%dx
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movl $113,%edx
|
||||
/APP
|
||||
inb %dx,%al
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movb %al,-40(%ebp)
|
||||
movzbl -40(%ebp),%eax
|
||||
movl %eax,-24(%ebp)
|
||||
movl $136,%eax
|
||||
movl $112,%edx
|
||||
/APP
|
||||
outb %al,%dx
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movl $113,%edx
|
||||
/APP
|
||||
inb %dx,%al
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movb %al,-40(%ebp)
|
||||
movzbl -40(%ebp),%eax
|
||||
movl %eax,-20(%ebp)
|
||||
movl $137,%eax
|
||||
movl $112,%edx
|
||||
/APP
|
||||
outb %al,%dx
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movl $113,%edx
|
||||
/APP
|
||||
inb %dx,%al
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movb %al,-40(%ebp)
|
||||
movzbl -40(%ebp),%eax
|
||||
movl %eax,-16(%ebp)
|
||||
movl $128,%eax
|
||||
movl $112,%edx
|
||||
/APP
|
||||
outb %al,%dx
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movl $113,%edx
|
||||
/APP
|
||||
inb %dx,%al
|
||||
jmp 1f
|
||||
1: jmp 1f
|
||||
1:
|
||||
/NO_APP
|
||||
movb %al,-40(%ebp)
|
||||
movzbl -40(%ebp),%eax
|
||||
cmpl -36(%ebp),%eax
|
||||
jne L65
|
||||
movl -36(%ebp),%eax
|
||||
andl $15,%eax
|
||||
movl -36(%ebp),%edx
|
||||
sarl $4,%edx
|
||||
leal (%edx,%edx,4),%edx
|
||||
leal (%eax,%edx,2),%eax
|
||||
movl %eax,-36(%ebp)
|
||||
movl -32(%ebp),%eax
|
||||
andl $15,%eax
|
||||
movl -32(%ebp),%edx
|
||||
sarl $4,%edx
|
||||
leal (%edx,%edx,4),%edx
|
||||
leal (%eax,%edx,2),%eax
|
||||
movl %eax,-32(%ebp)
|
||||
movl -28(%ebp),%eax
|
||||
andl $15,%eax
|
||||
movl -28(%ebp),%edx
|
||||
sarl $4,%edx
|
||||
leal (%edx,%edx,4),%edx
|
||||
leal (%eax,%edx,2),%eax
|
||||
movl %eax,-28(%ebp)
|
||||
movl -24(%ebp),%eax
|
||||
andl $15,%eax
|
||||
movl -24(%ebp),%edx
|
||||
sarl $4,%edx
|
||||
leal (%edx,%edx,4),%edx
|
||||
leal (%eax,%edx,2),%eax
|
||||
movl %eax,-24(%ebp)
|
||||
movl -20(%ebp),%eax
|
||||
andl $15,%eax
|
||||
movl -20(%ebp),%edx
|
||||
sarl $4,%edx
|
||||
leal (%edx,%edx,4),%edx
|
||||
leal (%eax,%edx,2),%eax
|
||||
movl %eax,-20(%ebp)
|
||||
movl -16(%ebp),%eax
|
||||
andl $15,%eax
|
||||
movl -16(%ebp),%edx
|
||||
sarl $4,%edx
|
||||
leal (%edx,%edx,4),%edx
|
||||
leal (%eax,%edx,2),%eax
|
||||
movl %eax,-16(%ebp)
|
||||
decl -20(%ebp)
|
||||
leal -36(%ebp),%eax
|
||||
pushl %eax
|
||||
call _kernel_mktime
|
||||
movl %eax,_startup_time
|
||||
leave
|
||||
ret
|
||||
.data
|
||||
.align 2
|
||||
_memory_end:
|
||||
.long 0
|
||||
.align 2
|
||||
_buffer_memory_end:
|
||||
.long 0
|
||||
.align 2
|
||||
_main_memory_start:
|
||||
.long 0
|
||||
.text
|
||||
LC1:
|
||||
.ascii "/bin/sh\0"
|
||||
.data
|
||||
.align 2
|
||||
_argv_rc:
|
||||
.long LC1
|
||||
.long 0
|
||||
.text
|
||||
LC2:
|
||||
.ascii "HOME=/\0"
|
||||
.data
|
||||
.align 2
|
||||
_envp_rc:
|
||||
.long LC2
|
||||
.long 0
|
||||
.long 0
|
||||
.text
|
||||
LC3:
|
||||
.ascii "-/bin/sh\0"
|
||||
.data
|
||||
.align 2
|
||||
_argv:
|
||||
.long LC3
|
||||
.long 0
|
||||
.text
|
||||
LC4:
|
||||
.ascii "HOME=/usr/root\0"
|
||||
.data
|
||||
.align 2
|
||||
_envp:
|
||||
.long LC4
|
||||
.long 0
|
||||
.long 0
|
||||
.text
|
||||
LC5:
|
||||
.ascii "TERM=con%dx%d\0"
|
||||
.align 2
|
||||
.globl _main
|
||||
_main:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
movzwl 590332,%eax
|
||||
movl %eax,_ROOT_DEV
|
||||
movzwl 590330,%eax
|
||||
movl %eax,_SWAP_DEV
|
||||
movw 589838,%dx
|
||||
andl $255,%edx
|
||||
pushl %edx
|
||||
movw 589838,%ax
|
||||
andw $65280,%ax
|
||||
shrw $8,%ax
|
||||
movw %ax,-4(%ebp)
|
||||
movzwl -4(%ebp),%eax
|
||||
pushl %eax
|
||||
pushl $LC5
|
||||
pushl $_term
|
||||
call _sprintf
|
||||
movl $_term,_envp+4
|
||||
movl $_term,_envp_rc+4
|
||||
movl $_drive_info,%edi
|
||||
movl $589952,%esi
|
||||
movl $8,%ecx
|
||||
cld
|
||||
rep
|
||||
movsl
|
||||
movzwl 589826,%eax
|
||||
sall $10,%eax
|
||||
addl $1048576,%eax
|
||||
movl %eax,_memory_end
|
||||
andl $-4096,_memory_end
|
||||
addl $16,%esp
|
||||
cmpl $16777216,_memory_end
|
||||
jle L69
|
||||
movl $16777216,_memory_end
|
||||
L69:
|
||||
cmpl $12582912,_memory_end
|
||||
jle L70
|
||||
movl $4194304,_buffer_memory_end
|
||||
jmp L71
|
||||
.align 2
|
||||
L70:
|
||||
cmpl $6291456,_memory_end
|
||||
jle L72
|
||||
movl $2097152,_buffer_memory_end
|
||||
jmp L71
|
||||
.align 2
|
||||
L72:
|
||||
movl $1048576,_buffer_memory_end
|
||||
L71:
|
||||
movl _buffer_memory_end,%eax
|
||||
movl %eax,_main_memory_start
|
||||
pushl _memory_end
|
||||
pushl _buffer_memory_end
|
||||
call _mem_init
|
||||
call _trap_init
|
||||
call _blk_dev_init
|
||||
call _chr_dev_init
|
||||
call _tty_init
|
||||
call _time_init
|
||||
call _sched_init
|
||||
pushl _buffer_memory_end
|
||||
call _buffer_init
|
||||
call _hd_init
|
||||
call _floppy_init
|
||||
/APP
|
||||
sti
|
||||
movl %esp,%eax
|
||||
pushl $0x17
|
||||
pushl %eax
|
||||
pushfl
|
||||
pushl $0x0f
|
||||
pushl $1f
|
||||
iret
|
||||
1: movl $0x17,%eax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
/NO_APP
|
||||
addl $12,%esp
|
||||
movl $2,%eax
|
||||
/APP
|
||||
int $0x80
|
||||
/NO_APP
|
||||
movl %eax,%edx
|
||||
testl %edx,%edx
|
||||
jge L75
|
||||
negl %edx
|
||||
movl %edx,_errno
|
||||
movl $-1,%edx
|
||||
L75:
|
||||
testl %edx,%edx
|
||||
jne L74
|
||||
call _init
|
||||
L74:
|
||||
L77:
|
||||
movl $29,%eax
|
||||
/APP
|
||||
int $0x80
|
||||
/NO_APP
|
||||
jmp L77
|
||||
.align 2
|
||||
leal -16(%ebp),%esp
|
||||
popl %esi
|
||||
popl %edi
|
||||
leave
|
||||
ret
|
||||
.align 2
|
||||
_printf:
|
||||
pushl %ebx
|
||||
leal 12(%esp),%eax
|
||||
pushl %eax
|
||||
pushl 12(%esp)
|
||||
pushl $_printbuf
|
||||
call _vsprintf
|
||||
movl %eax,%ebx
|
||||
pushl %ebx
|
||||
pushl $_printbuf
|
||||
pushl $1
|
||||
call _write
|
||||
movl %ebx,%eax
|
||||
addl $24,%esp
|
||||
popl %ebx
|
||||
ret
|
||||
LC6:
|
||||
.ascii "/dev/tty1\0"
|
||||
LC7:
|
||||
.ascii "%d buffers = %d bytes buffer space\12\15\0"
|
||||
LC8:
|
||||
.ascii "Free mem: %d bytes\12\15\0"
|
||||
LC9:
|
||||
.ascii "/etc/rc\0"
|
||||
LC10:
|
||||
.ascii "Fork failed in init\15\12\0"
|
||||
LC11:
|
||||
.ascii "\12\15child %d died with code %04x\12\15\0"
|
||||
.align 2
|
||||
.globl _init
|
||||
_init:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $4,%esp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
xorl %eax,%eax
|
||||
movl $_drive_info,%ebx
|
||||
/APP
|
||||
int $0x80
|
||||
/NO_APP
|
||||
testl %eax,%eax
|
||||
jge L82
|
||||
negl %eax
|
||||
movl %eax,_errno
|
||||
L82:
|
||||
pushl $0
|
||||
pushl $2
|
||||
pushl $LC6
|
||||
call _open
|
||||
pushl $0
|
||||
call _dup
|
||||
pushl $0
|
||||
call _dup
|
||||
movl _nr_buffers,%eax
|
||||
sall $10,%eax
|
||||
pushl %eax
|
||||
pushl _nr_buffers
|
||||
pushl $LC7
|
||||
call _printf
|
||||
addl $32,%esp
|
||||
movl _memory_end,%eax
|
||||
subl _main_memory_start,%eax
|
||||
pushl %eax
|
||||
pushl $LC8
|
||||
call _printf
|
||||
addl $8,%esp
|
||||
movl $2,%eax
|
||||
/APP
|
||||
int $0x80
|
||||
/NO_APP
|
||||
testl %eax,%eax
|
||||
jl L86
|
||||
movl %eax,%edi
|
||||
jmp L85
|
||||
.align 2
|
||||
L86:
|
||||
negl %eax
|
||||
movl %eax,_errno
|
||||
movl $-1,%edi
|
||||
L85:
|
||||
testl %edi,%edi
|
||||
jne L84
|
||||
pushl $0
|
||||
call _close
|
||||
pushl $0
|
||||
pushl $0
|
||||
pushl $LC9
|
||||
call _open
|
||||
addl $16,%esp
|
||||
testl %eax,%eax
|
||||
je L87
|
||||
pushl $1
|
||||
call __exit
|
||||
.align 2
|
||||
L87:
|
||||
pushl $_envp_rc
|
||||
pushl $_argv_rc
|
||||
pushl $LC1
|
||||
call _execve
|
||||
pushl $2
|
||||
call __exit
|
||||
.align 2
|
||||
L84:
|
||||
testl %edi,%edi
|
||||
jle L88
|
||||
leal -4(%ebp),%esi
|
||||
L89:
|
||||
pushl %esi
|
||||
call _wait
|
||||
addl $4,%esp
|
||||
cmpl %edi,%eax
|
||||
jne L89
|
||||
L88:
|
||||
leal -4(%ebp),%esi
|
||||
L91:
|
||||
movl $2,%eax
|
||||
/APP
|
||||
int $0x80
|
||||
/NO_APP
|
||||
testl %eax,%eax
|
||||
jge L94
|
||||
negl %eax
|
||||
movl %eax,_errno
|
||||
movl $-1,%eax
|
||||
L94:
|
||||
movl %eax,%edi
|
||||
testl %edi,%edi
|
||||
jge L93
|
||||
pushl $LC10
|
||||
call _printf
|
||||
addl $4,%esp
|
||||
jmp L91
|
||||
.align 2
|
||||
L93:
|
||||
testl %edi,%edi
|
||||
jne L96
|
||||
pushl $0
|
||||
call _close
|
||||
pushl $1
|
||||
call _close
|
||||
pushl $2
|
||||
call _close
|
||||
call _setsid
|
||||
pushl $0
|
||||
pushl $2
|
||||
pushl $LC6
|
||||
call _open
|
||||
pushl $0
|
||||
call _dup
|
||||
pushl $0
|
||||
call _dup
|
||||
addl $32,%esp
|
||||
pushl $_envp
|
||||
pushl $_argv
|
||||
pushl $LC1
|
||||
call _execve
|
||||
pushl %eax
|
||||
call __exit
|
||||
.align 2
|
||||
L96:
|
||||
L97:
|
||||
pushl %esi
|
||||
call _wait
|
||||
addl $4,%esp
|
||||
cmpl %edi,%eax
|
||||
jne L97
|
||||
pushl -4(%ebp)
|
||||
pushl %edi
|
||||
pushl $LC11
|
||||
call _printf
|
||||
addl $12,%esp
|
||||
movl $36,%eax
|
||||
/APP
|
||||
int $0x80
|
||||
/NO_APP
|
||||
testl %eax,%eax
|
||||
jge L91
|
||||
negl %eax
|
||||
movl %eax,_errno
|
||||
jmp L91
|
||||
.align 2
|
||||
leal -16(%ebp),%esp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
leave
|
||||
ret
|
||||
.comm _drive_info,32
|
||||
.lcomm _term,32
|
||||
.lcomm _printbuf,1024
|
||||
Reference in New Issue
Block a user