text
stringlengths
1
1.05M
SFX_Cry04_2_Ch1: dutycycle 240 unknownsfx0x20 4, 247, 160, 6 unknownsfx0x20 8, 230, 164, 6 unknownsfx0x20 4, 214, 160, 6 unknownsfx0x20 12, 211, 32, 6 unknownsfx0x20 8, 195, 36, 6 unknownsfx0x20 4, 194, 32, 6 unknownsfx0x20 8, 177, 16, 6 endchannel SFX_Cry04_2_Ch2: dutycycle 90 unknownsfx0x20 4, 231, 1, 6 unknownsfx0x20 8, 214, 3, 6 unknownsfx0x20 4, 198, 1, 6 unknownsfx0x20 12, 195, 129, 5 unknownsfx0x20 8, 179, 131, 5 unknownsfx0x20 4, 178, 130, 5 unknownsfx0x20 8, 161, 113, 5 endchannel SFX_Cry04_2_Ch3: unknownnoise0x20 7, 214, 92 unknownnoise0x20 8, 230, 76 unknownnoise0x20 4, 212, 92 unknownnoise0x20 4, 212, 76 unknownnoise0x20 7, 195, 76 unknownnoise0x20 8, 161, 92 endchannel
; A072260: a(n) = ((6*n+19)*4^n - 1)/3. ; 6,33,165,789,3669,16725,75093,333141,1463637,6378837,27612501,118838613,508908885,2169853269,9216283989,39012619605,164640413013,692921390421,2909124515157 mov $1,6 lpb $0 sub $0,1 add $1,$0 mul $1,4 lpe div $1,2 sub $1,1 mul $1,3 mov $0,$1
/** Copyright (c) 2015-present, Facebook, Inc. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. */ #include <xcdriver/ListAction.h> #include <xcdriver/Action.h> #include <xcdriver/Options.h> #include <libutil/Filesystem.h> #include <libutil/Strings.h> #include <process/Context.h> #include <process/User.h> using xcdriver::ListAction; using xcdriver::Options; using libutil::Filesystem; ListAction:: ListAction() { } ListAction:: ~ListAction() { } int ListAction:: Run(process::User const *user, process::Context const *processContext, Filesystem const *filesystem, Options const &options) { ext::optional<pbxbuild::Build::Environment> buildEnvironment = pbxbuild::Build::Environment::Default(user, processContext, filesystem); if (!buildEnvironment) { fprintf(stderr, "error: couldn't create build environment\n"); return -1; } std::vector<pbxsetting::Level> overrideLevels = Action::CreateOverrideLevels(processContext, filesystem, buildEnvironment->baseEnvironment(), options, processContext->currentDirectory()); xcexecution::Parameters parameters = Action::CreateParameters(options, overrideLevels); ext::optional<pbxbuild::WorkspaceContext> context = parameters.loadWorkspace(filesystem, user->userName(), *buildEnvironment, processContext->currentDirectory()); if (!context) { return -1; } /* Collect all schemes in the workspace. */ std::vector<xcscheme::XC::Scheme::shared_ptr> schemes; for (xcscheme::SchemeGroup::shared_ptr const &schemeGroup : context->schemeGroups()) { schemes.insert(schemes.end(), schemeGroup->schemes().begin(), schemeGroup->schemes().end()); } std::sort(schemes.begin(), schemes.end(), [](xcscheme::XC::Scheme::shared_ptr const &a, xcscheme::XC::Scheme::shared_ptr const &b) -> bool { return libutil::strcasecmp(a->name().c_str(), b->name().c_str()) < 0; }); auto I = std::unique(schemes.begin(), schemes.end(), [](xcscheme::XC::Scheme::shared_ptr const &a, xcscheme::XC::Scheme::shared_ptr const &b) -> bool { return (a->path() == b->path()); }); schemes.resize(std::distance(schemes.begin(), I)); if (context->workspace() != nullptr) { xcworkspace::XC::Workspace::shared_ptr const &workspace = context->workspace(); printf("Information about workspace \"%s\":\n", workspace->name().c_str()); if (schemes.empty()) { printf("\n%4sThis workspace contains no scheme.\n", ""); } else { printf("%4sSchemes:\n", ""); for (auto const &scheme : schemes) { printf("%8s%s\n", "", scheme->name().c_str()); } printf("\n"); } } else if (context->project() != nullptr) { pbxproj::PBX::Project::shared_ptr const &project = context->project(); printf("Information about project \"%s\":\n", project->name().c_str()); if (!project->targets().empty()) { printf("%4sTargets:\n", ""); for (auto const &target : project->targets()) { printf("%8s%s\n", "", target->name().c_str()); } } else { printf("%4sThis project contains no targets.\n", ""); } printf("\n"); if (project->buildConfigurationList()) { printf("%4sBuild Configurations:\n", ""); for (auto const &config : project->buildConfigurationList()->buildConfigurations()) { printf("%8s%s\n", "", config->name().c_str()); } printf("\n%4sIf no build configuration is specified and -scheme is not passed then \"%s\" is used.\n", "", project->buildConfigurationList()->defaultConfigurationName().c_str()); } else { printf("%4sThis project contains no build configurations.\n", ""); } printf("\n"); if (schemes.empty()) { printf("\n%4sThis project contains no scheme.\n", ""); } else { printf("%4sSchemes:\n", ""); for (auto const &scheme : schemes) { printf("%8s%s\n", "", scheme->name().c_str()); } printf("\n"); } } return 0; }
#include "button.h" #include "scene.h" void Button::DrawSelf(olcMFSG* game) { olc::Pixel colour = bgColour; if (bounds.contains(game->GetMousePos())) colour *= 1.5f; olc::vi2d vPos; vPos.x = bounds.position.x + (bounds.size.x >> 1) - (int)sLabel.length() * 4 * txtScale; vPos.y = bounds.position.y + (bounds.size.y >> 1) - 4 * txtScale; game->FillRect(bounds.position + olc::vi2d(3, 3), bounds.size, colour * 0.2f); game->FillRect(bounds.position, bounds.size, colour); game->DrawShadowedString(vPos, { 2, 2 }, sLabel, fgColour, shadowColour, txtScale); } Button CreateMenuButton(const std::string& label, rect<olc::vi2d> bounds, std::function<void(void)> onClick) { Button b; b.sLabel = label; b.onClick = onClick; b.bounds = bounds; b.bgColour = olc::VERY_DARK_GREY; b.fgColour = olc::WHITE; b.shadowColour = olc::BLACK; b.txtScale = 2U; return b; } Button CreateLoadSceneButton(scene* scn, rect<olc::vi2d> bounds, olcMFSG* game) { Button b; b.sLabel = scn->title; b.bounds = bounds; b.onClick = [game, scn](){ game->LoadScene(scn->id); }; b.bgColour = { 75, 75, 75, 255 }; b.fgColour = olc::WHITE; b.shadowColour = olc::BLACK; b.txtScale = 2U; return b; }
dnl IA-64 mpn_bdiv_dbm1. dnl Contributed to the GNU project by Torbjorn Granlund. dnl Copyright 2008, 2009 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C Itanium: 4 C Itanium 2: 2 C TODO C * Optimize feed-in and wind-down code, both for speed and code size. C INPUT PARAMETERS define(`rp', `r32') define(`up', `r33') define(`n', `r34') define(`bd', `r35') ASM_START() PROLOGUE(mpn_bdiv_dbm1c) .prologue .save ar.lc, r2 .body ifdef(`HAVE_ABI_32', ` addp4 rp = 0, rp C M I addp4 up = 0, up C M I zxt4 n = n C I ;; ') {.mmb mov r15 = r36 C M I ldf8 f9 = [up], 8 C M nop.b 0 C B } .Lcommon: {.mii adds r16 = -1, n C M I mov r2 = ar.lc C I0 and r14 = 3, n C M I ;; } {.mii setf.sig f6 = bd C M2 M3 shr.u r31 = r16, 2 C I0 cmp.eq p10, p0 = 0, r14 C M I } {.mii nop.m 0 C M cmp.eq p11, p0 = 2, r14 C M I cmp.eq p12, p0 = 3, r14 C M I ;; } {.mii cmp.ne p6, p7 = r0, r0 C M I mov.i ar.lc = r31 C I0 cmp.ne p8, p9 = r0, r0 C M I } {.bbb (p10) br.dptk .Lb00 C B (p11) br.dptk .Lb10 C B (p12) br.dptk .Lb11 C B ;; } .Lb01: br.cloop.dptk .grt1 ;; xma.l f38 = f9, f6, f0 xma.hu f39 = f9, f6, f0 ;; getf.sig r26 = f38 getf.sig r27 = f39 br .Lcj1 .grt1: ldf8 f10 = [r33], 8 ;; ldf8 f11 = [r33], 8 ;; ldf8 f12 = [r33], 8 ;; xma.l f38 = f9, f6, f0 xma.hu f39 = f9, f6, f0 ;; ldf8 f13 = [r33], 8 ;; xma.l f32 = f10, f6, f0 xma.hu f33 = f10, f6, f0 br.cloop.dptk .grt5 ;; getf.sig r26 = f38 xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 ;; getf.sig r27 = f39 ;; getf.sig r20 = f32 xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 ;; getf.sig r21 = f33 ;; getf.sig r22 = f34 xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 br .Lcj5 .grt5: ldf8 f10 = [r33], 8 ;; getf.sig r26 = f38 xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 ;; getf.sig r27 = f39 ldf8 f11 = [r33], 8 ;; getf.sig r20 = f32 xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 ;; getf.sig r21 = f33 ldf8 f12 = [r33], 8 ;; getf.sig r22 = f34 xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 br .LL01 .Lb10: ldf8 f13 = [r33], 8 br.cloop.dptk .grt2 ;; xma.l f36 = f9, f6, f0 xma.hu f37 = f9, f6, f0 ;; xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 ;; getf.sig r24 = f36 ;; getf.sig r25 = f37 ;; getf.sig r26 = f38 ;; getf.sig r27 = f39 br .Lcj2 .grt2: ldf8 f10 = [r33], 8 ;; ldf8 f11 = [r33], 8 ;; xma.l f36 = f9, f6, f0 xma.hu f37 = f9, f6, f0 ;; ldf8 f12 = [r33], 8 ;; xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 ;; ldf8 f13 = [r33], 8 ;; getf.sig r24 = f36 xma.l f32 = f10, f6, f0 xma.hu f33 = f10, f6, f0 br.cloop.dptk .grt6 getf.sig r25 = f37 ;; getf.sig r26 = f38 xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 ;; getf.sig r27 = f39 ;; getf.sig r20 = f32 xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 br .Lcj6 .grt6: getf.sig r25 = f37 ldf8 f10 = [r33], 8 ;; getf.sig r26 = f38 xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 ;; getf.sig r27 = f39 ldf8 f11 = [r33], 8 ;; getf.sig r20 = f32 xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 br .LL10 .Lb11: ldf8 f12 = [r33], 8 ;; ldf8 f13 = [r33], 8 br.cloop.dptk .grt3 ;; xma.l f34 = f9, f6, f0 xma.hu f35 = f9, f6, f0 ;; xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 ;; getf.sig r22 = f34 xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 ;; getf.sig r23 = f35 ;; getf.sig r24 = f36 ;; getf.sig r25 = f37 ;; getf.sig r26 = f38 br .Lcj3 .grt3: ldf8 f10 = [r33], 8 ;; xma.l f34 = f9, f6, f0 xma.hu f35 = f9, f6, f0 ;; ldf8 f11 = [r33], 8 ;; xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 ;; ldf8 f12 = [r33], 8 ;; getf.sig r22 = f34 xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 ;; getf.sig r23 = f35 ldf8 f13 = [r33], 8 ;; getf.sig r24 = f36 xma.l f32 = f10, f6, f0 xma.hu f33 = f10, f6, f0 br.cloop.dptk .grt7 getf.sig r25 = f37 ;; getf.sig r26 = f38 xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 br .Lcj7 .grt7: getf.sig r25 = f37 ldf8 f10 = [r33], 8 ;; getf.sig r26 = f38 xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 br .LL11 .Lb00: ldf8 f11 = [r33], 8 ;; ldf8 f12 = [r33], 8 ;; ldf8 f13 = [r33], 8 br.cloop.dptk .grt4 ;; xma.l f32 = f9, f6, f0 xma.hu f33 = f9, f6, f0 ;; xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 ;; getf.sig r20 = f32 xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 ;; getf.sig r21 = f33 ;; getf.sig r22 = f34 xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 ;; getf.sig r23 = f35 ;; getf.sig r24 = f36 br .Lcj4 .grt4: xma.l f32 = f9, f6, f0 xma.hu f33 = f9, f6, f0 ;; ldf8 f10 = [r33], 8 ;; xma.l f34 = f11, f6, f0 xma.hu f35 = f11, f6, f0 ;; ldf8 f11 = [r33], 8 ;; getf.sig r20 = f32 xma.l f36 = f12, f6, f0 xma.hu f37 = f12, f6, f0 ;; getf.sig r21 = f33 ldf8 f12 = [r33], 8 ;; getf.sig r22 = f34 xma.l f38 = f13, f6, f0 xma.hu f39 = f13, f6, f0 ;; getf.sig r23 = f35 ldf8 f13 = [r33], 8 ;; getf.sig r24 = f36 xma.l f32 = f10, f6, f0 xma.hu f33 = f10, f6, f0 br.cloop.dptk .LL00 br .Lcj8 C *** MAIN LOOP START *** ALIGN(32) .Ltop: .pred.rel "mutex",p6,p7 C .mfi getf.sig r24 = f36 xma.l f32 = f10, f6, f0 (p6) sub r15 = r19, r27, 1 C .mfi st8 [r32] = r19, 8 xma.hu f33 = f10, f6, f0 (p7) sub r15 = r19, r27 ;; .LL00: C .mfi getf.sig r25 = f37 nop.f 0 cmp.ltu p6, p7 = r15, r20 C .mib ldf8 f10 = [r33], 8 sub r16 = r15, r20 nop.b 0 ;; C .mfi getf.sig r26 = f38 xma.l f34 = f11, f6, f0 (p6) sub r15 = r16, r21, 1 C .mfi st8 [r32] = r16, 8 xma.hu f35 = f11, f6, f0 (p7) sub r15 = r16, r21 ;; .LL11: C .mfi getf.sig r27 = f39 nop.f 0 cmp.ltu p6, p7 = r15, r22 C .mib ldf8 f11 = [r33], 8 sub r17 = r15, r22 nop.b 0 ;; C .mfi getf.sig r20 = f32 xma.l f36 = f12, f6, f0 (p6) sub r15 = r17, r23, 1 C .mfi st8 [r32] = r17, 8 xma.hu f37 = f12, f6, f0 (p7) sub r15 = r17, r23 ;; .LL10: C .mfi getf.sig r21 = f33 nop.f 0 cmp.ltu p6, p7 = r15, r24 C .mib ldf8 f12 = [r33], 8 sub r18 = r15, r24 nop.b 0 ;; C .mfi getf.sig r22 = f34 xma.l f38 = f13, f6, f0 (p6) sub r15 = r18, r25, 1 C .mfi st8 [r32] = r18, 8 xma.hu f39 = f13, f6, f0 (p7) sub r15 = r18, r25 ;; .LL01: C .mfi getf.sig r23 = f35 nop.f 0 cmp.ltu p6, p7 = r15, r26 C .mib ldf8 f13 = [r33], 8 sub r19 = r15, r26 br.cloop.sptk.few .Ltop C *** MAIN LOOP END *** ;; getf.sig r24 = f36 xma.l f32 = f10, f6, f0 (p6) sub r15 = r19, r27, 1 st8 [r32] = r19, 8 xma.hu f33 = f10, f6, f0 (p7) sub r15 = r19, r27 ;; .Lcj8: getf.sig r25 = f37 cmp.ltu p6, p7 = r15, r20 sub r16 = r15, r20 ;; getf.sig r26 = f38 xma.l f34 = f11, f6, f0 (p6) sub r15 = r16, r21, 1 st8 [r32] = r16, 8 xma.hu f35 = f11, f6, f0 (p7) sub r15 = r16, r21 ;; .Lcj7: getf.sig r27 = f39 cmp.ltu p6, p7 = r15, r22 sub r17 = r15, r22 ;; getf.sig r20 = f32 xma.l f36 = f12, f6, f0 (p6) sub r15 = r17, r23, 1 st8 [r32] = r17, 8 xma.hu f37 = f12, f6, f0 (p7) sub r15 = r17, r23 ;; .Lcj6: getf.sig r21 = f33 cmp.ltu p6, p7 = r15, r24 sub r18 = r15, r24 ;; getf.sig r22 = f34 xma.l f38 = f13, f6, f0 (p6) sub r15 = r18, r25, 1 st8 [r32] = r18, 8 xma.hu f39 = f13, f6, f0 (p7) sub r15 = r18, r25 ;; .Lcj5: getf.sig r23 = f35 cmp.ltu p6, p7 = r15, r26 sub r19 = r15, r26 ;; getf.sig r24 = f36 (p6) sub r15 = r19, r27, 1 st8 [r32] = r19, 8 (p7) sub r15 = r19, r27 ;; .Lcj4: getf.sig r25 = f37 cmp.ltu p6, p7 = r15, r20 sub r16 = r15, r20 ;; getf.sig r26 = f38 (p6) sub r15 = r16, r21, 1 st8 [r32] = r16, 8 (p7) sub r15 = r16, r21 ;; .Lcj3: getf.sig r27 = f39 cmp.ltu p6, p7 = r15, r22 sub r17 = r15, r22 ;; (p6) sub r15 = r17, r23, 1 st8 [r32] = r17, 8 (p7) sub r15 = r17, r23 ;; .Lcj2: cmp.ltu p6, p7 = r15, r24 sub r18 = r15, r24 ;; (p6) sub r15 = r18, r25, 1 st8 [r32] = r18, 8 (p7) sub r15 = r18, r25 ;; .Lcj1: cmp.ltu p6, p7 = r15, r26 sub r19 = r15, r26 ;; (p6) sub r8 = r19, r27, 1 st8 [r32] = r19 (p7) sub r8 = r19, r27 mov ar.lc = r2 br.ret.sptk.many b0 EPILOGUE() ASM_END()
; A055156: Powers of 3 which are not powers of 3^3. ; 3,9,81,243,2187,6561,59049,177147,1594323,4782969,43046721,129140163,1162261467,3486784401,31381059609,94143178827,847288609443,2541865828329,22876792454961,68630377364883,617673396283947 mul $0,3 div $0,2 mov $1,3 pow $1,$0 div $1,2 mul $1,6 add $1,3
; int esxdos_disk_read(uchar device, ulong position, void *dst) SECTION code_clib SECTION code_esxdos PUBLIC _esxdos_disk_read_callee PUBLIC l0_esxdos_disk_read_callee EXTERN asm_esxdos_disk_read _esxdos_disk_read_callee: pop hl dec sp pop af pop de pop bc ex (sp),hl l0_esxdos_disk_read_callee: push ix push iy call asm_esxdos_disk_read pop iy pop ix ret
; ================================================================ ; GBMod demo ROM ; ================================================================ Easypack set 1 ; Debug flag ; If set to 1, enable debugging features. DebugFlag set 1 ; If set to 1, display numbers in decimal instead of hexadecimal. UseDecimal set 0 ; ================================================================ ; Project includes ; ================================================================ include "Variables.asm" include "Constants.asm" include "Macros.asm" include "hardware.inc" ; ================================================================ ; Reset vectors (actual ROM starts here) ; ================================================================ SECTION "Reset $00",ROM0[$00] Reset00: ret SECTION "Reset $08",ROM0[$08] Reset08: ret SECTION "Reset $10",ROM0[$10] Reset10: ret SECTION "Reset $18",ROM0[$18] Reset18: ret SECTION "Reset $20",ROM0[$20] Reset20: ret SECTION "Reset $28",ROM0[$28] Reset28: ret SECTION "Reset $30",ROM0[$30] Reset30: ret SECTION "Reset $38",ROM0[$38] Reset38: jr @ ; ================================================================ ; Interrupt vectors ; ================================================================ SECTION "VBlank interrupt",ROM0[$40] IRQ_VBlank: jp DoVBlank SECTION "LCD STAT interrupt",ROM0[$48] IRQ_STAT: reti SECTION "Timer interrupt",ROM0[$50] IRQ_Timer: jp DoTimer SECTION "Serial interrupt",ROM0[$58] IRQ_Serial: reti SECTION "Joypad interrupt",ROM0[$60] IRQ_Joypad: reti ; ================================================================ ; System routines ; ================================================================ include "SystemRoutines.asm" ; ================================================================ ; ROM header ; ================================================================ SECTION "ROM header",ROM0[$100] EntryPoint: nop jp ProgramStart NintendoLogo: ; DO NOT MODIFY OR ROM WILL NOT BOOT!!! db $ce,$ed,$66,$66,$cc,$0d,$00,$0b,$03,$73,$00,$83,$00,$0c,$00,$0d db $00,$08,$11,$1f,$88,$89,$00,$0e,$dc,$cc,$6e,$e6,$dd,$dd,$d9,$99 db $bb,$bb,$67,$63,$6e,$0e,$ec,$cc,$dd,$dc,$99,$9f,$bb,$b9,$33,$3e ROMTitle: db "GBMOD",0,0,0,0,0,0 ; ROM title (11 bytes) ProductCode: db 0,0,0,0 ; product code (4 bytes) GBCSupport: db $80 ; GBC support (0 = DMG only, $80 = DMG/GBC, $C0 = GBC only) NewLicenseCode: db "DS" ; new license code (2 bytes) SGBSupport: db 0 ; SGB support CartType: db $19 ; Cart type, see hardware.inc for a list of values ROMSize: ds 1 ; ROM size (handled by post-linking tool) RAMSize: db 0 ; RAM size DestCode: db 1 ; Destination code (0 = Japan, 1 = All others) OldLicenseCode: db $33 ; Old license code (if $33, check new license code) ROMVersion: db 0 ; ROM version HeaderChecksum: ds 1 ; Header checksum (handled by post-linking tool) ROMChecksum: ds 2 ; ROM checksum (2 bytes) (handled by post-linking tool) ; ================================================================ ; Start of program code ; ================================================================ ProgramStart: ld sp,$fffe push af di ; disable interrupts .wait ; wait for VBlank before disabling the LCD ldh a,[rLY] cp $90 jr nz,.wait xor a ld [rLCDC],a ; disable LCD call ClearWRAM ; clear HRAM xor a ld bc,$7c80 ._loop ld [c],a inc c dec b jr nz,._loop call ClearVRAM CopyTileset1BPP Font,0,(Font_End-Font)/8 pop af cp $11 jr nz,:+ ld hl,Pal_Grayscale xor a call LoadBGPalLine : ; Emulator check! ; This routine uses echo RAM access to detect lesser ; emulators (such as VBA) which are more likely to ; break when given situations that real hardware ; handles just fine. ld a,"e" ; this value isn't important ld [VBACheck],a ; copy value to WRAM ld b,a ld a,[VBACheck+$2000] ; read value back from echo RAM cp b ; (fails in emulators which don't emulate echo RAM) jp z,.noemu ; if check passes, don't display warning .emuscreen ld hl,.emutext call LoadMapText ; assumes font is already loaded into VRAM ld a,%11100100 ; 3 2 1 0 ldh [rBGP],a ; set background palette ld a,%10010001 ; LCD on + BG on + BG $8000 ldh [rLCDC],a ; enable LCD .emuwait call CheckInput ld a,[sys_btnPress] bit btnA,a ; check if A is pressed jp nz,.emubreak ; if a is pressed, break from loop jr .emuwait .emutext ; 20x18 char tilemap db "Nice emulator you " db "got there :^) " db " " db "For best results, " db "please use a better " db "emulator (such as " db "bgb or gambatte) or " db "run this ROM on real" db "hardware. " db " " db "Press A to continue " db "anyway, but don't " db "blame me if any part" db "of this ROM doesn't " db "work correctly due " db "to your terrible " db "choice of emulator! " db " " .emubreak ; no need to wait for vblank first because this code only runs in emulators xor a ldh [rLCDC],a ; disable lcd .noemu ld hl,MainText ; load main text call LoadMapText ld a,%11100100 ; 3 2 1 0 ldh [rBGP],a ; set background palette ld a,IEF_VBLANK | IEF_TIMER ldh [rIE],a ; set VBlank interrupt flag ld a,%10010001 ; LCD on + BG on + BG $8000 ldh [rLCDC],a ; enable LCD if Easypack==1 ld a,1 else xor a endc call GBM_LoadModule call DrawSongName ei MainLoop: if Easypack==0 ; draw song id ld a,[CurrentSong] ld hl,$9891 call DrawHex ; playback controls ld a,[sys_btnPress] bit btnUp,a jr nz,.add16 bit btnDown,a jr nz,.sub16 bit btnLeft,a jr nz,.sub1 bit btnRight,a jr nz,.add1 bit btnA,a jr nz,.loadSong bit btnB,a jr nz,.stopSong bit btnSelect,a jr nz,.toggleSpeed jr .continue .add1 ld a,[CurrentSong] inc a ld [CurrentSong],a jr .continue .sub1 ld a,[CurrentSong] dec a ld [CurrentSong],a jr .continue .add16 ld a,[CurrentSong] add 16 ld [CurrentSong],a jr .continue .sub16 ld a,[CurrentSong] sub 16 ld [CurrentSong],a jr .continue .loadSong ld a,[CurrentSong] call GBM_LoadModule call DrawSongName jr .continue .stopSong call GBM_Stop ld hl,str_NoSong ld de,$98a1 ld b,16 .stoploop ldh a,[rSTAT] and 2 jr nz,.stoploop ld a,[hl+] sub 32 ld [de],a inc de dec b jr nz,.stoploop jr .continue .toggleSpeed call DoSpeedSwitch jr .loadSong .continue call CheckInput endc call DrawSoundVars halt ; wait for VBlank ; ld a,c ; ld hl,MaxRasterTime ; cp [hl] ; jr c,.skip ; ld [hl],c ;.skip ; ld hl,$9a31 ; raster time display address in VRAM ; call DrawHex ; draw raster time ; call CheckInput jp MainLoop ; ================================================================ ; Graphics data ; ================================================================ MainText: if Easypack==1 ; #################### db " " db "GBMod v2.0 by DevEd " db " " db " " db " Now playing: " db " ???????????????? " db " " db " " db " " db " " db " " db " " db " CH1 ??? V? P? ???? " db " CH2 ??? V? P? ???? " db " CH3 ??? V? P? ???? " db " CH4 $?? V? P? ???? " db " " db " " ; #################### else ; #################### db " " db "GBMod v2.0 by DevEd " db " deved8@gmail.com " db " " db " Current song: $?? " db " ???????????????? " db " Controls: " db " A........Load song " db " B........Stop song " db " D-pad..Select song " db " Sel.Toggle CPU spd " db " " db " CH1 ??? V? P? ???? " db " CH2 ??? V? P? ???? " db " CH3 ??? V? P? ???? " db " CH4 $?? V? P? ???? " db " " db " " ; #################### endc Font: incbin "Font.1bpp" ; 1bpp font data Font_End: ; ==================== ; Draw sound variables ; ==================== DrawSoundVars: push bc ; ch1 ld a,[GBM_Note1] cp $ff jr z,.nonote1 call GetNoteString ld de,$9985 rept 3 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,[hl+] sub 32 ld [de],a inc de endr jr .cont1 .nonote1 ld hl,$9985 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,"-"-32 ld [hl+],a ld [hl+],a ld [hl+],a jr .cont1 .cont1 ld a,[GBM_Vol1] rra rra rra ld hl,$998a call DrawHexDigit ld a,[GBM_Pulse1] ld hl,$998d call DrawHexDigit ld a,[GBM_Command1] ld hl,$998f call DrawHex ld a,[GBM_Param1] call DrawHex ; ch2 ld a,[GBM_Note2] cp $ff jr z,.nonote2 call GetNoteString ld de,$99a5 rept 3 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,[hl+] sub 32 ld [de],a inc de endr jr .cont2 .nonote2 ld hl,$99a5 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,"-"-32 ld [hl+],a ld [hl+],a ld [hl+],a .cont2 ld a,[GBM_Vol2] rra rra rra ld hl,$99aa call DrawHexDigit ld a,[GBM_Pulse2] ld hl,$99ad call DrawHexDigit ld a,[GBM_Command2] ld hl,$99af call DrawHex ld a,[GBM_Param2] call DrawHex ; ch3 ld a,[GBM_Note3] cp $ff jr z,.nonote3 cp $80 jr z,.sample3 call GetNoteString ld de,$99c5 rept 3 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,[hl+] sub 32 ld [de],a inc de endr jr .cont3 .nonote3 ld hl,$99c5 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,"-"-32 ld [hl+],a ld [hl+],a ld [hl+],a jr .cont3 .sample3 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,"S"-32 ld [$99c5],a ld a,[GBM_SampleID] ld hl,$99c6 call DrawHex .cont3 ld a,[GBM_Vol3] ld hl,$99ca call DrawHexDigit ld a,[GBM_Wave3] inc a ld hl,$99cd call DrawHexDigit ld a,[GBM_Command3] ld hl,$99cf call DrawHex ld a,[GBM_Param3] call DrawHex ; ch4 ld a,[GBM_Note4] cp $ff jr z,.nonote4 ld hl,$99e6 call DrawHex jr .cont4 .nonote4 ld hl,$99e6 ldh a,[rSTAT] and 2 jr nz,@-4 ld a,"-"-32 ld [hl+],a ld [hl+],a .cont4 ld a,[GBM_Vol4] rra rra rra ld hl,$99ea call DrawHexDigit ld a,[GBM_Mode4] ld hl,$99ed call DrawHexDigit ld a,[GBM_Command4] ld hl,$99ef call DrawHex ld a,[GBM_Param4] call DrawHex pop bc ret GetNoteString: cp $48 jr nc,.unknownNote ld hl,MusicNoteStrTable ld b,a add b add b ld d,0 ld e,a add hl,de ret .unknownNote ld hl,UnknownNote ret DrawSongName: ld a,[GBM_SongID] inc a ld [rROMB0],a ld hl,$4010 ld de,$98a1 ld b,16 .loop ldh a,[rSTAT] and 2 jr nz,.loop ld a,[hl+] sub 32 ld [de],a inc de dec b jr nz,.loop ld a,1 ld [rROMB0],a ret MusicNoteStrTable: db "C-2","C#2","D-2","D#2","E-2","F-2","F#2","G-2","G#2","A-2","A#2","B-2" db "C-3","C#3","D-3","D#3","E-3","F-3","F#3","G-3","G#3","A-3","A#3","B-3" db "C-4","C#4","D-4","D#4","E-4","F-4","F#4","G-4","G#4","A-4","A#4","B-4" db "C-5","C#5","D-5","D#5","E-5","F-5","F#5","G-5","G#5","A-5","A#5","B-5" db "C-6","C#6","D-6","D#6","E-6","F-6","F#6","G-6","G#6","A-6","A#6","B-6" db "C-7","C#7","D-7","D#7","E-7","F-7","F#7","G-7","G#7","A-7","A#7","B-7" UnknownNote: db "???" str_NoSong: db "NO SONG " PrintString: ld de,$9800 and $f swap a rla jr nc,.nocarry inc d .nocarry ld e,a .loop ldh a,[rSTAT] and 2 jr nz,.loop ld a,[hl+] and a ret z sub 32 ld [de],a inc de jr .loop ClearScreen: ld hl,$9800 ld bc,$800 .clearLoop ldh a,[rSTAT] and 2 jr nz,.clearLoop xor a ld [hl+],a dec bc ld a,b or c jr nz,.clearLoop ret ; ================================================================ ; GBC routines ; ================================================================ ; Switches double speed mode off. ; TRASHES: a NormalSpeed: ldh a,[rKEY1] bit 7,a ; already in normal speed? ret z ; if yes, return jr DoSpeedSwitch ; Switches double speed mode on. ; TRASHES: a DoubleSpeed: ldh a,[rKEY1] bit 7,a ; already in double speed? ret nz ; if yes, return DoSpeedSwitch: ld a,%00110000 ldh [rP1],a xor %00110001 ; a = %00000001 ldh [rKEY1],a ; prepare speed switch stop ret ; Input: hl = palette data LoadBGPal: ld a,0 call LoadBGPalLine ld a,1 call LoadBGPalLine ld a,2 call LoadBGPalLine ld a,3 call LoadBGPalLine ld a,4 call LoadBGPalLine ld a,5 call LoadBGPalLine ld a,6 call LoadBGPalLine ld a,7 call LoadBGPalLine ret ; Input: hl = palette data LoadObjPal: ld a,0 call LoadObjPalLine ld a,1 call LoadObjPalLine ld a,2 call LoadObjPalLine ld a,3 call LoadObjPalLine ld a,4 call LoadObjPalLine ld a,5 call LoadObjPalLine ld a,6 call LoadObjPalLine ld a,7 call LoadObjPalLine ret ; Input: hl = palette data LoadBGPalLine: swap a ; \ multiply rrca ; / palette by 8 or $80 ; auto increment push af WaitForVRAM pop af ld [rBCPS],a ld a,[hl+] ld [rBCPD],a ld a,[hl+] ld [rBCPD],a ld a,[hl+] ld [rBCPD],a ld a,[hl+] ld [rBCPD],a ld a,[hl+] ld [rBCPD],a ld a,[hl+] ld [rBCPD],a ld a,[hl+] ld [rBCPD],a ld a,[hl+] ld [rBCPD],a ret ; Input: hl = palette data LoadObjPalLine: swap a ; \ multiply rrca ; / palette by 8 or $80 ; auto increment push af WaitForVRAM pop af ld [rOCPS],a ld a,[hl+] ld [rOCPD],a ld a,[hl+] ld [rOCPD],a ld a,[hl+] ld [rOCPD],a ld a,[hl+] ld [rOCPD],a ld a,[hl+] ld [rOCPD],a ld a,[hl+] ld [rOCPD],a ld a,[hl+] ld [rOCPD],a ld a,[hl+] ld [rOCPD],a ret Pal_Grayscale: dw $7fff,$6e94,$354a,$0000 ; ================================================================ ; SRAM routines ; ================================================================ ; include "SRAM.asm" ; ================================================================ ; Misc routines ; ================================================================ DoVBlank: push af ld a,[GBM_EnableTimer] and a jr nz,:+ push bc push de push hl call GBM_Update pop hl pop de pop bc : pop af reti DoTimer: push af ld a,[GBM_EnableTimer] and a jr z,:+ push bc push de push hl call GBM_Update pop hl pop de pop bc : pop af reti ; ================================================================ ; Sound driver ; ================================================================ include "GBMod_Player.asm" ; ================================================================ ; Song data ; ================================================================ if Easypack==0 section "Lost In Translation",romx,bank[1] incbin "Modules/LostInTranslation.bin" section "Endless Road",romx,bank[2] incbin "Modules/EndlessRoad.bin" section "Spring",romx,bank[3] incbin "Modules/Spring.bin" section "Slime Cave, bank 1",romx,bank[4] incbin "Modules/SlimeCave.bin",0,$4000 section "Slime Cave, bank 2",romx,bank[5] incbin "Modules/SlimeCave.bin",$4000 endc
; A296897: Numbers n whose base-15 digits d(m), d(m-1), ..., d(0) have #(pits) = #(peaks); see Comments. ; Submitted by Jamie Morken(s3) ; 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100 mov $1,$0 seq $1,50519 ; Increments of arithmetic progression of at least 6 terms having the same value of phi in A050518. mov $0,$1 sub $0,30 div $0,30 add $0,1
; A111367: Numbers k such that 7*k + 5 is prime. ; 0,2,6,8,12,14,18,24,32,36,38,44,54,56,62,66,72,74,84,86,96,98,102,104,108,122,126,132,138,144,152,156,164,168,174,176,182,186,188,204,206,212,218,222,228,236,242,248,254,258,266,278,282,284,294,308,314,324,326,336,338,342,348,362,372,384,386,392,396,398,402,404,408,414,416,428,452,464,474,486,492,494,498,504,506,516,518,522,524,528,558,566,578,582,584,596,602,608,612,624 mov $1,1 mov $2,$0 pow $2,2 mul $2,2 mov $5,1 lpb $2 add $1,3 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,3 add $1,$5 sub $2,1 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mul $1,2 div $1,28 mul $1,2 mov $0,$1
; A005915: Hexagonal prism numbers: a(n) = (n + 1)*(3*n^2 + 3*n + 1). ; 1,14,57,148,305,546,889,1352,1953,2710,3641,4764,6097,7658,9465,11536,13889,16542,19513,22820,26481,30514,34937,39768,45025,50726,56889,63532,70673,78330,86521,95264,104577,114478,124985,136116,147889,160322,173433,187240,201761,217014,233017,249788,267345,285706,304889,324912,345793,367550,390201,413764,438257,463698,490105,517496,545889,575302,605753,637260,669841,703514,738297,774208,811265,849486,888889,929492,971313,1014370,1058681,1104264,1151137,1199318,1248825,1299676,1351889,1405482,1460473,1516880,1574721,1634014,1694777,1757028,1820785,1886066,1952889,2021272,2091233,2162790,2235961,2310764,2387217,2465338,2545145,2626656,2709889,2794862,2881593,2970100 mov $1,6 mul $1,$0 add $1,4 pow $1,3 div $1,72 add $1,1 mov $0,$1
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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. * *=========================================================================*/ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif // I suspect that Purify is not working correctly. It should report a memory // leak for this program. int itkMemoryLeakTest(int, char* [] ) { // Leak 10000 bytes of memory, a little at a time. for(unsigned int i=0; i < 100; ++i) { char* leaker = new char[100]; *leaker = 0; // Prevent unused variable warning. } return 0; }
db 0 ; species ID placeholder db 95, 95, 85, 55, 125, 75 ; hp atk def spd sat sdf db GRASS, PSYCHIC ; type db 45 ; catch rate db 212 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/exeggutor/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_SLOW ; growth rate dn EGG_PLANT, EGG_PLANT ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, ROLLOUT, TOXIC, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, GIGA_DRAIN, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, PSYCHIC_M, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, DREAM_EATER, REST, ATTRACT, THIEF, NIGHTMARE, STRENGTH, FLASH ; end
//===- FunctionAttrs.cpp - Pass which marks functions attributes ----------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// /// /// \file /// This file implements interprocedural passes which walk the /// call-graph deducing and/or propagating function attributes. /// //===----------------------------------------------------------------------===// #include "llvm/Transforms/IPO/FunctionAttrs.h" #include "llvm/Transforms/IPO.h" #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/Analysis/CallGraphSCCPass.h" #include "llvm/Analysis/CaptureTracking.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/InstIterator.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Analysis/TargetLibraryInfo.h" using namespace llvm; #define DEBUG_TYPE "functionattrs" STATISTIC(NumReadNone, "Number of functions marked readnone"); STATISTIC(NumReadOnly, "Number of functions marked readonly"); STATISTIC(NumNoCapture, "Number of arguments marked nocapture"); STATISTIC(NumReadNoneArg, "Number of arguments marked readnone"); STATISTIC(NumReadOnlyArg, "Number of arguments marked readonly"); STATISTIC(NumNoAlias, "Number of function returns marked noalias"); STATISTIC(NumNonNullReturn, "Number of function returns marked nonnull"); STATISTIC(NumNoRecurse, "Number of functions marked as norecurse"); namespace { typedef SmallSetVector<Function *, 8> SCCNodeSet; } namespace { /// The three kinds of memory access relevant to 'readonly' and /// 'readnone' attributes. enum MemoryAccessKind { MAK_ReadNone = 0, MAK_ReadOnly = 1, MAK_MayWrite = 2 }; } static MemoryAccessKind checkFunctionMemoryAccess(Function &F, AAResults &AAR, const SCCNodeSet &SCCNodes) { FunctionModRefBehavior MRB = AAR.getModRefBehavior(&F); if (MRB == FMRB_DoesNotAccessMemory) // Already perfect! return MAK_ReadNone; // Non-exact function definitions may not be selected at link time, and an // alternative version that writes to memory may be selected. See the comment // on GlobalValue::isDefinitionExact for more details. if (!F.hasExactDefinition()) { if (AliasAnalysis::onlyReadsMemory(MRB)) return MAK_ReadOnly; // Conservatively assume it writes to memory. return MAK_MayWrite; } // Scan the function body for instructions that may read or write memory. bool ReadsMemory = false; for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) { Instruction *I = &*II; // Some instructions can be ignored even if they read or write memory. // Detect these now, skipping to the next instruction if one is found. CallSite CS(cast<Value>(I)); if (CS) { // Ignore calls to functions in the same SCC, as long as the call sites // don't have operand bundles. Calls with operand bundles are allowed to // have memory effects not described by the memory effects of the call // target. if (!CS.hasOperandBundles() && CS.getCalledFunction() && SCCNodes.count(CS.getCalledFunction())) continue; FunctionModRefBehavior MRB = AAR.getModRefBehavior(CS); // If the call doesn't access memory, we're done. if (!(MRB & MRI_ModRef)) continue; if (!AliasAnalysis::onlyAccessesArgPointees(MRB)) { // The call could access any memory. If that includes writes, give up. if (MRB & MRI_Mod) return MAK_MayWrite; // If it reads, note it. if (MRB & MRI_Ref) ReadsMemory = true; continue; } // Check whether all pointer arguments point to local memory, and // ignore calls that only access local memory. for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); CI != CE; ++CI) { Value *Arg = *CI; if (!Arg->getType()->isPtrOrPtrVectorTy()) continue; AAMDNodes AAInfo; I->getAAMetadata(AAInfo); MemoryLocation Loc(Arg, MemoryLocation::UnknownSize, AAInfo); // Skip accesses to local or constant memory as they don't impact the // externally visible mod/ref behavior. if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true)) continue; if (MRB & MRI_Mod) // Writes non-local memory. Give up. return MAK_MayWrite; if (MRB & MRI_Ref) // Ok, it reads non-local memory. ReadsMemory = true; } continue; } else if (LoadInst *LI = dyn_cast<LoadInst>(I)) { // Ignore non-volatile loads from local memory. (Atomic is okay here.) if (!LI->isVolatile()) { MemoryLocation Loc = MemoryLocation::get(LI); if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true)) continue; } } else if (StoreInst *SI = dyn_cast<StoreInst>(I)) { // Ignore non-volatile stores to local memory. (Atomic is okay here.) if (!SI->isVolatile()) { MemoryLocation Loc = MemoryLocation::get(SI); if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true)) continue; } } else if (VAArgInst *VI = dyn_cast<VAArgInst>(I)) { // Ignore vaargs on local memory. MemoryLocation Loc = MemoryLocation::get(VI); if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true)) continue; } // Any remaining instructions need to be taken seriously! Check if they // read or write memory. if (I->mayWriteToMemory()) // Writes memory. Just give up. return MAK_MayWrite; // If this instruction may read memory, remember that. ReadsMemory |= I->mayReadFromMemory(); } return ReadsMemory ? MAK_ReadOnly : MAK_ReadNone; } /// Deduce readonly/readnone attributes for the SCC. template <typename AARGetterT> static bool addReadAttrs(const SCCNodeSet &SCCNodes, AARGetterT AARGetter) { // Check if any of the functions in the SCC read or write memory. If they // write memory then they can't be marked readnone or readonly. bool ReadsMemory = false; for (Function *F : SCCNodes) { // Call the callable parameter to look up AA results for this function. AAResults &AAR = AARGetter(*F); switch (checkFunctionMemoryAccess(*F, AAR, SCCNodes)) { case MAK_MayWrite: return false; case MAK_ReadOnly: ReadsMemory = true; break; case MAK_ReadNone: // Nothing to do! break; } } // Success! Functions in this SCC do not access memory, or only read memory. // Give them the appropriate attribute. bool MadeChange = false; for (Function *F : SCCNodes) { if (F->doesNotAccessMemory()) // Already perfect! continue; if (F->onlyReadsMemory() && ReadsMemory) // No change. continue; MadeChange = true; // Clear out any existing attributes. AttrBuilder B; B.addAttribute(Attribute::ReadOnly).addAttribute(Attribute::ReadNone); F->removeAttributes( AttributeSet::FunctionIndex, AttributeSet::get(F->getContext(), AttributeSet::FunctionIndex, B)); // Add in the new attribute. F->addAttribute(AttributeSet::FunctionIndex, ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone); if (ReadsMemory) ++NumReadOnly; else ++NumReadNone; } return MadeChange; } namespace { /// For a given pointer Argument, this retains a list of Arguments of functions /// in the same SCC that the pointer data flows into. We use this to build an /// SCC of the arguments. struct ArgumentGraphNode { Argument *Definition; SmallVector<ArgumentGraphNode *, 4> Uses; }; class ArgumentGraph { // We store pointers to ArgumentGraphNode objects, so it's important that // that they not move around upon insert. typedef std::map<Argument *, ArgumentGraphNode> ArgumentMapTy; ArgumentMapTy ArgumentMap; // There is no root node for the argument graph, in fact: // void f(int *x, int *y) { if (...) f(x, y); } // is an example where the graph is disconnected. The SCCIterator requires a // single entry point, so we maintain a fake ("synthetic") root node that // uses every node. Because the graph is directed and nothing points into // the root, it will not participate in any SCCs (except for its own). ArgumentGraphNode SyntheticRoot; public: ArgumentGraph() { SyntheticRoot.Definition = nullptr; } typedef SmallVectorImpl<ArgumentGraphNode *>::iterator iterator; iterator begin() { return SyntheticRoot.Uses.begin(); } iterator end() { return SyntheticRoot.Uses.end(); } ArgumentGraphNode *getEntryNode() { return &SyntheticRoot; } ArgumentGraphNode *operator[](Argument *A) { ArgumentGraphNode &Node = ArgumentMap[A]; Node.Definition = A; SyntheticRoot.Uses.push_back(&Node); return &Node; } }; /// This tracker checks whether callees are in the SCC, and if so it does not /// consider that a capture, instead adding it to the "Uses" list and /// continuing with the analysis. struct ArgumentUsesTracker : public CaptureTracker { ArgumentUsesTracker(const SCCNodeSet &SCCNodes) : Captured(false), SCCNodes(SCCNodes) {} void tooManyUses() override { Captured = true; } bool captured(const Use *U) override { CallSite CS(U->getUser()); if (!CS.getInstruction()) { Captured = true; return true; } Function *F = CS.getCalledFunction(); if (!F || !F->hasExactDefinition() || !SCCNodes.count(F)) { Captured = true; return true; } // Note: the callee and the two successor blocks *follow* the argument // operands. This means there is no need to adjust UseIndex to account for // these. unsigned UseIndex = std::distance(const_cast<const Use *>(CS.arg_begin()), U); assert(UseIndex < CS.data_operands_size() && "Indirect function calls should have been filtered above!"); if (UseIndex >= CS.getNumArgOperands()) { // Data operand, but not a argument operand -- must be a bundle operand assert(CS.hasOperandBundles() && "Must be!"); // CaptureTracking told us that we're being captured by an operand bundle // use. In this case it does not matter if the callee is within our SCC // or not -- we've been captured in some unknown way, and we have to be // conservative. Captured = true; return true; } if (UseIndex >= F->arg_size()) { assert(F->isVarArg() && "More params than args in non-varargs call"); Captured = true; return true; } Uses.push_back(&*std::next(F->arg_begin(), UseIndex)); return false; } bool Captured; // True only if certainly captured (used outside our SCC). SmallVector<Argument *, 4> Uses; // Uses within our SCC. const SCCNodeSet &SCCNodes; }; } namespace llvm { template <> struct GraphTraits<ArgumentGraphNode *> { typedef ArgumentGraphNode NodeType; typedef SmallVectorImpl<ArgumentGraphNode *>::iterator ChildIteratorType; static inline NodeType *getEntryNode(NodeType *A) { return A; } static inline ChildIteratorType child_begin(NodeType *N) { return N->Uses.begin(); } static inline ChildIteratorType child_end(NodeType *N) { return N->Uses.end(); } }; template <> struct GraphTraits<ArgumentGraph *> : public GraphTraits<ArgumentGraphNode *> { static NodeType *getEntryNode(ArgumentGraph *AG) { return AG->getEntryNode(); } static ChildIteratorType nodes_begin(ArgumentGraph *AG) { return AG->begin(); } static ChildIteratorType nodes_end(ArgumentGraph *AG) { return AG->end(); } }; } /// Returns Attribute::None, Attribute::ReadOnly or Attribute::ReadNone. static Attribute::AttrKind determinePointerReadAttrs(Argument *A, const SmallPtrSet<Argument *, 8> &SCCNodes) { SmallVector<Use *, 32> Worklist; SmallSet<Use *, 32> Visited; // inalloca arguments are always clobbered by the call. if (A->hasInAllocaAttr()) return Attribute::None; bool IsRead = false; // We don't need to track IsWritten. If A is written to, return immediately. for (Use &U : A->uses()) { Visited.insert(&U); Worklist.push_back(&U); } while (!Worklist.empty()) { Use *U = Worklist.pop_back_val(); Instruction *I = cast<Instruction>(U->getUser()); switch (I->getOpcode()) { case Instruction::BitCast: case Instruction::GetElementPtr: case Instruction::PHI: case Instruction::Select: case Instruction::AddrSpaceCast: // The original value is not read/written via this if the new value isn't. for (Use &UU : I->uses()) if (Visited.insert(&UU).second) Worklist.push_back(&UU); break; case Instruction::Call: case Instruction::Invoke: { bool Captures = true; if (I->getType()->isVoidTy()) Captures = false; auto AddUsersToWorklistIfCapturing = [&] { if (Captures) for (Use &UU : I->uses()) if (Visited.insert(&UU).second) Worklist.push_back(&UU); }; CallSite CS(I); if (CS.doesNotAccessMemory()) { AddUsersToWorklistIfCapturing(); continue; } Function *F = CS.getCalledFunction(); if (!F) { if (CS.onlyReadsMemory()) { IsRead = true; AddUsersToWorklistIfCapturing(); continue; } return Attribute::None; } // Note: the callee and the two successor blocks *follow* the argument // operands. This means there is no need to adjust UseIndex to account // for these. unsigned UseIndex = std::distance(CS.arg_begin(), U); // U cannot be the callee operand use: since we're exploring the // transitive uses of an Argument, having such a use be a callee would // imply the CallSite is an indirect call or invoke; and we'd take the // early exit above. assert(UseIndex < CS.data_operands_size() && "Data operand use expected!"); bool IsOperandBundleUse = UseIndex >= CS.getNumArgOperands(); if (UseIndex >= F->arg_size() && !IsOperandBundleUse) { assert(F->isVarArg() && "More params than args in non-varargs call"); return Attribute::None; } Captures &= !CS.doesNotCapture(UseIndex); // Since the optimizer (by design) cannot see the data flow corresponding // to a operand bundle use, these cannot participate in the optimistic SCC // analysis. Instead, we model the operand bundle uses as arguments in // call to a function external to the SCC. if (!SCCNodes.count(&*std::next(F->arg_begin(), UseIndex)) || IsOperandBundleUse) { // The accessors used on CallSite here do the right thing for calls and // invokes with operand bundles. if (!CS.onlyReadsMemory() && !CS.onlyReadsMemory(UseIndex)) return Attribute::None; if (!CS.doesNotAccessMemory(UseIndex)) IsRead = true; } AddUsersToWorklistIfCapturing(); break; } case Instruction::Load: // A volatile load has side effects beyond what readonly can be relied // upon. if (cast<LoadInst>(I)->isVolatile()) return Attribute::None; IsRead = true; break; case Instruction::ICmp: case Instruction::Ret: break; default: return Attribute::None; } } return IsRead ? Attribute::ReadOnly : Attribute::ReadNone; } /// Deduce nocapture attributes for the SCC. static bool addArgumentAttrs(const SCCNodeSet &SCCNodes) { bool Changed = false; ArgumentGraph AG; AttrBuilder B; B.addAttribute(Attribute::NoCapture); // Check each function in turn, determining which pointer arguments are not // captured. for (Function *F : SCCNodes) { // We can infer and propagate function attributes only when we know that the // definition we'll get at link time is *exactly* the definition we see now. // For more details, see GlobalValue::mayBeDerefined. if (!F->hasExactDefinition()) continue; // Functions that are readonly (or readnone) and nounwind and don't return // a value can't capture arguments. Don't analyze them. if (F->onlyReadsMemory() && F->doesNotThrow() && F->getReturnType()->isVoidTy()) { for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end(); A != E; ++A) { if (A->getType()->isPointerTy() && !A->hasNoCaptureAttr()) { A->addAttr(AttributeSet::get(F->getContext(), A->getArgNo() + 1, B)); ++NumNoCapture; Changed = true; } } continue; } for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end(); A != E; ++A) { if (!A->getType()->isPointerTy()) continue; bool HasNonLocalUses = false; if (!A->hasNoCaptureAttr()) { ArgumentUsesTracker Tracker(SCCNodes); PointerMayBeCaptured(&*A, &Tracker); if (!Tracker.Captured) { if (Tracker.Uses.empty()) { // If it's trivially not captured, mark it nocapture now. A->addAttr( AttributeSet::get(F->getContext(), A->getArgNo() + 1, B)); ++NumNoCapture; Changed = true; } else { // If it's not trivially captured and not trivially not captured, // then it must be calling into another function in our SCC. Save // its particulars for Argument-SCC analysis later. ArgumentGraphNode *Node = AG[&*A]; for (Argument *Use : Tracker.Uses) { Node->Uses.push_back(AG[Use]); if (Use != &*A) HasNonLocalUses = true; } } } // Otherwise, it's captured. Don't bother doing SCC analysis on it. } if (!HasNonLocalUses && !A->onlyReadsMemory()) { // Can we determine that it's readonly/readnone without doing an SCC? // Note that we don't allow any calls at all here, or else our result // will be dependent on the iteration order through the functions in the // SCC. SmallPtrSet<Argument *, 8> Self; Self.insert(&*A); Attribute::AttrKind R = determinePointerReadAttrs(&*A, Self); if (R != Attribute::None) { AttrBuilder B; B.addAttribute(R); A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B)); Changed = true; R == Attribute::ReadOnly ? ++NumReadOnlyArg : ++NumReadNoneArg; } } } } // The graph we've collected is partial because we stopped scanning for // argument uses once we solved the argument trivially. These partial nodes // show up as ArgumentGraphNode objects with an empty Uses list, and for // these nodes the final decision about whether they capture has already been // made. If the definition doesn't have a 'nocapture' attribute by now, it // captures. for (scc_iterator<ArgumentGraph *> I = scc_begin(&AG); !I.isAtEnd(); ++I) { const std::vector<ArgumentGraphNode *> &ArgumentSCC = *I; if (ArgumentSCC.size() == 1) { if (!ArgumentSCC[0]->Definition) continue; // synthetic root node // eg. "void f(int* x) { if (...) f(x); }" if (ArgumentSCC[0]->Uses.size() == 1 && ArgumentSCC[0]->Uses[0] == ArgumentSCC[0]) { Argument *A = ArgumentSCC[0]->Definition; A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B)); ++NumNoCapture; Changed = true; } continue; } bool SCCCaptured = false; for (auto I = ArgumentSCC.begin(), E = ArgumentSCC.end(); I != E && !SCCCaptured; ++I) { ArgumentGraphNode *Node = *I; if (Node->Uses.empty()) { if (!Node->Definition->hasNoCaptureAttr()) SCCCaptured = true; } } if (SCCCaptured) continue; SmallPtrSet<Argument *, 8> ArgumentSCCNodes; // Fill ArgumentSCCNodes with the elements of the ArgumentSCC. Used for // quickly looking up whether a given Argument is in this ArgumentSCC. for (ArgumentGraphNode *I : ArgumentSCC) { ArgumentSCCNodes.insert(I->Definition); } for (auto I = ArgumentSCC.begin(), E = ArgumentSCC.end(); I != E && !SCCCaptured; ++I) { ArgumentGraphNode *N = *I; for (ArgumentGraphNode *Use : N->Uses) { Argument *A = Use->Definition; if (A->hasNoCaptureAttr() || ArgumentSCCNodes.count(A)) continue; SCCCaptured = true; break; } } if (SCCCaptured) continue; for (unsigned i = 0, e = ArgumentSCC.size(); i != e; ++i) { Argument *A = ArgumentSCC[i]->Definition; A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B)); ++NumNoCapture; Changed = true; } // We also want to compute readonly/readnone. With a small number of false // negatives, we can assume that any pointer which is captured isn't going // to be provably readonly or readnone, since by definition we can't // analyze all uses of a captured pointer. // // The false negatives happen when the pointer is captured by a function // that promises readonly/readnone behaviour on the pointer, then the // pointer's lifetime ends before anything that writes to arbitrary memory. // Also, a readonly/readnone pointer may be returned, but returning a // pointer is capturing it. Attribute::AttrKind ReadAttr = Attribute::ReadNone; for (unsigned i = 0, e = ArgumentSCC.size(); i != e; ++i) { Argument *A = ArgumentSCC[i]->Definition; Attribute::AttrKind K = determinePointerReadAttrs(A, ArgumentSCCNodes); if (K == Attribute::ReadNone) continue; if (K == Attribute::ReadOnly) { ReadAttr = Attribute::ReadOnly; continue; } ReadAttr = K; break; } if (ReadAttr != Attribute::None) { AttrBuilder B, R; B.addAttribute(ReadAttr); R.addAttribute(Attribute::ReadOnly).addAttribute(Attribute::ReadNone); for (unsigned i = 0, e = ArgumentSCC.size(); i != e; ++i) { Argument *A = ArgumentSCC[i]->Definition; // Clear out existing readonly/readnone attributes A->removeAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, R)); A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B)); ReadAttr == Attribute::ReadOnly ? ++NumReadOnlyArg : ++NumReadNoneArg; Changed = true; } } } return Changed; } /// Tests whether a function is "malloc-like". /// /// A function is "malloc-like" if it returns either null or a pointer that /// doesn't alias any other pointer visible to the caller. static bool isFunctionMallocLike(Function *F, const SCCNodeSet &SCCNodes) { SmallSetVector<Value *, 8> FlowsToReturn; for (BasicBlock &BB : *F) if (ReturnInst *Ret = dyn_cast<ReturnInst>(BB.getTerminator())) FlowsToReturn.insert(Ret->getReturnValue()); for (unsigned i = 0; i != FlowsToReturn.size(); ++i) { Value *RetVal = FlowsToReturn[i]; if (Constant *C = dyn_cast<Constant>(RetVal)) { if (!C->isNullValue() && !isa<UndefValue>(C)) return false; continue; } if (isa<Argument>(RetVal)) return false; if (Instruction *RVI = dyn_cast<Instruction>(RetVal)) switch (RVI->getOpcode()) { // Extend the analysis by looking upwards. case Instruction::BitCast: case Instruction::GetElementPtr: case Instruction::AddrSpaceCast: FlowsToReturn.insert(RVI->getOperand(0)); continue; case Instruction::Select: { SelectInst *SI = cast<SelectInst>(RVI); FlowsToReturn.insert(SI->getTrueValue()); FlowsToReturn.insert(SI->getFalseValue()); continue; } case Instruction::PHI: { PHINode *PN = cast<PHINode>(RVI); for (Value *IncValue : PN->incoming_values()) FlowsToReturn.insert(IncValue); continue; } // Check whether the pointer came from an allocation. case Instruction::Alloca: break; case Instruction::Call: case Instruction::Invoke: { CallSite CS(RVI); if (CS.paramHasAttr(0, Attribute::NoAlias)) break; if (CS.getCalledFunction() && SCCNodes.count(CS.getCalledFunction())) break; } // fall-through default: return false; // Did not come from an allocation. } if (PointerMayBeCaptured(RetVal, false, /*StoreCaptures=*/false)) return false; } return true; } /// Deduce noalias attributes for the SCC. static bool addNoAliasAttrs(const SCCNodeSet &SCCNodes) { // Check each function in turn, determining which functions return noalias // pointers. for (Function *F : SCCNodes) { // Already noalias. if (F->doesNotAlias(0)) continue; // We can infer and propagate function attributes only when we know that the // definition we'll get at link time is *exactly* the definition we see now. // For more details, see GlobalValue::mayBeDerefined. if (!F->hasExactDefinition()) return false; // We annotate noalias return values, which are only applicable to // pointer types. if (!F->getReturnType()->isPointerTy()) continue; if (!isFunctionMallocLike(F, SCCNodes)) return false; } bool MadeChange = false; for (Function *F : SCCNodes) { if (F->doesNotAlias(0) || !F->getReturnType()->isPointerTy()) continue; F->setDoesNotAlias(0); ++NumNoAlias; MadeChange = true; } return MadeChange; } /// Tests whether this function is known to not return null. /// /// Requires that the function returns a pointer. /// /// Returns true if it believes the function will not return a null, and sets /// \p Speculative based on whether the returned conclusion is a speculative /// conclusion due to SCC calls. static bool isReturnNonNull(Function *F, const SCCNodeSet &SCCNodes, bool &Speculative) { assert(F->getReturnType()->isPointerTy() && "nonnull only meaningful on pointer types"); Speculative = false; SmallSetVector<Value *, 8> FlowsToReturn; for (BasicBlock &BB : *F) if (auto *Ret = dyn_cast<ReturnInst>(BB.getTerminator())) FlowsToReturn.insert(Ret->getReturnValue()); for (unsigned i = 0; i != FlowsToReturn.size(); ++i) { Value *RetVal = FlowsToReturn[i]; // If this value is locally known to be non-null, we're good if (isKnownNonNull(RetVal)) continue; // Otherwise, we need to look upwards since we can't make any local // conclusions. Instruction *RVI = dyn_cast<Instruction>(RetVal); if (!RVI) return false; switch (RVI->getOpcode()) { // Extend the analysis by looking upwards. case Instruction::BitCast: case Instruction::GetElementPtr: case Instruction::AddrSpaceCast: FlowsToReturn.insert(RVI->getOperand(0)); continue; case Instruction::Select: { SelectInst *SI = cast<SelectInst>(RVI); FlowsToReturn.insert(SI->getTrueValue()); FlowsToReturn.insert(SI->getFalseValue()); continue; } case Instruction::PHI: { PHINode *PN = cast<PHINode>(RVI); for (int i = 0, e = PN->getNumIncomingValues(); i != e; ++i) FlowsToReturn.insert(PN->getIncomingValue(i)); continue; } case Instruction::Call: case Instruction::Invoke: { CallSite CS(RVI); Function *Callee = CS.getCalledFunction(); // A call to a node within the SCC is assumed to return null until // proven otherwise if (Callee && SCCNodes.count(Callee)) { Speculative = true; continue; } return false; } default: return false; // Unknown source, may be null }; llvm_unreachable("should have either continued or returned"); } return true; } /// Deduce nonnull attributes for the SCC. static bool addNonNullAttrs(const SCCNodeSet &SCCNodes) { // Speculative that all functions in the SCC return only nonnull // pointers. We may refute this as we analyze functions. bool SCCReturnsNonNull = true; bool MadeChange = false; // Check each function in turn, determining which functions return nonnull // pointers. for (Function *F : SCCNodes) { // Already nonnull. if (F->getAttributes().hasAttribute(AttributeSet::ReturnIndex, Attribute::NonNull)) continue; // We can infer and propagate function attributes only when we know that the // definition we'll get at link time is *exactly* the definition we see now. // For more details, see GlobalValue::mayBeDerefined. if (!F->hasExactDefinition()) return false; // We annotate nonnull return values, which are only applicable to // pointer types. if (!F->getReturnType()->isPointerTy()) continue; bool Speculative = false; if (isReturnNonNull(F, SCCNodes, Speculative)) { if (!Speculative) { // Mark the function eagerly since we may discover a function // which prevents us from speculating about the entire SCC DEBUG(dbgs() << "Eagerly marking " << F->getName() << " as nonnull\n"); F->addAttribute(AttributeSet::ReturnIndex, Attribute::NonNull); ++NumNonNullReturn; MadeChange = true; } continue; } // At least one function returns something which could be null, can't // speculate any more. SCCReturnsNonNull = false; } if (SCCReturnsNonNull) { for (Function *F : SCCNodes) { if (F->getAttributes().hasAttribute(AttributeSet::ReturnIndex, Attribute::NonNull) || !F->getReturnType()->isPointerTy()) continue; DEBUG(dbgs() << "SCC marking " << F->getName() << " as nonnull\n"); F->addAttribute(AttributeSet::ReturnIndex, Attribute::NonNull); ++NumNonNullReturn; MadeChange = true; } } return MadeChange; } /// Remove the convergent attribute from all functions in the SCC if every /// callsite within the SCC is not convergent (except for calls to functions /// within the SCC). Returns true if changes were made. static bool removeConvergentAttrs(const SCCNodeSet &SCCNodes) { // For every function in SCC, ensure that either // * it is not convergent, or // * we can remove its convergent attribute. bool HasConvergentFn = false; for (Function *F : SCCNodes) { if (!F->isConvergent()) continue; HasConvergentFn = true; // Can't remove convergent from function declarations. if (F->isDeclaration()) return false; // Can't remove convergent if any of our functions has a convergent call to a // function not in the SCC. for (Instruction &I : instructions(*F)) { CallSite CS(&I); // Bail if CS is a convergent call to a function not in the SCC. if (CS && CS.isConvergent() && SCCNodes.count(CS.getCalledFunction()) == 0) return false; } } // If the SCC doesn't have any convergent functions, we have nothing to do. if (!HasConvergentFn) return false; // If we got here, all of the calls the SCC makes to functions not in the SCC // are non-convergent. Therefore all of the SCC's functions can also be made // non-convergent. We'll remove the attr from the callsites in // InstCombineCalls. for (Function *F : SCCNodes) { if (!F->isConvergent()) continue; DEBUG(dbgs() << "Removing convergent attr from fn " << F->getName() << "\n"); F->setNotConvergent(); } return true; } static bool setDoesNotRecurse(Function &F) { if (F.doesNotRecurse()) return false; F.setDoesNotRecurse(); ++NumNoRecurse; return true; } static bool addNoRecurseAttrs(const SCCNodeSet &SCCNodes) { // Try and identify functions that do not recurse. // If the SCC contains multiple nodes we know for sure there is recursion. if (SCCNodes.size() != 1) return false; Function *F = *SCCNodes.begin(); if (!F || F->isDeclaration() || F->doesNotRecurse()) return false; // If all of the calls in F are identifiable and are to norecurse functions, F // is norecurse. This check also detects self-recursion as F is not currently // marked norecurse, so any called from F to F will not be marked norecurse. for (Instruction &I : instructions(*F)) if (auto CS = CallSite(&I)) { Function *Callee = CS.getCalledFunction(); if (!Callee || Callee == F || !Callee->doesNotRecurse()) // Function calls a potentially recursive function. return false; } // Every call was to a non-recursive function other than this function, and // we have no indirect recursion as the SCC size is one. This function cannot // recurse. return setDoesNotRecurse(*F); } PreservedAnalyses PostOrderFunctionAttrsPass::run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM) { FunctionAnalysisManager &FAM = AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C).getManager(); // We pass a lambda into functions to wire them up to the analysis manager // for getting function analyses. auto AARGetter = [&](Function &F) -> AAResults & { return FAM.getResult<AAManager>(F); }; // Fill SCCNodes with the elements of the SCC. Also track whether there are // any external or opt-none nodes that will prevent us from optimizing any // part of the SCC. SCCNodeSet SCCNodes; bool HasUnknownCall = false; for (LazyCallGraph::Node &N : C) { Function &F = N.getFunction(); if (F.hasFnAttribute(Attribute::OptimizeNone)) { // Treat any function we're trying not to optimize as if it were an // indirect call and omit it from the node set used below. HasUnknownCall = true; continue; } // Track whether any functions in this SCC have an unknown call edge. // Note: if this is ever a performance hit, we can common it with // subsequent routines which also do scans over the instructions of the // function. if (!HasUnknownCall) for (Instruction &I : instructions(F)) if (auto CS = CallSite(&I)) if (!CS.getCalledFunction()) { HasUnknownCall = true; break; } SCCNodes.insert(&F); } bool Changed = false; Changed |= addReadAttrs(SCCNodes, AARGetter); Changed |= addArgumentAttrs(SCCNodes); // If we have no external nodes participating in the SCC, we can deduce some // more precise attributes as well. if (!HasUnknownCall) { Changed |= addNoAliasAttrs(SCCNodes); Changed |= addNonNullAttrs(SCCNodes); Changed |= removeConvergentAttrs(SCCNodes); Changed |= addNoRecurseAttrs(SCCNodes); } return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all(); } namespace { struct PostOrderFunctionAttrsLegacyPass : public CallGraphSCCPass { static char ID; // Pass identification, replacement for typeid PostOrderFunctionAttrsLegacyPass() : CallGraphSCCPass(ID) { initializePostOrderFunctionAttrsLegacyPassPass(*PassRegistry::getPassRegistry()); } bool runOnSCC(CallGraphSCC &SCC) override; void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); AU.addRequired<AssumptionCacheTracker>(); getAAResultsAnalysisUsage(AU); CallGraphSCCPass::getAnalysisUsage(AU); } }; } char PostOrderFunctionAttrsLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(PostOrderFunctionAttrsLegacyPass, "functionattrs", "Deduce function attributes", false, false) INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass) INITIALIZE_PASS_END(PostOrderFunctionAttrsLegacyPass, "functionattrs", "Deduce function attributes", false, false) Pass *llvm::createPostOrderFunctionAttrsLegacyPass() { return new PostOrderFunctionAttrsLegacyPass(); } template <typename AARGetterT> static bool runImpl(CallGraphSCC &SCC, AARGetterT AARGetter) { bool Changed = false; // Fill SCCNodes with the elements of the SCC. Used for quickly looking up // whether a given CallGraphNode is in this SCC. Also track whether there are // any external or opt-none nodes that will prevent us from optimizing any // part of the SCC. SCCNodeSet SCCNodes; bool ExternalNode = false; for (CallGraphNode *I : SCC) { Function *F = I->getFunction(); if (!F || F->hasFnAttribute(Attribute::OptimizeNone)) { // External node or function we're trying not to optimize - we both avoid // transform them and avoid leveraging information they provide. ExternalNode = true; continue; } SCCNodes.insert(F); } Changed |= addReadAttrs(SCCNodes, AARGetter); Changed |= addArgumentAttrs(SCCNodes); // If we have no external nodes participating in the SCC, we can deduce some // more precise attributes as well. if (!ExternalNode) { Changed |= addNoAliasAttrs(SCCNodes); Changed |= addNonNullAttrs(SCCNodes); Changed |= removeConvergentAttrs(SCCNodes); Changed |= addNoRecurseAttrs(SCCNodes); } return Changed; } bool PostOrderFunctionAttrsLegacyPass::runOnSCC(CallGraphSCC &SCC) { if (skipSCC(SCC)) return false; // We compute dedicated AA results for each function in the SCC as needed. We // use a lambda referencing external objects so that they live long enough to // be queried, but we re-use them each time. Optional<BasicAAResult> BAR; Optional<AAResults> AAR; auto AARGetter = [&](Function &F) -> AAResults & { BAR.emplace(createLegacyPMBasicAAResult(*this, F)); AAR.emplace(createLegacyPMAAResults(*this, F, *BAR)); return *AAR; }; return runImpl(SCC, AARGetter); } namespace { struct ReversePostOrderFunctionAttrsLegacyPass : public ModulePass { static char ID; // Pass identification, replacement for typeid ReversePostOrderFunctionAttrsLegacyPass() : ModulePass(ID) { initializeReversePostOrderFunctionAttrsLegacyPassPass(*PassRegistry::getPassRegistry()); } bool runOnModule(Module &M) override; void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); AU.addRequired<CallGraphWrapperPass>(); AU.addPreserved<CallGraphWrapperPass>(); } }; } char ReversePostOrderFunctionAttrsLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(ReversePostOrderFunctionAttrsLegacyPass, "rpo-functionattrs", "Deduce function attributes in RPO", false, false) INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass) INITIALIZE_PASS_END(ReversePostOrderFunctionAttrsLegacyPass, "rpo-functionattrs", "Deduce function attributes in RPO", false, false) Pass *llvm::createReversePostOrderFunctionAttrsPass() { return new ReversePostOrderFunctionAttrsLegacyPass(); } static bool addNoRecurseAttrsTopDown(Function &F) { // We check the preconditions for the function prior to calling this to avoid // the cost of building up a reversible post-order list. We assert them here // to make sure none of the invariants this relies on were violated. assert(!F.isDeclaration() && "Cannot deduce norecurse without a definition!"); assert(!F.doesNotRecurse() && "This function has already been deduced as norecurs!"); assert(F.hasInternalLinkage() && "Can only do top-down deduction for internal linkage functions!"); // If F is internal and all of its uses are calls from a non-recursive // functions, then none of its calls could in fact recurse without going // through a function marked norecurse, and so we can mark this function too // as norecurse. Note that the uses must actually be calls -- otherwise // a pointer to this function could be returned from a norecurse function but // this function could be recursively (indirectly) called. Note that this // also detects if F is directly recursive as F is not yet marked as // a norecurse function. for (auto *U : F.users()) { auto *I = dyn_cast<Instruction>(U); if (!I) return false; CallSite CS(I); if (!CS || !CS.getParent()->getParent()->doesNotRecurse()) return false; } return setDoesNotRecurse(F); } static bool deduceFunctionAttributeInRPO(Module &M, CallGraph &CG) { // We only have a post-order SCC traversal (because SCCs are inherently // discovered in post-order), so we accumulate them in a vector and then walk // it in reverse. This is simpler than using the RPO iterator infrastructure // because we need to combine SCC detection and the PO walk of the call // graph. We can also cheat egregiously because we're primarily interested in // synthesizing norecurse and so we can only save the singular SCCs as SCCs // with multiple functions in them will clearly be recursive. SmallVector<Function *, 16> Worklist; for (scc_iterator<CallGraph *> I = scc_begin(&CG); !I.isAtEnd(); ++I) { if (I->size() != 1) continue; Function *F = I->front()->getFunction(); if (F && !F->isDeclaration() && !F->doesNotRecurse() && F->hasInternalLinkage()) Worklist.push_back(F); } bool Changed = false; for (auto *F : reverse(Worklist)) Changed |= addNoRecurseAttrsTopDown(*F); return Changed; } bool ReversePostOrderFunctionAttrsLegacyPass::runOnModule(Module &M) { if (skipModule(M)) return false; auto &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph(); return deduceFunctionAttributeInRPO(M, CG); } PreservedAnalyses ReversePostOrderFunctionAttrsPass::run(Module &M, AnalysisManager<Module> &AM) { auto &CG = AM.getResult<CallGraphAnalysis>(M); bool Changed = deduceFunctionAttributeInRPO(M, CG); if (!Changed) return PreservedAnalyses::all(); PreservedAnalyses PA; PA.preserve<CallGraphAnalysis>(); return PA; }
; A167467: a(n) = 25*n^3 - n*(5*n+1)/2 + 1. ; 23,190,652,1559,3061,5308,8450,12637,18019,24746,32968,42835,54497,68104,83806,101753,122095,144982,170564,198991,230413,264980,302842,344149,389051,437698,490240,546827,607609,672736,742358,816625,895687,979694,1068796,1163143,1262885,1368172,1479154,1595981,1718803,1847770,1983032,2124739,2273041,2428088,2590030,2759017,2935199,3118726,3309748,3508415,3714877,3929284,4151786,4382533,4621675,4869362,5125744,5390971,5665193,5948560,6241222,6543329,6855031,7176478,7507820,7849207,8200789,8562716,8935138,9318205,9712067,10116874,10532776,10959923,11398465,11848552,12310334,12783961,13269583,13767350,14277412,14799919,15335021,15882868,16443610,17017397,17604379,18204706,18818528,19445995,20087257,20742464,21411766,22095313,22793255,23505742,24232924,24974951,25731973,26504140,27291602,28094509,28913011,29747258,30597400,31463587,32345969,33244696,34159918,35091785,36040447,37006054,37988756,38988703,40006045,41040932,42093514,43163941,44252363,45358930,46483792,47627099,48789001,49969648,51169190,52387777,53625559,54882686,56159308,57455575,58771637,60107644,61463746,62840093,64236835,65654122,67092104,68550931,70030753,71531720,73053982,74597689,76162991,77750038,79358980,80989967,82643149,84318676,86016698,87737365,89480827,91247234,93036736,94849483,96685625,98545312,100428694,102335921,104267143,106222510,108202172,110206279,112234981,114288428,116366770,118470157,120598739,122752666,124932088,127137155,129368017,131624824,133907726,136216873,138552415,140914502,143303284,145718911,148161533,150631300,153128362,155652869,158204971,160784818,163392560,166028347,168692329,171384656,174105478,176854945,179633207,182440414,185276716,188142263,191037205,193961692,196915874,199899901,202913923,205958090,209032552,212137459,215272961,218439208,221636350,224864537,228123919,231414646,234736868,238090735,241476397,244894004,248343706,251825653,255339995,258886882,262466464,266078891,269724313,273402880,277114742,280860049,284638951,288451598,292298140,296178727,300093509,304042636,308026258,312044525,316097587,320185594,324308696,328467043,332660785,336890072,341155054,345455881,349792703,354165670,358574932,363020639,367502941,372021988,376577930,381170917,385801099,390468626 mov $5,$0 add $0,6 mov $2,$0 lpb $2 add $1,$2 sub $2,1 lpe add $1,2 mov $3,$5 mul $3,63 add $1,$3 mov $4,$5 mul $4,$5 mov $3,$4 mul $3,72 add $1,$3 mul $4,$5 mov $3,$4 mul $3,25 add $1,$3
/* Copyright 2020 Google LLC 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 "tensorflow/compiler/xla/pjrt/distributed/client.h" #include <algorithm> #include <chrono> // NOLINT #include <random> #include <string> #include <utility> #include "absl/synchronization/mutex.h" #include "absl/synchronization/notification.h" #include "absl/time/time.h" #include "grpcpp/channel.h" #include "tensorflow/compiler/xla/pjrt/distributed/protocol.h" #include "tensorflow/compiler/xla/pjrt/distributed/util.h" #include "tensorflow/compiler/xla/util.h" #include "tensorflow/core/distributed_runtime/coordination/coordination_client.h" #include "tensorflow/core/distributed_runtime/coordination/coordination_service_agent.h" #include "tensorflow/core/distributed_runtime/coordination/coordination_service_error_util.h" #include "tensorflow/core/distributed_runtime/rpc/coordination/grpc_coordination_client.h" #include "tensorflow/core/distributed_runtime/worker_env.h" #include "tensorflow/core/platform/errors.h" #include "tensorflow/core/platform/random.h" #include "tensorflow/core/protobuf/coordination_config.pb.h" #include "tensorflow/core/protobuf/coordination_service.pb.h" namespace xla { class DistributedRuntimeClientImpl : public DistributedRuntimeClient { public: DistributedRuntimeClientImpl(std::shared_ptr<::grpc::Channel> channel, const Options& options); explicit DistributedRuntimeClientImpl( std::shared_ptr<::grpc::Channel> channel) : DistributedRuntimeClientImpl(channel, Options()) {} ~DistributedRuntimeClientImpl() override; xla::Status Connect() override; xla::Status Shutdown() override; xla::Status EnumerateDevices(const LocalTopologyProto& local_topology, GlobalTopologyProto* global_topology) override; xla::StatusOr<std::string> BlockingKeyValueGet( std::string key, absl::Duration timeout) override; xla::Status KeyValueSet(std::string key, std::string value) override; private: // Entry point for the heartbeat thread. void HeartbeatLoop(); const std::unique_ptr<grpc::DistributedRuntimeService::Stub> stub_; const DistributedRuntimeClient::Options options_; // Possible states of the client. // The only legal transitions are downwards in the order below. i.e., there is // no way to reopen a closed client. enum class State { // The client has not yet connected to the server, i.e., had a Connect() // RPC succeed. kNotConnected, // The client is connected to the server and as far as we are aware the // connection is healthy. kConnected, // The client is in the process of shutting down, i.e., Shutdown() has been // called. kShuttingDown, // The client has shut down its server connection, either due to an error // or due to an explicit shutdown. kClosed, }; static absl::string_view StateToString(State state); // state_ is protected by a mutex because the heartbeat thread needs to look // at it. absl::Mutex mu_; State state_ ABSL_GUARDED_BY(mu_) = State::kNotConnected; // A unique session ID, assigned by the server during Connect(). uint64_t session_id_; // Notification that tells the heartbeat thread to stop running. absl::Notification stop_heartbeats_; // Thread responsible for performing heartbeats. std::unique_ptr<tensorflow::Thread> heartbeat_thread_; }; class DistributedRuntimeCoordinationServiceClient : public DistributedRuntimeClient { public: DistributedRuntimeCoordinationServiceClient( std::shared_ptr<::grpc::Channel> channel, const Options& options); explicit DistributedRuntimeCoordinationServiceClient( std::shared_ptr<::grpc::Channel> channel) : DistributedRuntimeCoordinationServiceClient(channel, Options()) {} ~DistributedRuntimeCoordinationServiceClient() override; xla::Status Connect() override; xla::Status Shutdown() override; xla::Status EnumerateDevices(const LocalTopologyProto& local_topology, GlobalTopologyProto* global_topology) override; xla::StatusOr<std::string> BlockingKeyValueGet( std::string key, absl::Duration timeout) override; xla::Status KeyValueSet(std::string key, std::string value) override; private: std::unique_ptr<tensorflow::CoordinationServiceAgent> coord_agent_; tensorflow::CoordinationServiceConfig config_; int task_id_; }; DistributedRuntimeClientImpl::DistributedRuntimeClientImpl( std::shared_ptr<::grpc::Channel> channel, const Options& options) : stub_(grpc::DistributedRuntimeService::NewStub(std::move(channel))), options_(options) {} DistributedRuntimeClientImpl::~DistributedRuntimeClientImpl() { bool connected; { absl::MutexLock lock(&mu_); connected = (state_ == State::kConnected); } if (connected) { if (options_.shutdown_on_destruction) { Status status = Shutdown(); if (!status.ok()) { LOG(WARNING) << "PJRT shutdown failed: " << status; } } else { if (!stop_heartbeats_.HasBeenNotified()) { stop_heartbeats_.Notify(); } } } } /*static*/ absl::string_view DistributedRuntimeClientImpl::StateToString( State state) { switch (state) { case State::kNotConnected: return "kNotConnected"; case State::kConnected: return "kConnected"; case State::kShuttingDown: return "kShuttingDown"; case State::kClosed: return "kClosed"; } } xla::Status DistributedRuntimeClientImpl::Connect() { { absl::MutexLock lock(&mu_); if (state_ != State::kNotConnected) { return xla::FailedPrecondition("Connect() called when client in state %s", StateToString(state_)); } } ConnectRequest request; request.set_protocol_version(DistributedRuntimeProtocolVersion()); request.set_timeout_milliseconds( absl::ToInt64Milliseconds(options_.rpc_timeout) / 2); request.set_node_id(options_.node_id); VLOG(10) << "Connect: " << request.DebugString(); ConnectResponse response; ::grpc::Status status; absl::Time deadline = absl::Now() + options_.init_timeout; int attempt = 0; std::default_random_engine generator; std::uniform_real_distribution<double> distribution(0.0, 1.0); do { ::grpc::ClientContext ctx; ctx.set_fail_fast(false); ctx.set_deadline(absl::ToChronoTime(absl::Now() + options_.rpc_timeout)); request.set_client_id(tensorflow::random::New64()); response.Clear(); status = stub_->Connect(&ctx, request, &response); if (!status.ok()) { VLOG(1) << "Connect failed() with status: " << FromGrpcStatus(status); if (attempt % 10 == 0) { LOG(INFO) << "Connect failed() with status: " << FromGrpcStatus(status); } // Exponential backoff with jitter. Note we will retry for `init_timeout` // time in total; the `14` here corresponds to an ~16s maximum interval // between connection attempts. int backoff = 1 << std::min(14, attempt); absl::SleepFor(absl::Milliseconds(backoff * distribution(generator))); } ++attempt; } while (!status.ok() && absl::Now() < deadline); if (!status.ok()) { LOG(ERROR) << "Connect() failed after " << attempt << " retries in " << options_.init_timeout << "; most recent failure status: " << FromGrpcStatus(status); return tensorflow::errors::DeadlineExceeded( absl::StrFormat("Connect() timed out after %s with %d attempts. Most " "recent failure was: %s", absl::FormatDuration(options_.init_timeout), attempt, FromGrpcStatus(status).ToString())); } VLOG(10) << "Connect() response: " << response.DebugString(); { absl::MutexLock lock(&mu_); state_ = State::kConnected; } session_id_ = response.session_id(); heartbeat_thread_.reset(options_.env->StartThread( tensorflow::ThreadOptions(), "pjrt_distributed_heartbeat", [this]() { HeartbeatLoop(); })); LOG(INFO) << "Connected to distributed JAX controller"; return xla::Status::OK(); } xla::Status DistributedRuntimeClientImpl::EnumerateDevices( const LocalTopologyProto& local_topology, GlobalTopologyProto* global_topology) { { absl::MutexLock lock(&mu_); if (state_ != State::kConnected) { return xla::FailedPrecondition( "EnumerateDevices() called when client not connected."); } } ::grpc::ClientContext ctx; ctx.set_fail_fast(false); ctx.set_deadline(absl::ToChronoTime(absl::Now() + options_.rpc_timeout)); EnumerateDevicesRequest request; request.set_session_id(session_id_); *request.mutable_local_topology() = local_topology; request.mutable_local_topology()->set_node_id(options_.node_id); VLOG(10) << "EnumerateDevices: " << request.DebugString(); EnumerateDevicesResponse response; ::grpc::Status status = stub_->EnumerateDevices(&ctx, request, &response); if (!status.ok()) { return FromGrpcStatus(status); } VLOG(10) << "EnumerateDevices() response: " << response.DebugString(); response.mutable_global_topology()->Swap(global_topology); return xla::Status::OK(); } xla::Status DistributedRuntimeClientImpl::Shutdown() { LOG(INFO) << "Waiting for all distributed JAX tasks to shut down."; ::grpc::ClientContext ctx; { absl::MutexLock lock(&mu_); if (state_ != State::kConnected) { return xla::FailedPrecondition( "Shutdown() called when client not connected."); } state_ = State::kShuttingDown; } ctx.set_fail_fast(false); ctx.set_deadline(absl::ToChronoTime(absl::Now() + options_.shutdown_timeout)); ShutdownRequest request; request.set_session_id(session_id_); VLOG(10) << "Shutdown: " << request.DebugString(); ShutdownResponse response; ::grpc::Status status = stub_->Shutdown(&ctx, request, &response); LOG(INFO) << "Distributed task shutdown result: " << FromGrpcStatus(status); if (!status.ok()) { return FromGrpcStatus(status); } if (!stop_heartbeats_.HasBeenNotified()) { stop_heartbeats_.Notify(); } VLOG(10) << "Shutdown() response: " << response.DebugString(); absl::MutexLock lock(&mu_); state_ = State::kClosed; return xla::Status::OK(); } xla::StatusOr<std::string> DistributedRuntimeClientImpl::BlockingKeyValueGet( std::string key, absl::Duration timeout) { { absl::MutexLock lock(&mu_); if (state_ != State::kConnected) { return xla::FailedPrecondition( "BlockingKeyValueGet() called when client not connected."); } } ::grpc::ClientContext ctx; ctx.set_fail_fast(false); ctx.set_deadline(absl::ToChronoTime(absl::Now() + timeout)); KeyValueGetRequest request; request.set_session_id(session_id_); request.set_key(std::move(key)); timeout = std::min(timeout, absl::Minutes(10)); // Avoid overflow request.set_timeout_milliseconds(timeout / absl::Milliseconds(1)); VLOG(10) << "BlockingKeyValueGet: " << request.DebugString(); KeyValueGetResponse response; ::grpc::Status status = stub_->KeyValueGet(&ctx, request, &response); if (!status.ok()) { return FromGrpcStatus(status); } return response.value(); } xla::Status DistributedRuntimeClientImpl::KeyValueSet(std::string key, std::string value) { { absl::MutexLock lock(&mu_); if (state_ != State::kConnected) { return xla::FailedPrecondition( "KeyValueSet() called when client not connected."); } } ::grpc::ClientContext ctx; ctx.set_fail_fast(false); ctx.set_deadline(absl::ToChronoTime(absl::Now() + options_.rpc_timeout)); KeyValueSetRequest request; request.set_session_id(session_id_); request.set_key(std::move(key)); request.set_value(std::move(value)); VLOG(10) << "KeyValueSet: " << request.DebugString(); KeyValueSetResponse response; ::grpc::Status status = stub_->KeyValueSet(&ctx, request, &response); return FromGrpcStatus(status); } void DistributedRuntimeClientImpl::HeartbeatLoop() { int num_missing_heartbeats = 0; while (true) { stop_heartbeats_.WaitForNotificationWithTimeout( options_.heartbeat_interval); if (stop_heartbeats_.HasBeenNotified()) { return; } ::grpc::ClientContext ctx; ctx.set_fail_fast(false); ctx.set_deadline( absl::ToChronoTime(absl::Now() + options_.heartbeat_interval)); HeartbeatRequest request; request.set_session_id(session_id_); request.set_node_id(options_.node_id); VLOG(10) << "Heartbeat: " << request.DebugString(); HeartbeatResponse response; ::grpc::Status status = stub_->Heartbeat(&ctx, request, &response); if (status.ok()) { VLOG(10) << "Heartbeat ok"; num_missing_heartbeats = 0; } else { ++num_missing_heartbeats; VLOG(10) << "Heartbeat error, " << options_.max_missing_heartbeats - num_missing_heartbeats << " tries left: " << status.error_message(); bool is_transient_error = (status.error_code() == ::grpc::StatusCode::DEADLINE_EXCEEDED || status.error_code() == ::grpc::StatusCode::UNAVAILABLE); if (!stop_heartbeats_.HasBeenNotified() && (!is_transient_error || num_missing_heartbeats >= options_.max_missing_heartbeats)) { // If we are shutting down, missed heartbeats are benign: they may // simply mean that the server has shut down already before it saw // the heartbeat request. absl::MutexLock lock(&mu_); if (state_ != State::kShuttingDown) { options_.missed_heartbeat_callback(FromGrpcStatus(status), !is_transient_error); } return; } } } } DistributedRuntimeCoordinationServiceClient:: DistributedRuntimeCoordinationServiceClient( std::shared_ptr<::grpc::Channel> channel, const Options& options) { // Convert options to coordination config. tensorflow::CoordinationServiceConfig config; config.set_service_type("standalone"); config.set_service_leader("/job:jax_worker/task:0"); config.set_cluster_register_timeout_in_ms( absl::ToInt64Milliseconds(options.init_timeout)); config.set_heartbeat_timeout_in_ms(absl::ToInt64Milliseconds( options.heartbeat_interval * options.max_missing_heartbeats)); config.set_shutdown_barrier_timeout_in_ms( absl::ToInt64Milliseconds(options.shutdown_timeout)); config.set_agent_destruction_without_shutdown( !options.shutdown_on_destruction); auto error_fn = [timeout_fn = options.missed_heartbeat_callback](const Status& status) { LOG(ERROR) << "Coordination service agent in error status: " << status; timeout_fn(status, /*coordinator_reported_failure=*/true); }; std::unique_ptr<tensorflow::CoordinationClient> leader_client; leader_client.reset(tensorflow::NewGrpcCoordinationClient(channel)); coord_agent_ = tensorflow::CreateCoordinationServiceAgent(); const Status status = coord_agent_->Initialize(options.env, "jax_worker", options.node_id, config, std::move(leader_client), error_fn); if (!status.ok()) { LOG(ERROR) << "Coordination agent failed to initialize: " << status; } task_id_ = options.node_id; config_ = config; } DistributedRuntimeCoordinationServiceClient:: ~DistributedRuntimeCoordinationServiceClient() {} xla::Status DistributedRuntimeCoordinationServiceClient::Connect() { Status s = tensorflow::errors::Unknown("Connection not attempted yet."); absl::Duration timeout = absl::Milliseconds(config_.cluster_register_timeout_in_ms()); absl::Time deadline = absl::Now() + timeout; int attempt = 0; std::default_random_engine generator; std::uniform_real_distribution<double> distribution(0.0, 1.0); do { ++attempt; s = coord_agent_->Connect(); if (s.ok()) { s = coord_agent_->WaitAtBarrier("PjRT_Client_Connect", timeout, /*tasks=*/{}); } // Exponential backoff with jitter. Note we will retry for `init_timeout` // time in total; the `14` here corresponds to an ~16s maximum interval // between connection attempts. int backoff = 1 << std::min(14, attempt); absl::SleepFor(absl::Milliseconds(backoff * distribution(generator))); } while (!s.ok() && absl::Now() < deadline && // Retries are only made for RPC errors. If a valid service error is // returned, fail immediately. s.GetPayload(tensorflow::CoordinationErrorPayloadKey()) == absl::nullopt); if (s.ok()) { LOG(INFO) << "Connected to distributed JAX controller"; } else { LOG(INFO) << "Failed to connect to distributed JAX controller: " << s; } return s; } xla::Status DistributedRuntimeCoordinationServiceClient::Shutdown() { LOG(INFO) << "Distributed task shutdown initiated."; Status s = coord_agent_->Shutdown(); LOG(INFO) << "Distributed task shutdown result: " << s; return s; } xla::Status DistributedRuntimeCoordinationServiceClient::EnumerateDevices( const LocalTopologyProto& local_topology, GlobalTopologyProto* global_topology) { tensorflow::CoordinationServiceDeviceInfo devices; LocalTopologyProto* device = devices.mutable_xla()->mutable_devices()->add_nodes(); *device = local_topology; device->set_node_id(task_id_); Status s = coord_agent_->WaitForAllTasks(devices); if (!s.ok()) return s; *global_topology = coord_agent_->GetClusterDeviceInfo().xla().devices(); return xla::Status::OK(); } xla::StatusOr<std::string> DistributedRuntimeCoordinationServiceClient::BlockingKeyValueGet( std::string key, absl::Duration timeout) { return coord_agent_->GetKeyValue(key, timeout); } xla::Status DistributedRuntimeCoordinationServiceClient::KeyValueSet( std::string key, std::string value) { return coord_agent_->InsertKeyValue(key, value); } std::unique_ptr<DistributedRuntimeClient> GetDistributedRuntimeClient( std::shared_ptr<::grpc::Channel> channel, const DistributedRuntimeClient::Options& options, bool use_coordination_service) { if (use_coordination_service) { return std::make_unique<xla::DistributedRuntimeCoordinationServiceClient>( channel, options); } return std::make_unique<xla::DistributedRuntimeClientImpl>(channel, options); } } // namespace xla
/* * Copyright 2012 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "GrAAConvexPathRenderer.h" #include "GrAAConvexTessellator.h" #include "GrBatchFlushState.h" #include "GrBatchTest.h" #include "GrCaps.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" #include "GrPathUtils.h" #include "GrProcessor.h" #include "GrPipelineBuilder.h" #include "SkGeometry.h" #include "SkPathPriv.h" #include "SkString.h" #include "SkTraceEvent.h" #include "batches/GrVertexBatch.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLGeometryProcessor.h" #include "glsl/GrGLSLProgramDataManager.h" #include "glsl/GrGLSLUniformHandler.h" #include "glsl/GrGLSLVarying.h" #include "glsl/GrGLSLVertexShaderBuilder.h" GrAAConvexPathRenderer::GrAAConvexPathRenderer() { } struct Segment { enum { // These enum values are assumed in member functions below. kLine = 0, kQuad = 1, } fType; // line uses one pt, quad uses 2 pts SkPoint fPts[2]; // normal to edge ending at each pt SkVector fNorms[2]; // is the corner where the previous segment meets this segment // sharp. If so, fMid is a normalized bisector facing outward. SkVector fMid; int countPoints() { GR_STATIC_ASSERT(0 == kLine && 1 == kQuad); return fType + 1; } const SkPoint& endPt() const { GR_STATIC_ASSERT(0 == kLine && 1 == kQuad); return fPts[fType]; }; const SkPoint& endNorm() const { GR_STATIC_ASSERT(0 == kLine && 1 == kQuad); return fNorms[fType]; }; }; typedef SkTArray<Segment, true> SegmentArray; static void center_of_mass(const SegmentArray& segments, SkPoint* c) { SkScalar area = 0; SkPoint center = {0, 0}; int count = segments.count(); SkPoint p0 = {0, 0}; if (count > 2) { // We translate the polygon so that the first point is at the origin. // This avoids some precision issues with small area polygons far away // from the origin. p0 = segments[0].endPt(); SkPoint pi; SkPoint pj; // the first and last iteration of the below loop would compute // zeros since the starting / ending point is (0,0). So instead we start // at i=1 and make the last iteration i=count-2. pj = segments[1].endPt() - p0; for (int i = 1; i < count - 1; ++i) { pi = pj; pj = segments[i + 1].endPt() - p0; SkScalar t = SkPoint::CrossProduct(pi, pj); area += t; center.fX += (pi.fX + pj.fX) * t; center.fY += (pi.fY + pj.fY) * t; } } // If the poly has no area then we instead return the average of // its points. if (SkScalarNearlyZero(area)) { SkPoint avg; avg.set(0, 0); for (int i = 0; i < count; ++i) { const SkPoint& pt = segments[i].endPt(); avg.fX += pt.fX; avg.fY += pt.fY; } SkScalar denom = SK_Scalar1 / count; avg.scale(denom); *c = avg; } else { area *= 3; area = SkScalarInvert(area); center.scale(area); // undo the translate of p0 to the origin. *c = center + p0; } SkASSERT(!SkScalarIsNaN(c->fX) && !SkScalarIsNaN(c->fY)); } static void compute_vectors(SegmentArray* segments, SkPoint* fanPt, SkPathPriv::FirstDirection dir, int* vCount, int* iCount) { center_of_mass(*segments, fanPt); int count = segments->count(); // Make the normals point towards the outside SkPoint::Side normSide; if (dir == SkPathPriv::kCCW_FirstDirection) { normSide = SkPoint::kRight_Side; } else { normSide = SkPoint::kLeft_Side; } *vCount = 0; *iCount = 0; // compute normals at all points for (int a = 0; a < count; ++a) { Segment& sega = (*segments)[a]; int b = (a + 1) % count; Segment& segb = (*segments)[b]; const SkPoint* prevPt = &sega.endPt(); int n = segb.countPoints(); for (int p = 0; p < n; ++p) { segb.fNorms[p] = segb.fPts[p] - *prevPt; segb.fNorms[p].normalize(); segb.fNorms[p].setOrthog(segb.fNorms[p], normSide); prevPt = &segb.fPts[p]; } if (Segment::kLine == segb.fType) { *vCount += 5; *iCount += 9; } else { *vCount += 6; *iCount += 12; } } // compute mid-vectors where segments meet. TODO: Detect shallow corners // and leave out the wedges and close gaps by stitching segments together. for (int a = 0; a < count; ++a) { const Segment& sega = (*segments)[a]; int b = (a + 1) % count; Segment& segb = (*segments)[b]; segb.fMid = segb.fNorms[0] + sega.endNorm(); segb.fMid.normalize(); // corner wedges *vCount += 4; *iCount += 6; } } struct DegenerateTestData { DegenerateTestData() { fStage = kInitial; } bool isDegenerate() const { return kNonDegenerate != fStage; } enum { kInitial, kPoint, kLine, kNonDegenerate } fStage; SkPoint fFirstPoint; SkVector fLineNormal; SkScalar fLineC; }; static const SkScalar kClose = (SK_Scalar1 / 16); static const SkScalar kCloseSqd = SkScalarMul(kClose, kClose); static void update_degenerate_test(DegenerateTestData* data, const SkPoint& pt) { switch (data->fStage) { case DegenerateTestData::kInitial: data->fFirstPoint = pt; data->fStage = DegenerateTestData::kPoint; break; case DegenerateTestData::kPoint: if (pt.distanceToSqd(data->fFirstPoint) > kCloseSqd) { data->fLineNormal = pt - data->fFirstPoint; data->fLineNormal.normalize(); data->fLineNormal.setOrthog(data->fLineNormal); data->fLineC = -data->fLineNormal.dot(data->fFirstPoint); data->fStage = DegenerateTestData::kLine; } break; case DegenerateTestData::kLine: if (SkScalarAbs(data->fLineNormal.dot(pt) + data->fLineC) > kClose) { data->fStage = DegenerateTestData::kNonDegenerate; } case DegenerateTestData::kNonDegenerate: break; default: SkFAIL("Unexpected degenerate test stage."); } } static inline bool get_direction(const SkPath& path, const SkMatrix& m, SkPathPriv::FirstDirection* dir) { if (!SkPathPriv::CheapComputeFirstDirection(path, dir)) { return false; } // check whether m reverses the orientation SkASSERT(!m.hasPerspective()); SkScalar det2x2 = SkScalarMul(m.get(SkMatrix::kMScaleX), m.get(SkMatrix::kMScaleY)) - SkScalarMul(m.get(SkMatrix::kMSkewX), m.get(SkMatrix::kMSkewY)); if (det2x2 < 0) { *dir = SkPathPriv::OppositeFirstDirection(*dir); } return true; } static inline void add_line_to_segment(const SkPoint& pt, SegmentArray* segments) { segments->push_back(); segments->back().fType = Segment::kLine; segments->back().fPts[0] = pt; } static inline void add_quad_segment(const SkPoint pts[3], SegmentArray* segments) { if (pts[0].distanceToSqd(pts[1]) < kCloseSqd || pts[1].distanceToSqd(pts[2]) < kCloseSqd) { if (pts[0] != pts[2]) { add_line_to_segment(pts[2], segments); } } else { segments->push_back(); segments->back().fType = Segment::kQuad; segments->back().fPts[0] = pts[1]; segments->back().fPts[1] = pts[2]; } } static inline void add_cubic_segments(const SkPoint pts[4], SkPathPriv::FirstDirection dir, SegmentArray* segments) { SkSTArray<15, SkPoint, true> quads; GrPathUtils::convertCubicToQuadsConstrainToTangents(pts, SK_Scalar1, dir, &quads); int count = quads.count(); for (int q = 0; q < count; q += 3) { add_quad_segment(&quads[q], segments); } } static bool get_segments(const SkPath& path, const SkMatrix& m, SegmentArray* segments, SkPoint* fanPt, int* vCount, int* iCount) { SkPath::Iter iter(path, true); // This renderer over-emphasizes very thin path regions. We use the distance // to the path from the sample to compute coverage. Every pixel intersected // by the path will be hit and the maximum distance is sqrt(2)/2. We don't // notice that the sample may be close to a very thin area of the path and // thus should be very light. This is particularly egregious for degenerate // line paths. We detect paths that are very close to a line (zero area) and // draw nothing. DegenerateTestData degenerateData; SkPathPriv::FirstDirection dir; // get_direction can fail for some degenerate paths. if (!get_direction(path, m, &dir)) { return false; } for (;;) { SkPoint pts[4]; SkPath::Verb verb = iter.next(pts); switch (verb) { case SkPath::kMove_Verb: m.mapPoints(pts, 1); update_degenerate_test(&degenerateData, pts[0]); break; case SkPath::kLine_Verb: { m.mapPoints(&pts[1], 1); update_degenerate_test(&degenerateData, pts[1]); add_line_to_segment(pts[1], segments); break; } case SkPath::kQuad_Verb: m.mapPoints(pts, 3); update_degenerate_test(&degenerateData, pts[1]); update_degenerate_test(&degenerateData, pts[2]); add_quad_segment(pts, segments); break; case SkPath::kConic_Verb: { m.mapPoints(pts, 3); SkScalar weight = iter.conicWeight(); SkAutoConicToQuads converter; const SkPoint* quadPts = converter.computeQuads(pts, weight, 0.5f); for (int i = 0; i < converter.countQuads(); ++i) { update_degenerate_test(&degenerateData, quadPts[2*i + 1]); update_degenerate_test(&degenerateData, quadPts[2*i + 2]); add_quad_segment(quadPts + 2*i, segments); } break; } case SkPath::kCubic_Verb: { m.mapPoints(pts, 4); update_degenerate_test(&degenerateData, pts[1]); update_degenerate_test(&degenerateData, pts[2]); update_degenerate_test(&degenerateData, pts[3]); add_cubic_segments(pts, dir, segments); break; }; case SkPath::kDone_Verb: if (degenerateData.isDegenerate()) { return false; } else { compute_vectors(segments, fanPt, dir, vCount, iCount); return true; } default: break; } } } struct QuadVertex { SkPoint fPos; SkPoint fUV; SkScalar fD0; SkScalar fD1; }; struct Draw { Draw() : fVertexCnt(0), fIndexCnt(0) {} int fVertexCnt; int fIndexCnt; }; typedef SkTArray<Draw, true> DrawArray; static void create_vertices(const SegmentArray& segments, const SkPoint& fanPt, DrawArray* draws, QuadVertex* verts, uint16_t* idxs) { Draw* draw = &draws->push_back(); // alias just to make vert/index assignments easier to read. int* v = &draw->fVertexCnt; int* i = &draw->fIndexCnt; int count = segments.count(); for (int a = 0; a < count; ++a) { const Segment& sega = segments[a]; int b = (a + 1) % count; const Segment& segb = segments[b]; // Check whether adding the verts for this segment to the current draw would cause index // values to overflow. int vCount = 4; if (Segment::kLine == segb.fType) { vCount += 5; } else { vCount += 6; } if (draw->fVertexCnt + vCount > (1 << 16)) { verts += *v; idxs += *i; draw = &draws->push_back(); v = &draw->fVertexCnt; i = &draw->fIndexCnt; } // FIXME: These tris are inset in the 1 unit arc around the corner verts[*v + 0].fPos = sega.endPt(); verts[*v + 1].fPos = verts[*v + 0].fPos + sega.endNorm(); verts[*v + 2].fPos = verts[*v + 0].fPos + segb.fMid; verts[*v + 3].fPos = verts[*v + 0].fPos + segb.fNorms[0]; verts[*v + 0].fUV.set(0,0); verts[*v + 1].fUV.set(0,-SK_Scalar1); verts[*v + 2].fUV.set(0,-SK_Scalar1); verts[*v + 3].fUV.set(0,-SK_Scalar1); verts[*v + 0].fD0 = verts[*v + 0].fD1 = -SK_Scalar1; verts[*v + 1].fD0 = verts[*v + 1].fD1 = -SK_Scalar1; verts[*v + 2].fD0 = verts[*v + 2].fD1 = -SK_Scalar1; verts[*v + 3].fD0 = verts[*v + 3].fD1 = -SK_Scalar1; idxs[*i + 0] = *v + 0; idxs[*i + 1] = *v + 2; idxs[*i + 2] = *v + 1; idxs[*i + 3] = *v + 0; idxs[*i + 4] = *v + 3; idxs[*i + 5] = *v + 2; *v += 4; *i += 6; if (Segment::kLine == segb.fType) { verts[*v + 0].fPos = fanPt; verts[*v + 1].fPos = sega.endPt(); verts[*v + 2].fPos = segb.fPts[0]; verts[*v + 3].fPos = verts[*v + 1].fPos + segb.fNorms[0]; verts[*v + 4].fPos = verts[*v + 2].fPos + segb.fNorms[0]; // we draw the line edge as a degenerate quad (u is 0, v is the // signed distance to the edge) SkScalar dist = fanPt.distanceToLineBetween(verts[*v + 1].fPos, verts[*v + 2].fPos); verts[*v + 0].fUV.set(0, dist); verts[*v + 1].fUV.set(0, 0); verts[*v + 2].fUV.set(0, 0); verts[*v + 3].fUV.set(0, -SK_Scalar1); verts[*v + 4].fUV.set(0, -SK_Scalar1); verts[*v + 0].fD0 = verts[*v + 0].fD1 = -SK_Scalar1; verts[*v + 1].fD0 = verts[*v + 1].fD1 = -SK_Scalar1; verts[*v + 2].fD0 = verts[*v + 2].fD1 = -SK_Scalar1; verts[*v + 3].fD0 = verts[*v + 3].fD1 = -SK_Scalar1; verts[*v + 4].fD0 = verts[*v + 4].fD1 = -SK_Scalar1; idxs[*i + 0] = *v + 3; idxs[*i + 1] = *v + 1; idxs[*i + 2] = *v + 2; idxs[*i + 3] = *v + 4; idxs[*i + 4] = *v + 3; idxs[*i + 5] = *v + 2; *i += 6; // Draw the interior fan if it exists. // TODO: Detect and combine colinear segments. This will ensure we catch every case // with no interior, and that the resulting shared edge uses the same endpoints. if (count >= 3) { idxs[*i + 0] = *v + 0; idxs[*i + 1] = *v + 2; idxs[*i + 2] = *v + 1; *i += 3; } *v += 5; } else { SkPoint qpts[] = {sega.endPt(), segb.fPts[0], segb.fPts[1]}; SkVector midVec = segb.fNorms[0] + segb.fNorms[1]; midVec.normalize(); verts[*v + 0].fPos = fanPt; verts[*v + 1].fPos = qpts[0]; verts[*v + 2].fPos = qpts[2]; verts[*v + 3].fPos = qpts[0] + segb.fNorms[0]; verts[*v + 4].fPos = qpts[2] + segb.fNorms[1]; verts[*v + 5].fPos = qpts[1] + midVec; SkScalar c = segb.fNorms[0].dot(qpts[0]); verts[*v + 0].fD0 = -segb.fNorms[0].dot(fanPt) + c; verts[*v + 1].fD0 = 0.f; verts[*v + 2].fD0 = -segb.fNorms[0].dot(qpts[2]) + c; verts[*v + 3].fD0 = -SK_ScalarMax/100; verts[*v + 4].fD0 = -SK_ScalarMax/100; verts[*v + 5].fD0 = -SK_ScalarMax/100; c = segb.fNorms[1].dot(qpts[2]); verts[*v + 0].fD1 = -segb.fNorms[1].dot(fanPt) + c; verts[*v + 1].fD1 = -segb.fNorms[1].dot(qpts[0]) + c; verts[*v + 2].fD1 = 0.f; verts[*v + 3].fD1 = -SK_ScalarMax/100; verts[*v + 4].fD1 = -SK_ScalarMax/100; verts[*v + 5].fD1 = -SK_ScalarMax/100; GrPathUtils::QuadUVMatrix toUV(qpts); toUV.apply<6, sizeof(QuadVertex), sizeof(SkPoint)>(verts + *v); idxs[*i + 0] = *v + 3; idxs[*i + 1] = *v + 1; idxs[*i + 2] = *v + 2; idxs[*i + 3] = *v + 4; idxs[*i + 4] = *v + 3; idxs[*i + 5] = *v + 2; idxs[*i + 6] = *v + 5; idxs[*i + 7] = *v + 3; idxs[*i + 8] = *v + 4; *i += 9; // Draw the interior fan if it exists. // TODO: Detect and combine colinear segments. This will ensure we catch every case // with no interior, and that the resulting shared edge uses the same endpoints. if (count >= 3) { idxs[*i + 0] = *v + 0; idxs[*i + 1] = *v + 2; idxs[*i + 2] = *v + 1; *i += 3; } *v += 6; } } } /////////////////////////////////////////////////////////////////////////////// /* * Quadratic specified by 0=u^2-v canonical coords. u and v are the first * two components of the vertex attribute. Coverage is based on signed * distance with negative being inside, positive outside. The edge is specified in * window space (y-down). If either the third or fourth component of the interpolated * vertex coord is > 0 then the pixel is considered outside the edge. This is used to * attempt to trim to a portion of the infinite quad. * Requires shader derivative instruction support. */ class QuadEdgeEffect : public GrGeometryProcessor { public: static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoords) { return new QuadEdgeEffect(color, localMatrix, usesLocalCoords); } virtual ~QuadEdgeEffect() {} const char* name() const override { return "QuadEdge"; } const Attribute* inPosition() const { return fInPosition; } const Attribute* inQuadEdge() const { return fInQuadEdge; } GrColor color() const { return fColor; } bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } const SkMatrix& localMatrix() const { return fLocalMatrix; } bool usesLocalCoords() const { return fUsesLocalCoords; } class GLSLProcessor : public GrGLSLGeometryProcessor { public: GLSLProcessor() : fColor(GrColor_ILLEGAL) {} void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; // emit attributes varyingHandler->emitAttributes(qe); GrGLSLVertToFrag v(kVec4f_GrSLType); varyingHandler->addVarying("QuadEdge", &v); vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName); GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder; // Setup pass through color if (!qe.colorIgnored()) { this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform); } // Setup position this->setupPosition(vertBuilder, gpArgs, qe.inPosition()->fName); // emit transforms this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar, qe.inPosition()->fName, qe.localMatrix(), args.fTransformsIn, args.fTransformsOut); SkAssertResult(fragBuilder->enableFeature( GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("float edgeAlpha;"); // keep the derivative instructions outside the conditional fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(), v.fsIn()); // today we know z and w are in device space. We could use derivatives fragBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);", v.fsIn(), v.fsIn()); fragBuilder->codeAppendf ("} else {"); fragBuilder->codeAppendf("vec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y," " 2.0*%s.x*duvdy.x - duvdy.y);", v.fsIn(), v.fsIn()); fragBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(), v.fsIn()); fragBuilder->codeAppendf("edgeAlpha = " "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);}"); fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); } static inline void GenKey(const GrGeometryProcessor& gp, const GrGLSLCaps&, GrProcessorKeyBuilder* b) { const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>(); uint32_t key = 0; key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ? 0x1 : 0x0; key |= qee.colorIgnored() ? 0x2 : 0x0; b->add32(key); } void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override { const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>(); if (qe.color() != fColor) { float c[4]; GrColorToRGBAFloat(qe.color(), c); pdman.set4fv(fColorUniform, 1, c); fColor = qe.color(); } } void setTransformData(const GrPrimitiveProcessor& primProc, const GrGLSLProgramDataManager& pdman, int index, const SkTArray<const GrCoordTransform*, true>& transforms) override { this->setTransformDataHelper<QuadEdgeEffect>(primProc, pdman, index, transforms); } private: GrColor fColor; UniformHandle fColorUniform; typedef GrGLSLGeometryProcessor INHERITED; }; void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override { GLSLProcessor::GenKey(*this, caps, b); } GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override { return new GLSLProcessor(); } private: QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoords) : fColor(color) , fLocalMatrix(localMatrix) , fUsesLocalCoords(usesLocalCoords) { this->initClassID<QuadEdgeEffect>(); fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType)); fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVertexAttribType)); } const Attribute* fInPosition; const Attribute* fInQuadEdge; GrColor fColor; SkMatrix fLocalMatrix; bool fUsesLocalCoords; GR_DECLARE_GEOMETRY_PROCESSOR_TEST; typedef GrGeometryProcessor INHERITED; }; GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect); const GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) { // Doesn't work without derivative instructions. return d->fCaps->shaderCaps()->shaderDerivativeSupport() ? QuadEdgeEffect::Create(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool()) : nullptr; } /////////////////////////////////////////////////////////////////////////////// bool GrAAConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { return (args.fShaderCaps->shaderDerivativeSupport() && args.fAntiAlias && args.fStyle->isSimpleFill() && !args.fPath->isInverseFillType() && args.fPath->isConvex()); } // extract the result vertices and indices from the GrAAConvexTessellator static void extract_verts(const GrAAConvexTessellator& tess, void* vertices, size_t vertexStride, GrColor color, uint16_t* idxs, bool tweakAlphaForCoverage) { intptr_t verts = reinterpret_cast<intptr_t>(vertices); for (int i = 0; i < tess.numPts(); ++i) { *((SkPoint*)((intptr_t)verts + i * vertexStride)) = tess.point(i); } // Make 'verts' point to the colors verts += sizeof(SkPoint); for (int i = 0; i < tess.numPts(); ++i) { if (tweakAlphaForCoverage) { SkASSERT(SkScalarRoundToInt(255.0f * tess.coverage(i)) <= 255); unsigned scale = SkScalarRoundToInt(255.0f * tess.coverage(i)); GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale); *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor; } else { *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color; *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = tess.coverage(i); } } for (int i = 0; i < tess.numIndices(); ++i) { idxs[i] = tess.index(i); } } static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, const SkMatrix& viewMatrix, bool usesLocalCoords, bool coverageIgnored) { using namespace GrDefaultGeoProcFactory; Color color(Color::kAttribute_Type); Coverage::Type coverageType; // TODO remove coverage if coverage is ignored /*if (coverageIgnored) { coverageType = Coverage::kNone_Type; } else*/ if (tweakAlphaForCoverage) { coverageType = Coverage::kSolid_Type; } else { coverageType = Coverage::kAttribute_Type; } Coverage coverage(coverageType); LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : LocalCoords::kUnused_Type); return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); } class AAConvexPathBatch : public GrVertexBatch { public: DEFINE_BATCH_CLASS_ID struct Geometry { GrColor fColor; SkMatrix fViewMatrix; SkPath fPath; }; static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPathBatch(geometry); } const char* name() const override { return "AAConvexBatch"; } void computePipelineOptimizations(GrInitInvariantOutput* color, GrInitInvariantOutput* coverage, GrBatchToXPOverrides* overrides) const override { // When this is called on a batch, there is only one geometry bundle color->setKnownFourComponents(fGeoData[0].fColor); coverage->setUnknownSingleComponent(); } private: void initBatchTracker(const GrXPOverridesForBatch& overrides) override { // Handle any color overrides if (!overrides.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; } overrides.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties fBatch.fColorIgnored = !overrides.readsColor(); fBatch.fColor = fGeoData[0].fColor; fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); fBatch.fCoverageIgnored = !overrides.readsCoverage(); fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSegmentMasks(); fBatch.fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage(); } void prepareLinesOnlyDraws(Target* target) const { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); // Setup GrGeometryProcessor SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage, this->viewMatrix(), this->usesLocalCoords(), this->coverageIgnored())); if (!gp) { SkDebugf("Could not create GrGeometryProcessor\n"); return; } size_t vertexStride = gp->getVertexStride(); SkASSERT(canTweakAlphaForCoverage ? vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) : vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr)); GrAAConvexTessellator tess; int instanceCount = fGeoData.count(); for (int i = 0; i < instanceCount; i++) { tess.rewind(); const Geometry& args = fGeoData[i]; if (!tess.tessellate(args.fViewMatrix, args.fPath)) { continue; } const GrBuffer* vertexBuffer; int firstVertex; void* verts = target->makeVertexSpace(vertexStride, tess.numPts(), &vertexBuffer, &firstVertex); if (!verts) { SkDebugf("Could not allocate vertices\n"); return; } const GrBuffer* indexBuffer; int firstIndex; uint16_t* idxs = target->makeIndexSpace(tess.numIndices(), &indexBuffer, &firstIndex); if (!idxs) { SkDebugf("Could not allocate indices\n"); return; } extract_verts(tess, verts, vertexStride, args.fColor, idxs, canTweakAlphaForCoverage); GrMesh mesh; mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, tess.numPts(), tess.numIndices()); target->draw(gp, mesh); } } void onPrepareDraws(Target* target) const override { #ifndef SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS if (this->linesOnly()) { this->prepareLinesOnlyDraws(target); return; } #endif int instanceCount = fGeoData.count(); SkMatrix invert; if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { SkDebugf("Could not invert viewmatrix\n"); return; } // Setup GrGeometryProcessor SkAutoTUnref<GrGeometryProcessor> quadProcessor( QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoords())); // TODO generate all segments for all paths and use one vertex buffer for (int i = 0; i < instanceCount; i++) { const Geometry& args = fGeoData[i]; // We use the fact that SkPath::transform path does subdivision based on // perspective. Otherwise, we apply the view matrix when copying to the // segment representation. const SkMatrix* viewMatrix = &args.fViewMatrix; // We avoid initializing the path unless we have to const SkPath* pathPtr = &args.fPath; SkTLazy<SkPath> tmpPath; if (viewMatrix->hasPerspective()) { SkPath* tmpPathPtr = tmpPath.init(*pathPtr); tmpPathPtr->setIsVolatile(true); tmpPathPtr->transform(*viewMatrix); viewMatrix = &SkMatrix::I(); pathPtr = tmpPathPtr; } int vertexCount; int indexCount; enum { kPreallocSegmentCnt = 512 / sizeof(Segment), kPreallocDrawCnt = 4, }; SkSTArray<kPreallocSegmentCnt, Segment, true> segments; SkPoint fanPt; if (!get_segments(*pathPtr, *viewMatrix, &segments, &fanPt, &vertexCount, &indexCount)) { continue; } const GrBuffer* vertexBuffer; int firstVertex; size_t vertexStride = quadProcessor->getVertexStride(); QuadVertex* verts = reinterpret_cast<QuadVertex*>(target->makeVertexSpace( vertexStride, vertexCount, &vertexBuffer, &firstVertex)); if (!verts) { SkDebugf("Could not allocate vertices\n"); return; } const GrBuffer* indexBuffer; int firstIndex; uint16_t *idxs = target->makeIndexSpace(indexCount, &indexBuffer, &firstIndex); if (!idxs) { SkDebugf("Could not allocate indices\n"); return; } SkSTArray<kPreallocDrawCnt, Draw, true> draws; create_vertices(segments, fanPt, &draws, verts, idxs); GrMesh mesh; for (int j = 0; j < draws.count(); ++j) { const Draw& draw = draws[j]; mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, draw.fVertexCnt, draw.fIndexCnt); target->draw(quadProcessor, mesh); firstVertex += draw.fVertexCnt; firstIndex += draw.fIndexCnt; } } } SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) { fGeoData.push_back(geometry); // compute bounds fBounds = geometry.fPath.getBounds(); geometry.fViewMatrix.mapRect(&fBounds); } bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { AAConvexPathBatch* that = t->cast<AAConvexPathBatch>(); if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(), that->bounds(), caps)) { return false; } if (this->color() != that->color()) { return false; } SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { return false; } if (this->linesOnly() != that->linesOnly()) { return false; } // In the event of two batches, one who can tweak, one who cannot, we just fall back to // not tweaking if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) { fBatch.fCanTweakAlphaForCoverage = false; } fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()); this->joinBounds(that->bounds()); return true; } GrColor color() const { return fBatch.fColor; } bool linesOnly() const { return fBatch.fLinesOnly; } bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCoverage; } const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } bool coverageIgnored() const { return fBatch.fCoverageIgnored; } struct BatchTracker { GrColor fColor; bool fUsesLocalCoords; bool fColorIgnored; bool fCoverageIgnored; bool fLinesOnly; bool fCanTweakAlphaForCoverage; }; BatchTracker fBatch; SkSTArray<1, Geometry, true> fGeoData; typedef GrVertexBatch INHERITED; }; bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrAAConvexPathRenderer::onDrawPath"); if (args.fPath->isEmpty()) { return true; } AAConvexPathBatch::Geometry geometry; geometry.fColor = args.fColor; geometry.fViewMatrix = *args.fViewMatrix; geometry.fPath = *args.fPath; SkAutoTUnref<GrDrawBatch> batch(AAConvexPathBatch::Create(geometry)); args.fTarget->drawBatch(*args.fPipelineBuilder, *args.fClip, batch); return true; } /////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef GR_TEST_UTILS DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { AAConvexPathBatch::Geometry geometry; geometry.fColor = GrRandomColor(random); geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); geometry.fPath = GrTest::TestPathConvex(random); return AAConvexPathBatch::Create(geometry); } #endif
; A131081: Periodic sequence (8, 7, 4, 1, 0, 1, 4, 7). ; 8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8,7,4,1,0,1,4,7,8 add $0,6 mov $3,$0 add $3,4 lpb $0,1 sub $0,1 add $1,$2 trn $1,$3 add $2,4 add $3,$1 lpe
* Sprite bstart * * Mode 4 * +|-----------------+ * -wwwww ggg ggg- * | w g g| * | w gg g | * | w g g | * |w w w g g | * | www | * | w | * | | * |wwwwww | * |ww | * |ww rr rrrr rr rrrr| * |ww | * | rrr rr rrrrr rr| * | | * | rrrr rrr rr rrr| * +|-----------------+ * section sprite xdef mes_bstart xref mes_zero mes_bstart dc.w $0100,$0000 dc.w 18,15,0,0 dc.l mcs_bstart-* dc.l mes_zero-* dc.l sp_bstart-* mcs_bstart dc.w $F8F8,$1D00 dc.w $C000,$0000 dc.w $2020,$1000 dc.w $4000,$0000 dc.w $2020,$1800 dc.w $8000,$0000 dc.w $2020,$1100 dc.w $0000,$0000 dc.w $A8A8,$1100 dc.w $0000,$0000 dc.w $7070,$0000 dc.w $0000,$0000 dc.w $2020,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $FCFC,$0000 dc.w $0000,$0000 dc.w $C0C0,$0000 dc.w $0000,$0000 dc.w $C0DB,$00DB dc.w $00C0,$0000 dc.w $C0C0,$0000 dc.w $0000,$0000 dc.w $001D,$00BE dc.w $00C0,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $001E,$00ED dc.w $00C0,$0000 * sp_bstart incbin 'win1_util_icon_bstart_spr' end
#include once <store32.asm> ; Stores a 32 bit integer number (DE,HL) at (IX + BC) __PSTORE32: push hl push ix pop hl add hl, bc pop bc jp __STORE32
; A016075: Expansion of 1/((1-8*x)*(1-9*x)*(1-10*x)*(1-11*x)). ; Submitted by Christian Krause ; 1,38,905,17290,289821,4453638,64331905,887339330,11810819141,152832918238,1933092302505,23997027406170,293289532268461,3537885908902838,42204462297434705,498697803478957810,5844588402226277781,68011678300853991438,786547256602640400505,9047212519515959434250,103571460300639361647101,1180718273092559829848038,13410495744182720441071905,151816444664249550843875490,1713670925144970214630536421,19293439365411246930420216638,216714156793053272730806520905,2429222967278795091471131321530 mov $1,1 mov $2,$0 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 seq $0,20979 ; Expansion of 1/((1-8*x)*(1-10*x)*(1-11*x)). sub $0,$1 mul $1,10 add $1,$0 lpe mov $0,$1
// Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/maza-config.h" #endif #include "base58.h" #include "clientversion.h" #include "coins.h" #include "consensus/consensus.h" #include "core_io.h" #include "keystore.h" #include "policy/policy.h" #include "primitives/transaction.h" #include "script/script.h" #include "script/sign.h" #include "univalue.h" #include "util.h" #include "utilmoneystr.h" #include "utilstrencodings.h" #include <cstdio> #include <boost/algorithm/string.hpp> static bool fCreateBlank; static std::map<std::string, UniValue> registers; static const int CONTINUE_EXECUTION = -1; // // This function returns either one of EXIT_ codes when it's expected to stop // the process or CONTINUE_EXECUTION when it's expected to continue further. // static int AppInitRawTx(int argc, char *argv[]) { // // Parameters // ParseParameters(argc, argv); // Check for -testnet or -regtest parameter (Params() calls are only valid // after this clause) try { SelectParams(ChainNameFromCommandLine()); } catch (const std::exception &e) { fprintf(stderr, "Error: %s\n", e.what()); return EXIT_FAILURE; } fCreateBlank = GetBoolArg("-create", false); if (argc < 2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help")) { // First part of help message is specific to this utility std::string strUsage = strprintf(_("%s maza-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" + _("Usage:") + "\n" + " maza-tx [options] <hex-tx> [commands] " + _("Update hex-encoded maza transaction") + "\n" + " maza-tx [options] -create [commands] " + _("Create hex-encoded maza transaction") + "\n" + "\n"; fprintf(stdout, "%s", strUsage.c_str()); strUsage = HelpMessageGroup(_("Options:")); strUsage += HelpMessageOpt("-?", _("This help message")); strUsage += HelpMessageOpt("-create", _("Create new, empty TX.")); strUsage += HelpMessageOpt("-json", _("Select JSON output")); strUsage += HelpMessageOpt("-txid", _("Output only the hex-encoded transaction " "id of the resultant transaction.")); AppendParamsHelpMessages(strUsage); fprintf(stdout, "%s", strUsage.c_str()); strUsage = HelpMessageGroup(_("Commands:")); strUsage += HelpMessageOpt("delin=N", _("Delete input N from TX")); strUsage += HelpMessageOpt("delout=N", _("Delete output N from TX")); strUsage += HelpMessageOpt("in=TXID:VOUT(:SEQUENCE_NUMBER)", _("Add input to TX")); strUsage += HelpMessageOpt("locktime=N", _("Set TX lock time to N")); strUsage += HelpMessageOpt("nversion=N", _("Set TX version to N")); strUsage += HelpMessageOpt("outaddr=VALUE:ADDRESS", _("Add address-based output to TX")); strUsage += HelpMessageOpt("outpubkey=VALUE:PUBKEY[:FLAGS]", _("Add pay-to-pubkey output to TX") + ". " + _("Optionally add the \"S\" flag to wrap the " "output in a pay-to-script-hash.")); strUsage += HelpMessageOpt("outdata=[VALUE:]DATA", _("Add data-based output to TX")); strUsage += HelpMessageOpt("outscript=VALUE:SCRIPT[:FLAGS]", _("Add raw script output to TX") + ". " + _("Optionally add the \"S\" flag to wrap the " "output in a pay-to-script-hash.")); strUsage += HelpMessageOpt( "outmultisig=VALUE:REQUIRED:PUBKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]", _("Add Pay To n-of-m Multi-sig output to TX. n = REQUIRED, m = " "PUBKEYS") + ". " + _("Optionally add the \"S\" flag to wrap the output in " "a pay-to-script-hash.")); strUsage += HelpMessageOpt( "sign=SIGHASH-FLAGS", _("Add zero or more signatures to transaction") + ". " + _("This command requires JSON registers:") + _("prevtxs=JSON object") + ", " + _("privatekeys=JSON object") + ". " + _("See signrawtransaction docs for format of sighash " "flags, JSON objects.")); fprintf(stdout, "%s", strUsage.c_str()); strUsage = HelpMessageGroup(_("Register Commands:")); strUsage += HelpMessageOpt("load=NAME:FILENAME", _("Load JSON file FILENAME into register NAME")); strUsage += HelpMessageOpt("set=NAME:JSON-STRING", _("Set register NAME to given JSON-STRING")); fprintf(stdout, "%s", strUsage.c_str()); if (argc < 2) { fprintf(stderr, "Error: too few parameters\n"); return EXIT_FAILURE; } return EXIT_SUCCESS; } return CONTINUE_EXECUTION; } static void RegisterSetJson(const std::string &key, const std::string &rawJson) { UniValue val; if (!val.read(rawJson)) { std::string strErr = "Cannot parse JSON for key " + key; throw std::runtime_error(strErr); } registers[key] = val; } static void RegisterSet(const std::string &strInput) { // separate NAME:VALUE in string size_t pos = strInput.find(':'); if ((pos == std::string::npos) || (pos == 0) || (pos == (strInput.size() - 1))) { throw std::runtime_error("Register input requires NAME:VALUE"); } std::string key = strInput.substr(0, pos); std::string valStr = strInput.substr(pos + 1, std::string::npos); RegisterSetJson(key, valStr); } static void RegisterLoad(const std::string &strInput) { // separate NAME:FILENAME in string size_t pos = strInput.find(':'); if ((pos == std::string::npos) || (pos == 0) || (pos == (strInput.size() - 1))) { throw std::runtime_error("Register load requires NAME:FILENAME"); } std::string key = strInput.substr(0, pos); std::string filename = strInput.substr(pos + 1, std::string::npos); FILE *f = fopen(filename.c_str(), "r"); if (!f) { std::string strErr = "Cannot open file " + filename; throw std::runtime_error(strErr); } // load file chunks into one big buffer std::string valStr; while ((!feof(f)) && (!ferror(f))) { char buf[4096]; int bread = fread(buf, 1, sizeof(buf), f); if (bread <= 0) { break; } valStr.insert(valStr.size(), buf, bread); } int error = ferror(f); fclose(f); if (error) { std::string strErr = "Error reading file " + filename; throw std::runtime_error(strErr); } // evaluate as JSON buffer register RegisterSetJson(key, valStr); } static CAmount ExtractAndValidateValue(const std::string &strValue) { CAmount value; if (!ParseMoney(strValue, value)) { throw std::runtime_error("invalid TX output value"); } return value; } static void MutateTxVersion(CMutableTransaction &tx, const std::string &cmdVal) { int64_t newVersion = atoi64(cmdVal); if (newVersion < 1 || newVersion > CTransaction::MAX_STANDARD_VERSION) { throw std::runtime_error("Invalid TX version requested"); } tx.nVersion = int(newVersion); } static void MutateTxLocktime(CMutableTransaction &tx, const std::string &cmdVal) { int64_t newLocktime = atoi64(cmdVal); if (newLocktime < 0LL || newLocktime > 0xffffffffLL) { throw std::runtime_error("Invalid TX locktime requested"); } tx.nLockTime = (unsigned int)newLocktime; } static void MutateTxAddInput(CMutableTransaction &tx, const std::string &strInput) { std::vector<std::string> vStrInputParts; boost::split(vStrInputParts, strInput, boost::is_any_of(":")); // separate TXID:VOUT in string if (vStrInputParts.size() < 2) { throw std::runtime_error("TX input missing separator"); } // extract and validate TXID std::string strTxid = vStrInputParts[0]; if ((strTxid.size() != 64) || !IsHex(strTxid)) { throw std::runtime_error("invalid TX input txid"); } uint256 txid(uint256S(strTxid)); static const unsigned int minTxOutSz = 9; static const unsigned int maxVout = MAX_TX_SIZE / minTxOutSz; // extract and validate vout std::string strVout = vStrInputParts[1]; int vout = atoi(strVout); if ((vout < 0) || (vout > (int)maxVout)) { throw std::runtime_error("invalid TX input vout"); } // extract the optional sequence number uint32_t nSequenceIn = std::numeric_limits<unsigned int>::max(); if (vStrInputParts.size() > 2) { nSequenceIn = std::stoul(vStrInputParts[2]); } // append to transaction input list CTxIn txin(txid, vout, CScript(), nSequenceIn); tx.vin.push_back(txin); } static void MutateTxAddOutAddr(CMutableTransaction &tx, const std::string &strInput) { // Separate into VALUE:ADDRESS std::vector<std::string> vStrInputParts; boost::split(vStrInputParts, strInput, boost::is_any_of(":")); if (vStrInputParts.size() != 2) { throw std::runtime_error("TX output missing or too many separators"); } // Extract and validate VALUE CAmount value = ExtractAndValidateValue(vStrInputParts[0]); // extract and validate ADDRESS std::string strAddr = vStrInputParts[1]; CBitcoinAddress addr(strAddr); if (!addr.IsValid()) { throw std::runtime_error("invalid TX output address"); } // build standard output script via GetScriptForDestination() CScript scriptPubKey = GetScriptForDestination(addr.Get()); // construct TxOut, append to transaction output list CTxOut txout(value, scriptPubKey); tx.vout.push_back(txout); } static void MutateTxAddOutPubKey(CMutableTransaction &tx, const std::string &strInput) { // Separate into VALUE:PUBKEY[:FLAGS] std::vector<std::string> vStrInputParts; boost::split(vStrInputParts, strInput, boost::is_any_of(":")); if (vStrInputParts.size() < 2 || vStrInputParts.size() > 3) { throw std::runtime_error("TX output missing or too many separators"); } // Extract and validate VALUE CAmount value = ExtractAndValidateValue(vStrInputParts[0]); // Extract and validate PUBKEY CPubKey pubkey(ParseHex(vStrInputParts[1])); if (!pubkey.IsFullyValid()) { throw std::runtime_error("invalid TX output pubkey"); } CScript scriptPubKey = GetScriptForRawPubKey(pubkey); CBitcoinAddress addr(scriptPubKey); // Extract and validate FLAGS bool bScriptHash = false; if (vStrInputParts.size() == 3) { std::string flags = vStrInputParts[2]; bScriptHash = (flags.find("S") != std::string::npos); } if (bScriptHash) { // Get the address for the redeem script, then call // GetScriptForDestination() to construct a P2SH scriptPubKey. CBitcoinAddress redeemScriptAddr(scriptPubKey); scriptPubKey = GetScriptForDestination(redeemScriptAddr.Get()); } // construct TxOut, append to transaction output list CTxOut txout(value, scriptPubKey); tx.vout.push_back(txout); } static void MutateTxAddOutMultiSig(CMutableTransaction &tx, const std::string &strInput) { // Separate into VALUE:REQUIRED:NUMKEYS:PUBKEY1:PUBKEY2:....[:FLAGS] std::vector<std::string> vStrInputParts; boost::split(vStrInputParts, strInput, boost::is_any_of(":")); // Check that there are enough parameters if (vStrInputParts.size() < 3) { throw std::runtime_error("Not enough multisig parameters"); } // Extract and validate VALUE CAmount value = ExtractAndValidateValue(vStrInputParts[0]); // Extract REQUIRED uint32_t required = stoul(vStrInputParts[1]); // Extract NUMKEYS uint32_t numkeys = stoul(vStrInputParts[2]); // Validate there are the correct number of pubkeys if (vStrInputParts.size() < numkeys + 3) { throw std::runtime_error("incorrect number of multisig pubkeys"); } if (required < 1 || required > 20 || numkeys < 1 || numkeys > 20 || numkeys < required) { throw std::runtime_error("multisig parameter mismatch. Required " + std::to_string(required) + " of " + std::to_string(numkeys) + "signatures."); } // extract and validate PUBKEYs std::vector<CPubKey> pubkeys; for (int pos = 1; pos <= int(numkeys); pos++) { CPubKey pubkey(ParseHex(vStrInputParts[pos + 2])); if (!pubkey.IsFullyValid()) { throw std::runtime_error("invalid TX output pubkey"); } pubkeys.push_back(pubkey); } // Extract FLAGS bool bScriptHash = false; if (vStrInputParts.size() == numkeys + 4) { std::string flags = vStrInputParts.back(); bScriptHash = (flags.find("S") != std::string::npos); } else if (vStrInputParts.size() > numkeys + 4) { // Validate that there were no more parameters passed throw std::runtime_error("Too many parameters"); } CScript scriptPubKey = GetScriptForMultisig(required, pubkeys); if (bScriptHash) { // Get the address for the redeem script, then call // GetScriptForDestination() to construct a P2SH scriptPubKey. CBitcoinAddress addr(scriptPubKey); scriptPubKey = GetScriptForDestination(addr.Get()); } // construct TxOut, append to transaction output list CTxOut txout(value, scriptPubKey); tx.vout.push_back(txout); } static void MutateTxAddOutData(CMutableTransaction &tx, const std::string &strInput) { CAmount value = 0; // separate [VALUE:]DATA in string size_t pos = strInput.find(':'); if (pos == 0) { throw std::runtime_error("TX output value not specified"); } if (pos != std::string::npos) { // Extract and validate VALUE value = ExtractAndValidateValue(strInput.substr(0, pos)); } // extract and validate DATA std::string strData = strInput.substr(pos + 1, std::string::npos); if (!IsHex(strData)) { throw std::runtime_error("invalid TX output data"); } std::vector<uint8_t> data = ParseHex(strData); CTxOut txout(value, CScript() << OP_RETURN << data); tx.vout.push_back(txout); } static void MutateTxAddOutScript(CMutableTransaction &tx, const std::string &strInput) { // separate VALUE:SCRIPT[:FLAGS] std::vector<std::string> vStrInputParts; boost::split(vStrInputParts, strInput, boost::is_any_of(":")); if (vStrInputParts.size() < 2) throw std::runtime_error("TX output missing separator"); // Extract and validate VALUE CAmount value = ExtractAndValidateValue(vStrInputParts[0]); // extract and validate script std::string strScript = vStrInputParts[1]; CScript scriptPubKey = ParseScript(strScript); // Extract FLAGS bool bScriptHash = false; if (vStrInputParts.size() == 3) { std::string flags = vStrInputParts.back(); bScriptHash = (flags.find("S") != std::string::npos); } if (bScriptHash) { CBitcoinAddress addr(scriptPubKey); scriptPubKey = GetScriptForDestination(addr.Get()); } // construct TxOut, append to transaction output list CTxOut txout(value, scriptPubKey); tx.vout.push_back(txout); } static void MutateTxDelInput(CMutableTransaction &tx, const std::string &strInIdx) { // parse requested deletion index int inIdx = atoi(strInIdx); if (inIdx < 0 || inIdx >= (int)tx.vin.size()) { std::string strErr = "Invalid TX input index '" + strInIdx + "'"; throw std::runtime_error(strErr.c_str()); } // delete input from transaction tx.vin.erase(tx.vin.begin() + inIdx); } static void MutateTxDelOutput(CMutableTransaction &tx, const std::string &strOutIdx) { // parse requested deletion index int outIdx = atoi(strOutIdx); if (outIdx < 0 || outIdx >= (int)tx.vout.size()) { std::string strErr = "Invalid TX output index '" + strOutIdx + "'"; throw std::runtime_error(strErr.c_str()); } // delete output from transaction tx.vout.erase(tx.vout.begin() + outIdx); } static const unsigned int N_SIGHASH_OPTS = 12; static const struct { const char *flagStr; int flags; } sighashOptions[N_SIGHASH_OPTS] = { {"ALL", SIGHASH_ALL}, {"NONE", SIGHASH_NONE}, {"SINGLE", SIGHASH_SINGLE}, {"ALL|ANYONECANPAY", SIGHASH_ALL | SIGHASH_ANYONECANPAY}, {"NONE|ANYONECANPAY", SIGHASH_NONE | SIGHASH_ANYONECANPAY}, {"SINGLE|ANYONECANPAY", SIGHASH_SINGLE | SIGHASH_ANYONECANPAY}, {"ALL|FORKID", SIGHASH_ALL | SIGHASH_FORKID}, {"NONE|FORKID", SIGHASH_NONE | SIGHASH_FORKID}, {"SINGLE|FORKID", SIGHASH_SINGLE | SIGHASH_FORKID}, {"ALL|FORKID|ANYONECANPAY", SIGHASH_ALL | SIGHASH_FORKID | SIGHASH_ANYONECANPAY}, {"NONE|FORKID|ANYONECANPAY", SIGHASH_NONE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY}, {"SINGLE|FORKID|ANYONECANPAY", SIGHASH_SINGLE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY}, }; static bool findSighashFlags(int &flags, const std::string &flagStr) { flags = 0; for (unsigned int i = 0; i < N_SIGHASH_OPTS; i++) { if (flagStr == sighashOptions[i].flagStr) { flags = sighashOptions[i].flags; return true; } } return false; } uint256 ParseHashUO(std::map<std::string, UniValue> &o, std::string strKey) { if (!o.count(strKey)) { return uint256(); } return ParseHashUV(o[strKey], strKey); } std::vector<uint8_t> ParseHexUO(std::map<std::string, UniValue> &o, std::string strKey) { if (!o.count(strKey)) { std::vector<uint8_t> emptyVec; return emptyVec; } return ParseHexUV(o[strKey], strKey); } static CAmount AmountFromValue(const UniValue &value) { if (!value.isNum() && !value.isStr()) { throw std::runtime_error("Amount is not a number or string"); } CAmount amount; if (!ParseFixedPoint(value.getValStr(), 8, &amount)) { throw std::runtime_error("Invalid amount"); } if (!MoneyRange(amount)) { throw std::runtime_error("Amount out of range"); } return amount; } static void MutateTxSign(CMutableTransaction &tx, const std::string &flagStr) { int nHashType = SIGHASH_ALL | SIGHASH_FORKID; if ((flagStr.size() > 0) && !findSighashFlags(nHashType, flagStr)) { throw std::runtime_error("unknown sighash flag/sign option"); } std::vector<CTransaction> txVariants; txVariants.push_back(tx); // mergedTx will end up with all the signatures; it starts as a clone of the // raw tx: CMutableTransaction mergedTx(txVariants[0]); bool fComplete = true; CCoinsView viewDummy; CCoinsViewCache view(&viewDummy); if (!registers.count("privatekeys")) { throw std::runtime_error("privatekeys register variable must be set."); } CBasicKeyStore tempKeystore; UniValue keysObj = registers["privatekeys"]; for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) { if (!keysObj[kidx].isStr()) { throw std::runtime_error("privatekey not a std::string"); } CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(keysObj[kidx].getValStr()); if (!fGood) { throw std::runtime_error("privatekey not valid"); } CKey key = vchSecret.GetKey(); tempKeystore.AddKey(key); } // Add previous txouts given in the RPC call: if (!registers.count("prevtxs")) { throw std::runtime_error("prevtxs register variable must be set."); } UniValue prevtxsObj = registers["prevtxs"]; for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) { UniValue prevOut = prevtxsObj[previdx]; if (!prevOut.isObject()) { throw std::runtime_error("expected prevtxs internal object"); } std::map<std::string, UniValue::VType> types = { {"txid", UniValue::VSTR}, {"vout", UniValue::VNUM}, {"scriptPubKey", UniValue::VSTR}}; if (!prevOut.checkObject(types)) { throw std::runtime_error("prevtxs internal object typecheck fail"); } uint256 txid = ParseHashUV(prevOut["txid"], "txid"); int nOut = atoi(prevOut["vout"].getValStr()); if (nOut < 0) { throw std::runtime_error("vout must be positive"); } COutPoint out(txid, nOut); std::vector<uint8_t> pkData( ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey")); CScript scriptPubKey(pkData.begin(), pkData.end()); { const Coin &coin = view.AccessCoin(out); if (!coin.IsSpent() && coin.GetTxOut().scriptPubKey != scriptPubKey) { std::string err("Previous output scriptPubKey mismatch:\n"); err = err + ScriptToAsmStr(coin.GetTxOut().scriptPubKey) + "\nvs:\n" + ScriptToAsmStr(scriptPubKey); throw std::runtime_error(err); } CTxOut txout; txout.scriptPubKey = scriptPubKey; txout.nValue = 0; if (prevOut.exists("amount")) { txout.nValue = AmountFromValue(prevOut["amount"]); } view.AddCoin(out, Coin(txout, 1, false), true); } // If redeemScript given and private keys given, add redeemScript to the // tempKeystore so it can be signed: if (scriptPubKey.IsPayToScriptHash() && prevOut.exists("redeemScript")) { UniValue v = prevOut["redeemScript"]; std::vector<uint8_t> rsData(ParseHexUV(v, "redeemScript")); CScript redeemScript(rsData.begin(), rsData.end()); tempKeystore.AddCScript(redeemScript); } } const CKeyStore &keystore = tempKeystore; bool fHashSingle = ((nHashType & ~(SIGHASH_ANYONECANPAY | SIGHASH_FORKID)) == SIGHASH_SINGLE); // Sign what we can: for (size_t i = 0; i < mergedTx.vin.size(); i++) { CTxIn &txin = mergedTx.vin[i]; const Coin &coin = view.AccessCoin(txin.prevout); if (coin.IsSpent()) { fComplete = false; continue; } const CScript &prevPubKey = coin.GetTxOut().scriptPubKey; const CAmount &amount = coin.GetTxOut().nValue; SignatureData sigdata; // Only sign SIGHASH_SINGLE if there's a corresponding output: if (!fHashSingle || (i < mergedTx.vout.size())) { ProduceSignature(MutableTransactionSignatureCreator( &keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata); } // ... and merge in other signatures: for (const CTransaction &txv : txVariants) { sigdata = CombineSignatures( prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i)); } UpdateTransaction(mergedTx, i, sigdata); if (!VerifyScript( txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS | SCRIPT_ENABLE_SIGHASH_FORKID, MutableTransactionSignatureChecker(&mergedTx, i, amount))) { fComplete = false; } } if (fComplete) { // do nothing... for now // perhaps store this for later optional JSON output } tx = mergedTx; } class Secp256k1Init { ECCVerifyHandle globalVerifyHandle; public: Secp256k1Init() { ECC_Start(); } ~Secp256k1Init() { ECC_Stop(); } }; static void MutateTx(CMutableTransaction &tx, const std::string &command, const std::string &commandVal) { std::unique_ptr<Secp256k1Init> ecc; if (command == "nversion") { MutateTxVersion(tx, commandVal); } else if (command == "locktime") { MutateTxLocktime(tx, commandVal); } else if (command == "delin") { MutateTxDelInput(tx, commandVal); } else if (command == "in") { MutateTxAddInput(tx, commandVal); } else if (command == "delout") { MutateTxDelOutput(tx, commandVal); } else if (command == "outaddr") { MutateTxAddOutAddr(tx, commandVal); } else if (command == "outpubkey") { MutateTxAddOutPubKey(tx, commandVal); } else if (command == "outmultisig") { MutateTxAddOutMultiSig(tx, commandVal); } else if (command == "outscript") { MutateTxAddOutScript(tx, commandVal); } else if (command == "outdata") { MutateTxAddOutData(tx, commandVal); } else if (command == "sign") { if (!ecc) { ecc.reset(new Secp256k1Init()); } MutateTxSign(tx, commandVal); } else if (command == "load") { RegisterLoad(commandVal); } else if (command == "set") { RegisterSet(commandVal); } else { throw std::runtime_error("unknown command"); } } static void OutputTxJSON(const CTransaction &tx) { UniValue entry(UniValue::VOBJ); TxToUniv(tx, uint256(), entry); std::string jsonOutput = entry.write(4); fprintf(stdout, "%s\n", jsonOutput.c_str()); } static void OutputTxHash(const CTransaction &tx) { // the hex-encoded transaction id. std::string strHexHash = tx.GetId().GetHex(); fprintf(stdout, "%s\n", strHexHash.c_str()); } static void OutputTxHex(const CTransaction &tx) { std::string strHex = EncodeHexTx(tx); fprintf(stdout, "%s\n", strHex.c_str()); } static void OutputTx(const CTransaction &tx) { if (GetBoolArg("-json", false)) { OutputTxJSON(tx); } else if (GetBoolArg("-txid", false)) { OutputTxHash(tx); } else { OutputTxHex(tx); } } static std::string readStdin() { char buf[4096]; std::string ret; while (!feof(stdin)) { size_t bread = fread(buf, 1, sizeof(buf), stdin); ret.append(buf, bread); if (bread < sizeof(buf)) { break; } } if (ferror(stdin)) { throw std::runtime_error("error reading stdin"); } boost::algorithm::trim_right(ret); return ret; } static int CommandLineRawTx(int argc, char *argv[]) { std::string strPrint; int nRet = 0; try { // Skip switches; Permit common stdin convention "-" while (argc > 1 && IsSwitchChar(argv[1][0]) && (argv[1][1] != 0)) { argc--; argv++; } CMutableTransaction tx; int startArg; if (!fCreateBlank) { // require at least one param if (argc < 2) { throw std::runtime_error("too few parameters"); } // param: hex-encoded maza transaction std::string strHexTx(argv[1]); // "-" implies standard input if (strHexTx == "-") { strHexTx = readStdin(); } if (!DecodeHexTx(tx, strHexTx)) { throw std::runtime_error("invalid transaction encoding"); } startArg = 2; } else { startArg = 1; } for (int i = startArg; i < argc; i++) { std::string arg = argv[i]; std::string key, value; size_t eqpos = arg.find('='); if (eqpos == std::string::npos) { key = arg; } else { key = arg.substr(0, eqpos); value = arg.substr(eqpos + 1); } MutateTx(tx, key, value); } OutputTx(tx); } catch (const boost::thread_interrupted &) { throw; } catch (const std::exception &e) { strPrint = std::string("error: ") + e.what(); nRet = EXIT_FAILURE; } catch (...) { PrintExceptionContinue(nullptr, "CommandLineRawTx()"); throw; } if (strPrint != "") { fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str()); } return nRet; } int main(int argc, char *argv[]) { SetupEnvironment(); try { int ret = AppInitRawTx(argc, argv); if (ret != CONTINUE_EXECUTION) return ret; } catch (const std::exception &e) { PrintExceptionContinue(&e, "AppInitRawTx()"); return EXIT_FAILURE; } catch (...) { PrintExceptionContinue(nullptr, "AppInitRawTx()"); return EXIT_FAILURE; } int ret = EXIT_FAILURE; try { ret = CommandLineRawTx(argc, argv); } catch (const std::exception &e) { PrintExceptionContinue(&e, "CommandLineRawTx()"); } catch (...) { PrintExceptionContinue(nullptr, "CommandLineRawTx()"); } return ret; }
/** * Copyright 2020 The Magma Authors. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. * * 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 <memory> #include <folly/io/async/EventBaseManager.h> #include <glog/logging.h> #include <gtest/gtest.h> #include "LocalEnforcer.h" #include "MagmaService.h" #include "Matchers.h" #include "ProtobufCreators.h" #include "RuleStore.h" #include "ServiceRegistrySingleton.h" #include "SessionID.h" #include "SessionProxyResponderHandler.h" #include "SessionState.h" #include "SessionStore.h" #include "SessiondMocks.h" #include "StoredState.h" #include "magma_logging.h" using ::testing::Test; namespace magma { class SessionProxyResponderHandlerTest : public ::testing::Test { protected: virtual void SetUp() { evb = new folly::EventBase(); std::thread([&]() { std::cout << "Started event loop thread\n"; folly::EventBaseManager::get()->setEventBase(evb, 0); }) .detach(); imsi = "IMSI1"; imsi2 = "IMSI2"; sid = id_gen_.gen_session_id(imsi); sid2 = id_gen_.gen_session_id(imsi2); sid3 = id_gen_.gen_session_id(imsi2); monitoring_key = "mk1"; monitoring_key2 = "mk2"; rule_id_1 = "test_rule_1"; rule_id_2 = "test_rule_2"; rule_id_3 = "test_rule_3"; dynamic_rule_id_1 = "dynamic_rule_1"; dynamic_rule_id_2 = "dynamic_rule_2"; reporter = std::make_shared<MockSessionReporter>(); auto rule_store = std::make_shared<StaticRuleStore>(); session_store = std::make_shared<SessionStore>(rule_store); pipelined_client = std::make_shared<MockPipelinedClient>(); auto directoryd_client = std::make_shared<MockDirectorydClient>(); auto spgw_client = std::make_shared<MockSpgwServiceClient>(); auto aaa_client = std::make_shared<MockAAAClient>(); auto events_reporter = std::make_shared<MockEventsReporter>(); auto default_mconfig = get_default_mconfig(); local_enforcer = std::make_shared<LocalEnforcer>( reporter, rule_store, *session_store, pipelined_client, directoryd_client, events_reporter, spgw_client, aaa_client, 0, 0, default_mconfig); session_map = SessionMap{}; proxy_responder = std::make_shared<SessionProxyResponderHandlerImpl>( local_enforcer, *session_store); local_enforcer->attachEventBase(evb); } std::unique_ptr<SessionState> get_session( std::string session_id, std::shared_ptr<StaticRuleStore> rule_store) { std::string hardware_addr_bytes = {0x0f, 0x10, 0x2e, 0x12, 0x3a, 0x55}; std::string msisdn = "5100001234"; std::string radius_session_id = "AA-AA-AA-AA-AA-AA:TESTAP__" "0F-10-2E-12-3A-55"; std::string mac_addr = "0f:10:2e:12:3a:55"; SessionConfig cfg; cfg.common_context = build_common_context("", "128.0.0.1", "", "APN", msisdn, TGPP_WLAN); const auto& wlan = build_wlan_context(mac_addr, radius_session_id); cfg.rat_specific_context.mutable_wlan_context()->CopyFrom(wlan); auto tgpp_context = TgppContext{}; auto pdp_start_time = 12345; return std::make_unique<SessionState>( imsi, session_id, cfg, *rule_store, tgpp_context, pdp_start_time); } UsageMonitoringUpdateResponse* get_monitoring_update() { auto units = new GrantedUnits(); auto total = new CreditUnit(); total->set_is_valid(true); total->set_volume(1000); auto tx = new CreditUnit(); tx->set_is_valid(true); tx->set_volume(1000); auto rx = new CreditUnit(); rx->set_is_valid(true); rx->set_volume(1000); units->set_allocated_total(total); units->set_allocated_tx(tx); units->set_allocated_rx(rx); auto monitoring_credit = new UsageMonitoringCredit(); monitoring_credit->set_action(UsageMonitoringCredit_Action_CONTINUE); monitoring_credit->set_monitoring_key(monitoring_key); monitoring_credit->set_level(SESSION_LEVEL); monitoring_credit->set_allocated_granted_units(units); auto credit_update = new UsageMonitoringUpdateResponse(); credit_update->set_allocated_credit(monitoring_credit); credit_update->set_session_id("sid1"); credit_update->set_success(true); // Don't set event triggers // Don't set result code since the response is already successful // Don't set any rule installation/uninstallation // Don't set the TgppContext, assume gx_gy_relay disabled return credit_update; } PolicyReAuthRequest* get_policy_reauth_request() { auto request = new PolicyReAuthRequest(); request->set_session_id(""); request->set_imsi("IMSI1"); auto static_rule = new StaticRuleInstall(); static_rule->set_rule_id("static_1"); // This should be a duplicate rule auto static_rule_2 = new StaticRuleInstall(); static_rule_2->set_rule_id(rule_id_3); request->mutable_rules_to_install()->AddAllocated(static_rule); request->mutable_rules_to_install()->AddAllocated(static_rule_2); return request; } protected: std::string imsi; std::string imsi2; std::string sid; std::string sid2; std::string sid3; std::string monitoring_key; std::string monitoring_key2; std::string rule_id_1; std::string rule_id_2; std::string rule_id_3; std::string dynamic_rule_id_1; std::string dynamic_rule_id_2; std::shared_ptr<MockPipelinedClient> pipelined_client; std::shared_ptr<SessionProxyResponderHandlerImpl> proxy_responder; std::shared_ptr<MockSessionReporter> reporter; std::shared_ptr<LocalEnforcer> local_enforcer; SessionIDGenerator id_gen_; folly::EventBase* evb; SessionMap session_map; std::shared_ptr<SessionStore> session_store; std::shared_ptr<StaticRuleStore> rule_store; }; TEST_F(SessionProxyResponderHandlerTest, test_policy_reauth) { // 1) Create SessionStore auto rule_store = std::make_shared<StaticRuleStore>(); // 2) Create bare-bones session for IMSI1 auto uc = get_default_update_criteria(); auto session = get_session(sid, rule_store); RuleLifetime lifetime{ .activation_time = std::time_t(0), .deactivation_time = std::time_t(0), }; session->activate_static_rule(rule_id_3, lifetime, uc); EXPECT_EQ(session->get_session_id(), sid); EXPECT_EQ(session->get_request_number(), 1); EXPECT_EQ(session->is_static_rule_installed(rule_id_3), true); auto credit_update = get_monitoring_update(); UsageMonitoringUpdateResponse& credit_update_ref = *credit_update; session->receive_monitor(credit_update_ref, uc); // Add some used credit session->add_to_monitor(monitoring_key, uint64_t(111), uint64_t(333), uc); EXPECT_EQ(session->get_monitor(monitoring_key, USED_TX), 111); EXPECT_EQ(session->get_monitor(monitoring_key, USED_RX), 333); // 3) Commit session for IMSI1 into SessionStore auto sessions = SessionVector{}; EXPECT_EQ(sessions.size(), 0); sessions.push_back(std::move(session)); EXPECT_EQ(sessions.size(), 1); session_store->create_sessions(imsi, std::move(sessions)); // Just verify some things about the session before doing PolicyReAuth SessionRead read_req = {}; read_req.insert(imsi); auto session_map = session_store->read_sessions(read_req); EXPECT_EQ(session_map.size(), 1); EXPECT_EQ(session_map[imsi].size(), 1); EXPECT_EQ(session_map[imsi].front()->get_request_number(), 1); EXPECT_EQ( session_map[imsi].front()->is_static_rule_installed("static_1"), false); // 4) Now call PolicyReAuth // This is done with a duplicate install of rule_id_3. This checks that // duplicate rule installs are ignored, as they are occasionally // requested by the session proxy. If the duplicate rule install causes // a failure, then the entire PolicyReAuth will not save to the // SessionStore properly std::cout << "Andrei: Calling PolicyReAuth" << std::endl; auto request = get_policy_reauth_request(); grpc::ServerContext create_context; EXPECT_CALL( *pipelined_client, activate_flows_for_rules(imsi, _, _, _, CheckCount(1), _, _)) .Times(1); proxy_responder->PolicyReAuth( &create_context, request, [this](grpc::Status status, PolicyReAuthAnswer response_out) {}); // run LocalEnforcer's init_policy_reauth which was scheduled by // proxy_responder evb->loopOnce(); // 5) Read the session back from SessionStore and verify that the update // was done correctly to what's stored. // If the PolicyReAuth failed, then rule static_1 will not have been // installed. session_map = session_store->read_sessions(read_req); EXPECT_EQ(session_map.size(), 1); EXPECT_EQ(session_map[imsi].size(), 1); EXPECT_EQ(session_map[imsi].front()->get_request_number(), 1); EXPECT_EQ( session_map[imsi].front()->is_static_rule_installed("static_1"), true); } int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } } // namespace magma
SECTION "Map_066A", ROM0[$B800] Map_066A_Header: hdr_tileset 9 hdr_dimensions 7, 5 hdr_pointers_a Map_066A_Blocks, Map_066A_TextPointers hdr_pointers_b Map_066A_Script, Map_066A_Objects hdr_pointers_c Map_066A_InitScript, Map_066A_RAMScript hdr_palette $02 hdr_music MUSIC_CITIES1, AUDIO_1 hdr_connection NORTH, $0000, 0, 0 hdr_connection SOUTH, $0000, 0, 0 hdr_connection WEST, $0000, 0, 0 hdr_connection EAST, $0000, 0, 0 Map_066A_Objects: hdr_border $0a hdr_warp_count 2 hdr_warp 3, 9, 10, 14, $062F hdr_warp 2, 9, 10, 14, $062F hdr_sign_count 6 hdr_signpost 6, 1, $04 hdr_signpost 6, 2, $04 hdr_signpost 5, 2, $04 hdr_signpost 4, 2, $04 hdr_signpost 4, 1, $04 hdr_signpost 10, 5, $03 hdr_object_count 2 hdr_object SPRITE_BIKE_SHOP_GUY, 6, 5, STAY, NONE, $02 hdr_object SPRITE_OAK_AIDE, 1, 3, STAY, NONE, $01 Map_066A_RAMScript: rs_end Map_066A_Blocks: db $4d,$5e,$3d,$3e,$4d,$4d,$4d db $00,$00,$3f,$4b,$00,$00,$00 db $3a,$00,$00,$00,$58,$59,$5a db $00,$00,$00,$00,$00,$00,$00 db $3a,$0b,$00,$0a,$0a,$0a,$0a Map_066A_TextPointers: dw Map_066A_TX1 dw Map_066A_TX2 dw Map_066A_TX3 dw Map_066A_TX4 Map_066A_InitScript: ret Map_066A_Script: ret Map_066A_TX1: TX_ASM jp EnhancedTextOnly text "The Glitch Research Lab" next "is mostly responsible for" cont "the idea of creating a" cont "glitch museum." done Map_066A_TX2: TX_ASM jp EnhancedTextOnly text "Welcome to Glitchland's one" next "and only Glitch Museum!" para "We've built it just recently," next "so we don't have too many" cont "exhibits yet." para "But soon, we will be getting" next "more. You should visit us" cont "later and see!" done Map_066A_TX3: TX_ASM jp EnhancedTextOnly text "The bones of the Aerodactyl" next "Fossil Missingno.," cont "circa 1995." para "The only exhibit in this" next "museum so far. Quite boring." done Map_066A_TX4: TX_ASM jp EnhancedTextOnly text "A space shuttle." para "It has nothing to do with" next "glitches, but it looks cool!" done
; DV3 PC Compatible Floppy Disk Select Drive  1998 Tony Tebby section fd xdef fd_select ; select xdef fd_reset ; reset/reselect controller xdef fd_newdensity ; re-select with new density xdef fd_start ; start drive xdef fd_deselect ; deselect xref fd_srate xref fd_srtemp xref fd_result xref fd_wait xref.l fdc_dctl xref.l fdc_rate xref.s fdc.mots include 'dev8_dv3_keys' include 'dev8_dv3_fd_keys' ; include 'dev8_dv3_fd_pcf_keys' include 'dev8_mac_assert' dc.b fdc.rsd ; assumed rate (density -1) fdsl_rat dc.b fdc.rsd,fdc.rsd,fdc.rhd,fdc.red ; 250k, 250k, 500k, 1M rate dc.b 0 fds.reset equ 8 ; .14-.16 sec to reset ;+++ ; Set new density. ; ; d7 c p drive number (1...) ; a3 c p linkage block ; a4 c p drive definition block ; ; status return zero ;--- fd_newdensity move.b ddf_density(a4),d0 ; current density subq.b #1,d0 bpl.s fdn_set ; ... OK move.b fdl_mxdns(a3),d0 ; ... restart at max fdn_set move.b d0,ddf_density(a4) ; set new density ;+++ ; Reset controller and and reselect drive ; ; d7 c p drive number (1...) ; a3 c p linkage block ; a4 c p drive definition block ; ; status return OK ;--- fd_reset moveq #fds.reset,d0 ; reset time bsr.s fds_modes jmp fd_srtemp ; set the step rate again ;+++ ; Select disk drive. Sets FDL_SELC. Blats FDL_CTRK. ; ; d7 c p drive number (1...) ; a3 c p linkage block ; a4 c p drive definition block ; ; status return zero or err.mchk ;--- fd_select moveq #0,d0 ; ... no reset bsr.s fds_modes ; set mode and select jsr fd_srate ; set step rate bne.s fdsl_rts tst.b fdl_selc(a3) ; is a drive selected? bne.s fdsl_sel move.b fdl_rnup(a3),fdl_drvs(a3) ; runup time fdsl_sel move.b d7,fdl_selc(a3) ; this drive is selected st fdf_ctrk(a4) ; track unknown moveq #0,d0 fdsl_rts rts ;+++ ; Set drive mode dependent registers and select drive ; ; d0 cr pause after reset (0 for no reset) ; d7 c p drive number (1...) ; a3 c p linkage block ; a4 c p drive definition block ; ; status return OK ;--- fds_modes move.l a0,-(sp) move.l d1,-(sp) lea fdc_dctl,a0 move.b ddf_density(a4),d1 ; density 0,1=std, 2=high, 3=extended ext.w d1 move.b fdsl_rat(pc,d1.w),fdc_rate-fdc_dctl(a0) ; set data rate add.w #fdl_sltab-1,d7 move.b (a3,d7.w),d1 ; select drive sub.w #fdl_sltab-1,d7 tst.b d0 ; any reset? beq.s fdsm_set ; ... no move.b d1,(a0) ; drive control / reset jsr fd_wait ; wait for reset fdsm_set bset #fdc..rst,d1 move.b d1,(a0) ; drive control / unreset move.l (sp)+,d1 move.l (sp)+,a0 fdsl_ok moveq #0,d0 rts ;+++ ; Deselect disk drive. Clears FDL_SELC. ; ; a3 c p linkage block ; ; Status return OK ; ;--- fd_deselect moveq #fdc.desl,d0 fd_setmc move.b d0,fdc_dctl ; clear out drive control but no reset sf fdl_selc(a3) ; nothing selected bra.s fdsl_ok ;+++ ; Start disk drive (no drive selected) - a bit like deselect! ; Clears FDL_SELC. ; ; a3 c p linkage block ; ; status return OK ;--- fd_start moveq #fdc.mots,d0 ; set motor on and reset move.b fdl_rnup(a3),fdl_drvs(a3) ; run-up status bra.s fd_setmc end
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- /** * @ingroup vision_programs * * @defgroup haarDetection2D haarDetection2D * * @brief Creates an instance of roboticslab::HaarDetection2D. * * @section haarDetection2DOptions HaarDetection2D options: * * | PROPERTY | DESCRIPTION | DEFAULT | * |--------------|--------------------------------------|------------------| * | help | | | * | from | file.ini | | * | context | path | | * | cropSelector | | 0 | * | cameraDevice | device we create | remote_grabber | * | cameraLocal | if accesing remote, local port name | /haarDetection2D | * | cameraRemote | if accesing remote, remote port name | /frameGrabber2D | * | watchdog | | 2.000000 | * * * @section haarDetection2DPorts HaarDetection2D output ports: * * | OUTPUT PORT | CONTENT | * |--------------------------|---------------------------------------------------------| * | /haarDetection2D/img:o | Output camera image with object detection using squares | * | /haarDetection2D/state:o | xy coordinates of object detection | * * @section segmentorThread SegmentorThread options: * * | PROPERTY | DESCRIPTION | DEFAULT | * |------------|-------------|------------------------------| * | help | | | * | from | file.ini | | * | context | path | | * | fx_d | | 525.000000 | * | fy_d | | 525.000000 | * | cx_d | | 319.500000 | * | cy_d | | 239.500000 | * | rateMs | | 20 | * | xmlCascade | file.xml | haarcascade_cocacola_can.xml | */ #include <yarp/os/Network.h> #include <yarp/os/ResourceFinder.h> #include "HaarDetection2D.hpp" #include "ColorDebug.hpp" int main(int argc, char** argv) { yarp::os::ResourceFinder rf; rf.setVerbose(true); rf.setDefaultContext("haarDetection"); rf.setDefaultConfigFile("haarDetection2D.ini"); rf.configure(argc, argv); roboticslab::HaarDetection2D mod; if (rf.check("help")) { return mod.runModule(rf); } CD_INFO("Run \"%s --help\" for options.\n", argv[0]); CD_INFO("%s checking for yarp network... ", argv[0]); std::fflush(stdout); yarp::os::Network yarp; if (!yarp::os::Network::checkNetwork()) { CD_ERROR_NO_HEADER("[fail]\n"); CD_INFO("%s found no yarp network (try running \"yarpserver &\"), bye!\n", argv[0]); return 1; } else { CD_SUCCESS_NO_HEADER("[ok]\n"); } return mod.runModule(rf); }
#include <stdlib.h> #include <getopt.h> #include <sys/time.h> #include <sys/resource.h> #include <unistd.h> namespace wandbox { namespace prlimit { int main(int argc, char **argv) { { static const option opts[] = { { "core", 1, nullptr, 'c' }, { "data", 1, nullptr, 'd' }, { "nice", 1, nullptr, 'e' }, { "fsize", 1, nullptr, 'f' }, { "sigpending", 1, nullptr, 'i' }, { "memlock", 1, nullptr, 'l' }, { "rss", 1, nullptr, 'm' }, { "nofile", 1, nullptr, 'n' }, { "msgqueue", 1, nullptr, 'q' }, { "stack", 1, nullptr, 's' }, { "cpu", 1, nullptr, 't' }, { "nproc", 1, nullptr, 'u' }, { "as", 1, nullptr, 'v' }, { "locks", 1, nullptr, 'x' }, { "rttime", 1, nullptr, 'y' }, { nullptr, 0, nullptr, 0 }, }; for (int opt; (opt = getopt_long(argc, argv, "c:d:e:f:i:l:m:n:q:s:t:u:v:x:y:", opts, nullptr)) != -1; ) { const unsigned val = atoi(optarg); const struct rlimit lim = { val, val }; switch (opt) { case 'c': setrlimit(RLIMIT_CORE, &lim); break; case 'd': setrlimit(RLIMIT_DATA, &lim); break; case 'e': setrlimit(RLIMIT_NICE, &lim); break; case 'f': setrlimit(RLIMIT_FSIZE, &lim); break; case 'i': setrlimit(RLIMIT_SIGPENDING, &lim); break; case 'l': setrlimit(RLIMIT_MEMLOCK, &lim); break; case 'm': setrlimit(RLIMIT_RSS, &lim); break; case 'n': setrlimit(RLIMIT_NOFILE, &lim); break; case 'q': setrlimit(RLIMIT_MSGQUEUE, &lim); break; case 's': setrlimit(RLIMIT_STACK, &lim); break; case 't': setrlimit(RLIMIT_CPU, &lim); break; case 'u': setrlimit(RLIMIT_NPROC, &lim); break; case 'v': setrlimit(RLIMIT_AS, &lim); break; case 'x': setrlimit(RLIMIT_LOCKS, &lim); break; case 'y': setrlimit(RLIMIT_RTTIME, &lim); break; default: continue; } } } argv += optind; execv(argv[0], argv); return 1; } } } int main(int argc, char **argv) { return wandbox::prlimit::main(argc, argv); }
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.23.28008.0 TITLE C:\Users\libit\source\repos\L008A\L008A\L008A.cpp .686P .XMM include listing.inc .model flat INCLUDELIB LIBCMT INCLUDELIB OLDNAMES CONST SEGMENT $SG5675 DB 'hi %d,%d,%d', 0aH, 00H CONST ENDS PUBLIC ___local_stdio_printf_options PUBLIC __vsnprintf_l PUBLIC __vsnprintf PUBLIC __snprintf PUBLIC _main PUBLIC ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage EXTRN _puts:PROC EXTRN ___stdio_common_vsprintf:PROC EXTRN @__security_check_cookie@4:PROC EXTRN __alloca_probe_16:PROC EXTRN ___security_cookie:DWORD ; COMDAT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA _BSS SEGMENT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA DQ 01H DUP (?) ; `__local_stdio_printf_options'::`2'::_OptionsStorage _BSS ENDS ; Function compile flags: /Odtp _TEXT SEGMENT tv66 = -12 ; size = 4 _buffer$ = -8 ; size = 4 __$ArrayPad$ = -4 ; size = 4 _main PROC ; File C:\Users\libit\source\repos\L008A\L008A\L008A.cpp ; Line 17 push ebp mov ebp, esp sub esp, 12 ; 0000000cH mov eax, DWORD PTR ___security_cookie xor eax, ebp mov DWORD PTR __$ArrayPad$[ebp], eax ; Line 21 mov eax, 600 ; 00000258H call __alloca_probe_16 mov DWORD PTR tv66[ebp], esp mov eax, DWORD PTR tv66[ebp] mov DWORD PTR _buffer$[ebp], eax ; Line 22 push 3 push 2 push 1 push OFFSET $SG5675 push 600 ; 00000258H mov ecx, DWORD PTR _buffer$[ebp] push ecx call __snprintf add esp, 24 ; 00000018H ; Line 23 mov edx, DWORD PTR _buffer$[ebp] push edx call _puts add esp, 4 ; Line 28 xor eax, eax lea esp, DWORD PTR [ebp-12] mov ecx, DWORD PTR __$ArrayPad$[ebp] xor ecx, ebp call @__security_check_cookie@4 mov esp, ebp pop ebp ret 0 _main ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT __snprintf _TEXT SEGMENT __Result$ = -8 ; size = 4 __ArgList$ = -4 ; size = 4 __Buffer$ = 8 ; size = 4 __BufferCount$ = 12 ; size = 4 __Format$ = 16 ; size = 4 __snprintf PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 1969 push ebp mov ebp, esp sub esp, 8 ; Line 1972 lea eax, DWORD PTR __Format$[ebp+4] mov DWORD PTR __ArgList$[ebp], eax ; Line 1974 mov ecx, DWORD PTR __ArgList$[ebp] push ecx mov edx, DWORD PTR __Format$[ebp] push edx mov eax, DWORD PTR __BufferCount$[ebp] push eax mov ecx, DWORD PTR __Buffer$[ebp] push ecx call __vsnprintf add esp, 16 ; 00000010H mov DWORD PTR __Result$[ebp], eax ; Line 1975 mov DWORD PTR __ArgList$[ebp], 0 ; Line 1976 mov eax, DWORD PTR __Result$[ebp] ; Line 1977 mov esp, ebp pop ebp ret 0 __snprintf ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT __vsnprintf _TEXT SEGMENT __Buffer$ = 8 ; size = 4 __BufferCount$ = 12 ; size = 4 __Format$ = 16 ; size = 4 __ArgList$ = 20 ; size = 4 __vsnprintf PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 1409 push ebp mov ebp, esp ; Line 1412 mov eax, DWORD PTR __ArgList$[ebp] push eax push 0 mov ecx, DWORD PTR __Format$[ebp] push ecx mov edx, DWORD PTR __BufferCount$[ebp] push edx mov eax, DWORD PTR __Buffer$[ebp] push eax call __vsnprintf_l add esp, 20 ; 00000014H ; Line 1414 pop ebp ret 0 __vsnprintf ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT __vsnprintf_l _TEXT SEGMENT tv74 = -8 ; size = 4 __Result$ = -4 ; size = 4 __Buffer$ = 8 ; size = 4 __BufferCount$ = 12 ; size = 4 __Format$ = 16 ; size = 4 __Locale$ = 20 ; size = 4 __ArgList$ = 24 ; size = 4 __vsnprintf_l PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 1389 push ebp mov ebp, esp sub esp, 8 ; Line 1390 mov eax, DWORD PTR __ArgList$[ebp] push eax mov ecx, DWORD PTR __Locale$[ebp] push ecx mov edx, DWORD PTR __Format$[ebp] push edx mov eax, DWORD PTR __BufferCount$[ebp] push eax mov ecx, DWORD PTR __Buffer$[ebp] push ecx call ___local_stdio_printf_options mov edx, DWORD PTR [eax] or edx, 1 mov eax, DWORD PTR [eax+4] push eax push edx call ___stdio_common_vsprintf add esp, 28 ; 0000001cH mov DWORD PTR __Result$[ebp], eax ; Line 1394 cmp DWORD PTR __Result$[ebp], 0 jge SHORT $LN3@vsnprintf_ mov DWORD PTR tv74[ebp], -1 jmp SHORT $LN4@vsnprintf_ $LN3@vsnprintf_: mov ecx, DWORD PTR __Result$[ebp] mov DWORD PTR tv74[ebp], ecx $LN4@vsnprintf_: mov eax, DWORD PTR tv74[ebp] ; Line 1395 mov esp, ebp pop ebp ret 0 __vsnprintf_l ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT ___local_stdio_printf_options _TEXT SEGMENT ___local_stdio_printf_options PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h ; Line 86 push ebp mov ebp, esp ; Line 88 mov eax, OFFSET ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage ; Line 89 pop ebp ret 0 ___local_stdio_printf_options ENDP _TEXT ENDS END
.include "defaults_mod.asm" table_file_jp equ "exe4-utf8.tbl" table_file_en equ "bn4-utf8.tbl" game_code_len equ 3 game_code equ 0x4234574A // B4WJ game_code_2 equ 0x42345745 // B4WE game_code_3 equ 0x42345750 // B4WP card_type equ 1 card_id equ 77 card_no equ "077" card_sub equ "Mod Card 077" card_sub_x equ 64 card_desc_len equ 3 card_desc_1 equ "Address 0D" card_desc_2 equ "AllGuard 2/2" card_desc_3 equ "Buggy" card_name_jp_full equ "オールガード2/2" card_name_jp_game equ "オールガード2/2" card_name_en_full equ "AllGuard 2/2" card_name_en_game equ "AllGuard 2/2" card_address equ "0D" card_address_id equ 3 card_bug equ 1 card_wrote_en equ "AllGuard 2/2" card_wrote_jp equ "オールガード2/2"
;/* ; Copyright Oliver Kowalke 2009. ; Distributed under the Boost Software License, Version 1.0. ; (See accompanying file LICENSE_1_0.txt or copy at ; http://www.boost.org/LICENSE_1_0.txt) ;*/ ; ******************************************************* ; * * ; * ------------------------------------------------- * ; * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * ; * ------------------------------------------------- * ; * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * ; * ------------------------------------------------- * ; * |deall|limit| base|hiddn| v1 | v2 | v3 | v4 | * ; * ------------------------------------------------- * ; * ------------------------------------------------- * ; * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * ; * ------------------------------------------------- * ; * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * ; * ------------------------------------------------- * ; * | v5 | v6 | v7 | v8 | lr | pc | FCTX| DATA| * ; * ------------------------------------------------- * ; * * ; ******************************************************* AREA |.text|, CODE ALIGN 4 EXPORT ostd_make_fcontext IMPORT _exit ostd_make_fcontext PROC ; first arg of ostd_make_fcontext() == top of context-stack ; save top of context-stack (base) A4 mov a4, a1 ; shift address in A1 to lower 16 byte boundary bic a1, a1, #0x0f ; reserve space for context-data on context-stack sub a1, a1, #0x48 ; save top address of context_stack as 'base' str a4, [a1, #0x8] ; second arg of ostd_make_fcontext() == size of context-stack ; compute bottom address of context-stack (limit) sub a4, a4, a2 ; save bottom address of context-stack as 'limit' str a4, [a1, #0x4] ; save bottom address of context-stack as 'dealloction stack' str a4, [a1, #0x0] ; third arg of ostd_make_fcontext() == address of context-function str a3, [a1, #0x34] ; compute address of returned transfer_t add a2, a1, #0x38 mov a3, a2 str a3, [a1, #0xc] ; compute abs address of label finish adr a2, finish ; save address of finish as return-address for context-function ; will be entered after context-function returns str a2, [a1, #0x30] bx lr ; return pointer to context-data finish ; exit code is zero mov a1, #0 ; exit application bl _exit ENDP END
; A003688: a(n) = 3*a(n-1) + a(n-2), with a(1)=1 and a(2)=4. ; Submitted by Jon Maiga ; 1,4,13,43,142,469,1549,5116,16897,55807,184318,608761,2010601,6640564,21932293,72437443,239244622,790171309,2609758549,8619446956,28468099417,94023745207,310539335038,1025641750321,3387464586001,11188035508324,36951571110973,122042748841243,403079817634702,1331282201745349,4396926422870749,14522061470357596,47963110833943537,158411393972188207,523197292750508158,1728003272223712681,5707207109421646201,18849624600488651284,62256080910887600053,205617867333151451443,679109682910341954382 lpb $0 sub $0,1 add $1,1 mov $2,$3 mul $2,3 mul $3,2 add $3,$1 add $1,$2 lpe mov $0,$3 mul $0,3 add $0,1
; A138908: a(n) = d^d, where d is the number of digits in n. ; 1,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27 mov $3,1 lpb $0 div $0,10 add $1,1 add $2,$3 lpe pow $1,$2
; A297402: a(n) = gcd_{k=1..n} (prime(k+1)^n-1)/2. ; 1,4,1,8,1,4,1,16,1,4,1,8,1,4,1,32,1,4,1,8,1,4,1,16,1,4,1,8,1,4,1,64,1,4,1,8,1,4,1,16,1,4,1,8,1,4,1,32,1,4,1,8,1,4,1,16,1,4,1,8,1,4,1,128,1,4,1,8,1,4,1,16,1,4,1,8,1,4,1,32,1,4,1,8,1,4,1,16,1,4,1,8,1,4,1,64,1,4,1,8 mov $1,2 sub $2,$0 sub $0,7 pow $0,4 sub $1,$2 sub $1,$2 gcd $0,$1
; uint __FASTCALL__ astar_PathLength(struct astar_path *p) ; return the length of the path ; 01.2007 aralbrec XLIB astar_PathLength ; enter : hl = struct astar_path * ; exit : hl = path length ; uses : af, bc, de, hl .astar_PathLength ld bc,3 ld d,b ld e,b .loop ld a,h or l jr z, done inc de add hl,bc ld a,(hl) inc hl ld h,(hl) ld l,a jp loop .done ex de,hl ret
; A293332: Least integer k such that k/2^n > sqrt(5). ; Submitted by Christian Krause ; 3,5,9,18,36,72,144,287,573,1145,2290,4580,9159,18318,36636,73272,146543,293086,586172,1172344,2344688,4689375,9378749,18757498,37514996,75029991,150059982,300119964,600239928,1200479855,2400959709,4801919418,9603838835,19207677670,38415355340,76830710680,153661421360,307322842720,614645685440,1229291370880,2458582741759,4917165483518,9834330967035,19668661934069,39337323868138,78674647736275,157349295472550,314698590945099,629397181890197,1258794363780394,2517588727560788,5035177455121576 mov $1,1 mov $2,1 mov $3,$0 add $3,2 mov $4,$0 add $4,2 mov $7,10 pow $7,$4 lpb $3 mov $4,$2 pow $4,2 mul $4,5 mov $5,$1 pow $5,2 add $4,$5 mov $6,$1 mov $1,$4 mul $6,$2 mul $6,2 mov $2,$6 mov $8,$4 div $8,$7 max $8,1 div $1,$8 div $2,$8 sub $3,1 mov $9,2 lpe mov $3,$9 pow $3,$0 div $2,$3 div $1,$2 mov $0,$1 add $0,1
; A260866: Base-16 representation of a(n) is the concatenation of the base-16 representations of 1, 2, ..., n, n-1, ..., 1. ; 0,1,289,74529,19088161,4886709025,1250999747361,320255971115809,81985529178309409,20988295478809805601,5373003642721911784225,1375488932539155041567521,352125166730061220638180129,90144042682896272963324429089,23076874926821455486290258903841 mov $1,16 pow $1,$0 sub $1,1 pow $1,2 div $1,225 mov $0,$1
INCLUDE "config_private.inc" SECTION code_clib SECTION code_l PUBLIC l_utoa ; write unsigned decimal integer to ascii buffer (no termination) ; ; enter : hl = unsigned integer ; de = char *buffer ; carry reset (implementation may write leading zeroes if carry set) ; ; exit : de = char *buffer (one byte past last char written) ; ; uses : af, bc, de, hl IF __CLIB_OPT_NUM2TXT_SELECT & $04 EXTERN l_fast_utoa defc l_utoa = l_fast_utoa ELSE EXTERN l_small_utoa defc l_utoa = l_small_utoa ENDIF
; A202200: Number of (n+2) X 8 binary arrays avoiding patterns 001 and 101 in rows and columns. ; 1728,7680,26400,76032,192192,439296,926640,1830400,3422848,6110208,10480704,17364480,27907200,43659264,66682704,99677952,146132800,210496000,298378080,416782080,574367040,781747200,1051830000,1400196096,1845524736,2410067968,3120177280,4006886400,5106554112,6461571072,8121134736,10142096640,12589886400,15539516928,19076675488,23298905344,28316882880,34255795200,41256823344,49478736384,59099601792,70318617600,83358072000,98465436160,115915596160,136013230080,159095336400,185533920000 mov $2,$0 add $0,3 add $2,9 bin $2,7 mul $0,$2 sub $0,108 mul $0,16 add $0,1728
db 0 ; species ID placeholder db 90, 55, 75, 30, 60, 75 ; hp atk def spd sat sdf db NORMAL, NORMAL ; type db 45 ; catch rate db 127 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 20 ; step cycles to hatch INCBIN "gfx/pokemon/lickitung/front.dimensions" db GROWTH_MEDIUM_FAST ; growth rate dn EGG_MONSTER, EGG_MONSTER ; egg groups db 70 ; happiness ; tm/hm learnset tmhm FOCUS_PUNCH, WATER_PULSE, TOXIC, HIDDEN_POWER, SUNNY_DAY, ICE_BEAM, BLIZZARD, HYPER_BEAM, PROTECT, RAIN_DANCE, FRUSTRATION, SOLARBEAM, IRON_TAIL, THUNDERBOLT, THUNDER, EARTHQUAKE, RETURN, DIG, SHADOW_BALL, BRICK_BREAK, DOUBLE_TEAM, SHOCK_WAVE, FLAMETHROWER, SANDSTORM, FIRE_BLAST, ROCK_TOMB, FACADE, SECRET_POWER, REST, ATTRACT, THIEF, FLING, ENDURE, GIGA_IMPACT, SWORDS_DANCE, PSYCH_UP, CAPTIVATE, ROCK_SLIDE, SLEEP_TALK, NATURAL_GIFT, DREAM_EATER, SWAGGER, SUBSTITUTE, CUT, SURF, STRENGTH, ROCK_SMASH, ROCK_CLIMB, AQUA_TAIL, FIRE_PUNCH, ICE_PUNCH, ICY_WIND, KNOCK_OFF, MUD_SLAP, ROLLOUT, SNORE, THUNDERPUNCH, ZEN_HEADBUTT ; end
;; ;; Copyright (c) 2020-2021, Intel Corporation ;; ;; 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 "include/os.asm" %include "include/reg_sizes.asm" %include "include/crc32_refl_const.inc" %include "include/clear_regs.asm" %include "include/cet.inc" %include "include/error.inc" [bits 64] default rel %ifndef CRC16_X25_FN %define CRC16_X25_FN crc16_x25_avx %endif %ifdef LINUX %define arg1 rdi %define arg2 rsi %define arg3 rdx %define arg4 rcx %else %define arg1 rcx %define arg2 rdx %define arg3 r8 %define arg4 r9 %endif struc STACK_FRAME _xmm_save: resq 8 * 2 _rsp_save: resq 1 endstruc mksection .text ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; arg1 - buffer pointer ;; arg2 - buffer size in bytes ;; Returns CRC value through RAX align 32 MKGLOBAL(CRC16_X25_FN, function,) CRC16_X25_FN: endbranch64 %ifdef SAFE_PARAM ;; Reset imb_errno IMB_ERR_CHECK_RESET ;; Check len == 0 or arg2, arg2 jz .end_param_check ;; Check in == NULL (invalid if len != 0) or arg1, arg1 jz .wrong_param .end_param_check: %endif %ifndef LINUX mov rax, rsp sub rsp, STACK_FRAME_size and rsp, -16 mov [rsp + _rsp_save], rax vmovdqa [rsp + _xmm_save + 16*0], xmm6 vmovdqa [rsp + _xmm_save + 16*1], xmm7 vmovdqa [rsp + _xmm_save + 16*2], xmm8 vmovdqa [rsp + _xmm_save + 16*3], xmm9 vmovdqa [rsp + _xmm_save + 16*4], xmm10 vmovdqa [rsp + _xmm_save + 16*5], xmm11 vmovdqa [rsp + _xmm_save + 16*6], xmm12 vmovdqa [rsp + _xmm_save + 16*7], xmm13 %endif lea arg4, [rel crc16_x25_ccitt_const] mov arg3, arg2 mov arg2, arg1 mov DWORD(arg1), 0xffff0000 call crc32_refl_by8_avx and eax, 0xffff %ifdef SAFE_DATA clear_scratch_xmms_avx_asm %endif %ifndef LINUX vmovdqa xmm6, [rsp + _xmm_save + 16*0] vmovdqa xmm7, [rsp + _xmm_save + 16*1] vmovdqa xmm8, [rsp + _xmm_save + 16*2] vmovdqa xmm9, [rsp + _xmm_save + 16*3] vmovdqa xmm10, [rsp + _xmm_save + 16*4] vmovdqa xmm11, [rsp + _xmm_save + 16*5] vmovdqa xmm12, [rsp + _xmm_save + 16*6] vmovdqa xmm13, [rsp + _xmm_save + 16*7] mov rsp, [rsp + _rsp_save] %endif ret %ifdef SAFE_PARAM .wrong_param: ;; Clear reg and imb_errno IMB_ERR_CHECK_START rax ;; Check in != NULL IMB_ERR_CHECK_NULL arg1, rax, IMB_ERR_NULL_SRC ;; Set imb_errno IMB_ERR_CHECK_END rax ret %endif mksection stack-noexec
%ifdef CONFIG { "RegData": { "R15": "0x1F" }, "MemoryRegions": { "0x100000000": "4096" } } %endif %macro cfmerge 0 ; Get CF sbb r14, r14 and r14, 1 ; Merge in to results shl r15, 1 or r15, r14 %endmacro mov rdx, 0xe0000000 mov rax, 0xFFFFFFFF80000000 mov [rdx + 8 * 0], rax mov [rdx + 8 * 1], rax mov rax, 0x0 mov [rdx + 8 * 2], rax mov rax, 0x01 mov [rdx + 8 * 3], eax mov rax, 0x0 mov [rdx + 8 * 3 + 4], eax xor r15, r15 ; Will contain our results ; Test and set bts word [rdx], 1 cfmerge ; Ensure it is set bt word [rdx], 1 cfmerge mov r13, 32 bts dword [rdx], r13d cfmerge bt dword [rdx], r13d cfmerge bts qword [rdx], 64 * 2 + 63 cfmerge bt qword [rdx], 64 * 2 + 63 cfmerge hlt
; Stub for the Philips P2000 family ; ; Stefano Bodrato - 7/4/2014 ; ; $Id: p2000_crt0.asm,v 1.12 2016-07-15 21:03:25 dom Exp $ ; MODULE p2000_crt0 ;-------- ; Include zcc_opt.def to find out some info ;-------- defc crt0 = 1 INCLUDE "zcc_opt.def" ;-------- ; Some scope definitions ;-------- EXTERN _main ;main() is always external to crt0 code PUBLIC cleanup ;jp'd to by exit() PUBLIC l_dcal ;jp(hl) ; Now, getting to the real stuff now! IF !DEFINED_CRT_ORG_CODE defc CRT_ORG_CODE = $6547 ENDIF org CRT_ORG_CODE basic_block: defw line_20 defw 10 defb $8E ; REM defm " Z88DK - Small C+ P2000 " defb 0 line_20: defw basic_end defw 20 defb $A3 ; DEF defb $B5 ; USR defb $CA ; '=' defm "&H6580" defb ':' defb 'A' defb $CA ; '=' defb $B5 ; USR defm "(0)" defb 0 basic_end: ; BASIC is abt 50 bytes long defs $6580 - CRT_ORG_CODE - (basic_end - basic_block) start: ld (start1+1),sp ;Save entry stack ld hl,-64 add hl,sp ld sp,hl call crt0_init_bss 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 call _main cleanup: ; ; Deallocate memory which has been allocated here! ; IF !DEFINED_nostreams EXTERN closeall call closeall ENDIF start1: ld sp,0 ret l_dcal: jp (hl) ;Used for function pointer calls ; defm "Small C+ P2000" ; defb 0 INCLUDE "crt0_runtime_selection.asm" INCLUDE "crt0_section.asm" SECTION code_crt_init ld hl,$5000 ld (base_graphics),hl
; A267209: Binary representation of the middle column of the "Rule 109" elementary cellular automaton starting with a single ON (black) cell. ; Submitted by Jamie Morken(s2) ; 1,11,111,1110,11101,111011,1110110,11101101,111011011,1110110110,11101101101,111011011011,1110110110110,11101101101101,111011011011011,1110110110110110,11101101101101101,111011011011011011,1110110110110110110,11101101101101101101,111011011011011011011,1110110110110110110110,11101101101101101101101,111011011011011011011011,1110110110110110110110110,11101101101101101101101101,111011011011011011011011011,1110110110110110110110110110,11101101101101101101101101101,111011011011011011011011011011 seq $0,267210 ; Decimal representation of the middle column of the "Rule 109" elementary cellular automaton starting with a single ON (black) cell. seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2.
; A007744: Expansion of (1+6*x)/(1-4*x)^(7/2). ; 1,20,210,1680,11550,72072,420420,2333760,12471030,64664600,327202876,1622493600,7909656300,38003792400,180324117000,846321189120,3934071152550,18132120329400,82937661506700,376780512108000,1701164012167620,7637879238303600,34117964696719800,151692727725302400,671556346700557500,2961294866410778352,13010422711893508440,56967447594463757120,248651282740121143960,1082120921318482029600,4696404798522212008464,20329910470189804323840,87791859471854799531270,378254733371848227181560,1626233585517375163574700,6977537735085162334488672,29880659282193403515750100,127729450781151057249210800,545061548278014414660413400,2322155708640061411570992000,9877869845627661229470107220,41955973050435158345280526800,177956116986029396110764683400,753787078547637766543812331200,3188799676293984146691024273000,13473269150800655979796742557920,56860252134522617154813284991600,239693376132491901740887872268800,1009333826057915117487020024631900,4245844082959159802840025926190000,17842735174227573155454924952220856,74910675933319914977919177423395520,314214824865279022070842940213073960 mov $1,$0 add $0,1 seq $1,2802 ; a(n) = (2*n+3)!/(6*n!*(n+1)!). mul $0,$1
#include <ros/ros.h> #include <std_msgs/String.h> #include <sensor_msgs/CompressedImage.h> #include <sensor_msgs/Image.h> #include <sensor_msgs/CameraInfo.h> #include <image_transport/image_transport.h> #include <cv_bridge/cv_bridge.h> #include <opencv2/opencv.hpp> #include <stdio.h> #include <iostream> #include <eigen3/Eigen/Dense> //This node subscribes to /grasseater/camera_node/image/compressed and undistort the image. Then it publish the image to imgpreproc/undist using namespace cv; using namespace std; const double fx=259.5050; const double fy=263.0909; const double cx=333.0998; const double cy=254.7687; const double s=0.3627; const double dist[]={-0.2912,0.0630,-0.0051,-0.00062276,0.0017}; //Calibration Parameters Mat cameraMatrix = (Mat_<double>(3,3) << fx,s,cx,0.0,fy,cy,0.0,0.0,1.0); Mat distParamCV = (Mat_<double>(1,5) << dist[0],dist[1],dist[2],dist[3],dist[4]); //Create a Mat object to store the undistorted image Mat undistImg; image_transport::Publisher image_pub; void chatterCallback(sensor_msgs::CompressedImage image_msg) { ros::Time time = ros::Time::now(); // cv_bridge::CvImagePtr cv_ptr; // cv_ptr = cv_bridge::toCvCopy(image_msg,sensor_msgs::image_encodings::BGR8); // // //Undistort the image // undistort(cv_ptr->image,undistImg,cameraMatrix,distParamCV); // //Create a cvImage to transform from OpenCVImage to ImageMsg // cv_bridge::CvImage cvi_undist; // cvi_undist.header.stamp = time; // cvi_undist.header.frame_id = "undist"; // cvi_undist.encoding = "bgr8"; // cvi_undist.image = undistImg; // // //Publish the image // image_pub.publish(cvi_undist.toImageMsg()); // // ROS_INFO_ONCE("First image published"); } //Transform from world coodinates to image coordinates void w2imCoord(cv::Point2f worldPoint, cv::Point2f &imagePoint, Eigen::MatrixXd homog) { Eigen::Vector3d wPointEig(worldPoint.x,worldPoint.y,1.0); Eigen::Vector3d imPointEig; imPointEig=homog*wPointEig; imPointEig=imPointEig/imPointEig(2); imagePoint=Point2f(imPointEig(0),imPointEig(1)); } //Transform from image coordinates to world coordinates void im2wCoord(cv::Point2f imagePoint, cv::Point2f &worldPoint, Eigen::MatrixXd homogInv) { Eigen::Vector3d imPointEig(imagePoint.x,imagePoint.y,1.0); Eigen::Vector3d wPointEig; wPointEig=homogInv*imPointEig; wPointEig=wPointEig/wPointEig(2); worldPoint=Point2f(wPointEig(0),wPointEig(1)); } int main(int argc, char **argv) { ros::init(argc, argv, "imgpreproc"); ros::NodeHandle n; image_transport::ImageTransport it(n); image_pub = it.advertise("/imgpreproc/undist",1); ros::Subscriber sub = n.subscribe("/grasseaterpi3/camera_node/image/compressed",1, chatterCallback); ros::spin(); return 0; }
; A021152: Decimal expansion of 1/148. ; 0,0,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7,5,6,7 lpb $0,1 add $2,$0 mov $0,1 mov $1,4 mul $2,2 mod $2,3 sub $1,$2 add $3,$1 add $4,3 sub $4,$3 lpe add $4,$1 add $1,$4
; void sp1_MoveSprAbs(struct sp1_ss *s, struct sp1_Rect *clip, uchar *frame, uchar row, uchar col, uchar vrot, uchar hrot) ; 04.2006 aralbrec, Sprite Pack v3.0 ; sinclair spectrum version ; *** PLEASE HELP ME I'VE BEEN MADE UGLY BY BUGFIXES INCLUDE "clib_target_cfg.asm" SECTION code_clib SECTION code_temp_sp1 PUBLIC asm_sp1_MoveSprAbs EXTERN asm_sp1_GetUpdateStruct, __sp1_add_spr_char, __sp1_remove_spr_char asm_sp1_MoveSprAbs: ; enter: ix = & struct sp1_ss ; hl = sprite frame address (0 = no change) ; d = new row coord in chars ; e = new col coord in chars ; b = new horizontal rotation (0..7) ie horizontal pixel position ; c = new vertical rotation (0..7) ie vertical pixel position ; iy = clipping rectangle entirely on screen ; (iy+0) = row, (iy+1) = col, (iy+2) = width, (iy+3) = height ; uses : all except ix, iy which remain unchanged ld (ix+5),b ; store new horizontal rotation ld a,b cp (ix+17) ; decide if last col should draw, result in b rl b add a,a add a,SP1V_ROTTBL/256 ld (ix+9),a ; store effective horizontal rotation (MSB of lookup table to use) xor a sub c ; a = - (vertical rotation in pixels) bit 7,(ix+4) jp z, onebytedef sub c ; a = - 2*(vertical rotation) for 2-byte definitions set 7,c .onebytedef ld (ix+4),c ; store new vertical rotation ld c,a ; c = vertical rotation offset for graphics ptrs ld a,(ix+4) ; decide if last row should draw and $07 cp (ix+18) ld a,b rla ex af,af ld a,h or l jr nz, newframe ld l,(ix+6) ld h,(ix+7) ; hl = old sprite frame pointer jp framerejoin .newframe ld (ix+6),l ld (ix+7),h ; store new frame pointer .framerejoin ld a,c or a jr z, skipadj ld b,$ff ; bc = negative vertical rotation offset add hl,bc ; add vertical rotation offset .skipadj ld (ix+11),l ld (ix+12),h ; store new effective offset for graphics pointers ; d = new row coord (chars) ; e = new col coord (chars) ; ix = & struct sp1_ss ; iy = clipping rectangle ; a' = bit 0 = 1 if last row should not draw, bit 1 = 1 if last col should not draw ; ; 329 cycles to this point worst case ld (ix+19),0 ld a,(ix+0) ; has the row coord changed? cp d jp nz, changing0 ld a,(ix+1) ; has the col coord changed? cp e jp nz, changing1 ; not changing character coordinate, no need to remove sprite from update struct lists ; ///////////////////////////////////////////////////////////////////////////////// ; MOVE SPRITE, CHARACTER COORDINATES NOT CHANGING ; ///////////////////////////////////////////////////////////////////////////////// ld h,(ix+15) ld l,(ix+16) push de exx pop de ld hl,(SP1V_UPDATELISTT) ld bc,6 add hl,bc push hl call asm_sp1_GetUpdateStruct ld b,(ix+0) pop de push hl push de ; b = row coord ; c = col coord (in column loop) ; hl = struct sp1_update ; hl'= & struct sp1_cs ; a' = bit 0 = 1 if last row should not draw, bit 1 = 1 if last col should not draw ; iy = & clipping rectangle ; ix = & struct sp1_ss ; stack = & struct sp1_update.ulist (tail of invalidated list), row INCLUDE "temp/sp1/zx/sprites/__sp1_move_nc.asm" .done exx ld de,-6 add hl,de ; hl = & last struct sp1_update.ulist in invalidated list ld (SP1V_UPDATELISTT),hl ret ; changing character coordinate, must remove and place sprite in update struct lists ; ///////////////////////////////////////////////////////////////////////////////// ; MOVE SPRITE, CHANGING CHARACTER COORDINATES ; ///////////////////////////////////////////////////////////////////////////////// .changing0 ld (ix+0),d ; write new row coord .changing1 ld (ix+1),e ; write new col coord ; d = new row coord (chars) ; e = new col coord (chars) ; ix = & struct sp1_ss ; iy = & clipping rectangle ; a' = bit 0 = 1 if last row should not draw, bit 1 = 1 if last col should not draw ld h,(ix+15) ld l,(ix+16) push de exx pop de ld hl,(SP1V_UPDATELISTT) ld bc,6 add hl,bc push hl call asm_sp1_GetUpdateStruct ld b,(ix+0) pop de push hl push de ; b = row coord ; c = col coord (in column loop) ; hl = struct sp1_update ; hl'= & struct sp1_cs ; a' = bit 0 = 1 if last row should not draw, bit 1 = 1 if last col should not draw ; iy = & clipping rectangle ; ix = & struct sp1_ss ; stack = & struct sp1_update.ulist (tail of invalidated list), row INCLUDE "temp/sp1/zx/sprites/__sp1_move_c.asm" ; jumps to done for exit inside INCLUDE
#include "colordepthTexture.h" #include <math.h> #include <maya/MPlug.h> #include <maya/MDataBlock.h> #include <maya/MDataHandle.h> #include <maya/MFnNumericAttribute.h> #include <maya/MFnEnumAttribute.h> #include <maya/MFnGenericAttribute.h> #include <maya/MFnMessageAttribute.h> #include <maya/MFnTypedAttribute.h> #include <maya/MFloatVector.h> MTypeId colordepth::id( 0x0011EF47 ); MObject colordepth::outColor; //---------------------------- automatically created attributes start ------------------------------------ MObject colordepth::depth; MObject colordepth::Kt; MObject colordepth::luxOutColor; //---------------------------- automatically created attributes end ------------------------------------ #define MAKE_INPUT(attr) \ CHECK_MSTATUS ( attr.setKeyable(true) ); \ CHECK_MSTATUS ( attr.setStorable(true) ); \ CHECK_MSTATUS ( attr.setReadable(true) ); \ CHECK_MSTATUS ( attr.setWritable(true) ); #define MAKE_OUTPUT(attr) \ CHECK_MSTATUS ( attr.setKeyable(false) ); \ CHECK_MSTATUS ( attr.setStorable(false) ); \ CHECK_MSTATUS ( attr.setReadable(true) ); \ CHECK_MSTATUS ( attr.setWritable(false) ); // // DESCRIPTION: void colordepth::postConstructor( ) { setMPSafe(true); } // // DESCRIPTION: colordepth::colordepth() { } // // DESCRIPTION: colordepth::~colordepth() { } // // DESCRIPTION: void *colordepth::creator() { return new colordepth(); } // // DESCRIPTION: MStatus colordepth::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus status; outColor = nAttr.createColor("outColor", "outColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( outColor )); //---------------------------- automatically created attributes start ------------------------------------ depth = nAttr.create("depth", "depth", MFnNumericData::kFloat, 1.0); MAKE_INPUT(nAttr); CHECK_MSTATUS(addAttribute( depth )); Kt = nAttr.createColor("Kt", "Kt"); MAKE_INPUT(nAttr); nAttr.setDefault(0.0,0.0,0.0); CHECK_MSTATUS(addAttribute( Kt )); luxOutColor = nAttr.createColor("luxOutColor", "luxOutColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( luxOutColor )); CHECK_MSTATUS ( attributeAffects( depth, luxOutColor)); CHECK_MSTATUS ( attributeAffects( depth, outColor)); //---------------------------- automatically created attributes end ------------------------------------ return MS::kSuccess; } // // DESCRIPTION: MStatus colordepth::compute(const MPlug &plug, MDataBlock &block) { return MS::kSuccess; }
; A186188: Least k such that A156077^(k)(n)=1 where a^(k)=a(a^(k-1)). ; 1,1,1,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 mov $2,3 lpb $0 trn $0,$2 add $0,$2 sub $0,1 sub $0,$1 add $1,1 mul $2,2 lpe add $1,1
; A005914: Number of points on surface of hexagonal prism: 12*n^2 + 2 for n > 0 (coordination sequence for W(2)). ; 1,14,50,110,194,302,434,590,770,974,1202,1454,1730,2030,2354,2702,3074,3470,3890,4334,4802,5294,5810,6350,6914,7502,8114,8750,9410,10094,10802,11534,12290,13070,13874,14702,15554,16430,17330,18254,19202,20174,21170,22190,23234,24302,25394,26510,27650,28814,30002,31214,32450,33710,34994,36302,37634,38990,40370,41774,43202,44654,46130,47630,49154,50702,52274,53870,55490,57134,58802,60494,62210,63950,65714,67502,69314,71150,73010,74894,76802,78734,80690,82670,84674,86702,88754,90830,92930,95054,97202,99374,101570,103790,106034,108302,110594,112910,115250,117614 pow $1,$0 gcd $1,2 mov $3,$0 mul $3,$0 mov $2,$3 mul $2,12 add $1,$2 mov $0,$1
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/lakeformation/model/PutDataLakeSettingsResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::LakeFormation::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; PutDataLakeSettingsResult::PutDataLakeSettingsResult() { } PutDataLakeSettingsResult::PutDataLakeSettingsResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } PutDataLakeSettingsResult& PutDataLakeSettingsResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { AWS_UNREFERENCED_PARAM(result); return *this; }
/* * SPDX-License-Identifier: Apache-2.0 */ //===- ElideKrnlGlobalConstants.cpp - Krnl Constant lobal Value Elision ---===// // // Copyright 2019-2020 The IBM Research Authors. // // ============================================================================= // // In practice, the constant values of Global Krnl operations may be large // enough to hinder the readability of the MLIR intermediate representation. // // This file creates a pass which elides the explicit values of constant // global operations. This pass has purely cosmetic purposes and should only be // run to obtain a compact representation of the program when emitting Krnl // dialect code. This pass should never be invoked on code meant to be run. // //===----------------------------------------------------------------------===// #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "src/Dialect/Krnl/KrnlOps.hpp" #include "src/Pass/Passes.hpp" #include "src/Support/KrnlSupport.hpp" #include "ElideKrnlGlobalConstants.hpp" using namespace mlir; constexpr uint64_t KrnlConstGlobalValueElision::kDefaultElisionThreshold; mlir::LogicalResult KrnlConstGlobalValueElision::matchAndRewrite( mlir::KrnlGlobalOp op, mlir::PatternRewriter &rewriter) const { auto loc = op.getLoc(); // Only elide if value is available. if (!op.value().hasValue()) return success(); // Only elide dense and opaque attributes. if (!(op.value()->isa<DenseElementsAttr>() || op.value()->isa<OpaqueElementsAttr>())) return success(); if (op.value()->isa<DenseElementsAttr>()) { // Elide the dense attribute. const auto &valAttr = op.valueAttr().dyn_cast_or_null<DenseElementsAttr>(); if (valAttr.getNumElements() > elisionThreshold && !valAttr.isSplat()) { IntegerAttr offsetAttr = op.offset() ? op.offsetAttr() : nullptr; IntegerAttr alignmentAttr = op.alignment() ? op.alignmentAttr() : nullptr; auto newGlobalOp = rewriter.create<KrnlGlobalOp>(loc, op.getResult().getType(), /*shape=*/op.shape(), /*name=*/op.name(), /*value=*/nullptr, /*offset=*/offsetAttr, /*alignment=*/alignmentAttr); rewriter.replaceOp(op, newGlobalOp.getResult()); } } else { // Elide the opaque attribute. const auto &valAttr = op.valueAttr().dyn_cast_or_null<OpaqueElementsAttr>(); if ((unsigned int)valAttr.getValue().size() > elisionThreshold) { IntegerAttr offsetAttr = op.offset() ? op.offsetAttr() : nullptr; IntegerAttr alignmentAttr = op.alignment() ? op.alignmentAttr() : nullptr; auto newGlobalOp = rewriter.create<KrnlGlobalOp>(loc, op.getResult().getType(), /*shape=*/op.shape(), /*name=*/op.name(), /*value=*/nullptr, /*offset=*/offsetAttr, /*alignment=*/alignmentAttr); rewriter.replaceOp(op, newGlobalOp.getResult()); } } return success(); } namespace { /*! * Function pass that performs constant value elision of Krnl globals. */ class ElideConstGlobalValuePass : public PassWrapper<ElideConstGlobalValuePass, FunctionPass> { public: void runOnFunction() override { auto function = getFunction(); ConversionTarget target(getContext()); RewritePatternSet patterns(&getContext()); patterns.insert<KrnlConstGlobalValueElision>( &getContext(), KrnlConstGlobalValueElision::kDefaultElisionThreshold); // No need to test, its ok to fail the apply. LogicalResult res = applyPatternsAndFoldGreedily(function, std::move(patterns)); assert((succeeded(res) || failed(res)) && "remove unused var warning"); } }; } // namespace std::unique_ptr<Pass> mlir::createElideConstGlobalValuePass() { return std::make_unique<ElideConstGlobalValuePass>(); }
//*=================================================================== //The Medical Imaging Interaction Toolkit (MITK) //Copyright (c) German Cancer Research Center, //Division of Medical and Biological Informatics. //All rights reserved. //This software is distributed WITHOUT ANY WARRANTY; without //even the implied warranty of MERCHANTABILITY or FITNESS FOR //A PARTICULAR PURPOSE. //See LICENSE.txt or http://www.mitk.org for details. //===================================================================*/ #include <mitkTestFixture.h> #include <mitkTestingMacros.h> #include <mitkPASpectralUnmixingFilterBase.h> #include <mitkPALinearSpectralUnmixingFilter.h> #include <mitkPASpectralUnmixingFilterVigra.h> #include <mitkPASpectralUnmixingFilterSimplex.h> #include <mitkPASpectralUnmixingSO2.h> #include <mitkImageReadAccessor.h> class mitkSpectralUnmixingTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkSpectralUnmixingTestSuite); MITK_TEST(testEigenSUAlgorithm); MITK_TEST(testVigraSUAlgorithm); //MITK_TEST(testSimplexSUAlgorithm); MITK_TEST(testSO2); MITK_TEST(testExceptionSO2); MITK_TEST(testWavelengthExceptions); MITK_TEST(testNoChromophoresSelected); MITK_TEST(testInputImage); MITK_TEST(testAddOutput); MITK_TEST(testWeightsError); MITK_TEST(testOutputs); CPPUNIT_TEST_SUITE_END(); private: mitk::pa::SpectralUnmixingFilterBase::Pointer m_SpectralUnmixingFilter; mitk::Image::Pointer inputImage; std::vector<int> m_inputWavelengths; std::vector<double> m_inputWeights; std::vector<float> m_CorrectResult; float threshold; public: void setUp() override { //Set empty input image: inputImage = mitk::Image::New(); mitk::PixelType pixelType = mitk::MakeScalarPixelType<float>(); const int NUMBER_OF_SPATIAL_DIMENSIONS = 3; auto* dimensions = new unsigned int[NUMBER_OF_SPATIAL_DIMENSIONS]; dimensions[0] = 1; dimensions[1] = 1; dimensions[2] = 5; inputImage->Initialize(pixelType, NUMBER_OF_SPATIAL_DIMENSIONS, dimensions); //Set wavelengths for unmixing: m_inputWavelengths.push_back(750); m_inputWavelengths.push_back(800); m_inputWeights.push_back(50); m_inputWeights.push_back(100); //Set fraction of Hb and HbO2 to unmix: float fracHb = 100; float fracHbO2 = 300; m_CorrectResult.push_back(fracHbO2); m_CorrectResult.push_back(fracHb); m_CorrectResult.push_back(fracHbO2 + 10); m_CorrectResult.push_back(fracHb - 10); threshold = 0.01; //Multiply values of wavelengths (750,800,850 nm) with fractions to get pixel values: float px1 = fracHb * 7.52 + fracHbO2 * 2.77; float px2 = fracHb * 4.08 + fracHbO2 * 4.37; float px3 = (fracHb - 10) * 7.52 + (fracHbO2 + 10) * 2.77; float px4 = (fracHb - 10) * 4.08 + (fracHbO2 + 10) * 4.37; float* data = new float[6]; data[0] = px1; data[1] = px2; data[2] = px3; data[3] = px4; data[5] = 0; inputImage->SetImportVolume(data, mitk::Image::ImportMemoryManagementType::CopyMemory); delete[] data; } // Tests implemented EIGEN algortihms with correct inputs void testEigenSUAlgorithm() { MITK_INFO << "START FILTER TEST ... "; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::LinearSpectralUnmixingFilter::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } //Set Chromophores to filter m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); ofstream myfile; myfile.open("EigenTestResult.txt"); std::vector<mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType> m_Eigen = { mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR, /* mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::LDLT, mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::LLT,*/ mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::COLPIVHOUSEHOLDERQR, mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::JACOBISVD, mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::FULLPIVLU, mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::FULLPIVHOUSEHOLDERQR}; for (unsigned int Algorithmidx = 0; Algorithmidx < m_Eigen.size();++Algorithmidx) { m_SpectralUnmixingFilter->SetAlgorithm(m_Eigen[Algorithmidx]); m_SpectralUnmixingFilter->Update(); /*For printed pixel values and results look at: [...]\mitk-superbuild\MITK-build\Modules\PhotoacousticsLib\test\*/ for (int i = 0; i < 2; ++i) { mitk::Image::Pointer output = m_SpectralUnmixingFilter->GetOutput(i); mitk::ImageReadAccessor readAccess(output); const float* inputDataArray = ((const float*)readAccess.GetData()); auto pixel = inputDataArray[0]; auto pixel2 = inputDataArray[1]; myfile << "Algorithmidx: " << Algorithmidx << "\n Output " << i << ": " << "\n" << inputDataArray[0] << "\n" << inputDataArray[1] << "\n"; myfile << "Correct Result: " << "\n" << m_CorrectResult[i] << "\n" << m_CorrectResult[i + 2] << "\n"; CPPUNIT_ASSERT(std::abs(pixel - m_CorrectResult[i]) < threshold); CPPUNIT_ASSERT(std::abs(pixel2 - m_CorrectResult[i + 2]) < threshold); } } myfile.close(); MITK_INFO << "EIGEN FILTER TEST SUCCESFULL :)"; } // Tests implemented VIGRA algortihms with correct inputs void testVigraSUAlgorithm() { MITK_INFO << "START FILTER TEST ... "; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::SpectralUnmixingFilterVigra::New(); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; double Weight = m_inputWeights[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); m_SpectralUnmixingFilter->AddWeight(Weight); } //Set Chromophores to filter m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); std::vector<mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType> Vigra = { mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::LARS, mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::GOLDFARB, mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::WEIGHTED, mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::LS/*, mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::vigratest*/}; ofstream myfile; myfile.open("VigraTestResult.txt"); for (unsigned int Algorithmidx = 0; Algorithmidx < Vigra.size();++Algorithmidx) { m_SpectralUnmixingFilter->SetAlgorithm(Vigra[0]); m_SpectralUnmixingFilter->Update(); /*For printed pixel values and results look at: [...]\mitk-superbuild\MITK-build\Modules\PhotoacousticsLib\test\*/ for (int i = 0; i < 2; ++i) { mitk::Image::Pointer output = m_SpectralUnmixingFilter->GetOutput(i); mitk::ImageReadAccessor readAccess(output); const float* inputDataArray = ((const float*)readAccess.GetData()); auto pixel = inputDataArray[0]; auto pixel2 = inputDataArray[1]; myfile << "Algorithmidx: " << Algorithmidx << "\n Output " << i << ": " << "\n" << inputDataArray[0] << "\n" << inputDataArray[1] << "\n"; myfile << "Correct Result: " << "\n" << m_CorrectResult[i] << "\n" << m_CorrectResult[i + 2] << "\n"; CPPUNIT_ASSERT(std::abs(pixel - m_CorrectResult[i]) < threshold); CPPUNIT_ASSERT(std::abs(pixel2 - m_CorrectResult[i + 2]) < threshold); } } myfile.close(); MITK_INFO << "VIGRA FILTER TEST SUCCESFULL :)"; } void testSimplexSUAlgorithm() { MITK_INFO << "START FILTER TEST ... "; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::SpectralUnmixingFilterSimplex::New(); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); m_SpectralUnmixingFilter->Verbose(true); m_SpectralUnmixingFilter->RelativeError(false); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } //Set Chromophores to filter m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); m_SpectralUnmixingFilter->Update(); /*For printed pixel values and results look at: [...]\mitk-superbuild\MITK-build\Modules\PhotoacousticsLib\test\*/ ofstream myfile; myfile.open("SimplexTestResult.txt"); for (int i = 0; i < 2; ++i) { mitk::Image::Pointer output = m_SpectralUnmixingFilter->GetOutput(i); mitk::ImageReadAccessor readAccess(output); const float* inputDataArray = ((const float*)readAccess.GetData()); auto pixel = inputDataArray[0]; auto pixel2 = inputDataArray[1]; myfile << "Output " << i << ": " << "\n" << inputDataArray[0] << "\n" << inputDataArray[1] << "\n"; myfile << "Correct Result: " << "\n" << m_CorrectResult[i] << "\n" << m_CorrectResult[i + 2] << "\n"; CPPUNIT_ASSERT(std::abs(pixel - m_CorrectResult[i])<threshold); CPPUNIT_ASSERT(std::abs(pixel2 - m_CorrectResult[i + 2])<threshold); } myfile.close(); MITK_INFO << "SIMPLEX FILTER TEST SUCCESFULL :)"; } // Tests SO2 Filter with unequal inputs void testExceptionSO2() { MITK_INFO << "START EXCEPTION SO2 TEST ... "; auto m_sO2 = mitk::pa::SpectralUnmixingSO2::New(); m_sO2->SetInput(0, inputImage); inputImage = nullptr; inputImage = mitk::Image::New(); mitk::PixelType pixelType = mitk::MakeScalarPixelType<float>(); const int NUMBER_OF_SPATIAL_DIMENSIONS = 3; auto* dimensions = new unsigned int[NUMBER_OF_SPATIAL_DIMENSIONS]; dimensions[0] = 1; dimensions[1] = 1; dimensions[2] = 4; inputImage->Initialize(pixelType, NUMBER_OF_SPATIAL_DIMENSIONS, dimensions); float* data = new float[4]; data[0] = 1; data[1] = 2; data[2] = 3; data[3] = 4; inputImage->SetImportVolume(data, mitk::Image::ImportMemoryManagementType::CopyMemory); delete[] data; m_sO2->SetInput(1, inputImage); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_sO2->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) } // Tests SO2 Filter with correct inputs void testSO2() { MITK_INFO << "START SO2 TEST ... "; std::vector<float> CorrectSO2Result1 = { 0, 0, 0, 0, 0 }; std::vector<float> Test1 = { 0,0,0,51 }; std::vector<float> CorrectSO2Result2 = { 0, 0.5, 0, 0.5, 0 }; std::vector<float> Test2 = { 1584, 0, 0, 0 }; std::vector<float> CorrectSO2Result3 = { 0.5, 0.5, 0, 0.5, 0 }; std::vector<float> Test3 = { 0, 1536, 0, 0 }; std::vector<float> CorrectSO2Result4 = { 0.5, 0.5, 0, 0.5, 0 }; std::vector<float> Test4 = { 0, 0, 3072, 49 }; std::vector<float> CorrectSO2Result5 = { 0.5, 0.5, 0.5, 0.5, 0 }; std::vector<float> Test5 = { 1, 1, 1, 49 }; std::vector<std::vector<float>> TestList; std::vector<std::vector<float>> ResultList; TestList.push_back(Test1); TestList.push_back(Test2); TestList.push_back(Test3); TestList.push_back(Test4); TestList.push_back(Test5); ResultList.push_back(CorrectSO2Result1); ResultList.push_back(CorrectSO2Result2); ResultList.push_back(CorrectSO2Result3); ResultList.push_back(CorrectSO2Result4); ResultList.push_back(CorrectSO2Result5); /*For printed pixel values and results look at: [...]\mitk-superbuild\MITK-build\Modules\PhotoacousticsLib\test\*/ ofstream myfile; myfile.open("SO2TestResult.txt"); for (int k = 0; k < 5; ++k) { std::vector<float> SO2Settings = TestList[k]; std::vector<float> m_CorrectSO2Result = ResultList[k]; auto m_sO2 = mitk::pa::SpectralUnmixingSO2::New(); m_sO2->SetInput(0, inputImage); m_sO2->SetInput(1, inputImage); for (unsigned int i = 0; i < SO2Settings.size(); ++i) m_sO2->AddSO2Settings(SO2Settings[i]); m_sO2->Update(); mitk::Image::Pointer output = m_sO2->GetOutput(0); mitk::ImageReadAccessor readAccess(output); const float* inputDataArray = ((const float*)readAccess.GetData()); for (unsigned int Pixel = 0; Pixel < inputImage->GetDimensions()[2]; ++Pixel) { auto Value = inputDataArray[Pixel]; myfile << "Output(Test " << k << ") " << Pixel << ": " << "\n" << Value << "\n"; myfile << "Correct Result: " << "\n" << m_CorrectSO2Result[Pixel] << "\n"; CPPUNIT_ASSERT(std::abs(Value - m_CorrectSO2Result[Pixel]) < threshold); } } myfile.close(); MITK_INFO << "SO2 TEST SUCCESFULL :)"; } // Test exceptions for wrong wavelength inputs void testWavelengthExceptions() { MITK_INFO << "START WavelengthExceptions TEST ... "; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::LinearSpectralUnmixingFilter::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); m_SpectralUnmixingFilter->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) m_SpectralUnmixingFilter->AddWavelength(300); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) m_SpectralUnmixingFilter->AddWavelength(299); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) MITK_INFO << "DONE"; } // Test exceptions for wrong chromophore inputs void testNoChromophoresSelected() { MITK_INFO << "testNoChromophoresSelected"; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::LinearSpectralUnmixingFilter::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } m_SpectralUnmixingFilter->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) } // Test exceptions for wrong input image void testInputImage() { MITK_INFO << "INPUT IMAGE TEST"; inputImage = nullptr; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::LinearSpectralUnmixingFilter::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); //m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); m_SpectralUnmixingFilter->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) inputImage = mitk::Image::New(); mitk::PixelType pixelType = mitk::MakeScalarPixelType<double>(); const int NUMBER_OF_SPATIAL_DIMENSIONS = 3; auto* dimensions = new unsigned int[NUMBER_OF_SPATIAL_DIMENSIONS]; dimensions[0] = 1; dimensions[1] = 1; dimensions[2] = 5; inputImage->Initialize(pixelType, NUMBER_OF_SPATIAL_DIMENSIONS, dimensions); double* data = new double[6]; data[0] = 1; data[1] = 2; data[2] = 3; data[3] = 4; data[5] = 0; inputImage->SetImportVolume(data, mitk::Image::ImportMemoryManagementType::CopyMemory); delete[] data; m_SpectralUnmixingFilter->SetInput(inputImage); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) } // Test exceptions for addOutputs method void testAddOutput() { MITK_INFO << "addOutputs TEST"; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::LinearSpectralUnmixingFilter::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); m_SpectralUnmixingFilter->SetInput(inputImage); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); m_SpectralUnmixingFilter->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR); for (int i = 0; i < 4; ++i) { MITK_INFO << "i: " << i; if (i != 2) { MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->AddOutputs(i); m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) } else { m_SpectralUnmixingFilter->AddOutputs(2); m_SpectralUnmixingFilter->Update(); for (int i = 0; i < 2; ++i) { mitk::Image::Pointer output = m_SpectralUnmixingFilter->GetOutput(i); mitk::ImageReadAccessor readAccess(output); const float* inputDataArray = ((const float*)readAccess.GetData()); auto pixel = inputDataArray[0]; auto pixel2 = inputDataArray[1]; CPPUNIT_ASSERT(std::abs(pixel - m_CorrectResult[i]) < threshold); CPPUNIT_ASSERT(std::abs(pixel2 - m_CorrectResult[i + 2]) < threshold); } } } } // Test exceptions for weights error void testWeightsError() { MITK_INFO << "testWeightsError"; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::SpectralUnmixingFilterVigra::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); m_SpectralUnmixingFilter->SetAlgorithm(mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::WEIGHTED); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) m_SpectralUnmixingFilter->AddWeight(50); MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) m_SpectralUnmixingFilter->AddWeight(50); m_SpectralUnmixingFilter->Update(); for (int i = 0; i < 2; ++i) { mitk::Image::Pointer output = m_SpectralUnmixingFilter->GetOutput(i); mitk::ImageReadAccessor readAccess(output); const float* inputDataArray = ((const float*)readAccess.GetData()); auto pixel = inputDataArray[0]; auto pixel2 = inputDataArray[1]; CPPUNIT_ASSERT(std::abs(pixel - m_CorrectResult[i]) < threshold); CPPUNIT_ASSERT(std::abs(pixel2 - m_CorrectResult[i + 2]) < threshold); } } // Test correct outputs void testOutputs() { MITK_INFO << "TEST"; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::LinearSpectralUnmixingFilter::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); m_SpectralUnmixingFilter->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR); m_SpectralUnmixingFilter->Update(); for (int i = 0; i < 2; ++i) { mitk::Image::Pointer output = m_SpectralUnmixingFilter->GetOutput(i); mitk::ImageReadAccessor readAccess(output); const float* inputDataArray = ((const float*)readAccess.GetData()); auto pixel = inputDataArray[0]; auto pixel2 = inputDataArray[1]; CPPUNIT_ASSERT(std::abs(pixel - m_CorrectResult[i]) < threshold); CPPUNIT_ASSERT(std::abs(pixel2 - m_CorrectResult[i + 2]) < threshold); // test correct output dimensions and pixel type CPPUNIT_ASSERT(inputImage->GetDimensions()[0] == output->GetDimensions()[0]); CPPUNIT_ASSERT(inputImage->GetDimensions()[0] == output->GetDimensions()[1]); CPPUNIT_ASSERT(2 == output->GetDimensions()[2]); CPPUNIT_ASSERT(output->GetPixelType() == mitk::MakeScalarPixelType<float>()); } } // TEST TEMPLATE: /* // Test exceptions for void test() { MITK_INFO << "TEST"; // Set input image auto m_SpectralUnmixingFilter = mitk::pa::LinearSpectralUnmixingFilter::New(); m_SpectralUnmixingFilter->Verbose(false); m_SpectralUnmixingFilter->RelativeError(false); m_SpectralUnmixingFilter->SetInput(inputImage); m_SpectralUnmixingFilter->AddOutputs(2); //Set wavelengths to filter for (unsigned int imageIndex = 0; imageIndex < m_inputWavelengths.size(); imageIndex++) { unsigned int wavelength = m_inputWavelengths[imageIndex]; m_SpectralUnmixingFilter->AddWavelength(wavelength); } m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED); m_SpectralUnmixingFilter->AddChromophore( mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED); m_SpectralUnmixingFilter->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR); //MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) m_SpectralUnmixingFilter->Update(); //MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) }*/ void tearDown() override { m_SpectralUnmixingFilter = nullptr; inputImage = nullptr; m_inputWavelengths.clear(); m_CorrectResult.clear(); } }; MITK_TEST_SUITE_REGISTRATION(mitkSpectralUnmixing)
; ---------------------------------------------------------------- ; Z88DK INTERFACE LIBRARY FOR THE NIRVANA ENGINE - by Einar Saukas ; ; See "nirvana-.h" for further details ; ---------------------------------------------------------------- ; void NIRVANAM_drawW(unsigned int tile, unsigned int lin, unsigned int col) ; callee SECTION code_clib SECTION code_nirvanam PUBLIC _NIRVANAM_drawW_callee EXTERN asm_NIRVANAM_drawW _NIRVANAM_drawW_callee: pop hl ; RET address pop de ; tile ld a,e pop de ; lin ld d,e ex (sp),hl ; col ld e,l jp asm_NIRVANAM_drawW
; A134538: a(n) = 5*n^2 - 1. ; 4,19,44,79,124,179,244,319,404,499,604,719,844,979,1124,1279,1444,1619,1804,1999,2204,2419,2644,2879,3124,3379,3644,3919,4204,4499,4804,5119,5444,5779,6124,6479,6844,7219,7604,7999,8404,8819,9244,9679,10124,10579,11044,11519,12004,12499,13004,13519,14044,14579,15124,15679,16244,16819,17404,17999,18604,19219,19844,20479,21124,21779,22444,23119,23804,24499,25204,25919,26644,27379,28124,28879,29644,30419,31204,31999,32804,33619,34444,35279,36124,36979,37844,38719,39604,40499,41404,42319,43244 mov $1,$0 add $1,2 mul $1,5 mul $0,$1 add $0,4
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 <gtest/gtest.h> #include "tensorflow/lite/delegates/hexagon/builders/tests/hexagon_delegate_op_model.h" namespace tflite { using testing::ElementsAreArray; class L2NormOpModel : public SingleOpModelWithHexagon { public: L2NormOpModel(const std::initializer_list<int> input_shape, const TensorType tensor_type) { TensorData data = TensorData{tensor_type}; data.min = -2.0; data.max = 2.0; data.scale = 2.0; data.zero_point = 128; input_ = AddInput(data); data.min = -1.0; data.max = 127.0 / 128.0; output_ = AddOutput(data); SetBuiltinOp( BuiltinOperator_L2_NORMALIZATION, BuiltinOptions_L2NormOptions, CreateL2NormOptions(builder_, ActivationFunctionType_NONE).Union()); BuildInterpreter({input_shape}); } void SetInput(std::initializer_list<float> data) { PopulateTensor(input_, data); } template <typename T> std::vector<T> GetOutput() { return ExtractVector<T>(output_); } template <typename T> std::vector<float> GetDequantizedOutput() { return Dequantize<T>(ExtractVector<T>(output_), GetScale(output_), GetZeroPoint(output_)); } int input() const { return input_; } private: int input_; int output_; }; TEST(L2NormOpTest, ZerosVectorUint8Test) { L2NormOpModel m({1, 1, 1, 6}, TensorType_UINT8); m.QuantizeAndPopulate<uint8_t>(m.input(), {0, 0, 0, 0, 0, 0}); m.ApplyDelegateAndInvoke(); EXPECT_THAT(m.GetDequantizedOutput<uint8_t>(), ElementsAreArray(ArrayFloatNear({0, 0, 0, 0, 0, 0}, 0.1))); } TEST(L2NormOpTest, ZerosVectorInt8Test) { L2NormOpModel m({1, 1, 1, 6}, TensorType_INT8); m.QuantizeAndPopulate<int8_t>(m.input(), {0, 0, 0, 0, 0, 0}); m.ApplyDelegateAndInvoke(); EXPECT_THAT(m.GetDequantizedOutput<int8_t>(), ElementsAreArray(ArrayFloatNear({0, 0, 0, 0, 0, 0}, 0.1))); } TEST(L2NormOpTest, MultipleBatchUint8Test) { L2NormOpModel m({3, 1, 1, 6}, TensorType_UINT8); m.QuantizeAndPopulate<uint8_t>(m.input(), { -1.1, 0.6, 0.7, 1.2, -0.7, 0.1, // batch 1 -1.1, 0.6, 0.7, 1.2, -0.7, 0.1, // batch 2 -1.1, 0.6, 0.7, 1.2, -0.7, 0.1, // batch 3 }); m.ApplyDelegateAndInvoke(); EXPECT_THAT(m.GetDequantizedOutput<uint8_t>(), ElementsAreArray(ArrayFloatNear( { -0.55, 0.3, 0.35, 0.6, -0.35, 0.05, // batch 1 -0.55, 0.3, 0.35, 0.6, -0.35, 0.05, // batch 2 -0.55, 0.3, 0.35, 0.6, -0.35, 0.05, // batch 3 }, 0.1))); } TEST(L2NormOpTest, MultipleBatchInt8Test) { L2NormOpModel m({3, 1, 1, 6}, TensorType_INT8); m.QuantizeAndPopulate<int8_t>(m.input(), { -1.1, 0.6, 0.7, 1.2, -0.7, 0.1, // batch 1 -1.1, 0.6, 0.7, 1.2, -0.7, 0.1, // batch 2 -1.1, 0.6, 0.7, 1.2, -0.7, 0.1, // batch 3 }); m.ApplyDelegateAndInvoke(); EXPECT_THAT(m.GetDequantizedOutput<int8_t>(), ElementsAreArray(ArrayFloatNear( { -0.55, 0.3, 0.35, 0.6, -0.35, 0.05, // batch 1 -0.55, 0.3, 0.35, 0.6, -0.35, 0.05, // batch 2 -0.55, 0.3, 0.35, 0.6, -0.35, 0.05, // batch 3 }, 0.1))); } } // namespace tflite
#include "shaderprog.h" #include "utlgl.h" //============================================================================ //============================================================================ ShaderProg::ShaderProg() : _hProg(NULL), _shdrVert(new Shader(GL_VERTEX_SHADER_ARB)), _shdrFrag(new Shader(GL_FRAGMENT_SHADER_ARB)) { } //============================================================================ //============================================================================ ShaderProg::~ShaderProg() { destroy(); } //============================================================================ //============================================================================ bool ShaderProg::enable() { if (!_hProg) return false; glUseProgramObjectARB(_hProg); return true; } //============================================================================ //============================================================================ void ShaderProg::disable() { glUseProgramObjectARB(NULL); } //============================================================================ // throws runtime exception on error //============================================================================ void ShaderProg::loadVert(const char *pacFile) { if (!_shdrVert) _shdrVert.reset(new Shader(GL_VERTEX_SHADER_ARB)); load(pacFile, _shdrVert.get()); } //============================================================================ // throws runtime exception on error //============================================================================ void ShaderProg::loadFrag(const char *pacFile) { if (!_shdrFrag) _shdrFrag.reset(new Shader(GL_FRAGMENT_SHADER_ARB)); load(pacFile, _shdrFrag.get()); } //============================================================================ // throws runtime exception on error //============================================================================ void ShaderProg::loadVertStr(const GLcharARB *pacShdrSrc) { if (!_shdrVert) _shdrVert.reset(new Shader(GL_VERTEX_SHADER_ARB)); loadStr(pacShdrSrc, _shdrVert.get()); } //============================================================================ // throws runtime exception on error //============================================================================ void ShaderProg::loadFragStr(const GLcharARB *pacShdrSrc) { if (!_shdrFrag) _shdrFrag.reset(new Shader(GL_FRAGMENT_SHADER_ARB)); loadStr(pacShdrSrc, _shdrFrag.get()); } //============================================================================ //============================================================================ void ShaderProg::setTextureLoc(const GLcharARB *acSamplerName, GLint iTexLoc) { if (!_hProg) return; GLint loc = glGetUniformLocationARB(_hProg, acSamplerName); if (loc != -1) { glUniform1iARB(loc, iTexLoc); } } //============================================================================ //============================================================================ GLint ShaderProg::getUniformLoc(const GLcharARB *name) { if (!_hProg) return -1; return glGetUniformLocationARB(_hProg, name); } //============================================================================ //============================================================================ bool ShaderProg::valid() { if (_hProg) return true; return false; } //============================================================================ //============================================================================ void ShaderProg::destroy() { _shdrVert.reset(); _shdrFrag.reset(); if (_hProg) { glDeleteObjectARB(_hProg); _hProg = 0; } } //============================================================================ //============================================================================ GLhandleARB ShaderProg::progHndl() { return _hProg; } //============================================================================ // throws runtime exception on error //============================================================================ void ShaderProg::load(const char* pacFile, Shader *shdr) { remove(shdr); shdr->load(pacFile); attach(shdr); } //============================================================================ // throws runtime exception on error //============================================================================ void ShaderProg::loadStr(const GLcharARB *pacShdrSrc, Shader *shdr) { remove(shdr); shdr->loadStr(pacShdrSrc); attach(shdr); } //============================================================================ // throws runtime exception on error //============================================================================ void ShaderProg::attach(Shader *shdr) { GLint linked = 0; if (!_hProg) _hProg = glCreateProgramObjectARB(); glAttachObjectARB(_hProg, shdr->handle()); glLinkProgramARB(_hProg); glGetObjectParameterivARB(_hProg, GL_OBJECT_LINK_STATUS_ARB, &linked); if (!linked) { // link error! Check compiler log! std::string log = UtlGL::getLog(_hProg); std::string err = "Shader failed to link:\n "; if (log.size() > 0) err += log; else err += "An unknown link error occured."; throw std::runtime_error(err); } } //============================================================================ //============================================================================ void ShaderProg::remove(Shader *shdr) { if (!shdr || !shdr->valid()) return; if (_hProg) { glDetachObjectARB(_hProg, shdr->handle()); shdr->destroy(); } }
#include "GameEngine/ConfigLoader.h" #include "GameplayUtilities/File.h" #include "GameEngine/FilePathHelper.h" using namespace GameEngine::DataUtils; using namespace GameplayUtilities::IO; const std::string ConfigLoader::LoadDataFrom(const std::string& root_folder, const std::string& config_folder, const std::string& file_name) { std::string player_anim_file = FilePathHelper::GeneratePath(root_folder, config_folder, file_name); File file_reader; file_reader.OpenForRead(player_anim_file); return file_reader.Read(); }
[bits 32] [extern main] call main jmp $
.386p Kernel Segment public para use32 assume cs:Kernel __kAudioProc proc pushad push ds push es mov ax,rwData32Seg mov ds,ax mov es,ax jmp _kaudioProcIoe mov ebp,esp add ebp,32 push dword ptr ICW2_MASTER_INT_NO + 5 push dword ptr 0 push dword ptr [ebp] push dword ptr [ebp + 4] push dword ptr [ebp + 8] test dword ptr [ebp + 4],3 jz _kaudioKernelModeInt push dword ptr [ebp + 12] push dword ptr [ebp + 16] jmp _kaudioShowExpInfo _kaudioKernelModeInt: push dword ptr 0 push dword ptr 0 _kaudioShowExpInfo: call __exceptionInfo add esp,28 _kaudioProcIoe: mov ebx,KernelData shl ebx,4 cmp dword ptr ds:[ebx + offset _kSoundCardInt],0 jz _kaudioProcEnd call dword ptr ds:[ebx + offset _kSoundCardInt] _kaudioProcEnd: mov al,20h out 20h,al pop es pop ds popad iretd __kAudioProc endp Kernel ends
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r15 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x85a3, %rax nop nop nop nop xor $42045, %r12 movw $0x6162, (%rax) nop nop nop nop nop add $33419, %rbx lea addresses_UC_ht+0x3543, %rsi lea addresses_normal_ht+0xc843, %rdi clflush (%rsi) cmp $11216, %r12 mov $94, %rcx rep movsq nop nop nop and %rsi, %rsi lea addresses_WC_ht+0x110c3, %rax nop nop nop nop nop cmp $52892, %r15 movw $0x6162, (%rax) nop cmp $64425, %rdi lea addresses_normal_ht+0x1d56f, %rdi cmp $59488, %r12 mov (%rdi), %rsi nop nop nop xor %rax, %rax lea addresses_WT_ht+0x28c3, %rsi lea addresses_A_ht+0x91cf, %rdi nop cmp %r12, %r12 mov $57, %rcx rep movsb and $11702, %rcx lea addresses_normal_ht+0xf883, %r12 nop nop nop dec %r15 mov $0x6162636465666768, %rax movq %rax, (%r12) nop add $55432, %rax lea addresses_WT_ht+0xeef3, %r15 sub $46702, %r12 vmovups (%r15), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %rsi nop nop nop dec %rsi lea addresses_D_ht+0x16eff, %rdi nop dec %rax movups (%rdi), %xmm7 vpextrq $1, %xmm7, %rcx nop nop cmp $30809, %rax lea addresses_WT_ht+0x3083, %rax nop nop nop xor $33457, %rbx mov $0x6162636465666768, %rcx movq %rcx, %xmm2 movups %xmm2, (%rax) cmp %r15, %r15 lea addresses_WC_ht+0x1cb43, %r15 nop nop nop add %rax, %rax mov $0x6162636465666768, %rsi movq %rsi, %xmm0 movups %xmm0, (%r15) nop nop nop dec %r12 lea addresses_D_ht+0x1a543, %rbx and $23050, %r12 and $0xffffffffffffffc0, %rbx vmovntdqa (%rbx), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $0, %xmm1, %rsi nop nop and $39021, %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r8 push %rax push %rbx push %rsi // Load lea addresses_A+0x7463, %rax nop nop nop cmp %r14, %r14 mov (%rax), %r11d add $27972, %r14 // Faulty Load lea addresses_A+0x19543, %r12 clflush (%r12) nop nop nop nop xor $63555, %rbx mov (%r12), %r11d lea oracles, %rsi and $0xff, %r11 shlq $12, %r11 mov (%rsi,%r11,1), %r11 pop %rsi pop %rbx pop %rax pop %r8 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_A'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4, 'same': False, 'type': 'addresses_A'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_A'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2, 'same': True, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'00': 1, '35': 21828} 00 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
// test driver for scoped timer. // fixes are required to be fuzzed // with single and multi-threaded mode and short timeouts. // run it with app-verifier (becuzz yes ...) #include "util/scoped_timer.h" #include "util/util.h" #include "util/vector.h" #include "util/trace.h" #include <thread> #include <atomic> class test_scoped_eh : public event_handler { std::atomic<bool> m_called = false; public: void operator()(event_handler_caller_t id) override { m_caller_id = id; m_called = true; } bool called() const { return m_called; } }; static void worker_thread(unsigned tid) { for (unsigned i = 0; i < 100; ++i) { test_scoped_eh eh; scoped_timer sc(1, &eh); unsigned_vector v; for (unsigned j = 0; j < (2 << 25); ++j) { v.push_back(j); if (eh.called()) { // IF_VERBOSE(0, verbose_stream() << tid << " " << i << " " << j << "\n"); break; } } } } void tst_scoped_timer() { std::cout << "sequential test\n"; worker_thread(0); std::cout << "thread test\n"; unsigned num_threads = 3; vector<std::thread> threads(num_threads); for (unsigned i = 0; i < num_threads; ++i) threads[i] = std::thread([&, i]() { worker_thread(i); }); for (auto& th : threads) th.join(); }
include comparison_predicates.inc .code ; int AVX_Scalar_Compare_VCMPSD_Double_(double a, double b) AVX_Scalar_Compare_VCMPSD_Double_ proc xor r8, r8 vcmpsd xmm2, xmm0, xmm1, CMP_LT_OS vmovq rax, xmm2 and al, 1 ; Remove unecessary bits and set RFLAGS. If comparison fails ZF will be zero. jnz Smaller vcmpsd xmm2, xmm0, xmm1, CMP_EQ_OQ vmovq rax, xmm2 and al, 1 jnz Done vcmpsd xmm2, xmm0, xmm1, CMP_GT_OS vmovq rax, xmm2 and al, 1 jnz Bigger Smaller: dec r8 ; r8 = -1 jmp Done Bigger: inc r8 ; r8 = 1 Done: mov eax, r8d ret AVX_Scalar_Compare_VCMPSD_Double_ endp end
; A001841: Related to Zarankiewicz's problem. ; 3,5,10,14,21,26,36,43,55,64,78,88,105,117,136,150,171,186,210,227,253,272,300,320,351,373,406,430,465,490,528,555,595,624,666,696,741,773,820,854,903,938,990,1027,1081,1120,1176,1216,1275,1317,1378,1422,1485,1530,1596,1643,1711,1760,1830,1880,1953,2005,2080,2134,2211,2266,2346,2403,2485,2544,2628,2688,2775,2837,2926,2990,3081,3146,3240,3307,3403,3472,3570,3640,3741,3813,3916,3990,4095,4170,4278,4355,4465,4544,4656,4736,4851,4933,5050,5134,5253,5338,5460,5547,5671,5760,5886,5976,6105,6197,6328,6422,6555,6650,6786,6883,7021,7120,7260,7360,7503,7605,7750,7854,8001,8106,8256,8363,8515,8624,8778,8888,9045,9157,9316,9430,9591,9706,9870,9987,10153,10272,10440,10560,10731,10853,11026,11150,11325,11450,11628,11755,11935,12064,12246,12376,12561,12693,12880,13014,13203,13338,13530,13667,13861,14000,14196,14336,14535,14677,14878,15022,15225,15370,15576,15723,15931,16080,16290,16440,16653,16805,17020,17174,17391,17546,17766,17923,18145,18304,18528,18688,18915,19077,19306,19470,19701,19866,20100,20267,20503,20672,20910,21080,21321,21493,21736,21910,22155,22330,22578,22755,23005,23184,23436,23616,23871,24053,24310,24494,24753,24938,25200,25387,25651,25840,26106,26296,26565,26757,27028,27222,27495,27690,27966,28163,28441,28640,28920,29120,29403,29605,29890,30094,30381,30586,30876,31083,31375,31584 mov $2,$0 add $0,3 div $2,2 add $2,$0 mul $0,$2 mov $3,$0 lpb $0 sub $0,1 mov $1,$3 div $1,3 lpe
;/*! ; @file ; ; @brief BvsScrollUp DOS wrapper ; ; (c) osFree Project 2008-2022, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ;----------------------------------------------------------------------------------- ; ; *0 NO_ERROR ; *355 ERROR_VIO_MODE ; *358 ERROR_VIO_ROW ; *359 ERROR_VIO_COL ; *436 ERROR_VIO_INVALID_HANDLE ; *465 ERROR_VIO_DETACHED ; ;----------------------------------------------------------------------------------- ; ;*/ .8086 ; Helpers INCLUDE HELPERS.INC INCLUDE BSEERR.INC _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @BVSPROLOG BVSSCROLLUP VIOHANDLE DW ? CELL DD ? LINES DW ? RIGHTCOL DW ? BOTROW DW ? LEFTCOL DW ? TOPROW DW ? @BVSSTART BVSSCROLLUP EXTERN VIOCHECKHANDLE: PROC MOV BX,[DS:BP].ARGS.VIOHANDLE ; GET HANDLE CALL VIOCHECKHANDLE JNZ EXIT MOV AX,[DS:BP].ARGS.TOPROW ; GET TOP ROW MOV CH,AL ; PUT IN PLACE MOV AX,[DS:BP].ARGS.LEFTCOL ; GET LEFT COLUMN MOV CL,AL ; PUT IN PLACE MOV AX,[DS:BP].ARGS.BOTROW ; GET BOTTOM ROW MOV DH,AL ; PUT IN PLACE MOV AX,[DS:BP].ARGS.RIGHTCOL ; GET RIGHT COLUMN MOV DL,AL ; PUT IN PLACE LDS SI,[DS:BP].ARGS.CELL ; GET POINTER TO CELL LODSW ; GET THE CELL TO USE MOV BH,AH ; PUT ATTRIBUTE IN PLACE MOV AX,[DS:BP].ARGS.LINES ; GET LINES TO SCROLL OR AX,AX ; IS IT 0? JNE F10_20 ; NO, SO GO ON XOR AX,AX ; NOTHING TO DO, SO RETURN GOOD JMP EXIT ; GO AWAY F10_20: CMP AX,-1 ; IF IT IS -1, MAKE IT 0 JNE F10_21 ; ITS NOT, SO GO ON XOR AX,AX ; MAKE IT 0 F10_21: MOV AH,6 ; SCROLL UP BIOS CALL INT 10H ; DO THE CALL XOR AX,AX EXIT: @BVSEPILOG BVSSCROLLUP _TEXT ENDS END
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xba2a, %rsi lea addresses_UC_ht+0x5aba, %rdi nop nop nop nop sub %r8, %r8 mov $41, %rcx rep movsb nop and $33471, %rdx lea addresses_WT_ht+0x1253a, %r14 clflush (%r14) and %r15, %r15 mov $0x6162636465666768, %rdi movq %rdi, %xmm3 movups %xmm3, (%r14) nop nop sub $15232, %r14 lea addresses_D_ht+0x8b7a, %r15 nop nop nop nop xor %r14, %r14 mov $0x6162636465666768, %rsi movq %rsi, %xmm0 vmovups %ymm0, (%r15) nop nop nop nop nop add $23937, %rdx lea addresses_normal_ht+0x19aba, %rsi lea addresses_UC_ht+0xe13a, %rdi clflush (%rsi) nop nop xor %r14, %r14 mov $103, %rcx rep movsl nop nop nop and %r14, %r14 lea addresses_WT_ht+0xdf43, %r14 nop nop nop nop sub %rdx, %rdx vmovups (%r14), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $0, %xmm0, %r15 nop nop nop nop nop and %r14, %r14 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r8 push %rax push %rbp push %rcx push %rsi // Store lea addresses_WC+0x28ba, %r10 nop nop cmp $31116, %r11 movl $0x51525354, (%r10) nop nop nop add %rbp, %rbp // Store lea addresses_A+0x130a, %rax nop cmp $27011, %r8 mov $0x5152535455565758, %rbp movq %rbp, %xmm5 movups %xmm5, (%rax) sub %rcx, %rcx // Faulty Load lea addresses_US+0x4aba, %rcx nop sub $25447, %rsi mov (%rcx), %eax lea oracles, %rbp and $0xff, %rax shlq $12, %rax mov (%rbp,%rax,1), %rax pop %rsi pop %rcx pop %rbp pop %rax pop %r8 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 3}} [Faulty Load] {'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 4}} {'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'00': 1} 00 */
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 a0 10 00 mov $0x10a000,%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 c5 10 80 mov $0x8010c5c0,%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 b0 30 10 80 mov $0x801030b0,%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 c5 10 80 mov $0x8010c5f4,%ebx struct buf head; } bcache; void binit(void) { 80100049: 83 ec 0c sub $0xc,%esp struct buf *b; initlock(&bcache.lock, "bcache"); 8010004c: 68 60 80 10 80 push $0x80108060 80100051: 68 c0 c5 10 80 push $0x8010c5c0 80100056: e8 75 4f 00 00 call 80104fd0 <initlock> //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; 8010005b: c7 05 0c 0d 11 80 bc movl $0x80110cbc,0x80110d0c 80100062: 0c 11 80 bcache.head.next = &bcache.head; 80100065: c7 05 10 0d 11 80 bc movl $0x80110cbc,0x80110d10 8010006c: 0c 11 80 8010006f: 83 c4 10 add $0x10,%esp 80100072: ba bc 0c 11 80 mov $0x80110cbc,%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 bc 0c 11 80 movl $0x80110cbc,0x50(%ebx) initsleeplock(&b->lock, "buffer"); 80100092: 68 67 80 10 80 push $0x80108067 80100097: 50 push %eax 80100098: e8 03 4e 00 00 call 80104ea0 <initsleeplock> bcache.head.next->prev = b; 8010009d: a1 10 0d 11 80 mov 0x80110d10,%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 10 0d 11 80 mov %ebx,0x80110d10 //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 bc 0c 11 80 cmp $0x80110cbc,%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 c0 c5 10 80 push $0x8010c5c0 801000e4: e8 47 50 00 00 call 80105130 <acquire> // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ 801000e9: 8b 1d 10 0d 11 80 mov 0x80110d10,%ebx 801000ef: 83 c4 10 add $0x10,%esp 801000f2: 81 fb bc 0c 11 80 cmp $0x80110cbc,%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 bc 0c 11 80 cmp $0x80110cbc,%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 0d 11 80 mov 0x80110d0c,%ebx 80100126: 81 fb bc 0c 11 80 cmp $0x80110cbc,%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 bc 0c 11 80 cmp $0x80110cbc,%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 c0 c5 10 80 push $0x8010c5c0 80100162: e8 79 50 00 00 call 801051e0 <release> acquiresleep(&b->lock); 80100167: 8d 43 0c lea 0xc(%ebx),%eax 8010016a: 89 04 24 mov %eax,(%esp) 8010016d: e8 6e 4d 00 00 call 80104ee0 <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 bd 21 00 00 call 80102340 <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 6e 80 10 80 push $0x8010806e 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 cd 4d 00 00 call 80104f80 <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 77 21 00 00 jmp 80102340 <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 7f 80 10 80 push $0x8010807f 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 8c 4d 00 00 call 80104f80 <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 3c 4d 00 00 call 80104f40 <releasesleep> acquire(&bcache.lock); 80100204: c7 04 24 c0 c5 10 80 movl $0x8010c5c0,(%esp) 8010020b: e8 20 4f 00 00 call 80105130 <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 10 0d 11 80 mov 0x80110d10,%eax b->prev = &bcache.head; 80100237: c7 43 50 bc 0c 11 80 movl $0x80110cbc,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 10 0d 11 80 mov 0x80110d10,%eax 80100246: 89 58 50 mov %ebx,0x50(%eax) bcache.head.next = b; 80100249: 89 1d 10 0d 11 80 mov %ebx,0x80110d10 } release(&bcache.lock); 8010024f: c7 45 08 c0 c5 10 80 movl $0x8010c5c0,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 7f 4f 00 00 jmp 801051e0 <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 86 80 10 80 push $0x80108086 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 1b 17 00 00 call 801019a0 <iunlock> target = n; acquire(&cons.lock); 80100285: c7 04 24 20 b5 10 80 movl $0x8010b520,(%esp) 8010028c: e8 9f 4e 00 00 call 80105130 <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 20 10 11 80 mov 0x80111020,%eax 801002a6: 3b 05 24 10 11 80 cmp 0x80111024,%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 b5 10 80 push $0x8010b520 801002b8: 68 20 10 11 80 push $0x80111020 801002bd: e8 0e 41 00 00 call 801043d0 <sleep> iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ 801002c2: a1 20 10 11 80 mov 0x80111020,%eax 801002c7: 83 c4 10 add $0x10,%esp 801002ca: 3b 05 24 10 11 80 cmp 0x80111024,%eax 801002d0: 75 36 jne 80100308 <consoleread+0x98> if(myproc()->killed){ 801002d2: e8 59 37 00 00 call 80103a30 <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 b5 10 80 push $0x8010b520 801002e6: e8 f5 4e 00 00 call 801051e0 <release> ilock(ip); 801002eb: 89 3c 24 mov %edi,(%esp) 801002ee: e8 cd 15 00 00 call 801018c0 <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 20 10 11 80 mov %edx,0x80111020 80100311: 89 c2 mov %eax,%edx 80100313: 83 e2 7f and $0x7f,%edx 80100316: 0f be 92 a0 0f 11 80 movsbl -0x7feef060(%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 b5 10 80 push $0x8010b520 80100346: e8 95 4e 00 00 call 801051e0 <release> ilock(ip); 8010034b: 89 3c 24 mov %edi,(%esp) 8010034e: e8 6d 15 00 00 call 801018c0 <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 20 10 11 80 mov %eax,0x80111020 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 b5 10 80 00 movl $0x0,0x8010b554 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 b2 25 00 00 call 80102940 <lapicid> 8010038e: 83 ec 08 sub $0x8,%esp 80100391: 50 push %eax 80100392: 68 8d 80 10 80 push $0x8010808d 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 90 86 10 80 movl $0x80108690,(%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 33 4c 00 00 call 80104ff0 <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 a1 80 10 80 push $0x801080a1 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 b5 10 80 01 movl $0x1,0x8010b558 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 b5 10 80 mov 0x8010b558,%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 01 68 00 00 call 80106c20 <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 48 67 00 00 call 80106c20 <uartputc> 801004d8: c7 04 24 20 00 00 00 movl $0x20,(%esp) 801004df: e8 3c 67 00 00 call 80106c20 <uartputc> 801004e4: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004eb: e8 30 67 00 00 call 80106c20 <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 c7 4d 00 00 call 801052e0 <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 02 4d 00 00 call 80105230 <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 a5 80 10 80 push $0x801080a5 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 d0 80 10 80 movzbl -0x7fef7f30(%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 8c 13 00 00 call 801019a0 <iunlock> acquire(&cons.lock); 80100614: c7 04 24 20 b5 10 80 movl $0x8010b520,(%esp) 8010061b: e8 10 4b 00 00 call 80105130 <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 b5 10 80 push $0x8010b520 80100647: e8 94 4b 00 00 call 801051e0 <release> ilock(ip); 8010064c: 58 pop %eax 8010064d: ff 75 08 pushl 0x8(%ebp) 80100650: e8 6b 12 00 00 call 801018c0 <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 b5 10 80 mov 0x8010b554,%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 b5 10 80 push $0x8010b520 8010070d: e8 ce 4a 00 00 call 801051e0 <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 b8 80 10 80 mov $0x801080b8,%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 b5 10 80 push $0x8010b520 801007c8: e8 63 49 00 00 call 80105130 <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 bf 80 10 80 push $0x801080bf 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 b5 10 80 push $0x8010b520 80100803: e8 28 49 00 00 call 80105130 <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 28 10 11 80 mov 0x80111028,%eax 80100836: 3b 05 24 10 11 80 cmp 0x80111024,%eax 8010083c: 74 d2 je 80100810 <consoleintr+0x20> input.e--; 8010083e: 83 e8 01 sub $0x1,%eax 80100841: a3 28 10 11 80 mov %eax,0x80111028 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 b5 10 80 push $0x8010b520 80100868: e8 73 49 00 00 call 801051e0 <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 28 10 11 80 mov 0x80111028,%eax 8010088e: 89 c2 mov %eax,%edx 80100890: 2b 15 20 10 11 80 sub 0x80111020,%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 28 10 11 80 mov %edx,0x80111028 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 a0 0f 11 80 mov %cl,-0x7feef060(%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 20 10 11 80 mov 0x80111020,%eax 801008da: 83 e8 80 sub $0xffffff80,%eax 801008dd: 39 05 28 10 11 80 cmp %eax,0x80111028 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 24 10 11 80 mov %eax,0x80111024 wakeup(&input.r); 801008f1: 68 20 10 11 80 push $0x80111020 801008f6: e8 95 3c 00 00 call 80104590 <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 28 10 11 80 mov 0x80111028,%eax 8010090d: 39 05 24 10 11 80 cmp %eax,0x80111024 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 28 10 11 80 mov %eax,0x80111028 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 28 10 11 80 mov 0x80111028,%eax 80100934: 3b 05 24 10 11 80 cmp 0x80111024,%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 a0 0f 11 80 0a cmpb $0xa,-0x7feef060(%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 d4 3e 00 00 jmp 80104850 <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 a0 0f 11 80 0a movb $0xa,-0x7feef060(%eax) consputc(c); 80100983: b8 0a 00 00 00 mov $0xa,%eax 80100988: e8 63 fa ff ff call 801003f0 <consputc> 8010098d: a1 28 10 11 80 mov 0x80111028,%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 c8 80 10 80 push $0x801080c8 801009ab: 68 20 b5 10 80 push $0x8010b520 801009b0: e8 1b 46 00 00 call 80104fd0 <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 ec 19 11 80 00 movl $0x80100600,0x801119ec 801009c2: 06 10 80 devsw[CONSOLE].read = consoleread; 801009c5: c7 05 e8 19 11 80 70 movl $0x80100270,0x801119e8 801009cc: 02 10 80 cons.locking = 1; 801009cf: c7 05 54 b5 10 80 01 movl $0x1,0x8010b554 801009d6: 00 00 00 ioapicenable(IRQ_KBD, 0); 801009d9: e8 12 1b 00 00 call 801024f0 <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 <get_size_string>: #include "proc.h" #include "defs.h" #include "x86.h" #include "elf.h" int get_size_string(char* string){ 801009f0: 55 push %ebp int i=0; 801009f1: 31 c0 xor %eax,%eax #include "proc.h" #include "defs.h" #include "x86.h" #include "elf.h" int get_size_string(char* string){ 801009f3: 89 e5 mov %esp,%ebp 801009f5: 8b 55 08 mov 0x8(%ebp),%edx int i=0; while(1){ if(string[i]=='\0') 801009f8: 80 3a 00 cmpb $0x0,(%edx) 801009fb: 74 0c je 80100a09 <get_size_string+0x19> 801009fd: 8d 76 00 lea 0x0(%esi),%esi break; i++; 80100a00: 83 c0 01 add $0x1,%eax #include "elf.h" int get_size_string(char* string){ int i=0; while(1){ if(string[i]=='\0') 80100a03: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 80100a07: 75 f7 jne 80100a00 <get_size_string+0x10> break; i++; } return i; } 80100a09: 5d pop %ebp 80100a0a: c3 ret 80100a0b: 90 nop 80100a0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100a10 <exec>: int exec(char *path, char **argv) { 80100a10: 55 push %ebp 80100a11: 89 e5 mov %esp,%ebp 80100a13: 57 push %edi 80100a14: 56 push %esi 80100a15: 53 push %ebx 80100a16: 81 ec 7c 01 00 00 sub $0x17c,%esp 80100a1c: 8b 5d 08 mov 0x8(%ebp),%ebx 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(); 80100a1f: e8 0c 30 00 00 call 80103a30 <myproc> 80100a24: 89 85 84 fe ff ff mov %eax,-0x17c(%ebp) #include "elf.h" int get_size_string(char* string){ int i=0; while(1){ if(string[i]=='\0') 80100a2a: 0f b6 03 movzbl (%ebx),%eax 80100a2d: 84 c0 test %al,%al 80100a2f: 0f 84 5f 03 00 00 je 80100d94 <exec+0x384> 80100a35: 31 f6 xor %esi,%esi 80100a37: 89 f6 mov %esi,%esi 80100a39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi break; i++; 80100a40: 83 c6 01 add $0x1,%esi #include "elf.h" int get_size_string(char* string){ int i=0; while(1){ if(string[i]=='\0') 80100a43: 80 3c 33 00 cmpb $0x0,(%ebx,%esi,1) 80100a47: 75 f7 jne 80100a40 <exec+0x30> 80100a49: 80 3d 20 0f 11 80 00 cmpb $0x0,0x80110f20 80100a50: 0f 84 1b 03 00 00 je 80100d71 <exec+0x361> #include "defs.h" #include "x86.h" #include "elf.h" int get_size_string(char* string){ int i=0; 80100a56: 31 d2 xor %edx,%edx 80100a58: 90 nop 80100a59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi while(1){ if(string[i]=='\0') break; i++; 80100a60: 83 c2 01 add $0x1,%edx #include "elf.h" int get_size_string(char* string){ int i=0; while(1){ if(string[i]=='\0') 80100a63: 80 ba 20 0f 11 80 00 cmpb $0x0,-0x7feef0e0(%edx) 80100a6a: 75 f4 jne 80100a60 <exec+0x50> 80100a6c: 84 c0 test %al,%al 80100a6e: 89 95 94 fe ff ff mov %edx,-0x16c(%ebp) 80100a74: 0f 84 06 03 00 00 je 80100d80 <exec+0x370> 80100a7a: 31 c0 xor %eax,%eax 80100a7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi break; i++; 80100a80: 83 c0 01 add $0x1,%eax #include "elf.h" int get_size_string(char* string){ int i=0; while(1){ if(string[i]=='\0') 80100a83: 80 3c 03 00 cmpb $0x0,(%ebx,%eax,1) 80100a87: 75 f7 jne 80100a80 <exec+0x70> 80100a89: 89 85 88 fe ff ff mov %eax,-0x178(%ebp) int fsize=get_size_string(path); int found=0;//found == 0 if ip not found int size=get_size_string(add_path); int psize=get_size_string(path); int c=0; begin_op(); 80100a8f: e8 0c 23 00 00 call 80102da0 <begin_op> //add if(size>0){ 80100a94: 8b 95 94 fe ff ff mov -0x16c(%ebp),%edx 80100a9a: 85 d2 test %edx,%edx 80100a9c: 0f 84 9f 01 00 00 je 80100c41 <exec+0x231> 80100aa2: 85 f6 test %esi,%esi 80100aa4: b8 00 00 00 00 mov $0x0,%eax 80100aa9: 0f 49 c6 cmovns %esi,%eax int fsize=get_size_string(path); int found=0;//found == 0 if ip not found int size=get_size_string(add_path); int psize=get_size_string(path); int c=0; begin_op(); 80100aac: 31 c9 xor %ecx,%ecx 80100aae: 89 85 8c fe ff ff mov %eax,-0x174(%ebp) 80100ab4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100ab8: 89 b5 90 fe ff ff mov %esi,-0x170(%ebp) 80100abe: 89 cf mov %ecx,%edi 80100ac0: 31 c0 xor %eax,%eax 80100ac2: 8b b5 94 fe ff ff mov -0x16c(%ebp),%esi 80100ac8: eb 17 jmp 80100ae1 <exec+0xd1> 80100aca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(size>0){ for(j=0;j<size;j++){ while(add_path[j]!=':'){ temp[ii]=add_path[j]; ii++; j++; 80100ad0: 83 c7 01 add $0x1,%edi begin_op(); //add if(size>0){ for(j=0;j<size;j++){ while(add_path[j]!=':'){ temp[ii]=add_path[j]; 80100ad3: 88 94 05 f4 fe ff ff mov %dl,-0x10c(%ebp,%eax,1) ii++; 80100ada: 83 c0 01 add $0x1,%eax j++; if(j>=size) 80100add: 39 f7 cmp %esi,%edi 80100adf: 7d 0d jge 80100aee <exec+0xde> int c=0; begin_op(); //add if(size>0){ for(j=0;j<size;j++){ while(add_path[j]!=':'){ 80100ae1: 0f b6 94 01 20 0f 11 movzbl -0x7feef0e0(%ecx,%eax,1),%edx 80100ae8: 80 80100ae9: 80 fa 3a cmp $0x3a,%dl 80100aec: 75 e2 jne 80100ad0 <exec+0xc0> 80100aee: 8b b5 90 fe ff ff mov -0x170(%ebp),%esi ii++; j++; if(j>=size) break; } temp[ii]='/'; 80100af4: c6 84 05 f4 fe ff ff movb $0x2f,-0x10c(%ebp,%eax,1) 80100afb: 2f ii++; 80100afc: 8d 48 01 lea 0x1(%eax),%ecx for(c=0;c<fsize;c++){ 80100aff: 85 f6 test %esi,%esi 80100b01: 74 2a je 80100b2d <exec+0x11d> temp[ii+c]=path[c];} 80100b03: 8d 95 f4 fe ff ff lea -0x10c(%ebp),%edx 80100b09: 89 8d 90 fe ff ff mov %ecx,-0x170(%ebp) 80100b0f: 01 d0 add %edx,%eax 80100b11: 31 d2 xor %edx,%edx 80100b13: 90 nop 80100b14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100b18: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 80100b1c: 88 4c 10 01 mov %cl,0x1(%eax,%edx,1) if(j>=size) break; } temp[ii]='/'; ii++; for(c=0;c<fsize;c++){ 80100b20: 83 c2 01 add $0x1,%edx 80100b23: 39 f2 cmp %esi,%edx 80100b25: 75 f1 jne 80100b18 <exec+0x108> 80100b27: 8b 8d 90 fe ff ff mov -0x170(%ebp),%ecx temp[ii+c]=path[c];} temp[ii+c]='\0'; 80100b2d: 8d 45 e8 lea -0x18(%ebp),%eax ii=0; //cprintf("search path:%s\n",temp); ip=namei(temp); 80100b30: 83 ec 0c sub $0xc,%esp } temp[ii]='/'; ii++; for(c=0;c<fsize;c++){ temp[ii+c]=path[c];} temp[ii+c]='\0'; 80100b33: 01 c1 add %eax,%ecx 80100b35: 8b 85 8c fe ff ff mov -0x174(%ebp),%eax 80100b3b: c6 84 08 0c ff ff ff movb $0x0,-0xf4(%eax,%ecx,1) 80100b42: 00 ii=0; //cprintf("search path:%s\n",temp); ip=namei(temp); 80100b43: 8d 85 f4 fe ff ff lea -0x10c(%ebp),%eax 80100b49: 50 push %eax 80100b4a: e8 c1 15 00 00 call 80102110 <namei> if(ip != 0){ 80100b4f: 83 c4 10 add $0x10,%esp 80100b52: 85 c0 test %eax,%eax 80100b54: 0f 85 8e 00 00 00 jne 80100be8 <exec+0x1d8> int psize=get_size_string(path); int c=0; begin_op(); //add if(size>0){ for(j=0;j<size;j++){ 80100b5a: 8d 4f 01 lea 0x1(%edi),%ecx 80100b5d: 3b 8d 94 fe ff ff cmp -0x16c(%ebp),%ecx 80100b63: 0f 8c 4f ff ff ff jl 80100ab8 <exec+0xa8> found=1; break; } } if(!found){ if(path[0]!='/'){ 80100b69: 80 3b 2f cmpb $0x2f,(%ebx) 80100b6c: 0f 84 cf 00 00 00 je 80100c41 <exec+0x231> temp[0]='/'; for (c=0;c<psize;c++){ 80100b72: 8b 8d 88 fe ff ff mov -0x178(%ebp),%ecx break; } } if(!found){ if(path[0]!='/'){ temp[0]='/'; 80100b78: c6 85 f4 fe ff ff 2f movb $0x2f,-0x10c(%ebp) for (c=0;c<psize;c++){ 80100b7f: 85 c9 test %ecx,%ecx 80100b81: 0f 84 21 02 00 00 je 80100da8 <exec+0x398> 80100b87: 31 c0 xor %eax,%eax 80100b89: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi temp[c+1]=path[c]; 80100b90: 83 c0 01 add $0x1,%eax 80100b93: 0f b6 54 03 ff movzbl -0x1(%ebx,%eax,1),%edx } } if(!found){ if(path[0]!='/'){ temp[0]='/'; for (c=0;c<psize;c++){ 80100b98: 39 c8 cmp %ecx,%eax temp[c+1]=path[c]; 80100b9a: 88 94 05 f4 fe ff ff mov %dl,-0x10c(%ebp,%eax,1) } } if(!found){ if(path[0]!='/'){ temp[0]='/'; for (c=0;c<psize;c++){ 80100ba1: 75 ed jne 80100b90 <exec+0x180> 80100ba3: 83 c0 01 add $0x1,%eax temp[c+1]=path[c]; } temp[c+1]='\0'; 80100ba6: c6 84 05 f4 fe ff ff movb $0x0,-0x10c(%ebp,%eax,1) 80100bad: 00 } if(path[0]!='/') ip=namei(temp); 80100bae: 8d 85 f4 fe ff ff lea -0x10c(%ebp),%eax 80100bb4: 83 ec 0c sub $0xc,%esp 80100bb7: 50 push %eax 80100bb8: e8 53 15 00 00 call 80102110 <namei> 80100bbd: 83 c4 10 add $0x10,%esp 80100bc0: 89 c2 mov %eax,%edx return -1; } } else{ ip=namei(path); if(ip == 0){ 80100bc2: 85 d2 test %edx,%edx 80100bc4: 75 24 jne 80100bea <exec+0x1da> end_op(); 80100bc6: e8 45 22 00 00 call 80102e10 <end_op> cprintf("exec: fail\n"); 80100bcb: 83 ec 0c sub $0xc,%esp 80100bce: 68 e1 80 10 80 push $0x801080e1 80100bd3: e8 88 fa ff ff call 80100660 <cprintf> return -1; 80100bd8: 83 c4 10 add $0x10,%esp if(ip){ iunlockput(ip); end_op(); } return -1; } 80100bdb: 8d 65 f4 lea -0xc(%ebp),%esp else{ ip=namei(path); if(ip == 0){ end_op(); cprintf("exec: fail\n"); return -1; 80100bde: b8 ff ff ff ff mov $0xffffffff,%eax if(ip){ iunlockput(ip); end_op(); } return -1; } 80100be3: 5b pop %ebx 80100be4: 5e pop %esi 80100be5: 5f pop %edi 80100be6: 5d pop %ebp 80100be7: c3 ret 80100be8: 89 c2 mov %eax,%edx end_op(); cprintf("exec: fail\n"); return -1; } } ilock(ip); 80100bea: 83 ec 0c sub $0xc,%esp 80100bed: 89 95 94 fe ff ff mov %edx,-0x16c(%ebp) 80100bf3: 52 push %edx 80100bf4: e8 c7 0c 00 00 call 801018c0 <ilock> pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) 80100bf9: 8b 95 94 fe ff ff mov -0x16c(%ebp),%edx 80100bff: 8d 85 c0 fe ff ff lea -0x140(%ebp),%eax 80100c05: 6a 34 push $0x34 80100c07: 6a 00 push $0x0 80100c09: 50 push %eax 80100c0a: 52 push %edx 80100c0b: e8 90 0f 00 00 call 80101ba0 <readi> 80100c10: 83 c4 20 add $0x20,%esp 80100c13: 83 f8 34 cmp $0x34,%eax 80100c16: 8b 95 94 fe ff ff mov -0x16c(%ebp),%edx 80100c1c: 74 36 je 80100c54 <exec+0x244> bad: if(pgdir) freevm(pgdir); if(ip){ iunlockput(ip); 80100c1e: 83 ec 0c sub $0xc,%esp 80100c21: 52 push %edx 80100c22: e8 29 0f 00 00 call 80101b50 <iunlockput> end_op(); 80100c27: e8 e4 21 00 00 call 80102e10 <end_op> 80100c2c: 83 c4 10 add $0x10,%esp } return -1; 80100c2f: b8 ff ff ff ff mov $0xffffffff,%eax } 80100c34: 8d 65 f4 lea -0xc(%ebp),%esp 80100c37: 5b pop %ebx 80100c38: 5e pop %esi 80100c39: 5f pop %edi 80100c3a: 5d pop %ebp 80100c3b: c3 ret int fsize=get_size_string(path); int found=0;//found == 0 if ip not found int size=get_size_string(add_path); int psize=get_size_string(path); int c=0; begin_op(); 80100c3c: e8 5f 21 00 00 call 80102da0 <begin_op> cprintf("exec: fail\n"); return -1; } } else{ ip=namei(path); 80100c41: 83 ec 0c sub $0xc,%esp 80100c44: 53 push %ebx 80100c45: e8 c6 14 00 00 call 80102110 <namei> if(ip == 0){ 80100c4a: 83 c4 10 add $0x10,%esp cprintf("exec: fail\n"); return -1; } } else{ ip=namei(path); 80100c4d: 89 c2 mov %eax,%edx 80100c4f: e9 6e ff ff ff jmp 80100bc2 <exec+0x1b2> pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) goto bad; if(elf.magic != ELF_MAGIC) 80100c54: 81 bd c0 fe ff ff 7f cmpl $0x464c457f,-0x140(%ebp) 80100c5b: 45 4c 46 80100c5e: 75 be jne 80100c1e <exec+0x20e> goto bad; if((pgdir = setupkvm()) == 0) 80100c60: e8 4b 71 00 00 call 80107db0 <setupkvm> 80100c65: 85 c0 test %eax,%eax 80100c67: 89 c6 mov %eax,%esi 80100c69: 8b 95 94 fe ff ff mov -0x16c(%ebp),%edx 80100c6f: 74 ad je 80100c1e <exec+0x20e> goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100c71: 66 83 bd ec fe ff ff cmpw $0x0,-0x114(%ebp) 80100c78: 00 80100c79: 8b 85 dc fe ff ff mov -0x124(%ebp),%eax 80100c7f: 89 85 90 fe ff ff mov %eax,-0x170(%ebp) 80100c85: 0f 84 27 01 00 00 je 80100db2 <exec+0x3a2> 80100c8b: 89 5d 08 mov %ebx,0x8(%ebp) 80100c8e: 31 ff xor %edi,%edi 80100c90: c7 85 94 fe ff ff 00 movl $0x0,-0x16c(%ebp) 80100c97: 00 00 00 80100c9a: 89 d3 mov %edx,%ebx 80100c9c: eb 25 jmp 80100cc3 <exec+0x2b3> 80100c9e: 66 90 xchg %ax,%ax 80100ca0: 83 85 94 fe ff ff 01 addl $0x1,-0x16c(%ebp) 80100ca7: 0f b7 85 ec fe ff ff movzwl -0x114(%ebp),%eax 80100cae: 8b 8d 94 fe ff ff mov -0x16c(%ebp),%ecx 80100cb4: 83 85 90 fe ff ff 20 addl $0x20,-0x170(%ebp) 80100cbb: 39 c8 cmp %ecx,%eax 80100cbd: 0f 8e 2f 01 00 00 jle 80100df2 <exec+0x3e2> if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) 80100cc3: 8d 85 a0 fe ff ff lea -0x160(%ebp),%eax 80100cc9: 6a 20 push $0x20 80100ccb: ff b5 90 fe ff ff pushl -0x170(%ebp) 80100cd1: 50 push %eax 80100cd2: 53 push %ebx 80100cd3: e8 c8 0e 00 00 call 80101ba0 <readi> 80100cd8: 83 c4 10 add $0x10,%esp 80100cdb: 83 f8 20 cmp $0x20,%eax 80100cde: 75 62 jne 80100d42 <exec+0x332> goto bad; if(ph.type != ELF_PROG_LOAD) 80100ce0: 83 bd a0 fe ff ff 01 cmpl $0x1,-0x160(%ebp) 80100ce7: 75 b7 jne 80100ca0 <exec+0x290> continue; if(ph.memsz < ph.filesz) 80100ce9: 8b 85 b4 fe ff ff mov -0x14c(%ebp),%eax 80100cef: 3b 85 b0 fe ff ff cmp -0x150(%ebp),%eax 80100cf5: 72 4b jb 80100d42 <exec+0x332> goto bad; if(ph.vaddr + ph.memsz < ph.vaddr) 80100cf7: 03 85 a8 fe ff ff add -0x158(%ebp),%eax 80100cfd: 72 43 jb 80100d42 <exec+0x332> goto bad; if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) 80100cff: 83 ec 04 sub $0x4,%esp 80100d02: 50 push %eax 80100d03: 57 push %edi 80100d04: 56 push %esi 80100d05: e8 f6 6e 00 00 call 80107c00 <allocuvm> 80100d0a: 83 c4 10 add $0x10,%esp 80100d0d: 85 c0 test %eax,%eax 80100d0f: 89 c7 mov %eax,%edi 80100d11: 74 2f je 80100d42 <exec+0x332> goto bad; if(ph.vaddr % PGSIZE != 0) 80100d13: 8b 85 a8 fe ff ff mov -0x158(%ebp),%eax 80100d19: a9 ff 0f 00 00 test $0xfff,%eax 80100d1e: 75 22 jne 80100d42 <exec+0x332> goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) 80100d20: 83 ec 0c sub $0xc,%esp 80100d23: ff b5 b0 fe ff ff pushl -0x150(%ebp) 80100d29: ff b5 a4 fe ff ff pushl -0x15c(%ebp) 80100d2f: 53 push %ebx 80100d30: 50 push %eax 80100d31: 56 push %esi 80100d32: e8 09 6e 00 00 call 80107b40 <loaduvm> 80100d37: 83 c4 20 add $0x20,%esp 80100d3a: 85 c0 test %eax,%eax 80100d3c: 0f 89 5e ff ff ff jns 80100ca0 <exec+0x290> 80100d42: 89 da mov %ebx,%edx freevm(oldpgdir); return 0; bad: if(pgdir) freevm(pgdir); 80100d44: 83 ec 0c sub $0xc,%esp 80100d47: 89 95 94 fe ff ff mov %edx,-0x16c(%ebp) 80100d4d: 56 push %esi 80100d4e: e8 dd 6f 00 00 call 80107d30 <freevm> if(ip){ 80100d53: 8b 95 94 fe ff ff mov -0x16c(%ebp),%edx 80100d59: 83 c4 10 add $0x10,%esp 80100d5c: 85 d2 test %edx,%edx 80100d5e: 0f 85 ba fe ff ff jne 80100c1e <exec+0x20e> iunlockput(ip); end_op(); } return -1; } 80100d64: 8d 65 f4 lea -0xc(%ebp),%esp freevm(pgdir); if(ip){ iunlockput(ip); end_op(); } return -1; 80100d67: b8 ff ff ff ff mov $0xffffffff,%eax } 80100d6c: 5b pop %ebx 80100d6d: 5e pop %esi 80100d6e: 5f pop %edi 80100d6f: 5d pop %ebp 80100d70: c3 ret #include "elf.h" int get_size_string(char* string){ int i=0; while(1){ if(string[i]=='\0') 80100d71: c7 85 94 fe ff ff 00 movl $0x0,-0x16c(%ebp) 80100d78: 00 00 00 80100d7b: e9 fa fc ff ff jmp 80100a7a <exec+0x6a> int fsize=get_size_string(path); int found=0;//found == 0 if ip not found int size=get_size_string(add_path); int psize=get_size_string(path); int c=0; begin_op(); 80100d80: e8 1b 20 00 00 call 80102da0 <begin_op> 80100d85: c7 85 88 fe ff ff 00 movl $0x0,-0x178(%ebp) 80100d8c: 00 00 00 80100d8f: e9 0e fd ff ff jmp 80100aa2 <exec+0x92> #include "elf.h" int get_size_string(char* string){ int i=0; while(1){ if(string[i]=='\0') 80100d94: 80 3d 20 0f 11 80 00 cmpb $0x0,0x80110f20 80100d9b: 0f 84 9b fe ff ff je 80100c3c <exec+0x22c> #include "defs.h" #include "x86.h" #include "elf.h" int get_size_string(char* string){ int i=0; 80100da1: 31 f6 xor %esi,%esi 80100da3: e9 ae fc ff ff jmp 80100a56 <exec+0x46> } } if(!found){ if(path[0]!='/'){ temp[0]='/'; for (c=0;c<psize;c++){ 80100da8: b8 01 00 00 00 mov $0x1,%eax 80100dad: e9 f4 fd ff ff jmp 80100ba6 <exec+0x196> if((pgdir = setupkvm()) == 0) goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100db2: b8 00 20 00 00 mov $0x2000,%eax 80100db7: 31 ff xor %edi,%edi if(ph.vaddr % PGSIZE != 0) goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) goto bad; } iunlockput(ip); 80100db9: 83 ec 0c sub $0xc,%esp 80100dbc: 89 85 94 fe ff ff mov %eax,-0x16c(%ebp) 80100dc2: 52 push %edx 80100dc3: e8 88 0d 00 00 call 80101b50 <iunlockput> end_op(); 80100dc8: e8 43 20 00 00 call 80102e10 <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); if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100dcd: 8b 85 94 fe ff ff mov -0x16c(%ebp),%eax 80100dd3: 83 c4 0c add $0xc,%esp 80100dd6: 50 push %eax 80100dd7: 57 push %edi 80100dd8: 56 push %esi 80100dd9: e8 22 6e 00 00 call 80107c00 <allocuvm> 80100dde: 83 c4 10 add $0x10,%esp 80100de1: 85 c0 test %eax,%eax 80100de3: 89 85 94 fe ff ff mov %eax,-0x16c(%ebp) 80100de9: 75 20 jne 80100e0b <exec+0x3fb> if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) goto bad; } iunlockput(ip); end_op(); ip = 0; 80100deb: 31 d2 xor %edx,%edx 80100ded: e9 52 ff ff ff jmp 80100d44 <exec+0x334> 80100df2: 81 c7 ff 0f 00 00 add $0xfff,%edi 80100df8: 89 da mov %ebx,%edx 80100dfa: 8b 5d 08 mov 0x8(%ebp),%ebx 80100dfd: 81 e7 00 f0 ff ff and $0xfffff000,%edi 80100e03: 8d 87 00 20 00 00 lea 0x2000(%edi),%eax 80100e09: eb ae jmp 80100db9 <exec+0x3a9> // 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)); 80100e0b: 8b bd 94 fe ff ff mov -0x16c(%ebp),%edi 80100e11: 83 ec 08 sub $0x8,%esp 80100e14: 89 f8 mov %edi,%eax 80100e16: 2d 00 20 00 00 sub $0x2000,%eax 80100e1b: 50 push %eax 80100e1c: 56 push %esi 80100e1d: e8 2e 70 00 00 call 80107e50 <clearpteu> sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100e22: 8b 45 0c mov 0xc(%ebp),%eax 80100e25: 83 c4 10 add $0x10,%esp 80100e28: 31 d2 xor %edx,%edx 80100e2a: 8b 08 mov (%eax),%ecx 80100e2c: 85 c9 test %ecx,%ecx 80100e2e: 74 6a je 80100e9a <exec+0x48a> 80100e30: 89 5d 08 mov %ebx,0x8(%ebp) 80100e33: 89 d3 mov %edx,%ebx if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100e35: 83 ec 0c sub $0xc,%esp 80100e38: 51 push %ecx 80100e39: e8 32 46 00 00 call 80105470 <strlen> 80100e3e: f7 d0 not %eax 80100e40: 01 c7 add %eax,%edi if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100e42: 58 pop %eax 80100e43: 8b 45 0c mov 0xc(%ebp),%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; 80100e46: 83 e7 fc and $0xfffffffc,%edi if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100e49: ff 34 98 pushl (%eax,%ebx,4) 80100e4c: e8 1f 46 00 00 call 80105470 <strlen> 80100e51: 83 c0 01 add $0x1,%eax 80100e54: 50 push %eax 80100e55: 8b 45 0c mov 0xc(%ebp),%eax 80100e58: ff 34 98 pushl (%eax,%ebx,4) 80100e5b: 57 push %edi 80100e5c: 56 push %esi 80100e5d: e8 5e 71 00 00 call 80107fc0 <copyout> 80100e62: 83 c4 20 add $0x20,%esp 80100e65: 85 c0 test %eax,%eax 80100e67: 78 82 js 80100deb <exec+0x3db> goto bad; ustack[3+argc] = sp; 80100e69: 8d 85 58 ff ff ff lea -0xa8(%ebp),%eax 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++) { 80100e6f: 8b 4d 0c mov 0xc(%ebp),%ecx 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; 80100e72: 89 bc 9d 64 ff ff ff mov %edi,-0x9c(%ebp,%ebx,4) 80100e79: 89 85 88 fe ff ff mov %eax,-0x178(%ebp) 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++) { 80100e7f: 8d 43 01 lea 0x1(%ebx),%eax 80100e82: 8b 0c 81 mov (%ecx,%eax,4),%ecx 80100e85: 85 c9 test %ecx,%ecx 80100e87: 0f 84 f8 00 00 00 je 80100f85 <exec+0x575> if(argc >= MAXARG) 80100e8d: 83 f8 20 cmp $0x20,%eax 80100e90: 0f 84 55 ff ff ff je 80100deb <exec+0x3db> 80100e96: 89 c3 mov %eax,%ebx 80100e98: eb 9b jmp 80100e35 <exec+0x425> 80100e9a: 8d 85 58 ff ff ff lea -0xa8(%ebp),%eax 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++) { 80100ea0: 8b bd 94 fe ff ff mov -0x16c(%ebp),%edi 80100ea6: b9 10 00 00 00 mov $0x10,%ecx 80100eab: ba 04 00 00 00 mov $0x4,%edx 80100eb0: c7 85 8c fe ff ff 03 movl $0x3,-0x174(%ebp) 80100eb7: 00 00 00 80100eba: c7 85 90 fe ff ff 00 movl $0x0,-0x170(%ebp) 80100ec1: 00 00 00 80100ec4: 89 85 88 fe ff ff mov %eax,-0x178(%ebp) 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; 80100eca: 8b 85 8c fe ff ff mov -0x174(%ebp),%eax ustack[0] = 0xffffffff; // fake return PC 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) 80100ed0: 51 push %ecx 80100ed1: ff b5 88 fe ff ff pushl -0x178(%ebp) 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; 80100ed7: c7 84 85 58 ff ff ff movl $0x0,-0xa8(%ebp,%eax,4) 80100ede: 00 00 00 00 ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; 80100ee2: 8b 85 90 fe ff ff mov -0x170(%ebp),%eax goto bad; ustack[3+argc] = sp; } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC 80100ee8: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp) 80100eef: ff ff ff ustack[1] = argc; 80100ef2: 89 85 5c ff ff ff mov %eax,-0xa4(%ebp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100ef8: 89 f8 mov %edi,%eax sp -= (3+argc+1) * 4; 80100efa: 29 cf sub %ecx,%edi if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100efc: 57 push %edi 80100efd: 56 push %esi } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer 80100efe: 29 d0 sub %edx,%eax 80100f00: 89 85 60 ff ff ff mov %eax,-0xa0(%ebp) sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100f06: e8 b5 70 00 00 call 80107fc0 <copyout> 80100f0b: 83 c4 10 add $0x10,%esp 80100f0e: 85 c0 test %eax,%eax 80100f10: 0f 88 d5 fe ff ff js 80100deb <exec+0x3db> goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100f16: 0f b6 13 movzbl (%ebx),%edx 80100f19: 84 d2 test %dl,%dl 80100f1b: 74 13 je 80100f30 <exec+0x520> 80100f1d: 8d 43 01 lea 0x1(%ebx),%eax if(*s == '/') last = s+1; 80100f20: 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++) 80100f23: 0f b6 10 movzbl (%eax),%edx if(*s == '/') last = s+1; 80100f26: 0f 44 d8 cmove %eax,%ebx 80100f29: 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++) 80100f2c: 84 d2 test %dl,%dl 80100f2e: 75 f0 jne 80100f20 <exec+0x510> if(*s == '/') last = s+1; safestrcpy(curproc->name, last, sizeof(curproc->name)); 80100f30: 83 ec 04 sub $0x4,%esp 80100f33: 6a 10 push $0x10 80100f35: 53 push %ebx 80100f36: 8b 9d 84 fe ff ff mov -0x17c(%ebp),%ebx 80100f3c: 89 d8 mov %ebx,%eax 80100f3e: 83 c0 6c add $0x6c,%eax 80100f41: 50 push %eax 80100f42: e8 e9 44 00 00 call 80105430 <safestrcpy> // Commit to the user image. oldpgdir = curproc->pgdir; 80100f47: 89 d8 mov %ebx,%eax 80100f49: 8b 5b 04 mov 0x4(%ebx),%ebx curproc->pgdir = pgdir; 80100f4c: 89 70 04 mov %esi,0x4(%eax) curproc->sz = sz; 80100f4f: 8b b5 94 fe ff ff mov -0x16c(%ebp),%esi 80100f55: 89 30 mov %esi,(%eax) /*curproc->start = 1; curproc->finish = 100000; curproc->queuenum = 1;*/ curproc->tf->eip = elf.entry; // main 80100f57: 89 c6 mov %eax,%esi 80100f59: 8b 95 d8 fe ff ff mov -0x128(%ebp),%edx 80100f5f: 8b 40 18 mov 0x18(%eax),%eax 80100f62: 89 50 38 mov %edx,0x38(%eax) curproc->tf->esp = sp; 80100f65: 8b 46 18 mov 0x18(%esi),%eax 80100f68: 89 78 44 mov %edi,0x44(%eax) switchuvm(curproc); 80100f6b: 89 34 24 mov %esi,(%esp) 80100f6e: e8 3d 6a 00 00 call 801079b0 <switchuvm> freevm(oldpgdir); 80100f73: 89 1c 24 mov %ebx,(%esp) 80100f76: e8 b5 6d 00 00 call 80107d30 <freevm> return 0; 80100f7b: 83 c4 10 add $0x10,%esp 80100f7e: 31 c0 xor %eax,%eax 80100f80: e9 af fc ff ff jmp 80100c34 <exec+0x224> 80100f85: 89 da mov %ebx,%edx 80100f87: 89 85 90 fe ff ff mov %eax,-0x170(%ebp) 80100f8d: 8b 5d 08 mov 0x8(%ebp),%ebx 80100f90: 8d 42 04 lea 0x4(%edx),%eax 80100f93: 8d 14 95 08 00 00 00 lea 0x8(,%edx,4),%edx 80100f9a: 89 85 8c fe ff ff mov %eax,-0x174(%ebp) 80100fa0: 8d 4a 0c lea 0xc(%edx),%ecx 80100fa3: e9 22 ff ff ff jmp 80100eca <exec+0x4ba> 80100fa8: 66 90 xchg %ax,%ax 80100faa: 66 90 xchg %ax,%ax 80100fac: 66 90 xchg %ax,%ax 80100fae: 66 90 xchg %ax,%ax 80100fb0 <fileinit>: struct file file[NFILE]; } ftable; void fileinit(void) { 80100fb0: 55 push %ebp 80100fb1: 89 e5 mov %esp,%ebp 80100fb3: 83 ec 10 sub $0x10,%esp initlock(&ftable.lock, "ftable"); 80100fb6: 68 ed 80 10 80 push $0x801080ed 80100fbb: 68 40 10 11 80 push $0x80111040 80100fc0: e8 0b 40 00 00 call 80104fd0 <initlock> } 80100fc5: 83 c4 10 add $0x10,%esp 80100fc8: c9 leave 80100fc9: c3 ret 80100fca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100fd0 <filealloc>: // Allocate a file structure. struct file* filealloc(void) { 80100fd0: 55 push %ebp 80100fd1: 89 e5 mov %esp,%ebp 80100fd3: 53 push %ebx struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100fd4: bb 74 10 11 80 mov $0x80111074,%ebx } // Allocate a file structure. struct file* filealloc(void) { 80100fd9: 83 ec 10 sub $0x10,%esp struct file *f; acquire(&ftable.lock); 80100fdc: 68 40 10 11 80 push $0x80111040 80100fe1: e8 4a 41 00 00 call 80105130 <acquire> 80100fe6: 83 c4 10 add $0x10,%esp 80100fe9: eb 10 jmp 80100ffb <filealloc+0x2b> 80100feb: 90 nop 80100fec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100ff0: 83 c3 18 add $0x18,%ebx 80100ff3: 81 fb d4 19 11 80 cmp $0x801119d4,%ebx 80100ff9: 74 25 je 80101020 <filealloc+0x50> if(f->ref == 0){ 80100ffb: 8b 43 04 mov 0x4(%ebx),%eax 80100ffe: 85 c0 test %eax,%eax 80101000: 75 ee jne 80100ff0 <filealloc+0x20> f->ref = 1; release(&ftable.lock); 80101002: 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; 80101005: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) release(&ftable.lock); 8010100c: 68 40 10 11 80 push $0x80111040 80101011: e8 ca 41 00 00 call 801051e0 <release> return f; 80101016: 89 d8 mov %ebx,%eax 80101018: 83 c4 10 add $0x10,%esp } } release(&ftable.lock); return 0; } 8010101b: 8b 5d fc mov -0x4(%ebp),%ebx 8010101e: c9 leave 8010101f: c3 ret f->ref = 1; release(&ftable.lock); return f; } } release(&ftable.lock); 80101020: 83 ec 0c sub $0xc,%esp 80101023: 68 40 10 11 80 push $0x80111040 80101028: e8 b3 41 00 00 call 801051e0 <release> return 0; 8010102d: 83 c4 10 add $0x10,%esp 80101030: 31 c0 xor %eax,%eax } 80101032: 8b 5d fc mov -0x4(%ebp),%ebx 80101035: c9 leave 80101036: c3 ret 80101037: 89 f6 mov %esi,%esi 80101039: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101040 <filedup>: // Increment ref count for file f. struct file* filedup(struct file *f) { 80101040: 55 push %ebp 80101041: 89 e5 mov %esp,%ebp 80101043: 53 push %ebx 80101044: 83 ec 10 sub $0x10,%esp 80101047: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ftable.lock); 8010104a: 68 40 10 11 80 push $0x80111040 8010104f: e8 dc 40 00 00 call 80105130 <acquire> if(f->ref < 1) 80101054: 8b 43 04 mov 0x4(%ebx),%eax 80101057: 83 c4 10 add $0x10,%esp 8010105a: 85 c0 test %eax,%eax 8010105c: 7e 1a jle 80101078 <filedup+0x38> panic("filedup"); f->ref++; 8010105e: 83 c0 01 add $0x1,%eax release(&ftable.lock); 80101061: 83 ec 0c sub $0xc,%esp filedup(struct file *f) { acquire(&ftable.lock); if(f->ref < 1) panic("filedup"); f->ref++; 80101064: 89 43 04 mov %eax,0x4(%ebx) release(&ftable.lock); 80101067: 68 40 10 11 80 push $0x80111040 8010106c: e8 6f 41 00 00 call 801051e0 <release> return f; } 80101071: 89 d8 mov %ebx,%eax 80101073: 8b 5d fc mov -0x4(%ebp),%ebx 80101076: c9 leave 80101077: c3 ret struct file* filedup(struct file *f) { acquire(&ftable.lock); if(f->ref < 1) panic("filedup"); 80101078: 83 ec 0c sub $0xc,%esp 8010107b: 68 f4 80 10 80 push $0x801080f4 80101080: e8 eb f2 ff ff call 80100370 <panic> 80101085: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101089: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101090 <fileclose>: } // Close file f. (Decrement ref count, close when reaches 0.) void fileclose(struct file *f) { 80101090: 55 push %ebp 80101091: 89 e5 mov %esp,%ebp 80101093: 57 push %edi 80101094: 56 push %esi 80101095: 53 push %ebx 80101096: 83 ec 28 sub $0x28,%esp 80101099: 8b 7d 08 mov 0x8(%ebp),%edi struct file ff; acquire(&ftable.lock); 8010109c: 68 40 10 11 80 push $0x80111040 801010a1: e8 8a 40 00 00 call 80105130 <acquire> if(f->ref < 1) 801010a6: 8b 47 04 mov 0x4(%edi),%eax 801010a9: 83 c4 10 add $0x10,%esp 801010ac: 85 c0 test %eax,%eax 801010ae: 0f 8e 9b 00 00 00 jle 8010114f <fileclose+0xbf> panic("fileclose"); if(--f->ref > 0){ 801010b4: 83 e8 01 sub $0x1,%eax 801010b7: 85 c0 test %eax,%eax 801010b9: 89 47 04 mov %eax,0x4(%edi) 801010bc: 74 1a je 801010d8 <fileclose+0x48> release(&ftable.lock); 801010be: c7 45 08 40 10 11 80 movl $0x80111040,0x8(%ebp) else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); } } 801010c5: 8d 65 f4 lea -0xc(%ebp),%esp 801010c8: 5b pop %ebx 801010c9: 5e pop %esi 801010ca: 5f pop %edi 801010cb: 5d pop %ebp acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); 801010cc: e9 0f 41 00 00 jmp 801051e0 <release> 801010d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return; } ff = *f; 801010d8: 0f b6 47 09 movzbl 0x9(%edi),%eax 801010dc: 8b 1f mov (%edi),%ebx f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 801010de: 83 ec 0c sub $0xc,%esp panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 801010e1: 8b 77 0c mov 0xc(%edi),%esi f->ref = 0; f->type = FD_NONE; 801010e4: c7 07 00 00 00 00 movl $0x0,(%edi) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 801010ea: 88 45 e7 mov %al,-0x19(%ebp) 801010ed: 8b 47 10 mov 0x10(%edi),%eax f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 801010f0: 68 40 10 11 80 push $0x80111040 panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); return; } ff = *f; 801010f5: 89 45 e0 mov %eax,-0x20(%ebp) f->ref = 0; f->type = FD_NONE; release(&ftable.lock); 801010f8: e8 e3 40 00 00 call 801051e0 <release> if(ff.type == FD_PIPE) 801010fd: 83 c4 10 add $0x10,%esp 80101100: 83 fb 01 cmp $0x1,%ebx 80101103: 74 13 je 80101118 <fileclose+0x88> pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ 80101105: 83 fb 02 cmp $0x2,%ebx 80101108: 74 26 je 80101130 <fileclose+0xa0> begin_op(); iput(ff.ip); end_op(); } } 8010110a: 8d 65 f4 lea -0xc(%ebp),%esp 8010110d: 5b pop %ebx 8010110e: 5e pop %esi 8010110f: 5f pop %edi 80101110: 5d pop %ebp 80101111: c3 ret 80101112: 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); 80101118: 0f be 5d e7 movsbl -0x19(%ebp),%ebx 8010111c: 83 ec 08 sub $0x8,%esp 8010111f: 53 push %ebx 80101120: 56 push %esi 80101121: e8 1a 24 00 00 call 80103540 <pipeclose> 80101126: 83 c4 10 add $0x10,%esp 80101129: eb df jmp 8010110a <fileclose+0x7a> 8010112b: 90 nop 8010112c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi else if(ff.type == FD_INODE){ begin_op(); 80101130: e8 6b 1c 00 00 call 80102da0 <begin_op> iput(ff.ip); 80101135: 83 ec 0c sub $0xc,%esp 80101138: ff 75 e0 pushl -0x20(%ebp) 8010113b: e8 b0 08 00 00 call 801019f0 <iput> end_op(); 80101140: 83 c4 10 add $0x10,%esp } } 80101143: 8d 65 f4 lea -0xc(%ebp),%esp 80101146: 5b pop %ebx 80101147: 5e pop %esi 80101148: 5f pop %edi 80101149: 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(); 8010114a: e9 c1 1c 00 00 jmp 80102e10 <end_op> { struct file ff; acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); 8010114f: 83 ec 0c sub $0xc,%esp 80101152: 68 fc 80 10 80 push $0x801080fc 80101157: e8 14 f2 ff ff call 80100370 <panic> 8010115c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101160 <filestat>: } // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 80101160: 55 push %ebp 80101161: 89 e5 mov %esp,%ebp 80101163: 53 push %ebx 80101164: 83 ec 04 sub $0x4,%esp 80101167: 8b 5d 08 mov 0x8(%ebp),%ebx if(f->type == FD_INODE){ 8010116a: 83 3b 02 cmpl $0x2,(%ebx) 8010116d: 75 31 jne 801011a0 <filestat+0x40> ilock(f->ip); 8010116f: 83 ec 0c sub $0xc,%esp 80101172: ff 73 10 pushl 0x10(%ebx) 80101175: e8 46 07 00 00 call 801018c0 <ilock> stati(f->ip, st); 8010117a: 58 pop %eax 8010117b: 5a pop %edx 8010117c: ff 75 0c pushl 0xc(%ebp) 8010117f: ff 73 10 pushl 0x10(%ebx) 80101182: e8 e9 09 00 00 call 80101b70 <stati> iunlock(f->ip); 80101187: 59 pop %ecx 80101188: ff 73 10 pushl 0x10(%ebx) 8010118b: e8 10 08 00 00 call 801019a0 <iunlock> return 0; 80101190: 83 c4 10 add $0x10,%esp 80101193: 31 c0 xor %eax,%eax } return -1; } 80101195: 8b 5d fc mov -0x4(%ebp),%ebx 80101198: c9 leave 80101199: c3 ret 8010119a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ilock(f->ip); stati(f->ip, st); iunlock(f->ip); return 0; } return -1; 801011a0: b8 ff ff ff ff mov $0xffffffff,%eax } 801011a5: 8b 5d fc mov -0x4(%ebp),%ebx 801011a8: c9 leave 801011a9: c3 ret 801011aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801011b0 <fileread>: // Read from file f. int fileread(struct file *f, char *addr, int n) { 801011b0: 55 push %ebp 801011b1: 89 e5 mov %esp,%ebp 801011b3: 57 push %edi 801011b4: 56 push %esi 801011b5: 53 push %ebx 801011b6: 83 ec 0c sub $0xc,%esp 801011b9: 8b 5d 08 mov 0x8(%ebp),%ebx 801011bc: 8b 75 0c mov 0xc(%ebp),%esi 801011bf: 8b 7d 10 mov 0x10(%ebp),%edi int r; if(f->readable == 0) 801011c2: 80 7b 08 00 cmpb $0x0,0x8(%ebx) 801011c6: 74 60 je 80101228 <fileread+0x78> return -1; if(f->type == FD_PIPE) 801011c8: 8b 03 mov (%ebx),%eax 801011ca: 83 f8 01 cmp $0x1,%eax 801011cd: 74 41 je 80101210 <fileread+0x60> return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ 801011cf: 83 f8 02 cmp $0x2,%eax 801011d2: 75 5b jne 8010122f <fileread+0x7f> ilock(f->ip); 801011d4: 83 ec 0c sub $0xc,%esp 801011d7: ff 73 10 pushl 0x10(%ebx) 801011da: e8 e1 06 00 00 call 801018c0 <ilock> if((r = readi(f->ip, addr, f->off, n)) > 0) 801011df: 57 push %edi 801011e0: ff 73 14 pushl 0x14(%ebx) 801011e3: 56 push %esi 801011e4: ff 73 10 pushl 0x10(%ebx) 801011e7: e8 b4 09 00 00 call 80101ba0 <readi> 801011ec: 83 c4 20 add $0x20,%esp 801011ef: 85 c0 test %eax,%eax 801011f1: 89 c6 mov %eax,%esi 801011f3: 7e 03 jle 801011f8 <fileread+0x48> f->off += r; 801011f5: 01 43 14 add %eax,0x14(%ebx) iunlock(f->ip); 801011f8: 83 ec 0c sub $0xc,%esp 801011fb: ff 73 10 pushl 0x10(%ebx) 801011fe: e8 9d 07 00 00 call 801019a0 <iunlock> return r; 80101203: 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) 80101206: 89 f0 mov %esi,%eax f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80101208: 8d 65 f4 lea -0xc(%ebp),%esp 8010120b: 5b pop %ebx 8010120c: 5e pop %esi 8010120d: 5f pop %edi 8010120e: 5d pop %ebp 8010120f: c3 ret int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80101210: 8b 43 0c mov 0xc(%ebx),%eax 80101213: 89 45 08 mov %eax,0x8(%ebp) f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80101216: 8d 65 f4 lea -0xc(%ebp),%esp 80101219: 5b pop %ebx 8010121a: 5e pop %esi 8010121b: 5f pop %edi 8010121c: 5d pop %ebp int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 8010121d: e9 be 24 00 00 jmp 801036e0 <piperead> 80101222: 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; 80101228: b8 ff ff ff ff mov $0xffffffff,%eax 8010122d: eb d9 jmp 80101208 <fileread+0x58> if((r = readi(f->ip, addr, f->off, n)) > 0) f->off += r; iunlock(f->ip); return r; } panic("fileread"); 8010122f: 83 ec 0c sub $0xc,%esp 80101232: 68 06 81 10 80 push $0x80108106 80101237: e8 34 f1 ff ff call 80100370 <panic> 8010123c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101240 <filewrite>: //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80101240: 55 push %ebp 80101241: 89 e5 mov %esp,%ebp 80101243: 57 push %edi 80101244: 56 push %esi 80101245: 53 push %ebx 80101246: 83 ec 1c sub $0x1c,%esp 80101249: 8b 75 08 mov 0x8(%ebp),%esi 8010124c: 8b 45 0c mov 0xc(%ebp),%eax int r; if(f->writable == 0) 8010124f: 80 7e 09 00 cmpb $0x0,0x9(%esi) //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80101253: 89 45 dc mov %eax,-0x24(%ebp) 80101256: 8b 45 10 mov 0x10(%ebp),%eax 80101259: 89 45 e4 mov %eax,-0x1c(%ebp) int r; if(f->writable == 0) 8010125c: 0f 84 aa 00 00 00 je 8010130c <filewrite+0xcc> return -1; if(f->type == FD_PIPE) 80101262: 8b 06 mov (%esi),%eax 80101264: 83 f8 01 cmp $0x1,%eax 80101267: 0f 84 c2 00 00 00 je 8010132f <filewrite+0xef> return pipewrite(f->pipe, addr, n); if(f->type == FD_INODE){ 8010126d: 83 f8 02 cmp $0x2,%eax 80101270: 0f 85 d8 00 00 00 jne 8010134e <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){ 80101276: 8b 45 e4 mov -0x1c(%ebp),%eax 80101279: 31 ff xor %edi,%edi 8010127b: 85 c0 test %eax,%eax 8010127d: 7f 34 jg 801012b3 <filewrite+0x73> 8010127f: e9 9c 00 00 00 jmp 80101320 <filewrite+0xe0> 80101284: 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; 80101288: 01 46 14 add %eax,0x14(%esi) iunlock(f->ip); 8010128b: 83 ec 0c sub $0xc,%esp 8010128e: 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; 80101291: 89 45 e0 mov %eax,-0x20(%ebp) iunlock(f->ip); 80101294: e8 07 07 00 00 call 801019a0 <iunlock> end_op(); 80101299: e8 72 1b 00 00 call 80102e10 <end_op> 8010129e: 8b 45 e0 mov -0x20(%ebp),%eax 801012a1: 83 c4 10 add $0x10,%esp if(r < 0) break; if(r != n1) 801012a4: 39 d8 cmp %ebx,%eax 801012a6: 0f 85 95 00 00 00 jne 80101341 <filewrite+0x101> panic("short filewrite"); i += r; 801012ac: 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){ 801012ae: 39 7d e4 cmp %edi,-0x1c(%ebp) 801012b1: 7e 6d jle 80101320 <filewrite+0xe0> int n1 = n - i; 801012b3: 8b 5d e4 mov -0x1c(%ebp),%ebx 801012b6: b8 00 06 00 00 mov $0x600,%eax 801012bb: 29 fb sub %edi,%ebx 801012bd: 81 fb 00 06 00 00 cmp $0x600,%ebx 801012c3: 0f 4f d8 cmovg %eax,%ebx if(n1 > max) n1 = max; begin_op(); 801012c6: e8 d5 1a 00 00 call 80102da0 <begin_op> ilock(f->ip); 801012cb: 83 ec 0c sub $0xc,%esp 801012ce: ff 76 10 pushl 0x10(%esi) 801012d1: e8 ea 05 00 00 call 801018c0 <ilock> if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) 801012d6: 8b 45 dc mov -0x24(%ebp),%eax 801012d9: 53 push %ebx 801012da: ff 76 14 pushl 0x14(%esi) 801012dd: 01 f8 add %edi,%eax 801012df: 50 push %eax 801012e0: ff 76 10 pushl 0x10(%esi) 801012e3: e8 b8 09 00 00 call 80101ca0 <writei> 801012e8: 83 c4 20 add $0x20,%esp 801012eb: 85 c0 test %eax,%eax 801012ed: 7f 99 jg 80101288 <filewrite+0x48> f->off += r; iunlock(f->ip); 801012ef: 83 ec 0c sub $0xc,%esp 801012f2: ff 76 10 pushl 0x10(%esi) 801012f5: 89 45 e0 mov %eax,-0x20(%ebp) 801012f8: e8 a3 06 00 00 call 801019a0 <iunlock> end_op(); 801012fd: e8 0e 1b 00 00 call 80102e10 <end_op> if(r < 0) 80101302: 8b 45 e0 mov -0x20(%ebp),%eax 80101305: 83 c4 10 add $0x10,%esp 80101308: 85 c0 test %eax,%eax 8010130a: 74 98 je 801012a4 <filewrite+0x64> i += r; } return i == n ? n : -1; } panic("filewrite"); } 8010130c: 8d 65 f4 lea -0xc(%ebp),%esp break; if(r != n1) panic("short filewrite"); i += r; } return i == n ? n : -1; 8010130f: b8 ff ff ff ff mov $0xffffffff,%eax } panic("filewrite"); } 80101314: 5b pop %ebx 80101315: 5e pop %esi 80101316: 5f pop %edi 80101317: 5d pop %ebp 80101318: c3 ret 80101319: 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; 80101320: 3b 7d e4 cmp -0x1c(%ebp),%edi 80101323: 75 e7 jne 8010130c <filewrite+0xcc> } panic("filewrite"); } 80101325: 8d 65 f4 lea -0xc(%ebp),%esp 80101328: 89 f8 mov %edi,%eax 8010132a: 5b pop %ebx 8010132b: 5e pop %esi 8010132c: 5f pop %edi 8010132d: 5d pop %ebp 8010132e: c3 ret int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 8010132f: 8b 46 0c mov 0xc(%esi),%eax 80101332: 89 45 08 mov %eax,0x8(%ebp) i += r; } return i == n ? n : -1; } panic("filewrite"); } 80101335: 8d 65 f4 lea -0xc(%ebp),%esp 80101338: 5b pop %ebx 80101339: 5e pop %esi 8010133a: 5f pop %edi 8010133b: 5d pop %ebp int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 8010133c: e9 9f 22 00 00 jmp 801035e0 <pipewrite> end_op(); if(r < 0) break; if(r != n1) panic("short filewrite"); 80101341: 83 ec 0c sub $0xc,%esp 80101344: 68 0f 81 10 80 push $0x8010810f 80101349: e8 22 f0 ff ff call 80100370 <panic> i += r; } return i == n ? n : -1; } panic("filewrite"); 8010134e: 83 ec 0c sub $0xc,%esp 80101351: 68 15 81 10 80 push $0x80108115 80101356: e8 15 f0 ff ff call 80100370 <panic> 8010135b: 66 90 xchg %ax,%ax 8010135d: 66 90 xchg %ax,%ax 8010135f: 90 nop 80101360 <bfree>: } // Free a disk block. static void bfree(int dev, uint b) { 80101360: 55 push %ebp 80101361: 89 e5 mov %esp,%ebp 80101363: 56 push %esi 80101364: 53 push %ebx 80101365: 89 d3 mov %edx,%ebx struct buf *bp; int bi, m; bp = bread(dev, BBLOCK(b, sb)); 80101367: c1 ea 0c shr $0xc,%edx 8010136a: 03 15 58 1a 11 80 add 0x80111a58,%edx 80101370: 83 ec 08 sub $0x8,%esp 80101373: 52 push %edx 80101374: 50 push %eax 80101375: e8 56 ed ff ff call 801000d0 <bread> bi = b % BPB; m = 1 << (bi % 8); 8010137a: 89 d9 mov %ebx,%ecx if((bp->data[bi/8] & m) == 0) 8010137c: 81 e3 ff 0f 00 00 and $0xfff,%ebx struct buf *bp; int bi, m; bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); 80101382: ba 01 00 00 00 mov $0x1,%edx 80101387: 83 e1 07 and $0x7,%ecx if((bp->data[bi/8] & m) == 0) 8010138a: c1 fb 03 sar $0x3,%ebx 8010138d: 83 c4 10 add $0x10,%esp struct buf *bp; int bi, m; bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); 80101390: d3 e2 shl %cl,%edx if((bp->data[bi/8] & m) == 0) 80101392: 0f b6 4c 18 5c movzbl 0x5c(%eax,%ebx,1),%ecx 80101397: 85 d1 test %edx,%ecx 80101399: 74 27 je 801013c2 <bfree+0x62> 8010139b: 89 c6 mov %eax,%esi panic("freeing free block"); bp->data[bi/8] &= ~m; 8010139d: f7 d2 not %edx 8010139f: 89 c8 mov %ecx,%eax log_write(bp); 801013a1: 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; 801013a4: 21 d0 and %edx,%eax 801013a6: 88 44 1e 5c mov %al,0x5c(%esi,%ebx,1) log_write(bp); 801013aa: 56 push %esi 801013ab: e8 d0 1b 00 00 call 80102f80 <log_write> brelse(bp); 801013b0: 89 34 24 mov %esi,(%esp) 801013b3: e8 28 ee ff ff call 801001e0 <brelse> } 801013b8: 83 c4 10 add $0x10,%esp 801013bb: 8d 65 f8 lea -0x8(%ebp),%esp 801013be: 5b pop %ebx 801013bf: 5e pop %esi 801013c0: 5d pop %ebp 801013c1: c3 ret bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) panic("freeing free block"); 801013c2: 83 ec 0c sub $0xc,%esp 801013c5: 68 1f 81 10 80 push $0x8010811f 801013ca: e8 a1 ef ff ff call 80100370 <panic> 801013cf: 90 nop 801013d0 <balloc>: // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 801013d0: 55 push %ebp 801013d1: 89 e5 mov %esp,%ebp 801013d3: 57 push %edi 801013d4: 56 push %esi 801013d5: 53 push %ebx 801013d6: 83 ec 1c sub $0x1c,%esp int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 801013d9: 8b 0d 40 1a 11 80 mov 0x80111a40,%ecx // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 801013df: 89 45 d8 mov %eax,-0x28(%ebp) int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 801013e2: 85 c9 test %ecx,%ecx 801013e4: 0f 84 85 00 00 00 je 8010146f <balloc+0x9f> 801013ea: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) bp = bread(dev, BBLOCK(b, sb)); 801013f1: 8b 75 dc mov -0x24(%ebp),%esi 801013f4: 83 ec 08 sub $0x8,%esp 801013f7: 89 f0 mov %esi,%eax 801013f9: c1 f8 0c sar $0xc,%eax 801013fc: 03 05 58 1a 11 80 add 0x80111a58,%eax 80101402: 50 push %eax 80101403: ff 75 d8 pushl -0x28(%ebp) 80101406: e8 c5 ec ff ff call 801000d0 <bread> 8010140b: 89 45 e4 mov %eax,-0x1c(%ebp) 8010140e: a1 40 1a 11 80 mov 0x80111a40,%eax 80101413: 83 c4 10 add $0x10,%esp 80101416: 89 45 e0 mov %eax,-0x20(%ebp) for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 80101419: 31 c0 xor %eax,%eax 8010141b: eb 2d jmp 8010144a <balloc+0x7a> 8010141d: 8d 76 00 lea 0x0(%esi),%esi m = 1 << (bi % 8); 80101420: 89 c1 mov %eax,%ecx 80101422: ba 01 00 00 00 mov $0x1,%edx if((bp->data[bi/8] & m) == 0){ // Is block free? 80101427: 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); 8010142a: 83 e1 07 and $0x7,%ecx 8010142d: d3 e2 shl %cl,%edx if((bp->data[bi/8] & m) == 0){ // Is block free? 8010142f: 89 c1 mov %eax,%ecx 80101431: c1 f9 03 sar $0x3,%ecx 80101434: 0f b6 7c 0b 5c movzbl 0x5c(%ebx,%ecx,1),%edi 80101439: 85 d7 test %edx,%edi 8010143b: 74 43 je 80101480 <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++){ 8010143d: 83 c0 01 add $0x1,%eax 80101440: 83 c6 01 add $0x1,%esi 80101443: 3d 00 10 00 00 cmp $0x1000,%eax 80101448: 74 05 je 8010144f <balloc+0x7f> 8010144a: 3b 75 e0 cmp -0x20(%ebp),%esi 8010144d: 72 d1 jb 80101420 <balloc+0x50> brelse(bp); bzero(dev, b + bi); return b + bi; } } brelse(bp); 8010144f: 83 ec 0c sub $0xc,%esp 80101452: ff 75 e4 pushl -0x1c(%ebp) 80101455: e8 86 ed ff ff call 801001e0 <brelse> { int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 8010145a: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) 80101461: 83 c4 10 add $0x10,%esp 80101464: 8b 45 dc mov -0x24(%ebp),%eax 80101467: 39 05 40 1a 11 80 cmp %eax,0x80111a40 8010146d: 77 82 ja 801013f1 <balloc+0x21> return b + bi; } } brelse(bp); } panic("balloc: out of blocks"); 8010146f: 83 ec 0c sub $0xc,%esp 80101472: 68 32 81 10 80 push $0x80108132 80101477: e8 f4 ee ff ff call 80100370 <panic> 8010147c: 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. 80101480: 09 fa or %edi,%edx 80101482: 8b 7d e4 mov -0x1c(%ebp),%edi log_write(bp); 80101485: 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. 80101488: 88 54 0f 5c mov %dl,0x5c(%edi,%ecx,1) log_write(bp); 8010148c: 57 push %edi 8010148d: e8 ee 1a 00 00 call 80102f80 <log_write> brelse(bp); 80101492: 89 3c 24 mov %edi,(%esp) 80101495: e8 46 ed ff ff call 801001e0 <brelse> static void bzero(int dev, int bno) { struct buf *bp; bp = bread(dev, bno); 8010149a: 58 pop %eax 8010149b: 5a pop %edx 8010149c: 56 push %esi 8010149d: ff 75 d8 pushl -0x28(%ebp) 801014a0: e8 2b ec ff ff call 801000d0 <bread> 801014a5: 89 c3 mov %eax,%ebx memset(bp->data, 0, BSIZE); 801014a7: 8d 40 5c lea 0x5c(%eax),%eax 801014aa: 83 c4 0c add $0xc,%esp 801014ad: 68 00 02 00 00 push $0x200 801014b2: 6a 00 push $0x0 801014b4: 50 push %eax 801014b5: e8 76 3d 00 00 call 80105230 <memset> log_write(bp); 801014ba: 89 1c 24 mov %ebx,(%esp) 801014bd: e8 be 1a 00 00 call 80102f80 <log_write> brelse(bp); 801014c2: 89 1c 24 mov %ebx,(%esp) 801014c5: e8 16 ed ff ff call 801001e0 <brelse> } } brelse(bp); } panic("balloc: out of blocks"); } 801014ca: 8d 65 f4 lea -0xc(%ebp),%esp 801014cd: 89 f0 mov %esi,%eax 801014cf: 5b pop %ebx 801014d0: 5e pop %esi 801014d1: 5f pop %edi 801014d2: 5d pop %ebp 801014d3: c3 ret 801014d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801014da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801014e0 <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) { 801014e0: 55 push %ebp 801014e1: 89 e5 mov %esp,%ebp 801014e3: 57 push %edi 801014e4: 56 push %esi 801014e5: 53 push %ebx 801014e6: 89 c7 mov %eax,%edi struct inode *ip, *empty; acquire(&icache.lock); // Is the inode already cached? empty = 0; 801014e8: 31 f6 xor %esi,%esi for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 801014ea: bb 94 1a 11 80 mov $0x80111a94,%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) { 801014ef: 83 ec 28 sub $0x28,%esp 801014f2: 89 55 e4 mov %edx,-0x1c(%ebp) struct inode *ip, *empty; acquire(&icache.lock); 801014f5: 68 60 1a 11 80 push $0x80111a60 801014fa: e8 31 3c 00 00 call 80105130 <acquire> 801014ff: 83 c4 10 add $0x10,%esp // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 80101502: 8b 55 e4 mov -0x1c(%ebp),%edx 80101505: eb 1b jmp 80101522 <iget+0x42> 80101507: 89 f6 mov %esi,%esi 80101509: 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. 80101510: 85 f6 test %esi,%esi 80101512: 74 44 je 80101558 <iget+0x78> acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 80101514: 81 c3 90 00 00 00 add $0x90,%ebx 8010151a: 81 fb b4 36 11 80 cmp $0x801136b4,%ebx 80101520: 74 4e je 80101570 <iget+0x90> if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ 80101522: 8b 4b 08 mov 0x8(%ebx),%ecx 80101525: 85 c9 test %ecx,%ecx 80101527: 7e e7 jle 80101510 <iget+0x30> 80101529: 39 3b cmp %edi,(%ebx) 8010152b: 75 e3 jne 80101510 <iget+0x30> 8010152d: 39 53 04 cmp %edx,0x4(%ebx) 80101530: 75 de jne 80101510 <iget+0x30> ip->ref++; release(&icache.lock); 80101532: 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++; 80101535: 83 c1 01 add $0x1,%ecx release(&icache.lock); return ip; 80101538: 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); 8010153a: 68 60 1a 11 80 push $0x80111a60 // 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++; 8010153f: 89 4b 08 mov %ecx,0x8(%ebx) release(&icache.lock); 80101542: e8 99 3c 00 00 call 801051e0 <release> return ip; 80101547: 83 c4 10 add $0x10,%esp ip->ref = 1; ip->valid = 0; release(&icache.lock); return ip; } 8010154a: 8d 65 f4 lea -0xc(%ebp),%esp 8010154d: 89 f0 mov %esi,%eax 8010154f: 5b pop %ebx 80101550: 5e pop %esi 80101551: 5f pop %edi 80101552: 5d pop %ebp 80101553: c3 ret 80101554: 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. 80101558: 85 c9 test %ecx,%ecx 8010155a: 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++){ 8010155d: 81 c3 90 00 00 00 add $0x90,%ebx 80101563: 81 fb b4 36 11 80 cmp $0x801136b4,%ebx 80101569: 75 b7 jne 80101522 <iget+0x42> 8010156b: 90 nop 8010156c: 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) 80101570: 85 f6 test %esi,%esi 80101572: 74 2d je 801015a1 <iget+0xc1> ip = empty; ip->dev = dev; ip->inum = inum; ip->ref = 1; ip->valid = 0; release(&icache.lock); 80101574: 83 ec 0c sub $0xc,%esp // Recycle an inode cache entry. if(empty == 0) panic("iget: no inodes"); ip = empty; ip->dev = dev; 80101577: 89 3e mov %edi,(%esi) ip->inum = inum; 80101579: 89 56 04 mov %edx,0x4(%esi) ip->ref = 1; 8010157c: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) ip->valid = 0; 80101583: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) release(&icache.lock); 8010158a: 68 60 1a 11 80 push $0x80111a60 8010158f: e8 4c 3c 00 00 call 801051e0 <release> return ip; 80101594: 83 c4 10 add $0x10,%esp } 80101597: 8d 65 f4 lea -0xc(%ebp),%esp 8010159a: 89 f0 mov %esi,%eax 8010159c: 5b pop %ebx 8010159d: 5e pop %esi 8010159e: 5f pop %edi 8010159f: 5d pop %ebp 801015a0: c3 ret empty = ip; } // Recycle an inode cache entry. if(empty == 0) panic("iget: no inodes"); 801015a1: 83 ec 0c sub $0xc,%esp 801015a4: 68 48 81 10 80 push $0x80108148 801015a9: e8 c2 ed ff ff call 80100370 <panic> 801015ae: 66 90 xchg %ax,%ax 801015b0 <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) { 801015b0: 55 push %ebp 801015b1: 89 e5 mov %esp,%ebp 801015b3: 57 push %edi 801015b4: 56 push %esi 801015b5: 53 push %ebx 801015b6: 89 c6 mov %eax,%esi 801015b8: 83 ec 1c sub $0x1c,%esp uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 801015bb: 83 fa 0b cmp $0xb,%edx 801015be: 77 18 ja 801015d8 <bmap+0x28> 801015c0: 8d 1c 90 lea (%eax,%edx,4),%ebx if((addr = ip->addrs[bn]) == 0) 801015c3: 8b 43 5c mov 0x5c(%ebx),%eax 801015c6: 85 c0 test %eax,%eax 801015c8: 74 76 je 80101640 <bmap+0x90> brelse(bp); return addr; } panic("bmap: out of range"); } 801015ca: 8d 65 f4 lea -0xc(%ebp),%esp 801015cd: 5b pop %ebx 801015ce: 5e pop %esi 801015cf: 5f pop %edi 801015d0: 5d pop %ebp 801015d1: c3 ret 801015d2: 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; 801015d8: 8d 5a f4 lea -0xc(%edx),%ebx if(bn < NINDIRECT){ 801015db: 83 fb 7f cmp $0x7f,%ebx 801015de: 0f 87 83 00 00 00 ja 80101667 <bmap+0xb7> // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) 801015e4: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax 801015ea: 85 c0 test %eax,%eax 801015ec: 74 6a je 80101658 <bmap+0xa8> ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); 801015ee: 83 ec 08 sub $0x8,%esp 801015f1: 50 push %eax 801015f2: ff 36 pushl (%esi) 801015f4: e8 d7 ea ff ff call 801000d0 <bread> a = (uint*)bp->data; if((addr = a[bn]) == 0){ 801015f9: 8d 54 98 5c lea 0x5c(%eax,%ebx,4),%edx 801015fd: 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); 80101600: 89 c7 mov %eax,%edi a = (uint*)bp->data; if((addr = a[bn]) == 0){ 80101602: 8b 1a mov (%edx),%ebx 80101604: 85 db test %ebx,%ebx 80101606: 75 1d jne 80101625 <bmap+0x75> a[bn] = addr = balloc(ip->dev); 80101608: 8b 06 mov (%esi),%eax 8010160a: 89 55 e4 mov %edx,-0x1c(%ebp) 8010160d: e8 be fd ff ff call 801013d0 <balloc> 80101612: 8b 55 e4 mov -0x1c(%ebp),%edx log_write(bp); 80101615: 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); 80101618: 89 c3 mov %eax,%ebx 8010161a: 89 02 mov %eax,(%edx) log_write(bp); 8010161c: 57 push %edi 8010161d: e8 5e 19 00 00 call 80102f80 <log_write> 80101622: 83 c4 10 add $0x10,%esp } brelse(bp); 80101625: 83 ec 0c sub $0xc,%esp 80101628: 57 push %edi 80101629: e8 b2 eb ff ff call 801001e0 <brelse> 8010162e: 83 c4 10 add $0x10,%esp return addr; } panic("bmap: out of range"); } 80101631: 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); 80101634: 89 d8 mov %ebx,%eax return addr; } panic("bmap: out of range"); } 80101636: 5b pop %ebx 80101637: 5e pop %esi 80101638: 5f pop %edi 80101639: 5d pop %ebp 8010163a: c3 ret 8010163b: 90 nop 8010163c: 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); 80101640: 8b 06 mov (%esi),%eax 80101642: e8 89 fd ff ff call 801013d0 <balloc> 80101647: 89 43 5c mov %eax,0x5c(%ebx) brelse(bp); return addr; } panic("bmap: out of range"); } 8010164a: 8d 65 f4 lea -0xc(%ebp),%esp 8010164d: 5b pop %ebx 8010164e: 5e pop %esi 8010164f: 5f pop %edi 80101650: 5d pop %ebp 80101651: c3 ret 80101652: 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); 80101658: 8b 06 mov (%esi),%eax 8010165a: e8 71 fd ff ff call 801013d0 <balloc> 8010165f: 89 86 8c 00 00 00 mov %eax,0x8c(%esi) 80101665: eb 87 jmp 801015ee <bmap+0x3e> } brelse(bp); return addr; } panic("bmap: out of range"); 80101667: 83 ec 0c sub $0xc,%esp 8010166a: 68 58 81 10 80 push $0x80108158 8010166f: e8 fc ec ff ff call 80100370 <panic> 80101674: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010167a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80101680 <readsb>: struct superblock sb; // Read the super block. void readsb(int dev, struct superblock *sb) { 80101680: 55 push %ebp 80101681: 89 e5 mov %esp,%ebp 80101683: 56 push %esi 80101684: 53 push %ebx 80101685: 8b 75 0c mov 0xc(%ebp),%esi struct buf *bp; bp = bread(dev, 1); 80101688: 83 ec 08 sub $0x8,%esp 8010168b: 6a 01 push $0x1 8010168d: ff 75 08 pushl 0x8(%ebp) 80101690: e8 3b ea ff ff call 801000d0 <bread> 80101695: 89 c3 mov %eax,%ebx memmove(sb, bp->data, sizeof(*sb)); 80101697: 8d 40 5c lea 0x5c(%eax),%eax 8010169a: 83 c4 0c add $0xc,%esp 8010169d: 6a 1c push $0x1c 8010169f: 50 push %eax 801016a0: 56 push %esi 801016a1: e8 3a 3c 00 00 call 801052e0 <memmove> brelse(bp); 801016a6: 89 5d 08 mov %ebx,0x8(%ebp) 801016a9: 83 c4 10 add $0x10,%esp } 801016ac: 8d 65 f8 lea -0x8(%ebp),%esp 801016af: 5b pop %ebx 801016b0: 5e pop %esi 801016b1: 5d pop %ebp { struct buf *bp; bp = bread(dev, 1); memmove(sb, bp->data, sizeof(*sb)); brelse(bp); 801016b2: e9 29 eb ff ff jmp 801001e0 <brelse> 801016b7: 89 f6 mov %esi,%esi 801016b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801016c0 <iinit>: struct inode inode[NINODE]; } icache; void iinit(int dev) { 801016c0: 55 push %ebp 801016c1: 89 e5 mov %esp,%ebp 801016c3: 53 push %ebx 801016c4: bb a0 1a 11 80 mov $0x80111aa0,%ebx 801016c9: 83 ec 0c sub $0xc,%esp int i = 0; initlock(&icache.lock, "icache"); 801016cc: 68 6b 81 10 80 push $0x8010816b 801016d1: 68 60 1a 11 80 push $0x80111a60 801016d6: e8 f5 38 00 00 call 80104fd0 <initlock> 801016db: 83 c4 10 add $0x10,%esp 801016de: 66 90 xchg %ax,%ax for(i = 0; i < NINODE; i++) { initsleeplock(&icache.inode[i].lock, "inode"); 801016e0: 83 ec 08 sub $0x8,%esp 801016e3: 68 72 81 10 80 push $0x80108172 801016e8: 53 push %ebx 801016e9: 81 c3 90 00 00 00 add $0x90,%ebx 801016ef: e8 ac 37 00 00 call 80104ea0 <initsleeplock> iinit(int dev) { int i = 0; initlock(&icache.lock, "icache"); for(i = 0; i < NINODE; i++) { 801016f4: 83 c4 10 add $0x10,%esp 801016f7: 81 fb c0 36 11 80 cmp $0x801136c0,%ebx 801016fd: 75 e1 jne 801016e0 <iinit+0x20> initsleeplock(&icache.inode[i].lock, "inode"); } readsb(dev, &sb); 801016ff: 83 ec 08 sub $0x8,%esp 80101702: 68 40 1a 11 80 push $0x80111a40 80101707: ff 75 08 pushl 0x8(%ebp) 8010170a: e8 71 ff ff ff call 80101680 <readsb> cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ 8010170f: ff 35 58 1a 11 80 pushl 0x80111a58 80101715: ff 35 54 1a 11 80 pushl 0x80111a54 8010171b: ff 35 50 1a 11 80 pushl 0x80111a50 80101721: ff 35 4c 1a 11 80 pushl 0x80111a4c 80101727: ff 35 48 1a 11 80 pushl 0x80111a48 8010172d: ff 35 44 1a 11 80 pushl 0x80111a44 80101733: ff 35 40 1a 11 80 pushl 0x80111a40 80101739: 68 d8 81 10 80 push $0x801081d8 8010173e: e8 1d ef 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); } 80101743: 83 c4 30 add $0x30,%esp 80101746: 8b 5d fc mov -0x4(%ebp),%ebx 80101749: c9 leave 8010174a: c3 ret 8010174b: 90 nop 8010174c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101750 <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) { 80101750: 55 push %ebp 80101751: 89 e5 mov %esp,%ebp 80101753: 57 push %edi 80101754: 56 push %esi 80101755: 53 push %ebx 80101756: 83 ec 1c sub $0x1c,%esp int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101759: 83 3d 48 1a 11 80 01 cmpl $0x1,0x80111a48 // 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) { 80101760: 8b 45 0c mov 0xc(%ebp),%eax 80101763: 8b 75 08 mov 0x8(%ebp),%esi 80101766: 89 45 e4 mov %eax,-0x1c(%ebp) int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101769: 0f 86 91 00 00 00 jbe 80101800 <ialloc+0xb0> 8010176f: bb 01 00 00 00 mov $0x1,%ebx 80101774: eb 21 jmp 80101797 <ialloc+0x47> 80101776: 8d 76 00 lea 0x0(%esi),%esi 80101779: 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); 80101780: 83 ec 0c sub $0xc,%esp { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101783: 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); 80101786: 57 push %edi 80101787: e8 54 ea ff ff call 801001e0 <brelse> { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 8010178c: 83 c4 10 add $0x10,%esp 8010178f: 39 1d 48 1a 11 80 cmp %ebx,0x80111a48 80101795: 76 69 jbe 80101800 <ialloc+0xb0> bp = bread(dev, IBLOCK(inum, sb)); 80101797: 89 d8 mov %ebx,%eax 80101799: 83 ec 08 sub $0x8,%esp 8010179c: c1 e8 03 shr $0x3,%eax 8010179f: 03 05 54 1a 11 80 add 0x80111a54,%eax 801017a5: 50 push %eax 801017a6: 56 push %esi 801017a7: e8 24 e9 ff ff call 801000d0 <bread> 801017ac: 89 c7 mov %eax,%edi dip = (struct dinode*)bp->data + inum%IPB; 801017ae: 89 d8 mov %ebx,%eax if(dip->type == 0){ // a free inode 801017b0: 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; 801017b3: 83 e0 07 and $0x7,%eax 801017b6: c1 e0 06 shl $0x6,%eax 801017b9: 8d 4c 07 5c lea 0x5c(%edi,%eax,1),%ecx if(dip->type == 0){ // a free inode 801017bd: 66 83 39 00 cmpw $0x0,(%ecx) 801017c1: 75 bd jne 80101780 <ialloc+0x30> memset(dip, 0, sizeof(*dip)); 801017c3: 83 ec 04 sub $0x4,%esp 801017c6: 89 4d e0 mov %ecx,-0x20(%ebp) 801017c9: 6a 40 push $0x40 801017cb: 6a 00 push $0x0 801017cd: 51 push %ecx 801017ce: e8 5d 3a 00 00 call 80105230 <memset> dip->type = type; 801017d3: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax 801017d7: 8b 4d e0 mov -0x20(%ebp),%ecx 801017da: 66 89 01 mov %ax,(%ecx) log_write(bp); // mark it allocated on the disk 801017dd: 89 3c 24 mov %edi,(%esp) 801017e0: e8 9b 17 00 00 call 80102f80 <log_write> brelse(bp); 801017e5: 89 3c 24 mov %edi,(%esp) 801017e8: e8 f3 e9 ff ff call 801001e0 <brelse> return iget(dev, inum); 801017ed: 83 c4 10 add $0x10,%esp } brelse(bp); } panic("ialloc: no inodes"); } 801017f0: 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); 801017f3: 89 da mov %ebx,%edx 801017f5: 89 f0 mov %esi,%eax } brelse(bp); } panic("ialloc: no inodes"); } 801017f7: 5b pop %ebx 801017f8: 5e pop %esi 801017f9: 5f pop %edi 801017fa: 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); 801017fb: e9 e0 fc ff ff jmp 801014e0 <iget> } brelse(bp); } panic("ialloc: no inodes"); 80101800: 83 ec 0c sub $0xc,%esp 80101803: 68 78 81 10 80 push $0x80108178 80101808: e8 63 eb ff ff call 80100370 <panic> 8010180d: 8d 76 00 lea 0x0(%esi),%esi 80101810 <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) { 80101810: 55 push %ebp 80101811: 89 e5 mov %esp,%ebp 80101813: 56 push %esi 80101814: 53 push %ebx 80101815: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101818: 83 ec 08 sub $0x8,%esp 8010181b: 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)); 8010181e: 83 c3 5c add $0x5c,%ebx iupdate(struct inode *ip) { struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101821: c1 e8 03 shr $0x3,%eax 80101824: 03 05 54 1a 11 80 add 0x80111a54,%eax 8010182a: 50 push %eax 8010182b: ff 73 a4 pushl -0x5c(%ebx) 8010182e: e8 9d e8 ff ff call 801000d0 <bread> 80101833: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; 80101835: 8b 43 a8 mov -0x58(%ebx),%eax dip->type = ip->type; 80101838: 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)); 8010183c: 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; 8010183f: 83 e0 07 and $0x7,%eax 80101842: c1 e0 06 shl $0x6,%eax 80101845: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax dip->type = ip->type; 80101849: 66 89 10 mov %dx,(%eax) dip->major = ip->major; 8010184c: 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)); 80101850: 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; 80101853: 66 89 50 f6 mov %dx,-0xa(%eax) dip->minor = ip->minor; 80101857: 0f b7 53 f8 movzwl -0x8(%ebx),%edx 8010185b: 66 89 50 f8 mov %dx,-0x8(%eax) dip->nlink = ip->nlink; 8010185f: 0f b7 53 fa movzwl -0x6(%ebx),%edx 80101863: 66 89 50 fa mov %dx,-0x6(%eax) dip->size = ip->size; 80101867: 8b 53 fc mov -0x4(%ebx),%edx 8010186a: 89 50 fc mov %edx,-0x4(%eax) memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010186d: 6a 34 push $0x34 8010186f: 53 push %ebx 80101870: 50 push %eax 80101871: e8 6a 3a 00 00 call 801052e0 <memmove> log_write(bp); 80101876: 89 34 24 mov %esi,(%esp) 80101879: e8 02 17 00 00 call 80102f80 <log_write> brelse(bp); 8010187e: 89 75 08 mov %esi,0x8(%ebp) 80101881: 83 c4 10 add $0x10,%esp } 80101884: 8d 65 f8 lea -0x8(%ebp),%esp 80101887: 5b pop %ebx 80101888: 5e pop %esi 80101889: 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); 8010188a: e9 51 e9 ff ff jmp 801001e0 <brelse> 8010188f: 90 nop 80101890 <idup>: // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { 80101890: 55 push %ebp 80101891: 89 e5 mov %esp,%ebp 80101893: 53 push %ebx 80101894: 83 ec 10 sub $0x10,%esp 80101897: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&icache.lock); 8010189a: 68 60 1a 11 80 push $0x80111a60 8010189f: e8 8c 38 00 00 call 80105130 <acquire> ip->ref++; 801018a4: 83 43 08 01 addl $0x1,0x8(%ebx) release(&icache.lock); 801018a8: c7 04 24 60 1a 11 80 movl $0x80111a60,(%esp) 801018af: e8 2c 39 00 00 call 801051e0 <release> return ip; } 801018b4: 89 d8 mov %ebx,%eax 801018b6: 8b 5d fc mov -0x4(%ebp),%ebx 801018b9: c9 leave 801018ba: c3 ret 801018bb: 90 nop 801018bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801018c0 <ilock>: // Lock the given inode. // Reads the inode from disk if necessary. void ilock(struct inode *ip) { 801018c0: 55 push %ebp 801018c1: 89 e5 mov %esp,%ebp 801018c3: 56 push %esi 801018c4: 53 push %ebx 801018c5: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) 801018c8: 85 db test %ebx,%ebx 801018ca: 0f 84 b7 00 00 00 je 80101987 <ilock+0xc7> 801018d0: 8b 53 08 mov 0x8(%ebx),%edx 801018d3: 85 d2 test %edx,%edx 801018d5: 0f 8e ac 00 00 00 jle 80101987 <ilock+0xc7> panic("ilock"); acquiresleep(&ip->lock); 801018db: 8d 43 0c lea 0xc(%ebx),%eax 801018de: 83 ec 0c sub $0xc,%esp 801018e1: 50 push %eax 801018e2: e8 f9 35 00 00 call 80104ee0 <acquiresleep> if(ip->valid == 0){ 801018e7: 8b 43 4c mov 0x4c(%ebx),%eax 801018ea: 83 c4 10 add $0x10,%esp 801018ed: 85 c0 test %eax,%eax 801018ef: 74 0f je 80101900 <ilock+0x40> brelse(bp); ip->valid = 1; if(ip->type == 0) panic("ilock: no type"); } } 801018f1: 8d 65 f8 lea -0x8(%ebp),%esp 801018f4: 5b pop %ebx 801018f5: 5e pop %esi 801018f6: 5d pop %ebp 801018f7: c3 ret 801018f8: 90 nop 801018f9: 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)); 80101900: 8b 43 04 mov 0x4(%ebx),%eax 80101903: 83 ec 08 sub $0x8,%esp 80101906: c1 e8 03 shr $0x3,%eax 80101909: 03 05 54 1a 11 80 add 0x80111a54,%eax 8010190f: 50 push %eax 80101910: ff 33 pushl (%ebx) 80101912: e8 b9 e7 ff ff call 801000d0 <bread> 80101917: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; 80101919: 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)); 8010191c: 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; 8010191f: 83 e0 07 and $0x7,%eax 80101922: c1 e0 06 shl $0x6,%eax 80101925: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax ip->type = dip->type; 80101929: 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)); 8010192c: 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; 8010192f: 66 89 53 50 mov %dx,0x50(%ebx) ip->major = dip->major; 80101933: 0f b7 50 f6 movzwl -0xa(%eax),%edx 80101937: 66 89 53 52 mov %dx,0x52(%ebx) ip->minor = dip->minor; 8010193b: 0f b7 50 f8 movzwl -0x8(%eax),%edx 8010193f: 66 89 53 54 mov %dx,0x54(%ebx) ip->nlink = dip->nlink; 80101943: 0f b7 50 fa movzwl -0x6(%eax),%edx 80101947: 66 89 53 56 mov %dx,0x56(%ebx) ip->size = dip->size; 8010194b: 8b 50 fc mov -0x4(%eax),%edx 8010194e: 89 53 58 mov %edx,0x58(%ebx) memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101951: 6a 34 push $0x34 80101953: 50 push %eax 80101954: 8d 43 5c lea 0x5c(%ebx),%eax 80101957: 50 push %eax 80101958: e8 83 39 00 00 call 801052e0 <memmove> brelse(bp); 8010195d: 89 34 24 mov %esi,(%esp) 80101960: e8 7b e8 ff ff call 801001e0 <brelse> ip->valid = 1; if(ip->type == 0) 80101965: 83 c4 10 add $0x10,%esp 80101968: 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; 8010196d: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) if(ip->type == 0) 80101974: 0f 85 77 ff ff ff jne 801018f1 <ilock+0x31> panic("ilock: no type"); 8010197a: 83 ec 0c sub $0xc,%esp 8010197d: 68 90 81 10 80 push $0x80108190 80101982: e8 e9 e9 ff ff call 80100370 <panic> { struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) panic("ilock"); 80101987: 83 ec 0c sub $0xc,%esp 8010198a: 68 8a 81 10 80 push $0x8010818a 8010198f: e8 dc e9 ff ff call 80100370 <panic> 80101994: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010199a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801019a0 <iunlock>: } // Unlock the given inode. void iunlock(struct inode *ip) { 801019a0: 55 push %ebp 801019a1: 89 e5 mov %esp,%ebp 801019a3: 56 push %esi 801019a4: 53 push %ebx 801019a5: 8b 5d 08 mov 0x8(%ebp),%ebx if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) 801019a8: 85 db test %ebx,%ebx 801019aa: 74 28 je 801019d4 <iunlock+0x34> 801019ac: 8d 73 0c lea 0xc(%ebx),%esi 801019af: 83 ec 0c sub $0xc,%esp 801019b2: 56 push %esi 801019b3: e8 c8 35 00 00 call 80104f80 <holdingsleep> 801019b8: 83 c4 10 add $0x10,%esp 801019bb: 85 c0 test %eax,%eax 801019bd: 74 15 je 801019d4 <iunlock+0x34> 801019bf: 8b 43 08 mov 0x8(%ebx),%eax 801019c2: 85 c0 test %eax,%eax 801019c4: 7e 0e jle 801019d4 <iunlock+0x34> panic("iunlock"); releasesleep(&ip->lock); 801019c6: 89 75 08 mov %esi,0x8(%ebp) } 801019c9: 8d 65 f8 lea -0x8(%ebp),%esp 801019cc: 5b pop %ebx 801019cd: 5e pop %esi 801019ce: 5d pop %ebp iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); releasesleep(&ip->lock); 801019cf: e9 6c 35 00 00 jmp 80104f40 <releasesleep> // Unlock the given inode. void iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); 801019d4: 83 ec 0c sub $0xc,%esp 801019d7: 68 9f 81 10 80 push $0x8010819f 801019dc: e8 8f e9 ff ff call 80100370 <panic> 801019e1: eb 0d jmp 801019f0 <iput> 801019e3: 90 nop 801019e4: 90 nop 801019e5: 90 nop 801019e6: 90 nop 801019e7: 90 nop 801019e8: 90 nop 801019e9: 90 nop 801019ea: 90 nop 801019eb: 90 nop 801019ec: 90 nop 801019ed: 90 nop 801019ee: 90 nop 801019ef: 90 nop 801019f0 <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) { 801019f0: 55 push %ebp 801019f1: 89 e5 mov %esp,%ebp 801019f3: 57 push %edi 801019f4: 56 push %esi 801019f5: 53 push %ebx 801019f6: 83 ec 28 sub $0x28,%esp 801019f9: 8b 75 08 mov 0x8(%ebp),%esi acquiresleep(&ip->lock); 801019fc: 8d 7e 0c lea 0xc(%esi),%edi 801019ff: 57 push %edi 80101a00: e8 db 34 00 00 call 80104ee0 <acquiresleep> if(ip->valid && ip->nlink == 0){ 80101a05: 8b 56 4c mov 0x4c(%esi),%edx 80101a08: 83 c4 10 add $0x10,%esp 80101a0b: 85 d2 test %edx,%edx 80101a0d: 74 07 je 80101a16 <iput+0x26> 80101a0f: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) 80101a14: 74 32 je 80101a48 <iput+0x58> ip->type = 0; iupdate(ip); ip->valid = 0; } } releasesleep(&ip->lock); 80101a16: 83 ec 0c sub $0xc,%esp 80101a19: 57 push %edi 80101a1a: e8 21 35 00 00 call 80104f40 <releasesleep> acquire(&icache.lock); 80101a1f: c7 04 24 60 1a 11 80 movl $0x80111a60,(%esp) 80101a26: e8 05 37 00 00 call 80105130 <acquire> ip->ref--; 80101a2b: 83 6e 08 01 subl $0x1,0x8(%esi) release(&icache.lock); 80101a2f: 83 c4 10 add $0x10,%esp 80101a32: c7 45 08 60 1a 11 80 movl $0x80111a60,0x8(%ebp) } 80101a39: 8d 65 f4 lea -0xc(%ebp),%esp 80101a3c: 5b pop %ebx 80101a3d: 5e pop %esi 80101a3e: 5f pop %edi 80101a3f: 5d pop %ebp } releasesleep(&ip->lock); acquire(&icache.lock); ip->ref--; release(&icache.lock); 80101a40: e9 9b 37 00 00 jmp 801051e0 <release> 80101a45: 8d 76 00 lea 0x0(%esi),%esi void iput(struct inode *ip) { acquiresleep(&ip->lock); if(ip->valid && ip->nlink == 0){ acquire(&icache.lock); 80101a48: 83 ec 0c sub $0xc,%esp 80101a4b: 68 60 1a 11 80 push $0x80111a60 80101a50: e8 db 36 00 00 call 80105130 <acquire> int r = ip->ref; 80101a55: 8b 5e 08 mov 0x8(%esi),%ebx release(&icache.lock); 80101a58: c7 04 24 60 1a 11 80 movl $0x80111a60,(%esp) 80101a5f: e8 7c 37 00 00 call 801051e0 <release> if(r == 1){ 80101a64: 83 c4 10 add $0x10,%esp 80101a67: 83 fb 01 cmp $0x1,%ebx 80101a6a: 75 aa jne 80101a16 <iput+0x26> 80101a6c: 8d 8e 8c 00 00 00 lea 0x8c(%esi),%ecx 80101a72: 89 7d e4 mov %edi,-0x1c(%ebp) 80101a75: 8d 5e 5c lea 0x5c(%esi),%ebx 80101a78: 89 cf mov %ecx,%edi 80101a7a: eb 0b jmp 80101a87 <iput+0x97> 80101a7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101a80: 83 c3 04 add $0x4,%ebx { int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101a83: 39 fb cmp %edi,%ebx 80101a85: 74 19 je 80101aa0 <iput+0xb0> if(ip->addrs[i]){ 80101a87: 8b 13 mov (%ebx),%edx 80101a89: 85 d2 test %edx,%edx 80101a8b: 74 f3 je 80101a80 <iput+0x90> bfree(ip->dev, ip->addrs[i]); 80101a8d: 8b 06 mov (%esi),%eax 80101a8f: e8 cc f8 ff ff call 80101360 <bfree> ip->addrs[i] = 0; 80101a94: c7 03 00 00 00 00 movl $0x0,(%ebx) 80101a9a: eb e4 jmp 80101a80 <iput+0x90> 80101a9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } } if(ip->addrs[NDIRECT]){ 80101aa0: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax 80101aa6: 8b 7d e4 mov -0x1c(%ebp),%edi 80101aa9: 85 c0 test %eax,%eax 80101aab: 75 33 jne 80101ae0 <iput+0xf0> bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; iupdate(ip); 80101aad: 83 ec 0c sub $0xc,%esp brelse(bp); bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; 80101ab0: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi) iupdate(ip); 80101ab7: 56 push %esi 80101ab8: e8 53 fd ff ff call 80101810 <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; 80101abd: 31 c0 xor %eax,%eax 80101abf: 66 89 46 50 mov %ax,0x50(%esi) iupdate(ip); 80101ac3: 89 34 24 mov %esi,(%esp) 80101ac6: e8 45 fd ff ff call 80101810 <iupdate> ip->valid = 0; 80101acb: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) 80101ad2: 83 c4 10 add $0x10,%esp 80101ad5: e9 3c ff ff ff jmp 80101a16 <iput+0x26> 80101ada: 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]); 80101ae0: 83 ec 08 sub $0x8,%esp 80101ae3: 50 push %eax 80101ae4: ff 36 pushl (%esi) 80101ae6: e8 e5 e5 ff ff call 801000d0 <bread> 80101aeb: 8d 88 5c 02 00 00 lea 0x25c(%eax),%ecx 80101af1: 89 7d e0 mov %edi,-0x20(%ebp) 80101af4: 89 45 e4 mov %eax,-0x1c(%ebp) a = (uint*)bp->data; 80101af7: 8d 58 5c lea 0x5c(%eax),%ebx 80101afa: 83 c4 10 add $0x10,%esp 80101afd: 89 cf mov %ecx,%edi 80101aff: eb 0e jmp 80101b0f <iput+0x11f> 80101b01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101b08: 83 c3 04 add $0x4,%ebx for(j = 0; j < NINDIRECT; j++){ 80101b0b: 39 fb cmp %edi,%ebx 80101b0d: 74 0f je 80101b1e <iput+0x12e> if(a[j]) 80101b0f: 8b 13 mov (%ebx),%edx 80101b11: 85 d2 test %edx,%edx 80101b13: 74 f3 je 80101b08 <iput+0x118> bfree(ip->dev, a[j]); 80101b15: 8b 06 mov (%esi),%eax 80101b17: e8 44 f8 ff ff call 80101360 <bfree> 80101b1c: eb ea jmp 80101b08 <iput+0x118> } brelse(bp); 80101b1e: 83 ec 0c sub $0xc,%esp 80101b21: ff 75 e4 pushl -0x1c(%ebp) 80101b24: 8b 7d e0 mov -0x20(%ebp),%edi 80101b27: e8 b4 e6 ff ff call 801001e0 <brelse> bfree(ip->dev, ip->addrs[NDIRECT]); 80101b2c: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx 80101b32: 8b 06 mov (%esi),%eax 80101b34: e8 27 f8 ff ff call 80101360 <bfree> ip->addrs[NDIRECT] = 0; 80101b39: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi) 80101b40: 00 00 00 80101b43: 83 c4 10 add $0x10,%esp 80101b46: e9 62 ff ff ff jmp 80101aad <iput+0xbd> 80101b4b: 90 nop 80101b4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101b50 <iunlockput>: } // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { 80101b50: 55 push %ebp 80101b51: 89 e5 mov %esp,%ebp 80101b53: 53 push %ebx 80101b54: 83 ec 10 sub $0x10,%esp 80101b57: 8b 5d 08 mov 0x8(%ebp),%ebx iunlock(ip); 80101b5a: 53 push %ebx 80101b5b: e8 40 fe ff ff call 801019a0 <iunlock> iput(ip); 80101b60: 89 5d 08 mov %ebx,0x8(%ebp) 80101b63: 83 c4 10 add $0x10,%esp } 80101b66: 8b 5d fc mov -0x4(%ebp),%ebx 80101b69: c9 leave // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); iput(ip); 80101b6a: e9 81 fe ff ff jmp 801019f0 <iput> 80101b6f: 90 nop 80101b70 <stati>: // Copy stat information from inode. // Caller must hold ip->lock. void stati(struct inode *ip, struct stat *st) { 80101b70: 55 push %ebp 80101b71: 89 e5 mov %esp,%ebp 80101b73: 8b 55 08 mov 0x8(%ebp),%edx 80101b76: 8b 45 0c mov 0xc(%ebp),%eax st->dev = ip->dev; 80101b79: 8b 0a mov (%edx),%ecx 80101b7b: 89 48 04 mov %ecx,0x4(%eax) st->ino = ip->inum; 80101b7e: 8b 4a 04 mov 0x4(%edx),%ecx 80101b81: 89 48 08 mov %ecx,0x8(%eax) st->type = ip->type; 80101b84: 0f b7 4a 50 movzwl 0x50(%edx),%ecx 80101b88: 66 89 08 mov %cx,(%eax) st->nlink = ip->nlink; 80101b8b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx 80101b8f: 66 89 48 0c mov %cx,0xc(%eax) st->size = ip->size; 80101b93: 8b 52 58 mov 0x58(%edx),%edx 80101b96: 89 50 10 mov %edx,0x10(%eax) } 80101b99: 5d pop %ebp 80101b9a: c3 ret 80101b9b: 90 nop 80101b9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101ba0 <readi>: //PAGEBREAK! // Read data from inode. // Caller must hold ip->lock. int readi(struct inode *ip, char *dst, uint off, uint n) { 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 45 08 mov 0x8(%ebp),%eax 80101bac: 8b 7d 0c mov 0xc(%ebp),%edi 80101baf: 8b 75 10 mov 0x10(%ebp),%esi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101bb2: 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) { 80101bb7: 89 7d e0 mov %edi,-0x20(%ebp) 80101bba: 8b 7d 14 mov 0x14(%ebp),%edi 80101bbd: 89 45 d8 mov %eax,-0x28(%ebp) 80101bc0: 89 7d e4 mov %edi,-0x1c(%ebp) uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101bc3: 0f 84 a7 00 00 00 je 80101c70 <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) 80101bc9: 8b 45 d8 mov -0x28(%ebp),%eax 80101bcc: 8b 40 58 mov 0x58(%eax),%eax 80101bcf: 39 f0 cmp %esi,%eax 80101bd1: 0f 82 c1 00 00 00 jb 80101c98 <readi+0xf8> 80101bd7: 8b 7d e4 mov -0x1c(%ebp),%edi 80101bda: 89 fa mov %edi,%edx 80101bdc: 01 f2 add %esi,%edx 80101bde: 0f 82 b4 00 00 00 jb 80101c98 <readi+0xf8> return -1; if(off + n > ip->size) n = ip->size - off; 80101be4: 89 c1 mov %eax,%ecx 80101be6: 29 f1 sub %esi,%ecx 80101be8: 39 d0 cmp %edx,%eax 80101bea: 0f 43 cf cmovae %edi,%ecx for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101bed: 31 ff xor %edi,%edi 80101bef: 85 c9 test %ecx,%ecx } if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; 80101bf1: 89 4d e4 mov %ecx,-0x1c(%ebp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101bf4: 74 6d je 80101c63 <readi+0xc3> 80101bf6: 8d 76 00 lea 0x0(%esi),%esi 80101bf9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101c00: 8b 5d d8 mov -0x28(%ebp),%ebx 80101c03: 89 f2 mov %esi,%edx 80101c05: c1 ea 09 shr $0x9,%edx 80101c08: 89 d8 mov %ebx,%eax 80101c0a: e8 a1 f9 ff ff call 801015b0 <bmap> 80101c0f: 83 ec 08 sub $0x8,%esp 80101c12: 50 push %eax 80101c13: ff 33 pushl (%ebx) m = min(n - tot, BSIZE - off%BSIZE); 80101c15: 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)); 80101c1a: e8 b1 e4 ff ff call 801000d0 <bread> 80101c1f: 89 c2 mov %eax,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101c21: 8b 45 e4 mov -0x1c(%ebp),%eax 80101c24: 89 f1 mov %esi,%ecx 80101c26: 81 e1 ff 01 00 00 and $0x1ff,%ecx 80101c2c: 83 c4 0c add $0xc,%esp memmove(dst, bp->data + off%BSIZE, m); 80101c2f: 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); 80101c32: 29 cb sub %ecx,%ebx 80101c34: 29 f8 sub %edi,%eax 80101c36: 39 c3 cmp %eax,%ebx 80101c38: 0f 47 d8 cmova %eax,%ebx memmove(dst, bp->data + off%BSIZE, m); 80101c3b: 8d 44 0a 5c lea 0x5c(%edx,%ecx,1),%eax 80101c3f: 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){ 80101c40: 01 df add %ebx,%edi 80101c42: 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); 80101c44: 50 push %eax 80101c45: ff 75 e0 pushl -0x20(%ebp) 80101c48: e8 93 36 00 00 call 801052e0 <memmove> brelse(bp); 80101c4d: 8b 55 dc mov -0x24(%ebp),%edx 80101c50: 89 14 24 mov %edx,(%esp) 80101c53: e8 88 e5 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){ 80101c58: 01 5d e0 add %ebx,-0x20(%ebp) 80101c5b: 83 c4 10 add $0x10,%esp 80101c5e: 39 7d e4 cmp %edi,-0x1c(%ebp) 80101c61: 77 9d ja 80101c00 <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; 80101c63: 8b 45 e4 mov -0x1c(%ebp),%eax } 80101c66: 8d 65 f4 lea -0xc(%ebp),%esp 80101c69: 5b pop %ebx 80101c6a: 5e pop %esi 80101c6b: 5f pop %edi 80101c6c: 5d pop %ebp 80101c6d: c3 ret 80101c6e: 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) 80101c70: 0f bf 40 52 movswl 0x52(%eax),%eax 80101c74: 66 83 f8 09 cmp $0x9,%ax 80101c78: 77 1e ja 80101c98 <readi+0xf8> 80101c7a: 8b 04 c5 e0 19 11 80 mov -0x7feee620(,%eax,8),%eax 80101c81: 85 c0 test %eax,%eax 80101c83: 74 13 je 80101c98 <readi+0xf8> return -1; return devsw[ip->major].read(ip, dst, n); 80101c85: 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; } 80101c88: 8d 65 f4 lea -0xc(%ebp),%esp 80101c8b: 5b pop %ebx 80101c8c: 5e pop %esi 80101c8d: 5f pop %edi 80101c8e: 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); 80101c8f: ff e0 jmp *%eax 80101c91: 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; 80101c98: b8 ff ff ff ff mov $0xffffffff,%eax 80101c9d: eb c7 jmp 80101c66 <readi+0xc6> 80101c9f: 90 nop 80101ca0 <writei>: // PAGEBREAK! // Write data to inode. // Caller must hold ip->lock. int writei(struct inode *ip, char *src, uint off, uint n) { 80101ca0: 55 push %ebp 80101ca1: 89 e5 mov %esp,%ebp 80101ca3: 57 push %edi 80101ca4: 56 push %esi 80101ca5: 53 push %ebx 80101ca6: 83 ec 1c sub $0x1c,%esp 80101ca9: 8b 45 08 mov 0x8(%ebp),%eax 80101cac: 8b 75 0c mov 0xc(%ebp),%esi 80101caf: 8b 7d 14 mov 0x14(%ebp),%edi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101cb2: 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) { 80101cb7: 89 75 dc mov %esi,-0x24(%ebp) 80101cba: 89 45 d8 mov %eax,-0x28(%ebp) 80101cbd: 8b 75 10 mov 0x10(%ebp),%esi 80101cc0: 89 7d e0 mov %edi,-0x20(%ebp) uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101cc3: 0f 84 b7 00 00 00 je 80101d80 <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) 80101cc9: 8b 45 d8 mov -0x28(%ebp),%eax 80101ccc: 39 70 58 cmp %esi,0x58(%eax) 80101ccf: 0f 82 eb 00 00 00 jb 80101dc0 <writei+0x120> 80101cd5: 8b 7d e0 mov -0x20(%ebp),%edi 80101cd8: 89 f8 mov %edi,%eax 80101cda: 01 f0 add %esi,%eax return -1; if(off + n > MAXFILE*BSIZE) 80101cdc: 3d 00 18 01 00 cmp $0x11800,%eax 80101ce1: 0f 87 d9 00 00 00 ja 80101dc0 <writei+0x120> 80101ce7: 39 c6 cmp %eax,%esi 80101ce9: 0f 87 d1 00 00 00 ja 80101dc0 <writei+0x120> return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101cef: 85 ff test %edi,%edi 80101cf1: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 80101cf8: 74 78 je 80101d72 <writei+0xd2> 80101cfa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101d00: 8b 7d d8 mov -0x28(%ebp),%edi 80101d03: 89 f2 mov %esi,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101d05: 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)); 80101d0a: c1 ea 09 shr $0x9,%edx 80101d0d: 89 f8 mov %edi,%eax 80101d0f: e8 9c f8 ff ff call 801015b0 <bmap> 80101d14: 83 ec 08 sub $0x8,%esp 80101d17: 50 push %eax 80101d18: ff 37 pushl (%edi) 80101d1a: e8 b1 e3 ff ff call 801000d0 <bread> 80101d1f: 89 c7 mov %eax,%edi m = min(n - tot, BSIZE - off%BSIZE); 80101d21: 8b 45 e0 mov -0x20(%ebp),%eax 80101d24: 2b 45 e4 sub -0x1c(%ebp),%eax 80101d27: 89 f1 mov %esi,%ecx 80101d29: 83 c4 0c add $0xc,%esp 80101d2c: 81 e1 ff 01 00 00 and $0x1ff,%ecx 80101d32: 29 cb sub %ecx,%ebx 80101d34: 39 c3 cmp %eax,%ebx 80101d36: 0f 47 d8 cmova %eax,%ebx memmove(bp->data + off%BSIZE, src, m); 80101d39: 8d 44 0f 5c lea 0x5c(%edi,%ecx,1),%eax 80101d3d: 53 push %ebx 80101d3e: 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){ 80101d41: 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); 80101d43: 50 push %eax 80101d44: e8 97 35 00 00 call 801052e0 <memmove> log_write(bp); 80101d49: 89 3c 24 mov %edi,(%esp) 80101d4c: e8 2f 12 00 00 call 80102f80 <log_write> brelse(bp); 80101d51: 89 3c 24 mov %edi,(%esp) 80101d54: e8 87 e4 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){ 80101d59: 01 5d e4 add %ebx,-0x1c(%ebp) 80101d5c: 01 5d dc add %ebx,-0x24(%ebp) 80101d5f: 83 c4 10 add $0x10,%esp 80101d62: 8b 55 e4 mov -0x1c(%ebp),%edx 80101d65: 39 55 e0 cmp %edx,-0x20(%ebp) 80101d68: 77 96 ja 80101d00 <writei+0x60> memmove(bp->data + off%BSIZE, src, m); log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ 80101d6a: 8b 45 d8 mov -0x28(%ebp),%eax 80101d6d: 3b 70 58 cmp 0x58(%eax),%esi 80101d70: 77 36 ja 80101da8 <writei+0x108> ip->size = off; iupdate(ip); } return n; 80101d72: 8b 45 e0 mov -0x20(%ebp),%eax } 80101d75: 8d 65 f4 lea -0xc(%ebp),%esp 80101d78: 5b pop %ebx 80101d79: 5e pop %esi 80101d7a: 5f pop %edi 80101d7b: 5d pop %ebp 80101d7c: c3 ret 80101d7d: 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) 80101d80: 0f bf 40 52 movswl 0x52(%eax),%eax 80101d84: 66 83 f8 09 cmp $0x9,%ax 80101d88: 77 36 ja 80101dc0 <writei+0x120> 80101d8a: 8b 04 c5 e4 19 11 80 mov -0x7feee61c(,%eax,8),%eax 80101d91: 85 c0 test %eax,%eax 80101d93: 74 2b je 80101dc0 <writei+0x120> return -1; return devsw[ip->major].write(ip, src, n); 80101d95: 89 7d 10 mov %edi,0x10(%ebp) if(n > 0 && off > ip->size){ ip->size = off; iupdate(ip); } return n; } 80101d98: 8d 65 f4 lea -0xc(%ebp),%esp 80101d9b: 5b pop %ebx 80101d9c: 5e pop %esi 80101d9d: 5f pop %edi 80101d9e: 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); 80101d9f: ff e0 jmp *%eax 80101da1: 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; 80101da8: 8b 45 d8 mov -0x28(%ebp),%eax iupdate(ip); 80101dab: 83 ec 0c sub $0xc,%esp log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ ip->size = off; 80101dae: 89 70 58 mov %esi,0x58(%eax) iupdate(ip); 80101db1: 50 push %eax 80101db2: e8 59 fa ff ff call 80101810 <iupdate> 80101db7: 83 c4 10 add $0x10,%esp 80101dba: eb b6 jmp 80101d72 <writei+0xd2> 80101dbc: 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; 80101dc0: b8 ff ff ff ff mov $0xffffffff,%eax 80101dc5: eb ae jmp 80101d75 <writei+0xd5> 80101dc7: 89 f6 mov %esi,%esi 80101dc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101dd0 <namecmp>: //PAGEBREAK! // Directories int namecmp(const char *s, const char *t) { 80101dd0: 55 push %ebp 80101dd1: 89 e5 mov %esp,%ebp 80101dd3: 83 ec 0c sub $0xc,%esp return strncmp(s, t, DIRSIZ); 80101dd6: 6a 0e push $0xe 80101dd8: ff 75 0c pushl 0xc(%ebp) 80101ddb: ff 75 08 pushl 0x8(%ebp) 80101dde: e8 7d 35 00 00 call 80105360 <strncmp> } 80101de3: c9 leave 80101de4: c3 ret 80101de5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101de9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101df0 <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) { 80101df0: 55 push %ebp 80101df1: 89 e5 mov %esp,%ebp 80101df3: 57 push %edi 80101df4: 56 push %esi 80101df5: 53 push %ebx 80101df6: 83 ec 1c sub $0x1c,%esp 80101df9: 8b 5d 08 mov 0x8(%ebp),%ebx uint off, inum; struct dirent de; if(dp->type != T_DIR) 80101dfc: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80101e01: 0f 85 80 00 00 00 jne 80101e87 <dirlookup+0x97> panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 80101e07: 8b 53 58 mov 0x58(%ebx),%edx 80101e0a: 31 ff xor %edi,%edi 80101e0c: 8d 75 d8 lea -0x28(%ebp),%esi 80101e0f: 85 d2 test %edx,%edx 80101e11: 75 0d jne 80101e20 <dirlookup+0x30> 80101e13: eb 5b jmp 80101e70 <dirlookup+0x80> 80101e15: 8d 76 00 lea 0x0(%esi),%esi 80101e18: 83 c7 10 add $0x10,%edi 80101e1b: 39 7b 58 cmp %edi,0x58(%ebx) 80101e1e: 76 50 jbe 80101e70 <dirlookup+0x80> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101e20: 6a 10 push $0x10 80101e22: 57 push %edi 80101e23: 56 push %esi 80101e24: 53 push %ebx 80101e25: e8 76 fd ff ff call 80101ba0 <readi> 80101e2a: 83 c4 10 add $0x10,%esp 80101e2d: 83 f8 10 cmp $0x10,%eax 80101e30: 75 48 jne 80101e7a <dirlookup+0x8a> panic("dirlookup read"); if(de.inum == 0) 80101e32: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101e37: 74 df je 80101e18 <dirlookup+0x28> // Directories int namecmp(const char *s, const char *t) { return strncmp(s, t, DIRSIZ); 80101e39: 8d 45 da lea -0x26(%ebp),%eax 80101e3c: 83 ec 04 sub $0x4,%esp 80101e3f: 6a 0e push $0xe 80101e41: 50 push %eax 80101e42: ff 75 0c pushl 0xc(%ebp) 80101e45: e8 16 35 00 00 call 80105360 <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){ 80101e4a: 83 c4 10 add $0x10,%esp 80101e4d: 85 c0 test %eax,%eax 80101e4f: 75 c7 jne 80101e18 <dirlookup+0x28> // entry matches path element if(poff) 80101e51: 8b 45 10 mov 0x10(%ebp),%eax 80101e54: 85 c0 test %eax,%eax 80101e56: 74 05 je 80101e5d <dirlookup+0x6d> *poff = off; 80101e58: 8b 45 10 mov 0x10(%ebp),%eax 80101e5b: 89 38 mov %edi,(%eax) inum = de.inum; return iget(dp->dev, inum); 80101e5d: 0f b7 55 d8 movzwl -0x28(%ebp),%edx 80101e61: 8b 03 mov (%ebx),%eax 80101e63: e8 78 f6 ff ff call 801014e0 <iget> } } return 0; } 80101e68: 8d 65 f4 lea -0xc(%ebp),%esp 80101e6b: 5b pop %ebx 80101e6c: 5e pop %esi 80101e6d: 5f pop %edi 80101e6e: 5d pop %ebp 80101e6f: c3 ret 80101e70: 8d 65 f4 lea -0xc(%ebp),%esp inum = de.inum; return iget(dp->dev, inum); } } return 0; 80101e73: 31 c0 xor %eax,%eax } 80101e75: 5b pop %ebx 80101e76: 5e pop %esi 80101e77: 5f pop %edi 80101e78: 5d pop %ebp 80101e79: 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"); 80101e7a: 83 ec 0c sub $0xc,%esp 80101e7d: 68 b9 81 10 80 push $0x801081b9 80101e82: e8 e9 e4 ff ff call 80100370 <panic> { uint off, inum; struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); 80101e87: 83 ec 0c sub $0xc,%esp 80101e8a: 68 a7 81 10 80 push $0x801081a7 80101e8f: e8 dc e4 ff ff call 80100370 <panic> 80101e94: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101e9a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80101ea0 <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) { 80101ea0: 55 push %ebp 80101ea1: 89 e5 mov %esp,%ebp 80101ea3: 57 push %edi 80101ea4: 56 push %esi 80101ea5: 53 push %ebx 80101ea6: 89 cf mov %ecx,%edi 80101ea8: 89 c3 mov %eax,%ebx 80101eaa: 83 ec 1c sub $0x1c,%esp struct inode *ip, *next; if(*path == '/') 80101ead: 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) { 80101eb0: 89 55 e0 mov %edx,-0x20(%ebp) struct inode *ip, *next; if(*path == '/') 80101eb3: 0f 84 53 01 00 00 je 8010200c <namex+0x16c> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); 80101eb9: e8 72 1b 00 00 call 80103a30 <myproc> // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { acquire(&icache.lock); 80101ebe: 83 ec 0c sub $0xc,%esp struct inode *ip, *next; if(*path == '/') ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); 80101ec1: 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); 80101ec4: 68 60 1a 11 80 push $0x80111a60 80101ec9: e8 62 32 00 00 call 80105130 <acquire> ip->ref++; 80101ece: 83 46 08 01 addl $0x1,0x8(%esi) release(&icache.lock); 80101ed2: c7 04 24 60 1a 11 80 movl $0x80111a60,(%esp) 80101ed9: e8 02 33 00 00 call 801051e0 <release> 80101ede: 83 c4 10 add $0x10,%esp 80101ee1: eb 08 jmp 80101eeb <namex+0x4b> 80101ee3: 90 nop 80101ee4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { char *s; int len; while(*path == '/') path++; 80101ee8: 83 c3 01 add $0x1,%ebx skipelem(char *path, char *name) { char *s; int len; while(*path == '/') 80101eeb: 0f b6 03 movzbl (%ebx),%eax 80101eee: 3c 2f cmp $0x2f,%al 80101ef0: 74 f6 je 80101ee8 <namex+0x48> path++; if(*path == 0) 80101ef2: 84 c0 test %al,%al 80101ef4: 0f 84 e3 00 00 00 je 80101fdd <namex+0x13d> return 0; s = path; while(*path != '/' && *path != 0) 80101efa: 0f b6 03 movzbl (%ebx),%eax 80101efd: 89 da mov %ebx,%edx 80101eff: 84 c0 test %al,%al 80101f01: 0f 84 ac 00 00 00 je 80101fb3 <namex+0x113> 80101f07: 3c 2f cmp $0x2f,%al 80101f09: 75 09 jne 80101f14 <namex+0x74> 80101f0b: e9 a3 00 00 00 jmp 80101fb3 <namex+0x113> 80101f10: 84 c0 test %al,%al 80101f12: 74 0a je 80101f1e <namex+0x7e> path++; 80101f14: 83 c2 01 add $0x1,%edx while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101f17: 0f b6 02 movzbl (%edx),%eax 80101f1a: 3c 2f cmp $0x2f,%al 80101f1c: 75 f2 jne 80101f10 <namex+0x70> 80101f1e: 89 d1 mov %edx,%ecx 80101f20: 29 d9 sub %ebx,%ecx path++; len = path - s; if(len >= DIRSIZ) 80101f22: 83 f9 0d cmp $0xd,%ecx 80101f25: 0f 8e 8d 00 00 00 jle 80101fb8 <namex+0x118> memmove(name, s, DIRSIZ); 80101f2b: 83 ec 04 sub $0x4,%esp 80101f2e: 89 55 e4 mov %edx,-0x1c(%ebp) 80101f31: 6a 0e push $0xe 80101f33: 53 push %ebx 80101f34: 57 push %edi 80101f35: e8 a6 33 00 00 call 801052e0 <memmove> path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) path++; 80101f3a: 8b 55 e4 mov -0x1c(%ebp),%edx len = path - s; if(len >= DIRSIZ) memmove(name, s, DIRSIZ); 80101f3d: 83 c4 10 add $0x10,%esp path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) path++; 80101f40: 89 d3 mov %edx,%ebx memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101f42: 80 3a 2f cmpb $0x2f,(%edx) 80101f45: 75 11 jne 80101f58 <namex+0xb8> 80101f47: 89 f6 mov %esi,%esi 80101f49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi path++; 80101f50: 83 c3 01 add $0x1,%ebx memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101f53: 80 3b 2f cmpb $0x2f,(%ebx) 80101f56: 74 f8 je 80101f50 <namex+0xb0> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); while((path = skipelem(path, name)) != 0){ ilock(ip); 80101f58: 83 ec 0c sub $0xc,%esp 80101f5b: 56 push %esi 80101f5c: e8 5f f9 ff ff call 801018c0 <ilock> if(ip->type != T_DIR){ 80101f61: 83 c4 10 add $0x10,%esp 80101f64: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80101f69: 0f 85 7f 00 00 00 jne 80101fee <namex+0x14e> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ 80101f6f: 8b 55 e0 mov -0x20(%ebp),%edx 80101f72: 85 d2 test %edx,%edx 80101f74: 74 09 je 80101f7f <namex+0xdf> 80101f76: 80 3b 00 cmpb $0x0,(%ebx) 80101f79: 0f 84 a3 00 00 00 je 80102022 <namex+0x182> // Stop one level early. iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ 80101f7f: 83 ec 04 sub $0x4,%esp 80101f82: 6a 00 push $0x0 80101f84: 57 push %edi 80101f85: 56 push %esi 80101f86: e8 65 fe ff ff call 80101df0 <dirlookup> 80101f8b: 83 c4 10 add $0x10,%esp 80101f8e: 85 c0 test %eax,%eax 80101f90: 74 5c je 80101fee <namex+0x14e> // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); 80101f92: 83 ec 0c sub $0xc,%esp 80101f95: 89 45 e4 mov %eax,-0x1c(%ebp) 80101f98: 56 push %esi 80101f99: e8 02 fa ff ff call 801019a0 <iunlock> iput(ip); 80101f9e: 89 34 24 mov %esi,(%esp) 80101fa1: e8 4a fa ff ff call 801019f0 <iput> 80101fa6: 8b 45 e4 mov -0x1c(%ebp),%eax 80101fa9: 83 c4 10 add $0x10,%esp 80101fac: 89 c6 mov %eax,%esi 80101fae: e9 38 ff ff ff jmp 80101eeb <namex+0x4b> while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101fb3: 31 c9 xor %ecx,%ecx 80101fb5: 8d 76 00 lea 0x0(%esi),%esi path++; len = path - s; if(len >= DIRSIZ) memmove(name, s, DIRSIZ); else { memmove(name, s, len); 80101fb8: 83 ec 04 sub $0x4,%esp 80101fbb: 89 55 dc mov %edx,-0x24(%ebp) 80101fbe: 89 4d e4 mov %ecx,-0x1c(%ebp) 80101fc1: 51 push %ecx 80101fc2: 53 push %ebx 80101fc3: 57 push %edi 80101fc4: e8 17 33 00 00 call 801052e0 <memmove> name[len] = 0; 80101fc9: 8b 4d e4 mov -0x1c(%ebp),%ecx 80101fcc: 8b 55 dc mov -0x24(%ebp),%edx 80101fcf: 83 c4 10 add $0x10,%esp 80101fd2: c6 04 0f 00 movb $0x0,(%edi,%ecx,1) 80101fd6: 89 d3 mov %edx,%ebx 80101fd8: e9 65 ff ff ff jmp 80101f42 <namex+0xa2> return 0; } iunlockput(ip); ip = next; } if(nameiparent){ 80101fdd: 8b 45 e0 mov -0x20(%ebp),%eax 80101fe0: 85 c0 test %eax,%eax 80101fe2: 75 54 jne 80102038 <namex+0x198> 80101fe4: 89 f0 mov %esi,%eax iput(ip); return 0; } return ip; } 80101fe6: 8d 65 f4 lea -0xc(%ebp),%esp 80101fe9: 5b pop %ebx 80101fea: 5e pop %esi 80101feb: 5f pop %edi 80101fec: 5d pop %ebp 80101fed: c3 ret // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); 80101fee: 83 ec 0c sub $0xc,%esp 80101ff1: 56 push %esi 80101ff2: e8 a9 f9 ff ff call 801019a0 <iunlock> iput(ip); 80101ff7: 89 34 24 mov %esi,(%esp) 80101ffa: e8 f1 f9 ff ff call 801019f0 <iput> iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ iunlockput(ip); return 0; 80101fff: 83 c4 10 add $0x10,%esp if(nameiparent){ iput(ip); return 0; } return ip; } 80102002: 8d 65 f4 lea -0xc(%ebp),%esp iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ iunlockput(ip); return 0; 80102005: 31 c0 xor %eax,%eax if(nameiparent){ iput(ip); return 0; } return ip; } 80102007: 5b pop %ebx 80102008: 5e pop %esi 80102009: 5f pop %edi 8010200a: 5d pop %ebp 8010200b: c3 ret namex(char *path, int nameiparent, char *name) { struct inode *ip, *next; if(*path == '/') ip = iget(ROOTDEV, ROOTINO); 8010200c: ba 01 00 00 00 mov $0x1,%edx 80102011: b8 01 00 00 00 mov $0x1,%eax 80102016: e8 c5 f4 ff ff call 801014e0 <iget> 8010201b: 89 c6 mov %eax,%esi 8010201d: e9 c9 fe ff ff jmp 80101eeb <namex+0x4b> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ // Stop one level early. iunlock(ip); 80102022: 83 ec 0c sub $0xc,%esp 80102025: 56 push %esi 80102026: e8 75 f9 ff ff call 801019a0 <iunlock> return ip; 8010202b: 83 c4 10 add $0x10,%esp if(nameiparent){ iput(ip); return 0; } return ip; } 8010202e: 8d 65 f4 lea -0xc(%ebp),%esp return 0; } if(nameiparent && *path == '\0'){ // Stop one level early. iunlock(ip); return ip; 80102031: 89 f0 mov %esi,%eax if(nameiparent){ iput(ip); return 0; } return ip; } 80102033: 5b pop %ebx 80102034: 5e pop %esi 80102035: 5f pop %edi 80102036: 5d pop %ebp 80102037: c3 ret } iunlockput(ip); ip = next; } if(nameiparent){ iput(ip); 80102038: 83 ec 0c sub $0xc,%esp 8010203b: 56 push %esi 8010203c: e8 af f9 ff ff call 801019f0 <iput> return 0; 80102041: 83 c4 10 add $0x10,%esp 80102044: 31 c0 xor %eax,%eax 80102046: eb 9e jmp 80101fe6 <namex+0x146> 80102048: 90 nop 80102049: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102050 <dirlink>: } // Write a new directory entry (name, inum) into the directory dp. int dirlink(struct inode *dp, char *name, uint inum) { 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 20 sub $0x20,%esp 80102059: 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){ 8010205c: 6a 00 push $0x0 8010205e: ff 75 0c pushl 0xc(%ebp) 80102061: 53 push %ebx 80102062: e8 89 fd ff ff call 80101df0 <dirlookup> 80102067: 83 c4 10 add $0x10,%esp 8010206a: 85 c0 test %eax,%eax 8010206c: 75 67 jne 801020d5 <dirlink+0x85> iput(ip); return -1; } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 8010206e: 8b 7b 58 mov 0x58(%ebx),%edi 80102071: 8d 75 d8 lea -0x28(%ebp),%esi 80102074: 85 ff test %edi,%edi 80102076: 74 29 je 801020a1 <dirlink+0x51> 80102078: 31 ff xor %edi,%edi 8010207a: 8d 75 d8 lea -0x28(%ebp),%esi 8010207d: eb 09 jmp 80102088 <dirlink+0x38> 8010207f: 90 nop 80102080: 83 c7 10 add $0x10,%edi 80102083: 39 7b 58 cmp %edi,0x58(%ebx) 80102086: 76 19 jbe 801020a1 <dirlink+0x51> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80102088: 6a 10 push $0x10 8010208a: 57 push %edi 8010208b: 56 push %esi 8010208c: 53 push %ebx 8010208d: e8 0e fb ff ff call 80101ba0 <readi> 80102092: 83 c4 10 add $0x10,%esp 80102095: 83 f8 10 cmp $0x10,%eax 80102098: 75 4e jne 801020e8 <dirlink+0x98> panic("dirlink read"); if(de.inum == 0) 8010209a: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 8010209f: 75 df jne 80102080 <dirlink+0x30> break; } strncpy(de.name, name, DIRSIZ); 801020a1: 8d 45 da lea -0x26(%ebp),%eax 801020a4: 83 ec 04 sub $0x4,%esp 801020a7: 6a 0e push $0xe 801020a9: ff 75 0c pushl 0xc(%ebp) 801020ac: 50 push %eax 801020ad: e8 1e 33 00 00 call 801053d0 <strncpy> de.inum = inum; 801020b2: 8b 45 10 mov 0x10(%ebp),%eax if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 801020b5: 6a 10 push $0x10 801020b7: 57 push %edi 801020b8: 56 push %esi 801020b9: 53 push %ebx if(de.inum == 0) break; } strncpy(de.name, name, DIRSIZ); de.inum = inum; 801020ba: 66 89 45 d8 mov %ax,-0x28(%ebp) if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 801020be: e8 dd fb ff ff call 80101ca0 <writei> 801020c3: 83 c4 20 add $0x20,%esp 801020c6: 83 f8 10 cmp $0x10,%eax 801020c9: 75 2a jne 801020f5 <dirlink+0xa5> panic("dirlink"); return 0; 801020cb: 31 c0 xor %eax,%eax } 801020cd: 8d 65 f4 lea -0xc(%ebp),%esp 801020d0: 5b pop %ebx 801020d1: 5e pop %esi 801020d2: 5f pop %edi 801020d3: 5d pop %ebp 801020d4: c3 ret struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ iput(ip); 801020d5: 83 ec 0c sub $0xc,%esp 801020d8: 50 push %eax 801020d9: e8 12 f9 ff ff call 801019f0 <iput> return -1; 801020de: 83 c4 10 add $0x10,%esp 801020e1: b8 ff ff ff ff mov $0xffffffff,%eax 801020e6: eb e5 jmp 801020cd <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"); 801020e8: 83 ec 0c sub $0xc,%esp 801020eb: 68 c8 81 10 80 push $0x801081c8 801020f0: e8 7b e2 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"); 801020f5: 83 ec 0c sub $0xc,%esp 801020f8: 68 46 89 10 80 push $0x80108946 801020fd: e8 6e e2 ff ff call 80100370 <panic> 80102102: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102109: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102110 <namei>: return ip; } struct inode* namei(char *path) { 80102110: 55 push %ebp char name[DIRSIZ]; return namex(path, 0, name); 80102111: 31 d2 xor %edx,%edx return ip; } struct inode* namei(char *path) { 80102113: 89 e5 mov %esp,%ebp 80102115: 83 ec 18 sub $0x18,%esp char name[DIRSIZ]; return namex(path, 0, name); 80102118: 8b 45 08 mov 0x8(%ebp),%eax 8010211b: 8d 4d ea lea -0x16(%ebp),%ecx 8010211e: e8 7d fd ff ff call 80101ea0 <namex> } 80102123: c9 leave 80102124: c3 ret 80102125: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102130 <nameiparent>: struct inode* nameiparent(char *path, char *name) { 80102130: 55 push %ebp return namex(path, 1, name); 80102131: ba 01 00 00 00 mov $0x1,%edx return namex(path, 0, name); } struct inode* nameiparent(char *path, char *name) { 80102136: 89 e5 mov %esp,%ebp return namex(path, 1, name); 80102138: 8b 4d 0c mov 0xc(%ebp),%ecx 8010213b: 8b 45 08 mov 0x8(%ebp),%eax } 8010213e: 5d pop %ebp } struct inode* nameiparent(char *path, char *name) { return namex(path, 1, name); 8010213f: e9 5c fd ff ff jmp 80101ea0 <namex> 80102144: 66 90 xchg %ax,%ax 80102146: 66 90 xchg %ax,%ax 80102148: 66 90 xchg %ax,%ax 8010214a: 66 90 xchg %ax,%ax 8010214c: 66 90 xchg %ax,%ax 8010214e: 66 90 xchg %ax,%ax 80102150 <idestart>: } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80102150: 55 push %ebp if(b == 0) 80102151: 85 c0 test %eax,%eax } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80102153: 89 e5 mov %esp,%ebp 80102155: 56 push %esi 80102156: 53 push %ebx if(b == 0) 80102157: 0f 84 ad 00 00 00 je 8010220a <idestart+0xba> panic("idestart"); if(b->blockno >= FSSIZE) 8010215d: 8b 58 08 mov 0x8(%eax),%ebx 80102160: 89 c1 mov %eax,%ecx 80102162: 81 fb e7 03 00 00 cmp $0x3e7,%ebx 80102168: 0f 87 8f 00 00 00 ja 801021fd <idestart+0xad> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010216e: ba f7 01 00 00 mov $0x1f7,%edx 80102173: 90 nop 80102174: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102178: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102179: 83 e0 c0 and $0xffffffc0,%eax 8010217c: 3c 40 cmp $0x40,%al 8010217e: 75 f8 jne 80102178 <idestart+0x28> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102180: 31 f6 xor %esi,%esi 80102182: ba f6 03 00 00 mov $0x3f6,%edx 80102187: 89 f0 mov %esi,%eax 80102189: ee out %al,(%dx) 8010218a: ba f2 01 00 00 mov $0x1f2,%edx 8010218f: b8 01 00 00 00 mov $0x1,%eax 80102194: ee out %al,(%dx) 80102195: ba f3 01 00 00 mov $0x1f3,%edx 8010219a: 89 d8 mov %ebx,%eax 8010219c: ee out %al,(%dx) 8010219d: 89 d8 mov %ebx,%eax 8010219f: ba f4 01 00 00 mov $0x1f4,%edx 801021a4: c1 f8 08 sar $0x8,%eax 801021a7: ee out %al,(%dx) 801021a8: ba f5 01 00 00 mov $0x1f5,%edx 801021ad: 89 f0 mov %esi,%eax 801021af: ee out %al,(%dx) 801021b0: 0f b6 41 04 movzbl 0x4(%ecx),%eax 801021b4: ba f6 01 00 00 mov $0x1f6,%edx 801021b9: 83 e0 01 and $0x1,%eax 801021bc: c1 e0 04 shl $0x4,%eax 801021bf: 83 c8 e0 or $0xffffffe0,%eax 801021c2: 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){ 801021c3: f6 01 04 testb $0x4,(%ecx) 801021c6: ba f7 01 00 00 mov $0x1f7,%edx 801021cb: 75 13 jne 801021e0 <idestart+0x90> 801021cd: b8 20 00 00 00 mov $0x20,%eax 801021d2: ee out %al,(%dx) outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); } else { outb(0x1f7, read_cmd); } } 801021d3: 8d 65 f8 lea -0x8(%ebp),%esp 801021d6: 5b pop %ebx 801021d7: 5e pop %esi 801021d8: 5d pop %ebp 801021d9: c3 ret 801021da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801021e0: b8 30 00 00 00 mov $0x30,%eax 801021e5: ee out %al,(%dx) } static inline void outsl(int port, const void *addr, int cnt) { asm volatile("cld; rep outsl" : 801021e6: 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); 801021eb: 8d 71 5c lea 0x5c(%ecx),%esi 801021ee: b9 80 00 00 00 mov $0x80,%ecx 801021f3: fc cld 801021f4: f3 6f rep outsl %ds:(%esi),(%dx) } else { outb(0x1f7, read_cmd); } } 801021f6: 8d 65 f8 lea -0x8(%ebp),%esp 801021f9: 5b pop %ebx 801021fa: 5e pop %esi 801021fb: 5d pop %ebp 801021fc: c3 ret idestart(struct buf *b) { if(b == 0) panic("idestart"); if(b->blockno >= FSSIZE) panic("incorrect blockno"); 801021fd: 83 ec 0c sub $0xc,%esp 80102200: 68 34 82 10 80 push $0x80108234 80102205: e8 66 e1 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"); 8010220a: 83 ec 0c sub $0xc,%esp 8010220d: 68 2b 82 10 80 push $0x8010822b 80102212: e8 59 e1 ff ff call 80100370 <panic> 80102217: 89 f6 mov %esi,%esi 80102219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102220 <ideinit>: return 0; } void ideinit(void) { 80102220: 55 push %ebp 80102221: 89 e5 mov %esp,%ebp 80102223: 83 ec 10 sub $0x10,%esp int i; initlock(&idelock, "ide"); 80102226: 68 46 82 10 80 push $0x80108246 8010222b: 68 80 b5 10 80 push $0x8010b580 80102230: e8 9b 2d 00 00 call 80104fd0 <initlock> ioapicenable(IRQ_IDE, ncpu - 1); 80102235: 58 pop %eax 80102236: a1 b0 38 11 80 mov 0x801138b0,%eax 8010223b: 5a pop %edx 8010223c: 83 e8 01 sub $0x1,%eax 8010223f: 50 push %eax 80102240: 6a 0e push $0xe 80102242: e8 a9 02 00 00 call 801024f0 <ioapicenable> 80102247: 83 c4 10 add $0x10,%esp static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010224a: ba f7 01 00 00 mov $0x1f7,%edx 8010224f: 90 nop 80102250: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102251: 83 e0 c0 and $0xffffffc0,%eax 80102254: 3c 40 cmp $0x40,%al 80102256: 75 f8 jne 80102250 <ideinit+0x30> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102258: ba f6 01 00 00 mov $0x1f6,%edx 8010225d: b8 f0 ff ff ff mov $0xfffffff0,%eax 80102262: ee out %al,(%dx) 80102263: 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)); 80102268: ba f7 01 00 00 mov $0x1f7,%edx 8010226d: eb 06 jmp 80102275 <ideinit+0x55> 8010226f: 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++){ 80102270: 83 e9 01 sub $0x1,%ecx 80102273: 74 0f je 80102284 <ideinit+0x64> 80102275: ec in (%dx),%al if(inb(0x1f7) != 0){ 80102276: 84 c0 test %al,%al 80102278: 74 f6 je 80102270 <ideinit+0x50> havedisk1 = 1; 8010227a: c7 05 60 b5 10 80 01 movl $0x1,0x8010b560 80102281: 00 00 00 } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102284: ba f6 01 00 00 mov $0x1f6,%edx 80102289: b8 e0 ff ff ff mov $0xffffffe0,%eax 8010228e: ee out %al,(%dx) } } // Switch back to disk 0. outb(0x1f6, 0xe0 | (0<<4)); } 8010228f: c9 leave 80102290: c3 ret 80102291: eb 0d jmp 801022a0 <ideintr> 80102293: 90 nop 80102294: 90 nop 80102295: 90 nop 80102296: 90 nop 80102297: 90 nop 80102298: 90 nop 80102299: 90 nop 8010229a: 90 nop 8010229b: 90 nop 8010229c: 90 nop 8010229d: 90 nop 8010229e: 90 nop 8010229f: 90 nop 801022a0 <ideintr>: } // Interrupt handler. void ideintr(void) { 801022a0: 55 push %ebp 801022a1: 89 e5 mov %esp,%ebp 801022a3: 57 push %edi 801022a4: 56 push %esi 801022a5: 53 push %ebx 801022a6: 83 ec 18 sub $0x18,%esp struct buf *b; // First queued buffer is the active request. acquire(&idelock); 801022a9: 68 80 b5 10 80 push $0x8010b580 801022ae: e8 7d 2e 00 00 call 80105130 <acquire> if((b = idequeue) == 0){ 801022b3: 8b 1d 64 b5 10 80 mov 0x8010b564,%ebx 801022b9: 83 c4 10 add $0x10,%esp 801022bc: 85 db test %ebx,%ebx 801022be: 74 34 je 801022f4 <ideintr+0x54> release(&idelock); return; } idequeue = b->qnext; 801022c0: 8b 43 58 mov 0x58(%ebx),%eax 801022c3: a3 64 b5 10 80 mov %eax,0x8010b564 // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) 801022c8: 8b 33 mov (%ebx),%esi 801022ca: f7 c6 04 00 00 00 test $0x4,%esi 801022d0: 74 3e je 80102310 <ideintr+0x70> insl(0x1f0, b->data, BSIZE/4); // Wake process waiting for this buf. b->flags |= B_VALID; b->flags &= ~B_DIRTY; 801022d2: 83 e6 fb and $0xfffffffb,%esi wakeup(b); 801022d5: 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; 801022d8: 83 ce 02 or $0x2,%esi 801022db: 89 33 mov %esi,(%ebx) wakeup(b); 801022dd: 53 push %ebx 801022de: e8 ad 22 00 00 call 80104590 <wakeup> // Start disk on next buf in queue. if(idequeue != 0) 801022e3: a1 64 b5 10 80 mov 0x8010b564,%eax 801022e8: 83 c4 10 add $0x10,%esp 801022eb: 85 c0 test %eax,%eax 801022ed: 74 05 je 801022f4 <ideintr+0x54> idestart(idequeue); 801022ef: e8 5c fe ff ff call 80102150 <idestart> // First queued buffer is the active request. acquire(&idelock); if((b = idequeue) == 0){ release(&idelock); 801022f4: 83 ec 0c sub $0xc,%esp 801022f7: 68 80 b5 10 80 push $0x8010b580 801022fc: e8 df 2e 00 00 call 801051e0 <release> // Start disk on next buf in queue. if(idequeue != 0) idestart(idequeue); release(&idelock); } 80102301: 8d 65 f4 lea -0xc(%ebp),%esp 80102304: 5b pop %ebx 80102305: 5e pop %esi 80102306: 5f pop %edi 80102307: 5d pop %ebp 80102308: c3 ret 80102309: 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)); 80102310: ba f7 01 00 00 mov $0x1f7,%edx 80102315: 8d 76 00 lea 0x0(%esi),%esi 80102318: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102319: 89 c1 mov %eax,%ecx 8010231b: 83 e1 c0 and $0xffffffc0,%ecx 8010231e: 80 f9 40 cmp $0x40,%cl 80102321: 75 f5 jne 80102318 <ideintr+0x78> ; if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) 80102323: a8 21 test $0x21,%al 80102325: 75 ab jne 801022d2 <ideintr+0x32> } idequeue = b->qnext; // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) insl(0x1f0, b->data, BSIZE/4); 80102327: 8d 7b 5c lea 0x5c(%ebx),%edi } static inline void insl(int port, void *addr, int cnt) { asm volatile("cld; rep insl" : 8010232a: b9 80 00 00 00 mov $0x80,%ecx 8010232f: ba f0 01 00 00 mov $0x1f0,%edx 80102334: fc cld 80102335: f3 6d rep insl (%dx),%es:(%edi) 80102337: 8b 33 mov (%ebx),%esi 80102339: eb 97 jmp 801022d2 <ideintr+0x32> 8010233b: 90 nop 8010233c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102340 <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) { 80102340: 55 push %ebp 80102341: 89 e5 mov %esp,%ebp 80102343: 53 push %ebx 80102344: 83 ec 10 sub $0x10,%esp 80102347: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf **pp; if(!holdingsleep(&b->lock)) 8010234a: 8d 43 0c lea 0xc(%ebx),%eax 8010234d: 50 push %eax 8010234e: e8 2d 2c 00 00 call 80104f80 <holdingsleep> 80102353: 83 c4 10 add $0x10,%esp 80102356: 85 c0 test %eax,%eax 80102358: 0f 84 ad 00 00 00 je 8010240b <iderw+0xcb> panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) 8010235e: 8b 03 mov (%ebx),%eax 80102360: 83 e0 06 and $0x6,%eax 80102363: 83 f8 02 cmp $0x2,%eax 80102366: 0f 84 b9 00 00 00 je 80102425 <iderw+0xe5> panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) 8010236c: 8b 53 04 mov 0x4(%ebx),%edx 8010236f: 85 d2 test %edx,%edx 80102371: 74 0d je 80102380 <iderw+0x40> 80102373: a1 60 b5 10 80 mov 0x8010b560,%eax 80102378: 85 c0 test %eax,%eax 8010237a: 0f 84 98 00 00 00 je 80102418 <iderw+0xd8> panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock 80102380: 83 ec 0c sub $0xc,%esp 80102383: 68 80 b5 10 80 push $0x8010b580 80102388: e8 a3 2d 00 00 call 80105130 <acquire> // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 8010238d: 8b 15 64 b5 10 80 mov 0x8010b564,%edx 80102393: 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; 80102396: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 8010239d: 85 d2 test %edx,%edx 8010239f: 75 09 jne 801023aa <iderw+0x6a> 801023a1: eb 58 jmp 801023fb <iderw+0xbb> 801023a3: 90 nop 801023a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801023a8: 89 c2 mov %eax,%edx 801023aa: 8b 42 58 mov 0x58(%edx),%eax 801023ad: 85 c0 test %eax,%eax 801023af: 75 f7 jne 801023a8 <iderw+0x68> 801023b1: 83 c2 58 add $0x58,%edx ; *pp = b; 801023b4: 89 1a mov %ebx,(%edx) // Start disk if necessary. if(idequeue == b) 801023b6: 3b 1d 64 b5 10 80 cmp 0x8010b564,%ebx 801023bc: 74 44 je 80102402 <iderw+0xc2> idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801023be: 8b 03 mov (%ebx),%eax 801023c0: 83 e0 06 and $0x6,%eax 801023c3: 83 f8 02 cmp $0x2,%eax 801023c6: 74 23 je 801023eb <iderw+0xab> 801023c8: 90 nop 801023c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi sleep(b, &idelock); 801023d0: 83 ec 08 sub $0x8,%esp 801023d3: 68 80 b5 10 80 push $0x8010b580 801023d8: 53 push %ebx 801023d9: e8 f2 1f 00 00 call 801043d0 <sleep> // Start disk if necessary. if(idequeue == b) idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801023de: 8b 03 mov (%ebx),%eax 801023e0: 83 c4 10 add $0x10,%esp 801023e3: 83 e0 06 and $0x6,%eax 801023e6: 83 f8 02 cmp $0x2,%eax 801023e9: 75 e5 jne 801023d0 <iderw+0x90> sleep(b, &idelock); } release(&idelock); 801023eb: c7 45 08 80 b5 10 80 movl $0x8010b580,0x8(%ebp) } 801023f2: 8b 5d fc mov -0x4(%ebp),%ebx 801023f5: c9 leave while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ sleep(b, &idelock); } release(&idelock); 801023f6: e9 e5 2d 00 00 jmp 801051e0 <release> acquire(&idelock); //DOC:acquire-lock // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 801023fb: ba 64 b5 10 80 mov $0x8010b564,%edx 80102400: eb b2 jmp 801023b4 <iderw+0x74> ; *pp = b; // Start disk if necessary. if(idequeue == b) idestart(b); 80102402: 89 d8 mov %ebx,%eax 80102404: e8 47 fd ff ff call 80102150 <idestart> 80102409: eb b3 jmp 801023be <iderw+0x7e> iderw(struct buf *b) { struct buf **pp; if(!holdingsleep(&b->lock)) panic("iderw: buf not locked"); 8010240b: 83 ec 0c sub $0xc,%esp 8010240e: 68 4a 82 10 80 push $0x8010824a 80102413: e8 58 df 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"); 80102418: 83 ec 0c sub $0xc,%esp 8010241b: 68 75 82 10 80 push $0x80108275 80102420: e8 4b df 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"); 80102425: 83 ec 0c sub $0xc,%esp 80102428: 68 60 82 10 80 push $0x80108260 8010242d: e8 3e df ff ff call 80100370 <panic> 80102432: 66 90 xchg %ax,%ax 80102434: 66 90 xchg %ax,%ax 80102436: 66 90 xchg %ax,%ax 80102438: 66 90 xchg %ax,%ax 8010243a: 66 90 xchg %ax,%ax 8010243c: 66 90 xchg %ax,%ax 8010243e: 66 90 xchg %ax,%ax 80102440 <ioapicinit>: ioapic->data = data; } void ioapicinit(void) { 80102440: 55 push %ebp int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; 80102441: c7 05 b4 36 11 80 00 movl $0xfec00000,0x801136b4 80102448: 00 c0 fe ioapic->data = data; } void ioapicinit(void) { 8010244b: 89 e5 mov %esp,%ebp 8010244d: 56 push %esi 8010244e: 53 push %ebx }; static uint ioapicread(int reg) { ioapic->reg = reg; 8010244f: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 80102456: 00 00 00 return ioapic->data; 80102459: 8b 15 b4 36 11 80 mov 0x801136b4,%edx 8010245f: 8b 72 10 mov 0x10(%edx),%esi }; static uint ioapicread(int reg) { ioapic->reg = reg; 80102462: c7 02 00 00 00 00 movl $0x0,(%edx) return ioapic->data; 80102468: 8b 0d b4 36 11 80 mov 0x801136b4,%ecx int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 8010246e: 0f b6 15 e0 37 11 80 movzbl 0x801137e0,%edx ioapicinit(void) { int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 80102475: 89 f0 mov %esi,%eax 80102477: c1 e8 10 shr $0x10,%eax 8010247a: 0f b6 f0 movzbl %al,%esi static uint ioapicread(int reg) { ioapic->reg = reg; return ioapic->data; 8010247d: 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) 80102480: c1 e8 18 shr $0x18,%eax 80102483: 39 d0 cmp %edx,%eax 80102485: 74 16 je 8010249d <ioapicinit+0x5d> cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); 80102487: 83 ec 0c sub $0xc,%esp 8010248a: 68 94 82 10 80 push $0x80108294 8010248f: e8 cc e1 ff ff call 80100660 <cprintf> 80102494: 8b 0d b4 36 11 80 mov 0x801136b4,%ecx 8010249a: 83 c4 10 add $0x10,%esp 8010249d: 83 c6 21 add $0x21,%esi ioapic->data = data; } void ioapicinit(void) { 801024a0: ba 10 00 00 00 mov $0x10,%edx 801024a5: b8 20 00 00 00 mov $0x20,%eax 801024aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801024b0: 89 11 mov %edx,(%ecx) ioapic->data = data; 801024b2: 8b 0d b4 36 11 80 mov 0x801136b4,%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)); 801024b8: 89 c3 mov %eax,%ebx 801024ba: 81 cb 00 00 01 00 or $0x10000,%ebx 801024c0: 83 c0 01 add $0x1,%eax static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 801024c3: 89 59 10 mov %ebx,0x10(%ecx) 801024c6: 8d 5a 01 lea 0x1(%edx),%ebx 801024c9: 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++){ 801024cc: 39 f0 cmp %esi,%eax } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801024ce: 89 19 mov %ebx,(%ecx) ioapic->data = data; 801024d0: 8b 0d b4 36 11 80 mov 0x801136b4,%ecx 801024d6: 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++){ 801024dd: 75 d1 jne 801024b0 <ioapicinit+0x70> ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); ioapicwrite(REG_TABLE+2*i+1, 0); } } 801024df: 8d 65 f8 lea -0x8(%ebp),%esp 801024e2: 5b pop %ebx 801024e3: 5e pop %esi 801024e4: 5d pop %ebp 801024e5: c3 ret 801024e6: 8d 76 00 lea 0x0(%esi),%esi 801024e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801024f0 <ioapicenable>: void ioapicenable(int irq, int cpunum) { 801024f0: 55 push %ebp } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 801024f1: 8b 0d b4 36 11 80 mov 0x801136b4,%ecx } } void ioapicenable(int irq, int cpunum) { 801024f7: 89 e5 mov %esp,%ebp 801024f9: 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); 801024fc: 8d 50 20 lea 0x20(%eax),%edx 801024ff: 8d 44 00 10 lea 0x10(%eax,%eax,1),%eax } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102503: 89 01 mov %eax,(%ecx) ioapic->data = data; 80102505: 8b 0d b4 36 11 80 mov 0x801136b4,%ecx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 8010250b: 83 c0 01 add $0x1,%eax ioapic->data = data; 8010250e: 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); 80102511: 8b 55 0c mov 0xc(%ebp),%edx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102514: 89 01 mov %eax,(%ecx) ioapic->data = data; 80102516: a1 b4 36 11 80 mov 0x801136b4,%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); 8010251b: c1 e2 18 shl $0x18,%edx static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 8010251e: 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); } 80102521: 5d pop %ebp 80102522: c3 ret 80102523: 66 90 xchg %ax,%ax 80102525: 66 90 xchg %ax,%ax 80102527: 66 90 xchg %ax,%ax 80102529: 66 90 xchg %ax,%ax 8010252b: 66 90 xchg %ax,%ax 8010252d: 66 90 xchg %ax,%ax 8010252f: 90 nop 80102530 <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) { 80102530: 55 push %ebp 80102531: 89 e5 mov %esp,%ebp 80102533: 53 push %ebx 80102534: 83 ec 04 sub $0x4,%esp 80102537: 8b 5d 08 mov 0x8(%ebp),%ebx struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) 8010253a: f7 c3 ff 0f 00 00 test $0xfff,%ebx 80102540: 75 70 jne 801025b2 <kfree+0x82> 80102542: 81 fb 68 66 11 80 cmp $0x80116668,%ebx 80102548: 72 68 jb 801025b2 <kfree+0x82> 8010254a: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80102550: 3d ff ff ff 0d cmp $0xdffffff,%eax 80102555: 77 5b ja 801025b2 <kfree+0x82> panic("kfree"); // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); 80102557: 83 ec 04 sub $0x4,%esp 8010255a: 68 00 10 00 00 push $0x1000 8010255f: 6a 01 push $0x1 80102561: 53 push %ebx 80102562: e8 c9 2c 00 00 call 80105230 <memset> if(kmem.use_lock) 80102567: 8b 15 f4 36 11 80 mov 0x801136f4,%edx 8010256d: 83 c4 10 add $0x10,%esp 80102570: 85 d2 test %edx,%edx 80102572: 75 2c jne 801025a0 <kfree+0x70> acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; 80102574: a1 f8 36 11 80 mov 0x801136f8,%eax 80102579: 89 03 mov %eax,(%ebx) kmem.freelist = r; if(kmem.use_lock) 8010257b: a1 f4 36 11 80 mov 0x801136f4,%eax if(kmem.use_lock) acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; 80102580: 89 1d f8 36 11 80 mov %ebx,0x801136f8 if(kmem.use_lock) 80102586: 85 c0 test %eax,%eax 80102588: 75 06 jne 80102590 <kfree+0x60> release(&kmem.lock); } 8010258a: 8b 5d fc mov -0x4(%ebp),%ebx 8010258d: c9 leave 8010258e: c3 ret 8010258f: 90 nop acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 80102590: c7 45 08 c0 36 11 80 movl $0x801136c0,0x8(%ebp) } 80102597: 8b 5d fc mov -0x4(%ebp),%ebx 8010259a: c9 leave acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 8010259b: e9 40 2c 00 00 jmp 801051e0 <release> // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); if(kmem.use_lock) acquire(&kmem.lock); 801025a0: 83 ec 0c sub $0xc,%esp 801025a3: 68 c0 36 11 80 push $0x801136c0 801025a8: e8 83 2b 00 00 call 80105130 <acquire> 801025ad: 83 c4 10 add $0x10,%esp 801025b0: eb c2 jmp 80102574 <kfree+0x44> kfree(char *v) { struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) panic("kfree"); 801025b2: 83 ec 0c sub $0xc,%esp 801025b5: 68 c6 82 10 80 push $0x801082c6 801025ba: e8 b1 dd ff ff call 80100370 <panic> 801025bf: 90 nop 801025c0 <freerange>: kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 801025c0: 55 push %ebp 801025c1: 89 e5 mov %esp,%ebp 801025c3: 56 push %esi 801025c4: 53 push %ebx char *p; p = (char*)PGROUNDUP((uint)vstart); 801025c5: 8b 45 08 mov 0x8(%ebp),%eax kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 801025c8: 8b 75 0c mov 0xc(%ebp),%esi char *p; p = (char*)PGROUNDUP((uint)vstart); 801025cb: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 801025d1: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801025d7: 81 c3 00 10 00 00 add $0x1000,%ebx 801025dd: 39 de cmp %ebx,%esi 801025df: 72 23 jb 80102604 <freerange+0x44> 801025e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi kfree(p); 801025e8: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax 801025ee: 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) 801025f1: 81 c3 00 10 00 00 add $0x1000,%ebx kfree(p); 801025f7: 50 push %eax 801025f8: e8 33 ff ff ff call 80102530 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801025fd: 83 c4 10 add $0x10,%esp 80102600: 39 f3 cmp %esi,%ebx 80102602: 76 e4 jbe 801025e8 <freerange+0x28> kfree(p); } 80102604: 8d 65 f8 lea -0x8(%ebp),%esp 80102607: 5b pop %ebx 80102608: 5e pop %esi 80102609: 5d pop %ebp 8010260a: c3 ret 8010260b: 90 nop 8010260c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102610 <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) { 80102610: 55 push %ebp 80102611: 89 e5 mov %esp,%ebp 80102613: 56 push %esi 80102614: 53 push %ebx 80102615: 8b 75 0c mov 0xc(%ebp),%esi initlock(&kmem.lock, "kmem"); 80102618: 83 ec 08 sub $0x8,%esp 8010261b: 68 cc 82 10 80 push $0x801082cc 80102620: 68 c0 36 11 80 push $0x801136c0 80102625: e8 a6 29 00 00 call 80104fd0 <initlock> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 8010262a: 8b 45 08 mov 0x8(%ebp),%eax for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 8010262d: 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; 80102630: c7 05 f4 36 11 80 00 movl $0x0,0x801136f4 80102637: 00 00 00 void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 8010263a: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80102640: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102646: 81 c3 00 10 00 00 add $0x1000,%ebx 8010264c: 39 de cmp %ebx,%esi 8010264e: 72 1c jb 8010266c <kinit1+0x5c> kfree(p); 80102650: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax 80102656: 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) 80102659: 81 c3 00 10 00 00 add $0x1000,%ebx kfree(p); 8010265f: 50 push %eax 80102660: e8 cb fe ff ff call 80102530 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102665: 83 c4 10 add $0x10,%esp 80102668: 39 de cmp %ebx,%esi 8010266a: 73 e4 jae 80102650 <kinit1+0x40> kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; freerange(vstart, vend); } 8010266c: 8d 65 f8 lea -0x8(%ebp),%esp 8010266f: 5b pop %ebx 80102670: 5e pop %esi 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 <kinit2>: void kinit2(void *vstart, void *vend) { 80102680: 55 push %ebp 80102681: 89 e5 mov %esp,%ebp 80102683: 56 push %esi 80102684: 53 push %ebx void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 80102685: 8b 45 08 mov 0x8(%ebp),%eax freerange(vstart, vend); } void kinit2(void *vstart, void *vend) { 80102688: 8b 75 0c mov 0xc(%ebp),%esi void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); 8010268b: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80102691: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102697: 81 c3 00 10 00 00 add $0x1000,%ebx 8010269d: 39 de cmp %ebx,%esi 8010269f: 72 23 jb 801026c4 <kinit2+0x44> 801026a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi kfree(p); 801026a8: 8d 83 00 f0 ff ff lea -0x1000(%ebx),%eax 801026ae: 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) 801026b1: 81 c3 00 10 00 00 add $0x1000,%ebx kfree(p); 801026b7: 50 push %eax 801026b8: e8 73 fe ff ff call 80102530 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801026bd: 83 c4 10 add $0x10,%esp 801026c0: 39 de cmp %ebx,%esi 801026c2: 73 e4 jae 801026a8 <kinit2+0x28> void kinit2(void *vstart, void *vend) { freerange(vstart, vend); kmem.use_lock = 1; 801026c4: c7 05 f4 36 11 80 01 movl $0x1,0x801136f4 801026cb: 00 00 00 } 801026ce: 8d 65 f8 lea -0x8(%ebp),%esp 801026d1: 5b pop %ebx 801026d2: 5e pop %esi 801026d3: 5d pop %ebp 801026d4: c3 ret 801026d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801026d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801026e0 <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) { 801026e0: 55 push %ebp 801026e1: 89 e5 mov %esp,%ebp 801026e3: 53 push %ebx 801026e4: 83 ec 04 sub $0x4,%esp struct run *r; if(kmem.use_lock) 801026e7: a1 f4 36 11 80 mov 0x801136f4,%eax 801026ec: 85 c0 test %eax,%eax 801026ee: 75 30 jne 80102720 <kalloc+0x40> acquire(&kmem.lock); r = kmem.freelist; 801026f0: 8b 1d f8 36 11 80 mov 0x801136f8,%ebx if(r) 801026f6: 85 db test %ebx,%ebx 801026f8: 74 1c je 80102716 <kalloc+0x36> kmem.freelist = r->next; 801026fa: 8b 13 mov (%ebx),%edx 801026fc: 89 15 f8 36 11 80 mov %edx,0x801136f8 if(kmem.use_lock) 80102702: 85 c0 test %eax,%eax 80102704: 74 10 je 80102716 <kalloc+0x36> release(&kmem.lock); 80102706: 83 ec 0c sub $0xc,%esp 80102709: 68 c0 36 11 80 push $0x801136c0 8010270e: e8 cd 2a 00 00 call 801051e0 <release> 80102713: 83 c4 10 add $0x10,%esp return (char*)r; } 80102716: 89 d8 mov %ebx,%eax 80102718: 8b 5d fc mov -0x4(%ebp),%ebx 8010271b: c9 leave 8010271c: c3 ret 8010271d: 8d 76 00 lea 0x0(%esi),%esi kalloc(void) { struct run *r; if(kmem.use_lock) acquire(&kmem.lock); 80102720: 83 ec 0c sub $0xc,%esp 80102723: 68 c0 36 11 80 push $0x801136c0 80102728: e8 03 2a 00 00 call 80105130 <acquire> r = kmem.freelist; 8010272d: 8b 1d f8 36 11 80 mov 0x801136f8,%ebx if(r) 80102733: 83 c4 10 add $0x10,%esp 80102736: a1 f4 36 11 80 mov 0x801136f4,%eax 8010273b: 85 db test %ebx,%ebx 8010273d: 75 bb jne 801026fa <kalloc+0x1a> 8010273f: eb c1 jmp 80102702 <kalloc+0x22> 80102741: 66 90 xchg %ax,%ax 80102743: 66 90 xchg %ax,%ax 80102745: 66 90 xchg %ax,%ax 80102747: 66 90 xchg %ax,%ax 80102749: 66 90 xchg %ax,%ax 8010274b: 66 90 xchg %ax,%ax 8010274d: 66 90 xchg %ax,%ax 8010274f: 90 nop 80102750 <kbdgetc>: #include "defs.h" #include "kbd.h" int kbdgetc(void) { 80102750: 55 push %ebp static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102751: ba 64 00 00 00 mov $0x64,%edx 80102756: 89 e5 mov %esp,%ebp 80102758: ec in (%dx),%al normalmap, shiftmap, ctlmap, ctlmap }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) 80102759: a8 01 test $0x1,%al 8010275b: 0f 84 af 00 00 00 je 80102810 <kbdgetc+0xc0> 80102761: ba 60 00 00 00 mov $0x60,%edx 80102766: ec in (%dx),%al return -1; data = inb(KBDATAP); 80102767: 0f b6 d0 movzbl %al,%edx if(data == 0xE0){ 8010276a: 81 fa e0 00 00 00 cmp $0xe0,%edx 80102770: 74 7e je 801027f0 <kbdgetc+0xa0> shift |= E0ESC; return 0; } else if(data & 0x80){ 80102772: 84 c0 test %al,%al // Key released data = (shift & E0ESC ? data : data & 0x7F); 80102774: 8b 0d b4 b5 10 80 mov 0x8010b5b4,%ecx data = inb(KBDATAP); if(data == 0xE0){ shift |= E0ESC; return 0; } else if(data & 0x80){ 8010277a: 79 24 jns 801027a0 <kbdgetc+0x50> // Key released data = (shift & E0ESC ? data : data & 0x7F); 8010277c: f6 c1 40 test $0x40,%cl 8010277f: 75 05 jne 80102786 <kbdgetc+0x36> 80102781: 89 c2 mov %eax,%edx 80102783: 83 e2 7f and $0x7f,%edx shift &= ~(shiftcode[data] | E0ESC); 80102786: 0f b6 82 00 84 10 80 movzbl -0x7fef7c00(%edx),%eax 8010278d: 83 c8 40 or $0x40,%eax 80102790: 0f b6 c0 movzbl %al,%eax 80102793: f7 d0 not %eax 80102795: 21 c8 and %ecx,%eax 80102797: a3 b4 b5 10 80 mov %eax,0x8010b5b4 return 0; 8010279c: 31 c0 xor %eax,%eax c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 8010279e: 5d pop %ebp 8010279f: c3 ret } else if(data & 0x80){ // Key released data = (shift & E0ESC ? data : data & 0x7F); shift &= ~(shiftcode[data] | E0ESC); return 0; } else if(shift & E0ESC){ 801027a0: f6 c1 40 test $0x40,%cl 801027a3: 74 09 je 801027ae <kbdgetc+0x5e> // Last character was an E0 escape; or with 0x80 data |= 0x80; 801027a5: 83 c8 80 or $0xffffff80,%eax shift &= ~E0ESC; 801027a8: 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; 801027ab: 0f b6 d0 movzbl %al,%edx shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; 801027ae: 0f b6 82 00 84 10 80 movzbl -0x7fef7c00(%edx),%eax 801027b5: 09 c1 or %eax,%ecx 801027b7: 0f b6 82 00 83 10 80 movzbl -0x7fef7d00(%edx),%eax 801027be: 31 c1 xor %eax,%ecx c = charcode[shift & (CTL | SHIFT)][data]; 801027c0: 89 c8 mov %ecx,%eax data |= 0x80; shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; 801027c2: 89 0d b4 b5 10 80 mov %ecx,0x8010b5b4 c = charcode[shift & (CTL | SHIFT)][data]; 801027c8: 83 e0 03 and $0x3,%eax if(shift & CAPSLOCK){ 801027cb: 83 e1 08 and $0x8,%ecx shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; c = charcode[shift & (CTL | SHIFT)][data]; 801027ce: 8b 04 85 e0 82 10 80 mov -0x7fef7d20(,%eax,4),%eax 801027d5: 0f b6 04 10 movzbl (%eax,%edx,1),%eax if(shift & CAPSLOCK){ 801027d9: 74 c3 je 8010279e <kbdgetc+0x4e> if('a' <= c && c <= 'z') 801027db: 8d 50 9f lea -0x61(%eax),%edx 801027de: 83 fa 19 cmp $0x19,%edx 801027e1: 77 1d ja 80102800 <kbdgetc+0xb0> c += 'A' - 'a'; 801027e3: 83 e8 20 sub $0x20,%eax else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801027e6: 5d pop %ebp 801027e7: c3 ret 801027e8: 90 nop 801027e9: 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; 801027f0: 31 c0 xor %eax,%eax if((st & KBS_DIB) == 0) return -1; data = inb(KBDATAP); if(data == 0xE0){ shift |= E0ESC; 801027f2: 83 0d b4 b5 10 80 40 orl $0x40,0x8010b5b4 c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801027f9: 5d pop %ebp 801027fa: c3 ret 801027fb: 90 nop 801027fc: 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') 80102800: 8d 48 bf lea -0x41(%eax),%ecx c += 'a' - 'A'; 80102803: 8d 50 20 lea 0x20(%eax),%edx } return c; } 80102806: 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'; 80102807: 83 f9 19 cmp $0x19,%ecx 8010280a: 0f 46 c2 cmovbe %edx,%eax } return c; } 8010280d: c3 ret 8010280e: 66 90 xchg %ax,%ax }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) return -1; 80102810: b8 ff ff ff ff mov $0xffffffff,%eax c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 80102815: 5d pop %ebp 80102816: c3 ret 80102817: 89 f6 mov %esi,%esi 80102819: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102820 <kbdintr>: void kbdintr(void) { 80102820: 55 push %ebp 80102821: 89 e5 mov %esp,%ebp 80102823: 83 ec 14 sub $0x14,%esp consoleintr(kbdgetc); 80102826: 68 50 27 10 80 push $0x80102750 8010282b: e8 c0 df ff ff call 801007f0 <consoleintr> } 80102830: 83 c4 10 add $0x10,%esp 80102833: c9 leave 80102834: c3 ret 80102835: 66 90 xchg %ax,%ax 80102837: 66 90 xchg %ax,%ax 80102839: 66 90 xchg %ax,%ax 8010283b: 66 90 xchg %ax,%ax 8010283d: 66 90 xchg %ax,%ax 8010283f: 90 nop 80102840 <lapicinit>: } void lapicinit(void) { if(!lapic) 80102840: a1 fc 36 11 80 mov 0x801136fc,%eax lapic[ID]; // wait for write to finish, by reading } void lapicinit(void) { 80102845: 55 push %ebp 80102846: 89 e5 mov %esp,%ebp if(!lapic) 80102848: 85 c0 test %eax,%eax 8010284a: 0f 84 c8 00 00 00 je 80102918 <lapicinit+0xd8> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102850: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) 80102857: 01 00 00 lapic[ID]; // wait for write to finish, by reading 8010285a: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010285d: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) 80102864: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102867: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010286a: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) 80102871: 00 02 00 lapic[ID]; // wait for write to finish, by reading 80102874: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102877: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) 8010287e: 96 98 00 lapic[ID]; // wait for write to finish, by reading 80102881: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102884: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) 8010288b: 00 01 00 lapic[ID]; // wait for write to finish, by reading 8010288e: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102891: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) 80102898: 00 01 00 lapic[ID]; // wait for write to finish, by reading 8010289b: 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) 8010289e: 8b 50 30 mov 0x30(%eax),%edx 801028a1: c1 ea 10 shr $0x10,%edx 801028a4: 80 fa 03 cmp $0x3,%dl 801028a7: 77 77 ja 80102920 <lapicinit+0xe0> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801028a9: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) 801028b0: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801028b3: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801028b6: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801028bd: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801028c0: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801028c3: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801028ca: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801028cd: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801028d0: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 801028d7: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801028da: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801028dd: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) 801028e4: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801028e7: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801028ea: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) 801028f1: 85 08 00 lapic[ID]; // wait for write to finish, by reading 801028f4: 8b 50 20 mov 0x20(%eax),%edx 801028f7: 89 f6 mov %esi,%esi 801028f9: 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) 80102900: 8b 90 00 03 00 00 mov 0x300(%eax),%edx 80102906: 80 e6 10 and $0x10,%dh 80102909: 75 f5 jne 80102900 <lapicinit+0xc0> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010290b: c7 80 80 00 00 00 00 movl $0x0,0x80(%eax) 80102912: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102915: 8b 40 20 mov 0x20(%eax),%eax while(lapic[ICRLO] & DELIVS) ; // Enable interrupts on the APIC (but not on the processor). lapicw(TPR, 0); } 80102918: 5d pop %ebp 80102919: c3 ret 8010291a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102920: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) 80102927: 00 01 00 lapic[ID]; // wait for write to finish, by reading 8010292a: 8b 50 20 mov 0x20(%eax),%edx 8010292d: e9 77 ff ff ff jmp 801028a9 <lapicinit+0x69> 80102932: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102939: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102940 <lapicid>: } int lapicid(void) { if (!lapic) 80102940: a1 fc 36 11 80 mov 0x801136fc,%eax lapicw(TPR, 0); } int lapicid(void) { 80102945: 55 push %ebp 80102946: 89 e5 mov %esp,%ebp if (!lapic) 80102948: 85 c0 test %eax,%eax 8010294a: 74 0c je 80102958 <lapicid+0x18> return 0; return lapic[ID] >> 24; 8010294c: 8b 40 20 mov 0x20(%eax),%eax } 8010294f: 5d pop %ebp int lapicid(void) { if (!lapic) return 0; return lapic[ID] >> 24; 80102950: c1 e8 18 shr $0x18,%eax } 80102953: c3 ret 80102954: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int lapicid(void) { if (!lapic) return 0; 80102958: 31 c0 xor %eax,%eax return lapic[ID] >> 24; } 8010295a: 5d pop %ebp 8010295b: c3 ret 8010295c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102960 <lapiceoi>: // Acknowledge interrupt. void lapiceoi(void) { if(lapic) 80102960: a1 fc 36 11 80 mov 0x801136fc,%eax } // Acknowledge interrupt. void lapiceoi(void) { 80102965: 55 push %ebp 80102966: 89 e5 mov %esp,%ebp if(lapic) 80102968: 85 c0 test %eax,%eax 8010296a: 74 0d je 80102979 <lapiceoi+0x19> //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 8010296c: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102973: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102976: 8b 40 20 mov 0x20(%eax),%eax void lapiceoi(void) { if(lapic) lapicw(EOI, 0); } 80102979: 5d pop %ebp 8010297a: c3 ret 8010297b: 90 nop 8010297c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102980 <microdelay>: // Spin for a given number of microseconds. // On real hardware would want to tune this dynamically. void microdelay(int us) { 80102980: 55 push %ebp 80102981: 89 e5 mov %esp,%ebp } 80102983: 5d pop %ebp 80102984: c3 ret 80102985: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102989: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102990 <lapicstartap>: // Start additional processor running entry code at addr. // See Appendix B of MultiProcessor Specification. void lapicstartap(uchar apicid, uint addr) { 80102990: 55 push %ebp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102991: ba 70 00 00 00 mov $0x70,%edx 80102996: b8 0f 00 00 00 mov $0xf,%eax 8010299b: 89 e5 mov %esp,%ebp 8010299d: 53 push %ebx 8010299e: 8b 4d 0c mov 0xc(%ebp),%ecx 801029a1: 8b 5d 08 mov 0x8(%ebp),%ebx 801029a4: ee out %al,(%dx) 801029a5: ba 71 00 00 00 mov $0x71,%edx 801029aa: b8 0a 00 00 00 mov $0xa,%eax 801029af: 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; 801029b0: 31 c0 xor %eax,%eax //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801029b2: 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; 801029b5: 66 a3 67 04 00 80 mov %ax,0x80000467 wrv[1] = addr >> 4; 801029bb: 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)); 801029bd: 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; 801029c0: c1 e8 04 shr $0x4,%eax //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801029c3: 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)); 801029c5: 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; 801029c8: 66 a3 69 04 00 80 mov %ax,0x80000469 //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801029ce: a1 fc 36 11 80 mov 0x801136fc,%eax 801029d3: 89 98 10 03 00 00 mov %ebx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 801029d9: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801029dc: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) 801029e3: c5 00 00 lapic[ID]; // wait for write to finish, by reading 801029e6: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801029e9: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) 801029f0: 85 00 00 lapic[ID]; // wait for write to finish, by reading 801029f3: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801029f6: 89 90 10 03 00 00 mov %edx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 801029fc: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 801029ff: 89 88 00 03 00 00 mov %ecx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102a05: 8b 58 20 mov 0x20(%eax),%ebx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102a08: 89 90 10 03 00 00 mov %edx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102a0e: 8b 50 20 mov 0x20(%eax),%edx //PAGEBREAK! static void lapicw(int index, int value) { lapic[index] = value; 80102a11: 89 88 00 03 00 00 mov %ecx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102a17: 8b 40 20 mov 0x20(%eax),%eax for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); microdelay(200); } } 80102a1a: 5b pop %ebx 80102a1b: 5d pop %ebp 80102a1c: c3 ret 80102a1d: 8d 76 00 lea 0x0(%esi),%esi 80102a20 <cmostime>: } // qemu seems to use 24-hour GWT and the values are BCD encoded void cmostime(struct rtcdate *r) { 80102a20: 55 push %ebp 80102a21: ba 70 00 00 00 mov $0x70,%edx 80102a26: b8 0b 00 00 00 mov $0xb,%eax 80102a2b: 89 e5 mov %esp,%ebp 80102a2d: 57 push %edi 80102a2e: 56 push %esi 80102a2f: 53 push %ebx 80102a30: 83 ec 4c sub $0x4c,%esp 80102a33: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102a34: ba 71 00 00 00 mov $0x71,%edx 80102a39: ec in (%dx),%al 80102a3a: 83 e0 04 and $0x4,%eax 80102a3d: 8d 75 d0 lea -0x30(%ebp),%esi } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102a40: 31 db xor %ebx,%ebx 80102a42: 88 45 b7 mov %al,-0x49(%ebp) 80102a45: bf 70 00 00 00 mov $0x70,%edi 80102a4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102a50: 89 d8 mov %ebx,%eax 80102a52: 89 fa mov %edi,%edx 80102a54: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102a55: b9 71 00 00 00 mov $0x71,%ecx 80102a5a: 89 ca mov %ecx,%edx 80102a5c: ec in (%dx),%al } static void fill_rtcdate(struct rtcdate *r) { r->second = cmos_read(SECS); 80102a5d: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102a60: 89 fa mov %edi,%edx 80102a62: 89 45 b8 mov %eax,-0x48(%ebp) 80102a65: b8 02 00 00 00 mov $0x2,%eax 80102a6a: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102a6b: 89 ca mov %ecx,%edx 80102a6d: ec in (%dx),%al r->minute = cmos_read(MINS); 80102a6e: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102a71: 89 fa mov %edi,%edx 80102a73: 89 45 bc mov %eax,-0x44(%ebp) 80102a76: b8 04 00 00 00 mov $0x4,%eax 80102a7b: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102a7c: 89 ca mov %ecx,%edx 80102a7e: ec in (%dx),%al r->hour = cmos_read(HOURS); 80102a7f: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102a82: 89 fa mov %edi,%edx 80102a84: 89 45 c0 mov %eax,-0x40(%ebp) 80102a87: b8 07 00 00 00 mov $0x7,%eax 80102a8c: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102a8d: 89 ca mov %ecx,%edx 80102a8f: ec in (%dx),%al r->day = cmos_read(DAY); 80102a90: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102a93: 89 fa mov %edi,%edx 80102a95: 89 45 c4 mov %eax,-0x3c(%ebp) 80102a98: b8 08 00 00 00 mov $0x8,%eax 80102a9d: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102a9e: 89 ca mov %ecx,%edx 80102aa0: ec in (%dx),%al r->month = cmos_read(MONTH); 80102aa1: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102aa4: 89 fa mov %edi,%edx 80102aa6: 89 45 c8 mov %eax,-0x38(%ebp) 80102aa9: b8 09 00 00 00 mov $0x9,%eax 80102aae: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102aaf: 89 ca mov %ecx,%edx 80102ab1: ec in (%dx),%al r->year = cmos_read(YEAR); 80102ab2: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102ab5: 89 fa mov %edi,%edx 80102ab7: 89 45 cc mov %eax,-0x34(%ebp) 80102aba: b8 0a 00 00 00 mov $0xa,%eax 80102abf: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102ac0: 89 ca mov %ecx,%edx 80102ac2: 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) 80102ac3: 84 c0 test %al,%al 80102ac5: 78 89 js 80102a50 <cmostime+0x30> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102ac7: 89 d8 mov %ebx,%eax 80102ac9: 89 fa mov %edi,%edx 80102acb: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102acc: 89 ca mov %ecx,%edx 80102ace: ec in (%dx),%al } static void fill_rtcdate(struct rtcdate *r) { r->second = cmos_read(SECS); 80102acf: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102ad2: 89 fa mov %edi,%edx 80102ad4: 89 45 d0 mov %eax,-0x30(%ebp) 80102ad7: b8 02 00 00 00 mov $0x2,%eax 80102adc: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102add: 89 ca mov %ecx,%edx 80102adf: ec in (%dx),%al r->minute = cmos_read(MINS); 80102ae0: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102ae3: 89 fa mov %edi,%edx 80102ae5: 89 45 d4 mov %eax,-0x2c(%ebp) 80102ae8: b8 04 00 00 00 mov $0x4,%eax 80102aed: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102aee: 89 ca mov %ecx,%edx 80102af0: ec in (%dx),%al r->hour = cmos_read(HOURS); 80102af1: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102af4: 89 fa mov %edi,%edx 80102af6: 89 45 d8 mov %eax,-0x28(%ebp) 80102af9: b8 07 00 00 00 mov $0x7,%eax 80102afe: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102aff: 89 ca mov %ecx,%edx 80102b01: ec in (%dx),%al r->day = cmos_read(DAY); 80102b02: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102b05: 89 fa mov %edi,%edx 80102b07: 89 45 dc mov %eax,-0x24(%ebp) 80102b0a: b8 08 00 00 00 mov $0x8,%eax 80102b0f: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102b10: 89 ca mov %ecx,%edx 80102b12: ec in (%dx),%al r->month = cmos_read(MONTH); 80102b13: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102b16: 89 fa mov %edi,%edx 80102b18: 89 45 e0 mov %eax,-0x20(%ebp) 80102b1b: b8 09 00 00 00 mov $0x9,%eax 80102b20: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102b21: 89 ca mov %ecx,%edx 80102b23: ec in (%dx),%al r->year = cmos_read(YEAR); 80102b24: 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) 80102b27: 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); 80102b2a: 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) 80102b2d: 8d 45 b8 lea -0x48(%ebp),%eax 80102b30: 6a 18 push $0x18 80102b32: 56 push %esi 80102b33: 50 push %eax 80102b34: e8 47 27 00 00 call 80105280 <memcmp> 80102b39: 83 c4 10 add $0x10,%esp 80102b3c: 85 c0 test %eax,%eax 80102b3e: 0f 85 0c ff ff ff jne 80102a50 <cmostime+0x30> break; } // convert if(bcd) { 80102b44: 80 7d b7 00 cmpb $0x0,-0x49(%ebp) 80102b48: 75 78 jne 80102bc2 <cmostime+0x1a2> #define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) CONV(second); 80102b4a: 8b 45 b8 mov -0x48(%ebp),%eax 80102b4d: 89 c2 mov %eax,%edx 80102b4f: 83 e0 0f and $0xf,%eax 80102b52: c1 ea 04 shr $0x4,%edx 80102b55: 8d 14 92 lea (%edx,%edx,4),%edx 80102b58: 8d 04 50 lea (%eax,%edx,2),%eax 80102b5b: 89 45 b8 mov %eax,-0x48(%ebp) CONV(minute); 80102b5e: 8b 45 bc mov -0x44(%ebp),%eax 80102b61: 89 c2 mov %eax,%edx 80102b63: 83 e0 0f and $0xf,%eax 80102b66: c1 ea 04 shr $0x4,%edx 80102b69: 8d 14 92 lea (%edx,%edx,4),%edx 80102b6c: 8d 04 50 lea (%eax,%edx,2),%eax 80102b6f: 89 45 bc mov %eax,-0x44(%ebp) CONV(hour ); 80102b72: 8b 45 c0 mov -0x40(%ebp),%eax 80102b75: 89 c2 mov %eax,%edx 80102b77: 83 e0 0f and $0xf,%eax 80102b7a: c1 ea 04 shr $0x4,%edx 80102b7d: 8d 14 92 lea (%edx,%edx,4),%edx 80102b80: 8d 04 50 lea (%eax,%edx,2),%eax 80102b83: 89 45 c0 mov %eax,-0x40(%ebp) CONV(day ); 80102b86: 8b 45 c4 mov -0x3c(%ebp),%eax 80102b89: 89 c2 mov %eax,%edx 80102b8b: 83 e0 0f and $0xf,%eax 80102b8e: c1 ea 04 shr $0x4,%edx 80102b91: 8d 14 92 lea (%edx,%edx,4),%edx 80102b94: 8d 04 50 lea (%eax,%edx,2),%eax 80102b97: 89 45 c4 mov %eax,-0x3c(%ebp) CONV(month ); 80102b9a: 8b 45 c8 mov -0x38(%ebp),%eax 80102b9d: 89 c2 mov %eax,%edx 80102b9f: 83 e0 0f and $0xf,%eax 80102ba2: c1 ea 04 shr $0x4,%edx 80102ba5: 8d 14 92 lea (%edx,%edx,4),%edx 80102ba8: 8d 04 50 lea (%eax,%edx,2),%eax 80102bab: 89 45 c8 mov %eax,-0x38(%ebp) CONV(year ); 80102bae: 8b 45 cc mov -0x34(%ebp),%eax 80102bb1: 89 c2 mov %eax,%edx 80102bb3: 83 e0 0f and $0xf,%eax 80102bb6: c1 ea 04 shr $0x4,%edx 80102bb9: 8d 14 92 lea (%edx,%edx,4),%edx 80102bbc: 8d 04 50 lea (%eax,%edx,2),%eax 80102bbf: 89 45 cc mov %eax,-0x34(%ebp) #undef CONV } *r = t1; 80102bc2: 8b 75 08 mov 0x8(%ebp),%esi 80102bc5: 8b 45 b8 mov -0x48(%ebp),%eax 80102bc8: 89 06 mov %eax,(%esi) 80102bca: 8b 45 bc mov -0x44(%ebp),%eax 80102bcd: 89 46 04 mov %eax,0x4(%esi) 80102bd0: 8b 45 c0 mov -0x40(%ebp),%eax 80102bd3: 89 46 08 mov %eax,0x8(%esi) 80102bd6: 8b 45 c4 mov -0x3c(%ebp),%eax 80102bd9: 89 46 0c mov %eax,0xc(%esi) 80102bdc: 8b 45 c8 mov -0x38(%ebp),%eax 80102bdf: 89 46 10 mov %eax,0x10(%esi) 80102be2: 8b 45 cc mov -0x34(%ebp),%eax 80102be5: 89 46 14 mov %eax,0x14(%esi) r->year += 2000; 80102be8: 81 46 14 d0 07 00 00 addl $0x7d0,0x14(%esi) } 80102bef: 8d 65 f4 lea -0xc(%ebp),%esp 80102bf2: 5b pop %ebx 80102bf3: 5e pop %esi 80102bf4: 5f pop %edi 80102bf5: 5d pop %ebp 80102bf6: c3 ret 80102bf7: 66 90 xchg %ax,%ax 80102bf9: 66 90 xchg %ax,%ax 80102bfb: 66 90 xchg %ax,%ax 80102bfd: 66 90 xchg %ax,%ax 80102bff: 90 nop 80102c00 <install_trans>: static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102c00: 8b 0d 48 37 11 80 mov 0x80113748,%ecx 80102c06: 85 c9 test %ecx,%ecx 80102c08: 0f 8e 85 00 00 00 jle 80102c93 <install_trans+0x93> } // Copy committed blocks from log to their home location static void install_trans(void) { 80102c0e: 55 push %ebp 80102c0f: 89 e5 mov %esp,%ebp 80102c11: 57 push %edi 80102c12: 56 push %esi 80102c13: 53 push %ebx 80102c14: 31 db xor %ebx,%ebx 80102c16: 83 ec 0c sub $0xc,%esp 80102c19: 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 80102c20: a1 34 37 11 80 mov 0x80113734,%eax 80102c25: 83 ec 08 sub $0x8,%esp 80102c28: 01 d8 add %ebx,%eax 80102c2a: 83 c0 01 add $0x1,%eax 80102c2d: 50 push %eax 80102c2e: ff 35 44 37 11 80 pushl 0x80113744 80102c34: e8 97 d4 ff ff call 801000d0 <bread> 80102c39: 89 c7 mov %eax,%edi struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 80102c3b: 58 pop %eax 80102c3c: 5a pop %edx 80102c3d: ff 34 9d 4c 37 11 80 pushl -0x7feec8b4(,%ebx,4) 80102c44: ff 35 44 37 11 80 pushl 0x80113744 static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102c4a: 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 80102c4d: e8 7e d4 ff ff call 801000d0 <bread> 80102c52: 89 c6 mov %eax,%esi memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 80102c54: 8d 47 5c lea 0x5c(%edi),%eax 80102c57: 83 c4 0c add $0xc,%esp 80102c5a: 68 00 02 00 00 push $0x200 80102c5f: 50 push %eax 80102c60: 8d 46 5c lea 0x5c(%esi),%eax 80102c63: 50 push %eax 80102c64: e8 77 26 00 00 call 801052e0 <memmove> bwrite(dbuf); // write dst to disk 80102c69: 89 34 24 mov %esi,(%esp) 80102c6c: e8 2f d5 ff ff call 801001a0 <bwrite> brelse(lbuf); 80102c71: 89 3c 24 mov %edi,(%esp) 80102c74: e8 67 d5 ff ff call 801001e0 <brelse> brelse(dbuf); 80102c79: 89 34 24 mov %esi,(%esp) 80102c7c: e8 5f d5 ff ff call 801001e0 <brelse> static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102c81: 83 c4 10 add $0x10,%esp 80102c84: 39 1d 48 37 11 80 cmp %ebx,0x80113748 80102c8a: 7f 94 jg 80102c20 <install_trans+0x20> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst bwrite(dbuf); // write dst to disk brelse(lbuf); brelse(dbuf); } } 80102c8c: 8d 65 f4 lea -0xc(%ebp),%esp 80102c8f: 5b pop %ebx 80102c90: 5e pop %esi 80102c91: 5f pop %edi 80102c92: 5d pop %ebp 80102c93: f3 c3 repz ret 80102c95: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102c99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102ca0 <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) { 80102ca0: 55 push %ebp 80102ca1: 89 e5 mov %esp,%ebp 80102ca3: 53 push %ebx 80102ca4: 83 ec 0c sub $0xc,%esp struct buf *buf = bread(log.dev, log.start); 80102ca7: ff 35 34 37 11 80 pushl 0x80113734 80102cad: ff 35 44 37 11 80 pushl 0x80113744 80102cb3: e8 18 d4 ff ff call 801000d0 <bread> struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; 80102cb8: 8b 0d 48 37 11 80 mov 0x80113748,%ecx for (i = 0; i < log.lh.n; i++) { 80102cbe: 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); 80102cc1: 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++) { 80102cc3: 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; 80102cc5: 89 48 5c mov %ecx,0x5c(%eax) for (i = 0; i < log.lh.n; i++) { 80102cc8: 7e 1f jle 80102ce9 <write_head+0x49> 80102cca: 8d 04 8d 00 00 00 00 lea 0x0(,%ecx,4),%eax 80102cd1: 31 d2 xor %edx,%edx 80102cd3: 90 nop 80102cd4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi hb->block[i] = log.lh.block[i]; 80102cd8: 8b 8a 4c 37 11 80 mov -0x7feec8b4(%edx),%ecx 80102cde: 89 4c 13 60 mov %ecx,0x60(%ebx,%edx,1) 80102ce2: 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++) { 80102ce5: 39 c2 cmp %eax,%edx 80102ce7: 75 ef jne 80102cd8 <write_head+0x38> hb->block[i] = log.lh.block[i]; } bwrite(buf); 80102ce9: 83 ec 0c sub $0xc,%esp 80102cec: 53 push %ebx 80102ced: e8 ae d4 ff ff call 801001a0 <bwrite> brelse(buf); 80102cf2: 89 1c 24 mov %ebx,(%esp) 80102cf5: e8 e6 d4 ff ff call 801001e0 <brelse> } 80102cfa: 8b 5d fc mov -0x4(%ebp),%ebx 80102cfd: c9 leave 80102cfe: c3 ret 80102cff: 90 nop 80102d00 <initlog>: static void recover_from_log(void); static void commit(); void initlog(int dev) { 80102d00: 55 push %ebp 80102d01: 89 e5 mov %esp,%ebp 80102d03: 53 push %ebx 80102d04: 83 ec 2c sub $0x2c,%esp 80102d07: 8b 5d 08 mov 0x8(%ebp),%ebx if (sizeof(struct logheader) >= BSIZE) panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); 80102d0a: 68 00 85 10 80 push $0x80108500 80102d0f: 68 00 37 11 80 push $0x80113700 80102d14: e8 b7 22 00 00 call 80104fd0 <initlock> readsb(dev, &sb); 80102d19: 58 pop %eax 80102d1a: 8d 45 dc lea -0x24(%ebp),%eax 80102d1d: 5a pop %edx 80102d1e: 50 push %eax 80102d1f: 53 push %ebx 80102d20: e8 5b e9 ff ff call 80101680 <readsb> log.start = sb.logstart; log.size = sb.nlog; 80102d25: 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; 80102d28: 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); 80102d2b: 59 pop %ecx struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; log.dev = dev; 80102d2c: 89 1d 44 37 11 80 mov %ebx,0x80113744 struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; 80102d32: 89 15 38 37 11 80 mov %edx,0x80113738 panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; 80102d38: a3 34 37 11 80 mov %eax,0x80113734 // 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); 80102d3d: 5a pop %edx 80102d3e: 50 push %eax 80102d3f: 53 push %ebx 80102d40: e8 8b d3 ff ff call 801000d0 <bread> struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; 80102d45: 8b 48 5c mov 0x5c(%eax),%ecx for (i = 0; i < log.lh.n; i++) { 80102d48: 83 c4 10 add $0x10,%esp 80102d4b: 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; 80102d4d: 89 0d 48 37 11 80 mov %ecx,0x80113748 for (i = 0; i < log.lh.n; i++) { 80102d53: 7e 1c jle 80102d71 <initlog+0x71> 80102d55: 8d 1c 8d 00 00 00 00 lea 0x0(,%ecx,4),%ebx 80102d5c: 31 d2 xor %edx,%edx 80102d5e: 66 90 xchg %ax,%ax log.lh.block[i] = lh->block[i]; 80102d60: 8b 4c 10 60 mov 0x60(%eax,%edx,1),%ecx 80102d64: 83 c2 04 add $0x4,%edx 80102d67: 89 8a 48 37 11 80 mov %ecx,-0x7feec8b8(%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++) { 80102d6d: 39 da cmp %ebx,%edx 80102d6f: 75 ef jne 80102d60 <initlog+0x60> log.lh.block[i] = lh->block[i]; } brelse(buf); 80102d71: 83 ec 0c sub $0xc,%esp 80102d74: 50 push %eax 80102d75: e8 66 d4 ff ff call 801001e0 <brelse> static void recover_from_log(void) { read_head(); install_trans(); // if committed, copy from log to disk 80102d7a: e8 81 fe ff ff call 80102c00 <install_trans> log.lh.n = 0; 80102d7f: c7 05 48 37 11 80 00 movl $0x0,0x80113748 80102d86: 00 00 00 write_head(); // clear the log 80102d89: e8 12 ff ff ff call 80102ca0 <write_head> readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; log.dev = dev; recover_from_log(); } 80102d8e: 8b 5d fc mov -0x4(%ebp),%ebx 80102d91: c9 leave 80102d92: c3 ret 80102d93: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102d99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102da0 <begin_op>: } // called at the start of each FS system call. void begin_op(void) { 80102da0: 55 push %ebp 80102da1: 89 e5 mov %esp,%ebp 80102da3: 83 ec 14 sub $0x14,%esp acquire(&log.lock); 80102da6: 68 00 37 11 80 push $0x80113700 80102dab: e8 80 23 00 00 call 80105130 <acquire> 80102db0: 83 c4 10 add $0x10,%esp 80102db3: eb 18 jmp 80102dcd <begin_op+0x2d> 80102db5: 8d 76 00 lea 0x0(%esi),%esi while(1){ if(log.committing){ sleep(&log, &log.lock); 80102db8: 83 ec 08 sub $0x8,%esp 80102dbb: 68 00 37 11 80 push $0x80113700 80102dc0: 68 00 37 11 80 push $0x80113700 80102dc5: e8 06 16 00 00 call 801043d0 <sleep> 80102dca: 83 c4 10 add $0x10,%esp void begin_op(void) { acquire(&log.lock); while(1){ if(log.committing){ 80102dcd: a1 40 37 11 80 mov 0x80113740,%eax 80102dd2: 85 c0 test %eax,%eax 80102dd4: 75 e2 jne 80102db8 <begin_op+0x18> sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ 80102dd6: a1 3c 37 11 80 mov 0x8011373c,%eax 80102ddb: 8b 15 48 37 11 80 mov 0x80113748,%edx 80102de1: 83 c0 01 add $0x1,%eax 80102de4: 8d 0c 80 lea (%eax,%eax,4),%ecx 80102de7: 8d 14 4a lea (%edx,%ecx,2),%edx 80102dea: 83 fa 1e cmp $0x1e,%edx 80102ded: 7f c9 jg 80102db8 <begin_op+0x18> // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; release(&log.lock); 80102def: 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; 80102df2: a3 3c 37 11 80 mov %eax,0x8011373c release(&log.lock); 80102df7: 68 00 37 11 80 push $0x80113700 80102dfc: e8 df 23 00 00 call 801051e0 <release> break; } } } 80102e01: 83 c4 10 add $0x10,%esp 80102e04: c9 leave 80102e05: c3 ret 80102e06: 8d 76 00 lea 0x0(%esi),%esi 80102e09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102e10 <end_op>: // called at the end of each FS system call. // commits if this was the last outstanding operation. void end_op(void) { 80102e10: 55 push %ebp 80102e11: 89 e5 mov %esp,%ebp 80102e13: 57 push %edi 80102e14: 56 push %esi 80102e15: 53 push %ebx 80102e16: 83 ec 18 sub $0x18,%esp int do_commit = 0; acquire(&log.lock); 80102e19: 68 00 37 11 80 push $0x80113700 80102e1e: e8 0d 23 00 00 call 80105130 <acquire> log.outstanding -= 1; 80102e23: a1 3c 37 11 80 mov 0x8011373c,%eax if(log.committing) 80102e28: 8b 1d 40 37 11 80 mov 0x80113740,%ebx 80102e2e: 83 c4 10 add $0x10,%esp end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102e31: 83 e8 01 sub $0x1,%eax if(log.committing) 80102e34: 85 db test %ebx,%ebx end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102e36: a3 3c 37 11 80 mov %eax,0x8011373c if(log.committing) 80102e3b: 0f 85 23 01 00 00 jne 80102f64 <end_op+0x154> panic("log.committing"); if(log.outstanding == 0){ 80102e41: 85 c0 test %eax,%eax 80102e43: 0f 85 f7 00 00 00 jne 80102f40 <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); 80102e49: 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; 80102e4c: c7 05 40 37 11 80 01 movl $0x1,0x80113740 80102e53: 00 00 00 } static void commit() { if (log.lh.n > 0) { 80102e56: 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); 80102e58: 68 00 37 11 80 push $0x80113700 80102e5d: e8 7e 23 00 00 call 801051e0 <release> } static void commit() { if (log.lh.n > 0) { 80102e62: 8b 0d 48 37 11 80 mov 0x80113748,%ecx 80102e68: 83 c4 10 add $0x10,%esp 80102e6b: 85 c9 test %ecx,%ecx 80102e6d: 0f 8e 8a 00 00 00 jle 80102efd <end_op+0xed> 80102e73: 90 nop 80102e74: 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 80102e78: a1 34 37 11 80 mov 0x80113734,%eax 80102e7d: 83 ec 08 sub $0x8,%esp 80102e80: 01 d8 add %ebx,%eax 80102e82: 83 c0 01 add $0x1,%eax 80102e85: 50 push %eax 80102e86: ff 35 44 37 11 80 pushl 0x80113744 80102e8c: e8 3f d2 ff ff call 801000d0 <bread> 80102e91: 89 c6 mov %eax,%esi struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102e93: 58 pop %eax 80102e94: 5a pop %edx 80102e95: ff 34 9d 4c 37 11 80 pushl -0x7feec8b4(,%ebx,4) 80102e9c: ff 35 44 37 11 80 pushl 0x80113744 static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102ea2: 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 80102ea5: e8 26 d2 ff ff call 801000d0 <bread> 80102eaa: 89 c7 mov %eax,%edi memmove(to->data, from->data, BSIZE); 80102eac: 8d 40 5c lea 0x5c(%eax),%eax 80102eaf: 83 c4 0c add $0xc,%esp 80102eb2: 68 00 02 00 00 push $0x200 80102eb7: 50 push %eax 80102eb8: 8d 46 5c lea 0x5c(%esi),%eax 80102ebb: 50 push %eax 80102ebc: e8 1f 24 00 00 call 801052e0 <memmove> bwrite(to); // write the log 80102ec1: 89 34 24 mov %esi,(%esp) 80102ec4: e8 d7 d2 ff ff call 801001a0 <bwrite> brelse(from); 80102ec9: 89 3c 24 mov %edi,(%esp) 80102ecc: e8 0f d3 ff ff call 801001e0 <brelse> brelse(to); 80102ed1: 89 34 24 mov %esi,(%esp) 80102ed4: e8 07 d3 ff ff call 801001e0 <brelse> static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102ed9: 83 c4 10 add $0x10,%esp 80102edc: 3b 1d 48 37 11 80 cmp 0x80113748,%ebx 80102ee2: 7c 94 jl 80102e78 <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 80102ee4: e8 b7 fd ff ff call 80102ca0 <write_head> install_trans(); // Now install writes to home locations 80102ee9: e8 12 fd ff ff call 80102c00 <install_trans> log.lh.n = 0; 80102eee: c7 05 48 37 11 80 00 movl $0x0,0x80113748 80102ef5: 00 00 00 write_head(); // Erase the transaction from the log 80102ef8: e8 a3 fd ff ff call 80102ca0 <write_head> if(do_commit){ // call commit w/o holding locks, since not allowed // to sleep with locks. commit(); acquire(&log.lock); 80102efd: 83 ec 0c sub $0xc,%esp 80102f00: 68 00 37 11 80 push $0x80113700 80102f05: e8 26 22 00 00 call 80105130 <acquire> log.committing = 0; wakeup(&log); 80102f0a: c7 04 24 00 37 11 80 movl $0x80113700,(%esp) if(do_commit){ // call commit w/o holding locks, since not allowed // to sleep with locks. commit(); acquire(&log.lock); log.committing = 0; 80102f11: c7 05 40 37 11 80 00 movl $0x0,0x80113740 80102f18: 00 00 00 wakeup(&log); 80102f1b: e8 70 16 00 00 call 80104590 <wakeup> release(&log.lock); 80102f20: c7 04 24 00 37 11 80 movl $0x80113700,(%esp) 80102f27: e8 b4 22 00 00 call 801051e0 <release> 80102f2c: 83 c4 10 add $0x10,%esp } } 80102f2f: 8d 65 f4 lea -0xc(%ebp),%esp 80102f32: 5b pop %ebx 80102f33: 5e pop %esi 80102f34: 5f pop %edi 80102f35: 5d pop %ebp 80102f36: c3 ret 80102f37: 89 f6 mov %esi,%esi 80102f39: 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); 80102f40: 83 ec 0c sub $0xc,%esp 80102f43: 68 00 37 11 80 push $0x80113700 80102f48: e8 43 16 00 00 call 80104590 <wakeup> } release(&log.lock); 80102f4d: c7 04 24 00 37 11 80 movl $0x80113700,(%esp) 80102f54: e8 87 22 00 00 call 801051e0 <release> 80102f59: 83 c4 10 add $0x10,%esp acquire(&log.lock); log.committing = 0; wakeup(&log); release(&log.lock); } } 80102f5c: 8d 65 f4 lea -0xc(%ebp),%esp 80102f5f: 5b pop %ebx 80102f60: 5e pop %esi 80102f61: 5f pop %edi 80102f62: 5d pop %ebp 80102f63: c3 ret int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; if(log.committing) panic("log.committing"); 80102f64: 83 ec 0c sub $0xc,%esp 80102f67: 68 04 85 10 80 push $0x80108504 80102f6c: e8 ff d3 ff ff call 80100370 <panic> 80102f71: eb 0d jmp 80102f80 <log_write> 80102f73: 90 nop 80102f74: 90 nop 80102f75: 90 nop 80102f76: 90 nop 80102f77: 90 nop 80102f78: 90 nop 80102f79: 90 nop 80102f7a: 90 nop 80102f7b: 90 nop 80102f7c: 90 nop 80102f7d: 90 nop 80102f7e: 90 nop 80102f7f: 90 nop 80102f80 <log_write>: // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102f80: 55 push %ebp 80102f81: 89 e5 mov %esp,%ebp 80102f83: 53 push %ebx 80102f84: 83 ec 04 sub $0x4,%esp int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102f87: 8b 15 48 37 11 80 mov 0x80113748,%edx // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102f8d: 8b 5d 08 mov 0x8(%ebp),%ebx int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102f90: 83 fa 1d cmp $0x1d,%edx 80102f93: 0f 8f 97 00 00 00 jg 80103030 <log_write+0xb0> 80102f99: a1 38 37 11 80 mov 0x80113738,%eax 80102f9e: 83 e8 01 sub $0x1,%eax 80102fa1: 39 c2 cmp %eax,%edx 80102fa3: 0f 8d 87 00 00 00 jge 80103030 <log_write+0xb0> panic("too big a transaction"); if (log.outstanding < 1) 80102fa9: a1 3c 37 11 80 mov 0x8011373c,%eax 80102fae: 85 c0 test %eax,%eax 80102fb0: 0f 8e 87 00 00 00 jle 8010303d <log_write+0xbd> panic("log_write outside of trans"); acquire(&log.lock); 80102fb6: 83 ec 0c sub $0xc,%esp 80102fb9: 68 00 37 11 80 push $0x80113700 80102fbe: e8 6d 21 00 00 call 80105130 <acquire> for (i = 0; i < log.lh.n; i++) { 80102fc3: 8b 15 48 37 11 80 mov 0x80113748,%edx 80102fc9: 83 c4 10 add $0x10,%esp 80102fcc: 83 fa 00 cmp $0x0,%edx 80102fcf: 7e 50 jle 80103021 <log_write+0xa1> if (log.lh.block[i] == b->blockno) // log absorbtion 80102fd1: 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++) { 80102fd4: 31 c0 xor %eax,%eax if (log.lh.block[i] == b->blockno) // log absorbtion 80102fd6: 3b 0d 4c 37 11 80 cmp 0x8011374c,%ecx 80102fdc: 75 0b jne 80102fe9 <log_write+0x69> 80102fde: eb 38 jmp 80103018 <log_write+0x98> 80102fe0: 39 0c 85 4c 37 11 80 cmp %ecx,-0x7feec8b4(,%eax,4) 80102fe7: 74 2f je 80103018 <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++) { 80102fe9: 83 c0 01 add $0x1,%eax 80102fec: 39 d0 cmp %edx,%eax 80102fee: 75 f0 jne 80102fe0 <log_write+0x60> if (log.lh.block[i] == b->blockno) // log absorbtion break; } log.lh.block[i] = b->blockno; 80102ff0: 89 0c 95 4c 37 11 80 mov %ecx,-0x7feec8b4(,%edx,4) if (i == log.lh.n) log.lh.n++; 80102ff7: 83 c2 01 add $0x1,%edx 80102ffa: 89 15 48 37 11 80 mov %edx,0x80113748 b->flags |= B_DIRTY; // prevent eviction 80103000: 83 0b 04 orl $0x4,(%ebx) release(&log.lock); 80103003: c7 45 08 00 37 11 80 movl $0x80113700,0x8(%ebp) } 8010300a: 8b 5d fc mov -0x4(%ebp),%ebx 8010300d: 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); 8010300e: e9 cd 21 00 00 jmp 801051e0 <release> 80103013: 90 nop 80103014: 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; 80103018: 89 0c 85 4c 37 11 80 mov %ecx,-0x7feec8b4(,%eax,4) 8010301f: eb df jmp 80103000 <log_write+0x80> 80103021: 8b 43 08 mov 0x8(%ebx),%eax 80103024: a3 4c 37 11 80 mov %eax,0x8011374c if (i == log.lh.n) 80103029: 75 d5 jne 80103000 <log_write+0x80> 8010302b: eb ca jmp 80102ff7 <log_write+0x77> 8010302d: 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"); 80103030: 83 ec 0c sub $0xc,%esp 80103033: 68 13 85 10 80 push $0x80108513 80103038: e8 33 d3 ff ff call 80100370 <panic> if (log.outstanding < 1) panic("log_write outside of trans"); 8010303d: 83 ec 0c sub $0xc,%esp 80103040: 68 29 85 10 80 push $0x80108529 80103045: e8 26 d3 ff ff call 80100370 <panic> 8010304a: 66 90 xchg %ax,%ax 8010304c: 66 90 xchg %ax,%ax 8010304e: 66 90 xchg %ax,%ax 80103050 <mpmain>: } // Common CPU setup code. static void mpmain(void) { 80103050: 55 push %ebp 80103051: 89 e5 mov %esp,%ebp 80103053: 53 push %ebx 80103054: 83 ec 04 sub $0x4,%esp cprintf("cpu%d: starting %d\n", cpuid(), cpuid()); 80103057: e8 b4 09 00 00 call 80103a10 <cpuid> 8010305c: 89 c3 mov %eax,%ebx 8010305e: e8 ad 09 00 00 call 80103a10 <cpuid> 80103063: 83 ec 04 sub $0x4,%esp 80103066: 53 push %ebx 80103067: 50 push %eax 80103068: 68 44 85 10 80 push $0x80108544 8010306d: e8 ee d5 ff ff call 80100660 <cprintf> idtinit(); // load idt register 80103072: e8 e9 37 00 00 call 80106860 <idtinit> xchg(&(mycpu()->started), 1); // tell startothers() we're up 80103077: e8 44 09 00 00 call 801039c0 <mycpu> 8010307c: 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" : 8010307e: b8 01 00 00 00 mov $0x1,%eax 80103083: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx) scheduler(); // start running processes 8010308a: e8 41 0f 00 00 call 80103fd0 <scheduler> 8010308f: 90 nop 80103090 <mpenter>: } // Other CPUs jump here from entryother.S. static void mpenter(void) { 80103090: 55 push %ebp 80103091: 89 e5 mov %esp,%ebp 80103093: 83 ec 08 sub $0x8,%esp switchkvm(); 80103096: e8 f5 48 00 00 call 80107990 <switchkvm> seginit(); 8010309b: e8 f0 47 00 00 call 80107890 <seginit> lapicinit(); 801030a0: e8 9b f7 ff ff call 80102840 <lapicinit> mpmain(); 801030a5: e8 a6 ff ff ff call 80103050 <mpmain> 801030aa: 66 90 xchg %ax,%ax 801030ac: 66 90 xchg %ax,%ax 801030ae: 66 90 xchg %ax,%ax 801030b0 <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) { 801030b0: 8d 4c 24 04 lea 0x4(%esp),%ecx 801030b4: 83 e4 f0 and $0xfffffff0,%esp 801030b7: ff 71 fc pushl -0x4(%ecx) 801030ba: 55 push %ebp 801030bb: 89 e5 mov %esp,%ebp 801030bd: 53 push %ebx 801030be: 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++){ 801030bf: bb 00 38 11 80 mov $0x80113800,%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 801030c4: 83 ec 08 sub $0x8,%esp 801030c7: 68 00 00 40 80 push $0x80400000 801030cc: 68 68 66 11 80 push $0x80116668 801030d1: e8 3a f5 ff ff call 80102610 <kinit1> kvmalloc(); // kernel page table 801030d6: e8 55 4d 00 00 call 80107e30 <kvmalloc> mpinit(); // detect other processors 801030db: e8 70 01 00 00 call 80103250 <mpinit> lapicinit(); // interrupt controller 801030e0: e8 5b f7 ff ff call 80102840 <lapicinit> seginit(); // segment descriptors 801030e5: e8 a6 47 00 00 call 80107890 <seginit> picinit(); // disable pic 801030ea: e8 31 03 00 00 call 80103420 <picinit> ioapicinit(); // another interrupt controller 801030ef: e8 4c f3 ff ff call 80102440 <ioapicinit> consoleinit(); // console hardware 801030f4: e8 a7 d8 ff ff call 801009a0 <consoleinit> uartinit(); // serial port 801030f9: e8 62 3a 00 00 call 80106b60 <uartinit> pinit(); // process table 801030fe: e8 9d 08 00 00 call 801039a0 <pinit> tvinit(); // trap vectors 80103103: e8 b8 36 00 00 call 801067c0 <tvinit> binit(); // buffer cache 80103108: e8 33 cf ff ff call 80100040 <binit> fileinit(); // file table 8010310d: e8 9e de ff ff call 80100fb0 <fileinit> ideinit(); // disk 80103112: e8 09 f1 ff ff call 80102220 <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); 80103117: 83 c4 0c add $0xc,%esp 8010311a: 68 8a 00 00 00 push $0x8a 8010311f: 68 8c b4 10 80 push $0x8010b48c 80103124: 68 00 70 00 80 push $0x80007000 80103129: e8 b2 21 00 00 call 801052e0 <memmove> for(c = cpus; c < cpus+ncpu; c++){ 8010312e: 69 05 b0 38 11 80 b0 imul $0xb0,0x801138b0,%eax 80103135: 00 00 00 80103138: 83 c4 10 add $0x10,%esp 8010313b: 05 00 38 11 80 add $0x80113800,%eax 80103140: 39 d8 cmp %ebx,%eax 80103142: 76 6f jbe 801031b3 <main+0x103> 80103144: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(c == mycpu()) // We've started already. 80103148: e8 73 08 00 00 call 801039c0 <mycpu> 8010314d: 39 d8 cmp %ebx,%eax 8010314f: 74 49 je 8010319a <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(); 80103151: e8 8a f5 ff ff call 801026e0 <kalloc> *(void**)(code-4) = stack + KSTACKSIZE; 80103156: 05 00 10 00 00 add $0x1000,%eax *(void(**)(void))(code-8) = mpenter; 8010315b: c7 05 f8 6f 00 80 90 movl $0x80103090,0x80006ff8 80103162: 30 10 80 *(int**)(code-12) = (void *) V2P(entrypgdir); 80103165: c7 05 f4 6f 00 80 00 movl $0x10a000,0x80006ff4 8010316c: a0 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; 8010316f: a3 fc 6f 00 80 mov %eax,0x80006ffc *(void(**)(void))(code-8) = mpenter; *(int**)(code-12) = (void *) V2P(entrypgdir); lapicstartap(c->apicid, V2P(code)); 80103174: 0f b6 03 movzbl (%ebx),%eax 80103177: 83 ec 08 sub $0x8,%esp 8010317a: 68 00 70 00 00 push $0x7000 8010317f: 50 push %eax 80103180: e8 0b f8 ff ff call 80102990 <lapicstartap> 80103185: 83 c4 10 add $0x10,%esp 80103188: 90 nop 80103189: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi // wait for cpu to finish mpmain() while(c->started == 0) 80103190: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax 80103196: 85 c0 test %eax,%eax 80103198: 74 f6 je 80103190 <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++){ 8010319a: 69 05 b0 38 11 80 b0 imul $0xb0,0x801138b0,%eax 801031a1: 00 00 00 801031a4: 81 c3 b0 00 00 00 add $0xb0,%ebx 801031aa: 05 00 38 11 80 add $0x80113800,%eax 801031af: 39 c3 cmp %eax,%ebx 801031b1: 72 95 jb 80103148 <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() 801031b3: 83 ec 08 sub $0x8,%esp 801031b6: 68 00 00 00 8e push $0x8e000000 801031bb: 68 00 00 40 80 push $0x80400000 801031c0: e8 bb f4 ff ff call 80102680 <kinit2> userinit(); // first user process 801031c5: e8 96 08 00 00 call 80103a60 <userinit> mpmain(); // finish this processor's setup 801031ca: e8 81 fe ff ff call 80103050 <mpmain> 801031cf: 90 nop 801031d0 <mpsearch1>: } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 801031d0: 55 push %ebp 801031d1: 89 e5 mov %esp,%ebp 801031d3: 57 push %edi 801031d4: 56 push %esi uchar *e, *p, *addr; addr = P2V(a); 801031d5: 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) { 801031db: 53 push %ebx uchar *e, *p, *addr; addr = P2V(a); e = addr+len; 801031dc: 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) { 801031df: 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)) 801031e2: 39 de cmp %ebx,%esi 801031e4: 73 48 jae 8010322e <mpsearch1+0x5e> 801031e6: 8d 76 00 lea 0x0(%esi),%esi 801031e9: 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) 801031f0: 83 ec 04 sub $0x4,%esp 801031f3: 8d 7e 10 lea 0x10(%esi),%edi 801031f6: 6a 04 push $0x4 801031f8: 68 58 85 10 80 push $0x80108558 801031fd: 56 push %esi 801031fe: e8 7d 20 00 00 call 80105280 <memcmp> 80103203: 83 c4 10 add $0x10,%esp 80103206: 85 c0 test %eax,%eax 80103208: 75 1e jne 80103228 <mpsearch1+0x58> 8010320a: 8d 7e 10 lea 0x10(%esi),%edi 8010320d: 89 f2 mov %esi,%edx 8010320f: 31 c9 xor %ecx,%ecx 80103211: 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]; 80103218: 0f b6 02 movzbl (%edx),%eax 8010321b: 83 c2 01 add $0x1,%edx 8010321e: 01 c1 add %eax,%ecx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80103220: 39 fa cmp %edi,%edx 80103222: 75 f4 jne 80103218 <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) 80103224: 84 c9 test %cl,%cl 80103226: 74 10 je 80103238 <mpsearch1+0x68> { uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 80103228: 39 fb cmp %edi,%ebx 8010322a: 89 fe mov %edi,%esi 8010322c: 77 c2 ja 801031f0 <mpsearch1+0x20> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; } 8010322e: 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; 80103231: 31 c0 xor %eax,%eax } 80103233: 5b pop %ebx 80103234: 5e pop %esi 80103235: 5f pop %edi 80103236: 5d pop %ebp 80103237: c3 ret 80103238: 8d 65 f4 lea -0xc(%ebp),%esp 8010323b: 89 f0 mov %esi,%eax 8010323d: 5b pop %ebx 8010323e: 5e pop %esi 8010323f: 5f pop %edi 80103240: 5d pop %ebp 80103241: c3 ret 80103242: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103250 <mpinit>: return conf; } void mpinit(void) { 80103250: 55 push %ebp 80103251: 89 e5 mov %esp,%ebp 80103253: 57 push %edi 80103254: 56 push %esi 80103255: 53 push %ebx 80103256: 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)){ 80103259: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax 80103260: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx 80103267: c1 e0 08 shl $0x8,%eax 8010326a: 09 d0 or %edx,%eax 8010326c: c1 e0 04 shl $0x4,%eax 8010326f: 85 c0 test %eax,%eax 80103271: 75 1b jne 8010328e <mpinit+0x3e> if((mp = mpsearch1(p, 1024))) return mp; } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) 80103273: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax 8010327a: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx 80103281: c1 e0 08 shl $0x8,%eax 80103284: 09 d0 or %edx,%eax 80103286: c1 e0 0a shl $0xa,%eax 80103289: 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))) 8010328e: ba 00 04 00 00 mov $0x400,%edx 80103293: e8 38 ff ff ff call 801031d0 <mpsearch1> 80103298: 85 c0 test %eax,%eax 8010329a: 89 45 e4 mov %eax,-0x1c(%ebp) 8010329d: 0f 84 38 01 00 00 je 801033db <mpinit+0x18b> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 801032a3: 8b 45 e4 mov -0x1c(%ebp),%eax 801032a6: 8b 58 04 mov 0x4(%eax),%ebx 801032a9: 85 db test %ebx,%ebx 801032ab: 0f 84 44 01 00 00 je 801033f5 <mpinit+0x1a5> return 0; conf = (struct mpconf*) P2V((uint) mp->physaddr); 801032b1: 8d b3 00 00 00 80 lea -0x80000000(%ebx),%esi if(memcmp(conf, "PCMP", 4) != 0) 801032b7: 83 ec 04 sub $0x4,%esp 801032ba: 6a 04 push $0x4 801032bc: 68 5d 85 10 80 push $0x8010855d 801032c1: 56 push %esi 801032c2: e8 b9 1f 00 00 call 80105280 <memcmp> 801032c7: 83 c4 10 add $0x10,%esp 801032ca: 85 c0 test %eax,%eax 801032cc: 0f 85 23 01 00 00 jne 801033f5 <mpinit+0x1a5> return 0; if(conf->version != 1 && conf->version != 4) 801032d2: 0f b6 83 06 00 00 80 movzbl -0x7ffffffa(%ebx),%eax 801032d9: 3c 01 cmp $0x1,%al 801032db: 74 08 je 801032e5 <mpinit+0x95> 801032dd: 3c 04 cmp $0x4,%al 801032df: 0f 85 10 01 00 00 jne 801033f5 <mpinit+0x1a5> return 0; if(sum((uchar*)conf, conf->length) != 0) 801032e5: 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++) 801032ec: 85 ff test %edi,%edi 801032ee: 74 21 je 80103311 <mpinit+0xc1> 801032f0: 31 d2 xor %edx,%edx 801032f2: 31 c0 xor %eax,%eax 801032f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sum += addr[i]; 801032f8: 0f b6 8c 03 00 00 00 movzbl -0x80000000(%ebx,%eax,1),%ecx 801032ff: 80 sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80103300: 83 c0 01 add $0x1,%eax sum += addr[i]; 80103303: 01 ca add %ecx,%edx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80103305: 39 c7 cmp %eax,%edi 80103307: 75 ef jne 801032f8 <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) 80103309: 84 d2 test %dl,%dl 8010330b: 0f 85 e4 00 00 00 jne 801033f5 <mpinit+0x1a5> struct mp *mp; struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) 80103311: 85 f6 test %esi,%esi 80103313: 0f 84 dc 00 00 00 je 801033f5 <mpinit+0x1a5> panic("Expect to run on an SMP"); ismp = 1; lapic = (uint*)conf->lapicaddr; 80103319: 8b 83 24 00 00 80 mov -0x7fffffdc(%ebx),%eax 8010331f: a3 fc 36 11 80 mov %eax,0x801136fc for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 80103324: 0f b7 93 04 00 00 80 movzwl -0x7ffffffc(%ebx),%edx 8010332b: 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; 80103331: bb 01 00 00 00 mov $0x1,%ebx lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 80103336: 01 d6 add %edx,%esi 80103338: 90 nop 80103339: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103340: 39 c6 cmp %eax,%esi 80103342: 76 23 jbe 80103367 <mpinit+0x117> 80103344: 0f b6 10 movzbl (%eax),%edx switch(*p){ 80103347: 80 fa 04 cmp $0x4,%dl 8010334a: 0f 87 c0 00 00 00 ja 80103410 <mpinit+0x1c0> 80103350: ff 24 95 9c 85 10 80 jmp *-0x7fef7a64(,%edx,4) 80103357: 89 f6 mov %esi,%esi 80103359: 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; 80103360: 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; ){ 80103363: 39 c6 cmp %eax,%esi 80103365: 77 dd ja 80103344 <mpinit+0xf4> default: ismp = 0; break; } } if(!ismp) 80103367: 85 db test %ebx,%ebx 80103369: 0f 84 93 00 00 00 je 80103402 <mpinit+0x1b2> panic("Didn't find a suitable machine"); if(mp->imcrp){ 8010336f: 8b 45 e4 mov -0x1c(%ebp),%eax 80103372: 80 78 0c 00 cmpb $0x0,0xc(%eax) 80103376: 74 15 je 8010338d <mpinit+0x13d> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80103378: ba 22 00 00 00 mov $0x22,%edx 8010337d: b8 70 00 00 00 mov $0x70,%eax 80103382: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80103383: ba 23 00 00 00 mov $0x23,%edx 80103388: ec in (%dx),%al } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80103389: 83 c8 01 or $0x1,%eax 8010338c: 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. } } 8010338d: 8d 65 f4 lea -0xc(%ebp),%esp 80103390: 5b pop %ebx 80103391: 5e pop %esi 80103392: 5f pop %edi 80103393: 5d pop %ebp 80103394: c3 ret 80103395: 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) { 80103398: 8b 0d b0 38 11 80 mov 0x801138b0,%ecx 8010339e: 85 c9 test %ecx,%ecx 801033a0: 7e 1e jle 801033c0 <mpinit+0x170> cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu ncpu++; } p += sizeof(struct mpproc); 801033a2: 83 c0 14 add $0x14,%eax continue; 801033a5: eb 99 jmp 80103340 <mpinit+0xf0> 801033a7: 89 f6 mov %esi,%esi 801033a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 801033b0: 0f b6 50 01 movzbl 0x1(%eax),%edx p += sizeof(struct mpioapic); 801033b4: 83 c0 08 add $0x8,%eax } p += sizeof(struct mpproc); continue; case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 801033b7: 88 15 e0 37 11 80 mov %dl,0x801137e0 p += sizeof(struct mpioapic); continue; 801033bd: eb 81 jmp 80103340 <mpinit+0xf0> 801033bf: 90 nop 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 801033c0: 0f b6 50 01 movzbl 0x1(%eax),%edx 801033c4: 69 f9 b0 00 00 00 imul $0xb0,%ecx,%edi ncpu++; 801033ca: 83 c1 01 add $0x1,%ecx 801033cd: 89 0d b0 38 11 80 mov %ecx,0x801138b0 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 801033d3: 88 97 00 38 11 80 mov %dl,-0x7feec800(%edi) 801033d9: eb c7 jmp 801033a2 <mpinit+0x152> } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) return mp; } return mpsearch1(0xF0000, 0x10000); 801033db: ba 00 00 01 00 mov $0x10000,%edx 801033e0: b8 00 00 0f 00 mov $0xf0000,%eax 801033e5: e8 e6 fd ff ff call 801031d0 <mpsearch1> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 801033ea: 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); 801033ec: 89 45 e4 mov %eax,-0x1c(%ebp) mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 801033ef: 0f 85 ae fe ff ff jne 801032a3 <mpinit+0x53> struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) panic("Expect to run on an SMP"); 801033f5: 83 ec 0c sub $0xc,%esp 801033f8: 68 62 85 10 80 push $0x80108562 801033fd: e8 6e cf ff ff call 80100370 <panic> ismp = 0; break; } } if(!ismp) panic("Didn't find a suitable machine"); 80103402: 83 ec 0c sub $0xc,%esp 80103405: 68 7c 85 10 80 push $0x8010857c 8010340a: e8 61 cf ff ff call 80100370 <panic> 8010340f: 90 nop case MPIOINTR: case MPLINTR: p += 8; continue; default: ismp = 0; 80103410: 31 db xor %ebx,%ebx 80103412: e9 30 ff ff ff jmp 80103347 <mpinit+0xf7> 80103417: 66 90 xchg %ax,%ax 80103419: 66 90 xchg %ax,%ax 8010341b: 66 90 xchg %ax,%ax 8010341d: 66 90 xchg %ax,%ax 8010341f: 90 nop 80103420 <picinit>: #define IO_PIC2 0xA0 // Slave (IRQs 8-15) // Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware. void picinit(void) { 80103420: 55 push %ebp 80103421: ba 21 00 00 00 mov $0x21,%edx 80103426: b8 ff ff ff ff mov $0xffffffff,%eax 8010342b: 89 e5 mov %esp,%ebp 8010342d: ee out %al,(%dx) 8010342e: ba a1 00 00 00 mov $0xa1,%edx 80103433: ee out %al,(%dx) // mask all interrupts outb(IO_PIC1+1, 0xFF); outb(IO_PIC2+1, 0xFF); } 80103434: 5d pop %ebp 80103435: c3 ret 80103436: 66 90 xchg %ax,%ax 80103438: 66 90 xchg %ax,%ax 8010343a: 66 90 xchg %ax,%ax 8010343c: 66 90 xchg %ax,%ax 8010343e: 66 90 xchg %ax,%ax 80103440 <pipealloc>: int writeopen; // write fd is still open }; int pipealloc(struct file **f0, struct file **f1) { 80103440: 55 push %ebp 80103441: 89 e5 mov %esp,%ebp 80103443: 57 push %edi 80103444: 56 push %esi 80103445: 53 push %ebx 80103446: 83 ec 0c sub $0xc,%esp 80103449: 8b 75 08 mov 0x8(%ebp),%esi 8010344c: 8b 5d 0c mov 0xc(%ebp),%ebx struct pipe *p; p = 0; *f0 = *f1 = 0; 8010344f: c7 03 00 00 00 00 movl $0x0,(%ebx) 80103455: c7 06 00 00 00 00 movl $0x0,(%esi) if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) 8010345b: e8 70 db ff ff call 80100fd0 <filealloc> 80103460: 85 c0 test %eax,%eax 80103462: 89 06 mov %eax,(%esi) 80103464: 0f 84 a8 00 00 00 je 80103512 <pipealloc+0xd2> 8010346a: e8 61 db ff ff call 80100fd0 <filealloc> 8010346f: 85 c0 test %eax,%eax 80103471: 89 03 mov %eax,(%ebx) 80103473: 0f 84 87 00 00 00 je 80103500 <pipealloc+0xc0> goto bad; if((p = (struct pipe*)kalloc()) == 0) 80103479: e8 62 f2 ff ff call 801026e0 <kalloc> 8010347e: 85 c0 test %eax,%eax 80103480: 89 c7 mov %eax,%edi 80103482: 0f 84 b0 00 00 00 je 80103538 <pipealloc+0xf8> goto bad; p->readopen = 1; p->writeopen = 1; p->nwrite = 0; p->nread = 0; initlock(&p->lock, "pipe"); 80103488: 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; 8010348b: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) 80103492: 00 00 00 p->writeopen = 1; 80103495: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) 8010349c: 00 00 00 p->nwrite = 0; 8010349f: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) 801034a6: 00 00 00 p->nread = 0; 801034a9: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) 801034b0: 00 00 00 initlock(&p->lock, "pipe"); 801034b3: 68 b0 85 10 80 push $0x801085b0 801034b8: 50 push %eax 801034b9: e8 12 1b 00 00 call 80104fd0 <initlock> (*f0)->type = FD_PIPE; 801034be: 8b 06 mov (%esi),%eax (*f0)->pipe = p; (*f1)->type = FD_PIPE; (*f1)->readable = 0; (*f1)->writable = 1; (*f1)->pipe = p; return 0; 801034c0: 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; 801034c3: c7 00 01 00 00 00 movl $0x1,(%eax) (*f0)->readable = 1; 801034c9: 8b 06 mov (%esi),%eax 801034cb: c6 40 08 01 movb $0x1,0x8(%eax) (*f0)->writable = 0; 801034cf: 8b 06 mov (%esi),%eax 801034d1: c6 40 09 00 movb $0x0,0x9(%eax) (*f0)->pipe = p; 801034d5: 8b 06 mov (%esi),%eax 801034d7: 89 78 0c mov %edi,0xc(%eax) (*f1)->type = FD_PIPE; 801034da: 8b 03 mov (%ebx),%eax 801034dc: c7 00 01 00 00 00 movl $0x1,(%eax) (*f1)->readable = 0; 801034e2: 8b 03 mov (%ebx),%eax 801034e4: c6 40 08 00 movb $0x0,0x8(%eax) (*f1)->writable = 1; 801034e8: 8b 03 mov (%ebx),%eax 801034ea: c6 40 09 01 movb $0x1,0x9(%eax) (*f1)->pipe = p; 801034ee: 8b 03 mov (%ebx),%eax 801034f0: 89 78 0c mov %edi,0xc(%eax) if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 801034f3: 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; 801034f6: 31 c0 xor %eax,%eax if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 801034f8: 5b pop %ebx 801034f9: 5e pop %esi 801034fa: 5f pop %edi 801034fb: 5d pop %ebp 801034fc: c3 ret 801034fd: 8d 76 00 lea 0x0(%esi),%esi //PAGEBREAK: 20 bad: if(p) kfree((char*)p); if(*f0) 80103500: 8b 06 mov (%esi),%eax 80103502: 85 c0 test %eax,%eax 80103504: 74 1e je 80103524 <pipealloc+0xe4> fileclose(*f0); 80103506: 83 ec 0c sub $0xc,%esp 80103509: 50 push %eax 8010350a: e8 81 db ff ff call 80101090 <fileclose> 8010350f: 83 c4 10 add $0x10,%esp if(*f1) 80103512: 8b 03 mov (%ebx),%eax 80103514: 85 c0 test %eax,%eax 80103516: 74 0c je 80103524 <pipealloc+0xe4> fileclose(*f1); 80103518: 83 ec 0c sub $0xc,%esp 8010351b: 50 push %eax 8010351c: e8 6f db ff ff call 80101090 <fileclose> 80103521: 83 c4 10 add $0x10,%esp return -1; } 80103524: 8d 65 f4 lea -0xc(%ebp),%esp kfree((char*)p); if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; 80103527: b8 ff ff ff ff mov $0xffffffff,%eax } 8010352c: 5b pop %ebx 8010352d: 5e pop %esi 8010352e: 5f pop %edi 8010352f: 5d pop %ebp 80103530: c3 ret 80103531: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi //PAGEBREAK: 20 bad: if(p) kfree((char*)p); if(*f0) 80103538: 8b 06 mov (%esi),%eax 8010353a: 85 c0 test %eax,%eax 8010353c: 75 c8 jne 80103506 <pipealloc+0xc6> 8010353e: eb d2 jmp 80103512 <pipealloc+0xd2> 80103540 <pipeclose>: return -1; } void pipeclose(struct pipe *p, int writable) { 80103540: 55 push %ebp 80103541: 89 e5 mov %esp,%ebp 80103543: 56 push %esi 80103544: 53 push %ebx 80103545: 8b 5d 08 mov 0x8(%ebp),%ebx 80103548: 8b 75 0c mov 0xc(%ebp),%esi acquire(&p->lock); 8010354b: 83 ec 0c sub $0xc,%esp 8010354e: 53 push %ebx 8010354f: e8 dc 1b 00 00 call 80105130 <acquire> if(writable){ 80103554: 83 c4 10 add $0x10,%esp 80103557: 85 f6 test %esi,%esi 80103559: 74 45 je 801035a0 <pipeclose+0x60> p->writeopen = 0; wakeup(&p->nread); 8010355b: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 80103561: 83 ec 0c sub $0xc,%esp void pipeclose(struct pipe *p, int writable) { acquire(&p->lock); if(writable){ p->writeopen = 0; 80103564: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) 8010356b: 00 00 00 wakeup(&p->nread); 8010356e: 50 push %eax 8010356f: e8 1c 10 00 00 call 80104590 <wakeup> 80103574: 83 c4 10 add $0x10,%esp } else { p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ 80103577: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 8010357d: 85 d2 test %edx,%edx 8010357f: 75 0a jne 8010358b <pipeclose+0x4b> 80103581: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax 80103587: 85 c0 test %eax,%eax 80103589: 74 35 je 801035c0 <pipeclose+0x80> release(&p->lock); kfree((char*)p); } else release(&p->lock); 8010358b: 89 5d 08 mov %ebx,0x8(%ebp) } 8010358e: 8d 65 f8 lea -0x8(%ebp),%esp 80103591: 5b pop %ebx 80103592: 5e pop %esi 80103593: 5d pop %ebp } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); } else release(&p->lock); 80103594: e9 47 1c 00 00 jmp 801051e0 <release> 80103599: 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); 801035a0: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax 801035a6: 83 ec 0c sub $0xc,%esp acquire(&p->lock); if(writable){ p->writeopen = 0; wakeup(&p->nread); } else { p->readopen = 0; 801035a9: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) 801035b0: 00 00 00 wakeup(&p->nwrite); 801035b3: 50 push %eax 801035b4: e8 d7 0f 00 00 call 80104590 <wakeup> 801035b9: 83 c4 10 add $0x10,%esp 801035bc: eb b9 jmp 80103577 <pipeclose+0x37> 801035be: 66 90 xchg %ax,%ax } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); 801035c0: 83 ec 0c sub $0xc,%esp 801035c3: 53 push %ebx 801035c4: e8 17 1c 00 00 call 801051e0 <release> kfree((char*)p); 801035c9: 89 5d 08 mov %ebx,0x8(%ebp) 801035cc: 83 c4 10 add $0x10,%esp } else release(&p->lock); } 801035cf: 8d 65 f8 lea -0x8(%ebp),%esp 801035d2: 5b pop %ebx 801035d3: 5e pop %esi 801035d4: 5d pop %ebp p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); 801035d5: e9 56 ef ff ff jmp 80102530 <kfree> 801035da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801035e0 <pipewrite>: } //PAGEBREAK: 40 int pipewrite(struct pipe *p, char *addr, int n) { 801035e0: 55 push %ebp 801035e1: 89 e5 mov %esp,%ebp 801035e3: 57 push %edi 801035e4: 56 push %esi 801035e5: 53 push %ebx 801035e6: 83 ec 28 sub $0x28,%esp 801035e9: 8b 5d 08 mov 0x8(%ebp),%ebx int i; acquire(&p->lock); 801035ec: 53 push %ebx 801035ed: e8 3e 1b 00 00 call 80105130 <acquire> for(i = 0; i < n; i++){ 801035f2: 8b 45 10 mov 0x10(%ebp),%eax 801035f5: 83 c4 10 add $0x10,%esp 801035f8: 85 c0 test %eax,%eax 801035fa: 0f 8e b9 00 00 00 jle 801036b9 <pipewrite+0xd9> 80103600: 8b 4d 0c mov 0xc(%ebp),%ecx 80103603: 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); 80103609: 8d bb 34 02 00 00 lea 0x234(%ebx),%edi sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 8010360f: 8d b3 38 02 00 00 lea 0x238(%ebx),%esi 80103615: 89 4d e4 mov %ecx,-0x1c(%ebp) 80103618: 03 4d 10 add 0x10(%ebp),%ecx 8010361b: 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 8010361e: 8b 8b 34 02 00 00 mov 0x234(%ebx),%ecx 80103624: 8d 91 00 02 00 00 lea 0x200(%ecx),%edx 8010362a: 39 d0 cmp %edx,%eax 8010362c: 74 38 je 80103666 <pipewrite+0x86> 8010362e: eb 59 jmp 80103689 <pipewrite+0xa9> if(p->readopen == 0 || myproc()->killed){ 80103630: e8 fb 03 00 00 call 80103a30 <myproc> 80103635: 8b 48 24 mov 0x24(%eax),%ecx 80103638: 85 c9 test %ecx,%ecx 8010363a: 75 34 jne 80103670 <pipewrite+0x90> release(&p->lock); return -1; } wakeup(&p->nread); 8010363c: 83 ec 0c sub $0xc,%esp 8010363f: 57 push %edi 80103640: e8 4b 0f 00 00 call 80104590 <wakeup> sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 80103645: 58 pop %eax 80103646: 5a pop %edx 80103647: 53 push %ebx 80103648: 56 push %esi 80103649: e8 82 0d 00 00 call 801043d0 <sleep> { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 8010364e: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 80103654: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx 8010365a: 83 c4 10 add $0x10,%esp 8010365d: 05 00 02 00 00 add $0x200,%eax 80103662: 39 c2 cmp %eax,%edx 80103664: 75 2a jne 80103690 <pipewrite+0xb0> if(p->readopen == 0 || myproc()->killed){ 80103666: 8b 83 3c 02 00 00 mov 0x23c(%ebx),%eax 8010366c: 85 c0 test %eax,%eax 8010366e: 75 c0 jne 80103630 <pipewrite+0x50> release(&p->lock); 80103670: 83 ec 0c sub $0xc,%esp 80103673: 53 push %ebx 80103674: e8 67 1b 00 00 call 801051e0 <release> return -1; 80103679: 83 c4 10 add $0x10,%esp 8010367c: 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; } 80103681: 8d 65 f4 lea -0xc(%ebp),%esp 80103684: 5b pop %ebx 80103685: 5e pop %esi 80103686: 5f pop %edi 80103687: 5d pop %ebp 80103688: c3 ret { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 80103689: 89 c2 mov %eax,%edx 8010368b: 90 nop 8010368c: 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]; 80103690: 8b 4d e4 mov -0x1c(%ebp),%ecx 80103693: 8d 42 01 lea 0x1(%edx),%eax 80103696: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 8010369a: 81 e2 ff 01 00 00 and $0x1ff,%edx 801036a0: 89 83 38 02 00 00 mov %eax,0x238(%ebx) 801036a6: 0f b6 09 movzbl (%ecx),%ecx 801036a9: 88 4c 13 34 mov %cl,0x34(%ebx,%edx,1) 801036ad: 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++){ 801036b0: 3b 4d e0 cmp -0x20(%ebp),%ecx 801036b3: 0f 85 65 ff ff ff jne 8010361e <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 801036b9: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 801036bf: 83 ec 0c sub $0xc,%esp 801036c2: 50 push %eax 801036c3: e8 c8 0e 00 00 call 80104590 <wakeup> release(&p->lock); 801036c8: 89 1c 24 mov %ebx,(%esp) 801036cb: e8 10 1b 00 00 call 801051e0 <release> return n; 801036d0: 83 c4 10 add $0x10,%esp 801036d3: 8b 45 10 mov 0x10(%ebp),%eax 801036d6: eb a9 jmp 80103681 <pipewrite+0xa1> 801036d8: 90 nop 801036d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801036e0 <piperead>: } int piperead(struct pipe *p, char *addr, int n) { 801036e0: 55 push %ebp 801036e1: 89 e5 mov %esp,%ebp 801036e3: 57 push %edi 801036e4: 56 push %esi 801036e5: 53 push %ebx 801036e6: 83 ec 18 sub $0x18,%esp 801036e9: 8b 5d 08 mov 0x8(%ebp),%ebx 801036ec: 8b 7d 0c mov 0xc(%ebp),%edi int i; acquire(&p->lock); 801036ef: 53 push %ebx 801036f0: e8 3b 1a 00 00 call 80105130 <acquire> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801036f5: 83 c4 10 add $0x10,%esp 801036f8: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 801036fe: 39 83 38 02 00 00 cmp %eax,0x238(%ebx) 80103704: 75 6a jne 80103770 <piperead+0x90> 80103706: 8b b3 40 02 00 00 mov 0x240(%ebx),%esi 8010370c: 85 f6 test %esi,%esi 8010370e: 0f 84 cc 00 00 00 je 801037e0 <piperead+0x100> if(myproc()->killed){ release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 80103714: 8d b3 34 02 00 00 lea 0x234(%ebx),%esi 8010371a: eb 2d jmp 80103749 <piperead+0x69> 8010371c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103720: 83 ec 08 sub $0x8,%esp 80103723: 53 push %ebx 80103724: 56 push %esi 80103725: e8 a6 0c 00 00 call 801043d0 <sleep> piperead(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 8010372a: 83 c4 10 add $0x10,%esp 8010372d: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax 80103733: 39 83 34 02 00 00 cmp %eax,0x234(%ebx) 80103739: 75 35 jne 80103770 <piperead+0x90> 8010373b: 8b 93 40 02 00 00 mov 0x240(%ebx),%edx 80103741: 85 d2 test %edx,%edx 80103743: 0f 84 97 00 00 00 je 801037e0 <piperead+0x100> if(myproc()->killed){ 80103749: e8 e2 02 00 00 call 80103a30 <myproc> 8010374e: 8b 48 24 mov 0x24(%eax),%ecx 80103751: 85 c9 test %ecx,%ecx 80103753: 74 cb je 80103720 <piperead+0x40> release(&p->lock); 80103755: 83 ec 0c sub $0xc,%esp 80103758: 53 push %ebx 80103759: e8 82 1a 00 00 call 801051e0 <release> return -1; 8010375e: 83 c4 10 add $0x10,%esp addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 80103761: 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; 80103764: 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; } 80103769: 5b pop %ebx 8010376a: 5e pop %esi 8010376b: 5f pop %edi 8010376c: 5d pop %ebp 8010376d: c3 ret 8010376e: 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 80103770: 8b 45 10 mov 0x10(%ebp),%eax 80103773: 85 c0 test %eax,%eax 80103775: 7e 69 jle 801037e0 <piperead+0x100> if(p->nread == p->nwrite) 80103777: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 8010377d: 31 c9 xor %ecx,%ecx 8010377f: eb 15 jmp 80103796 <piperead+0xb6> 80103781: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103788: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 8010378e: 3b 83 38 02 00 00 cmp 0x238(%ebx),%eax 80103794: 74 5a je 801037f0 <piperead+0x110> break; addr[i] = p->data[p->nread++ % PIPESIZE]; 80103796: 8d 70 01 lea 0x1(%eax),%esi 80103799: 25 ff 01 00 00 and $0x1ff,%eax 8010379e: 89 b3 34 02 00 00 mov %esi,0x234(%ebx) 801037a4: 0f b6 44 03 34 movzbl 0x34(%ebx,%eax,1),%eax 801037a9: 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 801037ac: 83 c1 01 add $0x1,%ecx 801037af: 39 4d 10 cmp %ecx,0x10(%ebp) 801037b2: 75 d4 jne 80103788 <piperead+0xa8> if(p->nread == p->nwrite) break; addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup 801037b4: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax 801037ba: 83 ec 0c sub $0xc,%esp 801037bd: 50 push %eax 801037be: e8 cd 0d 00 00 call 80104590 <wakeup> release(&p->lock); 801037c3: 89 1c 24 mov %ebx,(%esp) 801037c6: e8 15 1a 00 00 call 801051e0 <release> return i; 801037cb: 8b 45 10 mov 0x10(%ebp),%eax 801037ce: 83 c4 10 add $0x10,%esp } 801037d1: 8d 65 f4 lea -0xc(%ebp),%esp 801037d4: 5b pop %ebx 801037d5: 5e pop %esi 801037d6: 5f pop %edi 801037d7: 5d pop %ebp 801037d8: c3 ret 801037d9: 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 801037e0: c7 45 10 00 00 00 00 movl $0x0,0x10(%ebp) 801037e7: eb cb jmp 801037b4 <piperead+0xd4> 801037e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801037f0: 89 4d 10 mov %ecx,0x10(%ebp) 801037f3: eb bf jmp 801037b4 <piperead+0xd4> 801037f5: 66 90 xchg %ax,%ax 801037f7: 66 90 xchg %ax,%ax 801037f9: 66 90 xchg %ax,%ax 801037fb: 66 90 xchg %ax,%ax 801037fd: 66 90 xchg %ax,%ax 801037ff: 90 nop 80103800 <allocproc>: // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 80103800: 55 push %ebp 80103801: 89 e5 mov %esp,%ebp 80103803: 53 push %ebx struct proc *p; char *sp; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103804: bb 14 39 11 80 mov $0x80113914,%ebx // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 80103809: 83 ec 10 sub $0x10,%esp struct proc *p; char *sp; acquire(&ptable.lock); 8010380c: 68 e0 38 11 80 push $0x801138e0 80103811: e8 1a 19 00 00 call 80105130 <acquire> 80103816: 83 c4 10 add $0x10,%esp 80103819: eb 17 jmp 80103832 <allocproc+0x32> 8010381b: 90 nop 8010381c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103820: 81 c3 94 00 00 00 add $0x94,%ebx 80103826: 81 fb 14 5e 11 80 cmp $0x80115e14,%ebx 8010382c: 0f 84 c6 00 00 00 je 801038f8 <allocproc+0xf8> if(p->state == UNUSED) 80103832: 8b 43 0c mov 0xc(%ebx),%eax 80103835: 85 c0 test %eax,%eax 80103837: 75 e7 jne 80103820 <allocproc+0x20> release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 80103839: a1 04 b0 10 80 mov 0x8010b004,%eax p->tickets = 1000000; } p->tickets=10; p->priority = 0.01; p->executionCycle = 1; acquire(&tickslock); 8010383e: 83 ec 0c sub $0xc,%esp release(&ptable.lock); return 0; found: p->state = EMBRYO; 80103841: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx) p->tickets = 1000000; } p->tickets=10; p->priority = 0.01; p->executionCycle = 1; acquire(&tickslock); 80103848: 68 20 5e 11 80 push $0x80115e20 found: p->state = EMBRYO; p->pid = nextpid++; ///////////////////////focus///////////////////////// p->queuenum = 1; 8010384d: c7 83 80 00 00 00 01 movl $0x1,0x80(%ebx) 80103854: 00 00 00 //////////////////shell/////////////////// if(p->pid == 2){ p->tickets = 1000000; } p->tickets=10; 80103857: c7 83 84 00 00 00 0a movl $0xa,0x84(%ebx) 8010385e: 00 00 00 p->priority = 0.01; 80103861: c7 83 88 00 00 00 0a movl $0x3c23d70a,0x88(%ebx) 80103868: d7 23 3c release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 8010386b: 8d 50 01 lea 0x1(%eax),%edx 8010386e: 89 43 10 mov %eax,0x10(%ebx) if(p->pid == 2){ p->tickets = 1000000; } p->tickets=10; p->priority = 0.01; p->executionCycle = 1; 80103871: c7 83 90 00 00 00 01 movl $0x1,0x90(%ebx) 80103878: 00 00 00 release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 8010387b: 89 15 04 b0 10 80 mov %edx,0x8010b004 p->tickets = 1000000; } p->tickets=10; p->priority = 0.01; p->executionCycle = 1; acquire(&tickslock); 80103881: e8 aa 18 00 00 call 80105130 <acquire> p->createTime = ticks; 80103886: a1 60 66 11 80 mov 0x80116660,%eax release(&tickslock); 8010388b: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) } p->tickets=10; p->priority = 0.01; p->executionCycle = 1; acquire(&tickslock); p->createTime = ticks; 80103892: 89 83 8c 00 00 00 mov %eax,0x8c(%ebx) release(&tickslock); 80103898: e8 43 19 00 00 call 801051e0 <release> release(&ptable.lock); 8010389d: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 801038a4: e8 37 19 00 00 call 801051e0 <release> // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ 801038a9: e8 32 ee ff ff call 801026e0 <kalloc> 801038ae: 83 c4 10 add $0x10,%esp 801038b1: 85 c0 test %eax,%eax 801038b3: 89 43 08 mov %eax,0x8(%ebx) 801038b6: 74 57 je 8010390f <allocproc+0x10f> return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 801038b8: 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); 801038be: 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; 801038c1: 05 9c 0f 00 00 add $0xf9c,%eax return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 801038c6: 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; 801038c9: c7 40 14 b1 67 10 80 movl $0x801067b1,0x14(%eax) sp -= sizeof *p->context; p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); 801038d0: 6a 14 push $0x14 801038d2: 6a 00 push $0x0 801038d4: 50 push %eax // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; p->context = (struct context*)sp; 801038d5: 89 43 1c mov %eax,0x1c(%ebx) memset(p->context, 0, sizeof *p->context); 801038d8: e8 53 19 00 00 call 80105230 <memset> p->context->eip = (uint)forkret; 801038dd: 8b 43 1c mov 0x1c(%ebx),%eax return p; 801038e0: 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; 801038e3: c7 40 10 20 39 10 80 movl $0x80103920,0x10(%eax) return p; 801038ea: 89 d8 mov %ebx,%eax } 801038ec: 8b 5d fc mov -0x4(%ebp),%ebx 801038ef: c9 leave 801038f0: c3 ret 801038f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) if(p->state == UNUSED) goto found; release(&ptable.lock); 801038f8: 83 ec 0c sub $0xc,%esp 801038fb: 68 e0 38 11 80 push $0x801138e0 80103900: e8 db 18 00 00 call 801051e0 <release> return 0; 80103905: 83 c4 10 add $0x10,%esp 80103908: 31 c0 xor %eax,%eax p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); p->context->eip = (uint)forkret; return p; } 8010390a: 8b 5d fc mov -0x4(%ebp),%ebx 8010390d: c9 leave 8010390e: c3 ret release(&ptable.lock); // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ p->state = UNUSED; 8010390f: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) return 0; 80103916: eb d4 jmp 801038ec <allocproc+0xec> 80103918: 90 nop 80103919: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103920 <forkret>: // A fork child's very first scheduling by scheduler() // will swtch here. "Return" to user space. void forkret(void) { 80103920: 55 push %ebp 80103921: 89 e5 mov %esp,%ebp 80103923: 83 ec 14 sub $0x14,%esp static int first = 1; // Still holding ptable.lock from scheduler. release(&ptable.lock); 80103926: 68 e0 38 11 80 push $0x801138e0 8010392b: e8 b0 18 00 00 call 801051e0 <release> if (first) { 80103930: a1 00 b0 10 80 mov 0x8010b000,%eax 80103935: 83 c4 10 add $0x10,%esp 80103938: 85 c0 test %eax,%eax 8010393a: 75 04 jne 80103940 <forkret+0x20> iinit(ROOTDEV); initlog(ROOTDEV); } // Return to "caller", actually trapret (see allocproc). } 8010393c: c9 leave 8010393d: c3 ret 8010393e: 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); 80103940: 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; 80103943: c7 05 00 b0 10 80 00 movl $0x0,0x8010b000 8010394a: 00 00 00 iinit(ROOTDEV); 8010394d: 6a 01 push $0x1 8010394f: e8 6c dd ff ff call 801016c0 <iinit> initlog(ROOTDEV); 80103954: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8010395b: e8 a0 f3 ff ff call 80102d00 <initlog> 80103960: 83 c4 10 add $0x10,%esp } // Return to "caller", actually trapret (see allocproc). } 80103963: c9 leave 80103964: c3 ret 80103965: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103969: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103970 <rand>: static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767 */ { next = next * 1103515245 + 12345; 80103970: 69 05 08 b0 10 80 6d imul $0x41c64e6d,0x8010b008,%eax 80103977: 4e c6 41 #include "spinlock.h" static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767 */ { 8010397a: 55 push %ebp 8010397b: 89 e5 mov %esp,%ebp next = next * 1103515245 + 12345; return((unsigned int)(next/65536) % 32768); } 8010397d: 5d pop %ebp static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767 */ { next = next * 1103515245 + 12345; 8010397e: 05 39 30 00 00 add $0x3039,%eax 80103983: a3 08 b0 10 80 mov %eax,0x8010b008 return((unsigned int)(next/65536) % 32768); 80103988: c1 e8 10 shr $0x10,%eax 8010398b: 25 ff 7f 00 00 and $0x7fff,%eax } 80103990: c3 ret 80103991: eb 0d jmp 801039a0 <pinit> 80103993: 90 nop 80103994: 90 nop 80103995: 90 nop 80103996: 90 nop 80103997: 90 nop 80103998: 90 nop 80103999: 90 nop 8010399a: 90 nop 8010399b: 90 nop 8010399c: 90 nop 8010399d: 90 nop 8010399e: 90 nop 8010399f: 90 nop 801039a0 <pinit>: static void wakeup1(void *chan); void pinit(void) { 801039a0: 55 push %ebp 801039a1: 89 e5 mov %esp,%ebp 801039a3: 83 ec 10 sub $0x10,%esp initlock(&ptable.lock, "ptable"); 801039a6: 68 b5 85 10 80 push $0x801085b5 801039ab: 68 e0 38 11 80 push $0x801138e0 801039b0: e8 1b 16 00 00 call 80104fd0 <initlock> } 801039b5: 83 c4 10 add $0x10,%esp 801039b8: c9 leave 801039b9: c3 ret 801039ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801039c0 <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) { 801039c0: 55 push %ebp 801039c1: 89 e5 mov %esp,%ebp 801039c3: 83 ec 08 sub $0x8,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 801039c6: 9c pushf 801039c7: 58 pop %eax int apicid, i; if(readeflags()&FL_IF) 801039c8: f6 c4 02 test $0x2,%ah 801039cb: 75 32 jne 801039ff <mycpu+0x3f> panic("mycpu called with interrupts enabled\n"); apicid = lapicid(); 801039cd: e8 6e ef ff ff call 80102940 <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) { 801039d2: 8b 15 b0 38 11 80 mov 0x801138b0,%edx 801039d8: 85 d2 test %edx,%edx 801039da: 7e 0b jle 801039e7 <mycpu+0x27> if (cpus[i].apicid == apicid) 801039dc: 0f b6 15 00 38 11 80 movzbl 0x80113800,%edx 801039e3: 39 d0 cmp %edx,%eax 801039e5: 74 11 je 801039f8 <mycpu+0x38> return &cpus[i]; } panic("unknown apicid\n"); 801039e7: 83 ec 0c sub $0xc,%esp 801039ea: 68 bc 85 10 80 push $0x801085bc 801039ef: e8 7c c9 ff ff call 80100370 <panic> 801039f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } 801039f8: b8 00 38 11 80 mov $0x80113800,%eax 801039fd: c9 leave 801039fe: c3 ret mycpu(void) { int apicid, i; if(readeflags()&FL_IF) panic("mycpu called with interrupts enabled\n"); 801039ff: 83 ec 0c sub $0xc,%esp 80103a02: 68 bc 86 10 80 push $0x801086bc 80103a07: e8 64 c9 ff ff call 80100370 <panic> 80103a0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103a10 <cpuid>: initlock(&ptable.lock, "ptable"); } // Must be called with interrupts disabled int cpuid() { 80103a10: 55 push %ebp 80103a11: 89 e5 mov %esp,%ebp 80103a13: 83 ec 08 sub $0x8,%esp return mycpu()-cpus; 80103a16: e8 a5 ff ff ff call 801039c0 <mycpu> 80103a1b: 2d 00 38 11 80 sub $0x80113800,%eax } 80103a20: c9 leave } // Must be called with interrupts disabled int cpuid() { return mycpu()-cpus; 80103a21: c1 f8 04 sar $0x4,%eax 80103a24: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax } 80103a2a: c3 ret 80103a2b: 90 nop 80103a2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103a30 <myproc>: } // Disable interrupts so that we are not rescheduled // while reading proc from the cpu structure struct proc* myproc(void) { 80103a30: 55 push %ebp 80103a31: 89 e5 mov %esp,%ebp 80103a33: 53 push %ebx 80103a34: 83 ec 04 sub $0x4,%esp struct cpu *c; struct proc *p; pushcli(); 80103a37: e8 14 16 00 00 call 80105050 <pushcli> c = mycpu(); 80103a3c: e8 7f ff ff ff call 801039c0 <mycpu> p = c->proc; 80103a41: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103a47: e8 44 16 00 00 call 80105090 <popcli> return p; } 80103a4c: 83 c4 04 add $0x4,%esp 80103a4f: 89 d8 mov %ebx,%eax 80103a51: 5b pop %ebx 80103a52: 5d pop %ebp 80103a53: c3 ret 80103a54: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103a5a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80103a60 <userinit>: //PAGEBREAK: 32 // Set up first user process. void userinit(void) { 80103a60: 55 push %ebp 80103a61: 89 e5 mov %esp,%ebp 80103a63: 53 push %ebx 80103a64: 83 ec 10 sub $0x10,%esp struct proc *p; extern char _binary_initcode_start[], _binary_initcode_size[]; cprintf("init p\n"); 80103a67: 68 cc 85 10 80 push $0x801085cc 80103a6c: e8 ef cb ff ff call 80100660 <cprintf> p = allocproc(); 80103a71: e8 8a fd ff ff call 80103800 <allocproc> 80103a76: 89 c3 mov %eax,%ebx initproc = p; 80103a78: a3 b8 b5 10 80 mov %eax,0x8010b5b8 if((p->pgdir = setupkvm()) == 0) 80103a7d: e8 2e 43 00 00 call 80107db0 <setupkvm> 80103a82: 83 c4 10 add $0x10,%esp 80103a85: 85 c0 test %eax,%eax 80103a87: 89 43 04 mov %eax,0x4(%ebx) 80103a8a: 0f 84 bd 00 00 00 je 80103b4d <userinit+0xed> panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); 80103a90: 83 ec 04 sub $0x4,%esp 80103a93: 68 2c 00 00 00 push $0x2c 80103a98: 68 60 b4 10 80 push $0x8010b460 80103a9d: 50 push %eax 80103a9e: e8 1d 40 00 00 call 80107ac0 <inituvm> p->sz = PGSIZE; memset(p->tf, 0, sizeof(*p->tf)); 80103aa3: 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; 80103aa6: c7 03 00 10 00 00 movl $0x1000,(%ebx) memset(p->tf, 0, sizeof(*p->tf)); 80103aac: 6a 4c push $0x4c 80103aae: 6a 00 push $0x0 80103ab0: ff 73 18 pushl 0x18(%ebx) 80103ab3: e8 78 17 00 00 call 80105230 <memset> p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 80103ab8: 8b 43 18 mov 0x18(%ebx),%eax 80103abb: ba 1b 00 00 00 mov $0x1b,%edx p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 80103ac0: 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)); 80103ac5: 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; 80103ac8: 66 89 50 3c mov %dx,0x3c(%eax) p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 80103acc: 8b 43 18 mov 0x18(%ebx),%eax 80103acf: 66 89 48 2c mov %cx,0x2c(%eax) p->tf->es = p->tf->ds; 80103ad3: 8b 43 18 mov 0x18(%ebx),%eax 80103ad6: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80103ada: 66 89 50 28 mov %dx,0x28(%eax) p->tf->ss = p->tf->ds; 80103ade: 8b 43 18 mov 0x18(%ebx),%eax 80103ae1: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80103ae5: 66 89 50 48 mov %dx,0x48(%eax) p->tf->eflags = FL_IF; 80103ae9: 8b 43 18 mov 0x18(%ebx),%eax 80103aec: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) p->tf->esp = PGSIZE; 80103af3: 8b 43 18 mov 0x18(%ebx),%eax 80103af6: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) p->tf->eip = 0; // beginning of initcode.S 80103afd: 8b 43 18 mov 0x18(%ebx),%eax 80103b00: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) safestrcpy(p->name, "initcode", sizeof(p->name)); 80103b07: 8d 43 6c lea 0x6c(%ebx),%eax 80103b0a: 6a 10 push $0x10 80103b0c: 68 ed 85 10 80 push $0x801085ed 80103b11: 50 push %eax 80103b12: e8 19 19 00 00 call 80105430 <safestrcpy> p->cwd = namei("/"); 80103b17: c7 04 24 f6 85 10 80 movl $0x801085f6,(%esp) 80103b1e: e8 ed e5 ff ff call 80102110 <namei> 80103b23: 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); 80103b26: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 80103b2d: e8 fe 15 00 00 call 80105130 <acquire> p->state = RUNNABLE; 80103b32: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) release(&ptable.lock); 80103b39: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 80103b40: e8 9b 16 00 00 call 801051e0 <release> } 80103b45: 83 c4 10 add $0x10,%esp 80103b48: 8b 5d fc mov -0x4(%ebp),%ebx 80103b4b: c9 leave 80103b4c: c3 ret cprintf("init p\n"); p = allocproc(); initproc = p; if((p->pgdir = setupkvm()) == 0) panic("userinit: out of memory?"); 80103b4d: 83 ec 0c sub $0xc,%esp 80103b50: 68 d4 85 10 80 push $0x801085d4 80103b55: e8 16 c8 ff ff call 80100370 <panic> 80103b5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103b60 <growproc>: // Grow current process's memory by n bytes. // Return 0 on success, -1 on failure. int growproc(int n) { 80103b60: 55 push %ebp 80103b61: 89 e5 mov %esp,%ebp 80103b63: 56 push %esi 80103b64: 53 push %ebx 80103b65: 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(); 80103b68: e8 e3 14 00 00 call 80105050 <pushcli> c = mycpu(); 80103b6d: e8 4e fe ff ff call 801039c0 <mycpu> p = c->proc; 80103b72: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103b78: e8 13 15 00 00 call 80105090 <popcli> { uint sz; struct proc *curproc = myproc(); sz = curproc->sz; if(n > 0){ 80103b7d: 83 fe 00 cmp $0x0,%esi growproc(int n) { uint sz; struct proc *curproc = myproc(); sz = curproc->sz; 80103b80: 8b 03 mov (%ebx),%eax if(n > 0){ 80103b82: 7e 34 jle 80103bb8 <growproc+0x58> if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) 80103b84: 83 ec 04 sub $0x4,%esp 80103b87: 01 c6 add %eax,%esi 80103b89: 56 push %esi 80103b8a: 50 push %eax 80103b8b: ff 73 04 pushl 0x4(%ebx) 80103b8e: e8 6d 40 00 00 call 80107c00 <allocuvm> 80103b93: 83 c4 10 add $0x10,%esp 80103b96: 85 c0 test %eax,%eax 80103b98: 74 36 je 80103bd0 <growproc+0x70> } else if(n < 0){ if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; } curproc->sz = sz; switchuvm(curproc); 80103b9a: 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; 80103b9d: 89 03 mov %eax,(%ebx) switchuvm(curproc); 80103b9f: 53 push %ebx 80103ba0: e8 0b 3e 00 00 call 801079b0 <switchuvm> return 0; 80103ba5: 83 c4 10 add $0x10,%esp 80103ba8: 31 c0 xor %eax,%eax } 80103baa: 8d 65 f8 lea -0x8(%ebp),%esp 80103bad: 5b pop %ebx 80103bae: 5e pop %esi 80103baf: 5d pop %ebp 80103bb0: c3 ret 80103bb1: 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){ 80103bb8: 74 e0 je 80103b9a <growproc+0x3a> if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) 80103bba: 83 ec 04 sub $0x4,%esp 80103bbd: 01 c6 add %eax,%esi 80103bbf: 56 push %esi 80103bc0: 50 push %eax 80103bc1: ff 73 04 pushl 0x4(%ebx) 80103bc4: e8 37 41 00 00 call 80107d00 <deallocuvm> 80103bc9: 83 c4 10 add $0x10,%esp 80103bcc: 85 c0 test %eax,%eax 80103bce: 75 ca jne 80103b9a <growproc+0x3a> struct proc *curproc = myproc(); sz = curproc->sz; if(n > 0){ if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) return -1; 80103bd0: b8 ff ff ff ff mov $0xffffffff,%eax 80103bd5: eb d3 jmp 80103baa <growproc+0x4a> 80103bd7: 89 f6 mov %esi,%esi 80103bd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103be0 <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) { 80103be0: 55 push %ebp 80103be1: 89 e5 mov %esp,%ebp 80103be3: 57 push %edi 80103be4: 56 push %esi 80103be5: 53 push %ebx 80103be6: 83 ec 1c sub $0x1c,%esp // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80103be9: e8 62 14 00 00 call 80105050 <pushcli> c = mycpu(); 80103bee: e8 cd fd ff ff call 801039c0 <mycpu> p = c->proc; 80103bf3: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 80103bf9: e8 92 14 00 00 call 80105090 <popcli> int i, pid; struct proc *np; struct proc *curproc = myproc(); // Allocate process. if((np = allocproc()) == 0){ 80103bfe: e8 fd fb ff ff call 80103800 <allocproc> 80103c03: 85 c0 test %eax,%eax 80103c05: 89 c7 mov %eax,%edi 80103c07: 89 45 e4 mov %eax,-0x1c(%ebp) 80103c0a: 0f 84 b5 00 00 00 je 80103cc5 <fork+0xe5> return -1; } // Copy process state from proc. if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ 80103c10: 83 ec 08 sub $0x8,%esp 80103c13: ff 33 pushl (%ebx) 80103c15: ff 73 04 pushl 0x4(%ebx) 80103c18: e8 63 42 00 00 call 80107e80 <copyuvm> 80103c1d: 83 c4 10 add $0x10,%esp 80103c20: 85 c0 test %eax,%eax 80103c22: 89 47 04 mov %eax,0x4(%edi) 80103c25: 0f 84 a1 00 00 00 je 80103ccc <fork+0xec> kfree(np->kstack); np->kstack = 0; np->state = UNUSED; return -1; } np->sz = curproc->sz; 80103c2b: 8b 03 mov (%ebx),%eax 80103c2d: 8b 4d e4 mov -0x1c(%ebp),%ecx 80103c30: 89 01 mov %eax,(%ecx) np->parent = curproc; 80103c32: 89 59 14 mov %ebx,0x14(%ecx) *np->tf = *curproc->tf; 80103c35: 89 c8 mov %ecx,%eax 80103c37: 8b 79 18 mov 0x18(%ecx),%edi 80103c3a: 8b 73 18 mov 0x18(%ebx),%esi 80103c3d: b9 13 00 00 00 mov $0x13,%ecx 80103c42: 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++) 80103c44: 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; 80103c46: 8b 40 18 mov 0x18(%eax),%eax 80103c49: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) for(i = 0; i < NOFILE; i++) if(curproc->ofile[i]) 80103c50: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 80103c54: 85 c0 test %eax,%eax 80103c56: 74 13 je 80103c6b <fork+0x8b> np->ofile[i] = filedup(curproc->ofile[i]); 80103c58: 83 ec 0c sub $0xc,%esp 80103c5b: 50 push %eax 80103c5c: e8 df d3 ff ff call 80101040 <filedup> 80103c61: 8b 55 e4 mov -0x1c(%ebp),%edx 80103c64: 83 c4 10 add $0x10,%esp 80103c67: 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++) 80103c6b: 83 c6 01 add $0x1,%esi 80103c6e: 83 fe 10 cmp $0x10,%esi 80103c71: 75 dd jne 80103c50 <fork+0x70> if(curproc->ofile[i]) np->ofile[i] = filedup(curproc->ofile[i]); np->cwd = idup(curproc->cwd); 80103c73: 83 ec 0c sub $0xc,%esp 80103c76: ff 73 68 pushl 0x68(%ebx) safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 80103c79: 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); 80103c7c: e8 0f dc ff ff call 80101890 <idup> 80103c81: 8b 7d e4 mov -0x1c(%ebp),%edi safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 80103c84: 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); 80103c87: 89 47 68 mov %eax,0x68(%edi) safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 80103c8a: 8d 47 6c lea 0x6c(%edi),%eax 80103c8d: 6a 10 push $0x10 80103c8f: 53 push %ebx 80103c90: 50 push %eax 80103c91: e8 9a 17 00 00 call 80105430 <safestrcpy> pid = np->pid; 80103c96: 8b 5f 10 mov 0x10(%edi),%ebx acquire(&ptable.lock); 80103c99: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 80103ca0: e8 8b 14 00 00 call 80105130 <acquire> np->state = RUNNABLE; 80103ca5: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi) release(&ptable.lock); 80103cac: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 80103cb3: e8 28 15 00 00 call 801051e0 <release> return pid; 80103cb8: 83 c4 10 add $0x10,%esp 80103cbb: 89 d8 mov %ebx,%eax } 80103cbd: 8d 65 f4 lea -0xc(%ebp),%esp 80103cc0: 5b pop %ebx 80103cc1: 5e pop %esi 80103cc2: 5f pop %edi 80103cc3: 5d pop %ebp 80103cc4: c3 ret struct proc *np; struct proc *curproc = myproc(); // Allocate process. if((np = allocproc()) == 0){ return -1; 80103cc5: b8 ff ff ff ff mov $0xffffffff,%eax 80103cca: eb f1 jmp 80103cbd <fork+0xdd> } // Copy process state from proc. if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ kfree(np->kstack); 80103ccc: 8b 7d e4 mov -0x1c(%ebp),%edi 80103ccf: 83 ec 0c sub $0xc,%esp 80103cd2: ff 77 08 pushl 0x8(%edi) 80103cd5: e8 56 e8 ff ff call 80102530 <kfree> np->kstack = 0; 80103cda: c7 47 08 00 00 00 00 movl $0x0,0x8(%edi) np->state = UNUSED; 80103ce1: c7 47 0c 00 00 00 00 movl $0x0,0xc(%edi) return -1; 80103ce8: 83 c4 10 add $0x10,%esp 80103ceb: b8 ff ff ff ff mov $0xffffffff,%eax 80103cf0: eb cb jmp 80103cbd <fork+0xdd> 80103cf2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103cf9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103d00 <checkNotEmpty>: // - choose a process to run // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. int checkNotEmpty(int queueNum){ 80103d00: 55 push %ebp struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d01: b8 14 39 11 80 mov $0x80113914,%eax // - choose a process to run // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. int checkNotEmpty(int queueNum){ 80103d06: 89 e5 mov %esp,%ebp 80103d08: 8b 55 08 mov 0x8(%ebp),%edx 80103d0b: eb 0f jmp 80103d1c <checkNotEmpty+0x1c> 80103d0d: 8d 76 00 lea 0x0(%esi),%esi struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d10: 05 94 00 00 00 add $0x94,%eax 80103d15: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80103d1a: 74 1c je 80103d38 <checkNotEmpty+0x38> //cprintf("jj\n"); //cprintf("%d",p->queuenum); if(p->queuenum == queueNum && (p->state == RUNNABLE)){ 80103d1c: 39 90 80 00 00 00 cmp %edx,0x80(%eax) 80103d22: 75 ec jne 80103d10 <checkNotEmpty+0x10> 80103d24: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80103d28: 75 e6 jne 80103d10 <checkNotEmpty+0x10> //cprintf("samin\n"); //cprintf("%d",p->pid); return 1; 80103d2a: b8 01 00 00 00 mov $0x1,%eax } } return 0; } 80103d2f: 5d pop %ebp 80103d30: c3 ret 80103d31: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi //cprintf("samin\n"); //cprintf("%d",p->pid); return 1; } } return 0; 80103d38: 31 c0 xor %eax,%eax } 80103d3a: 5d pop %ebp 80103d3b: c3 ret 80103d3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103d40 <lottery_range>: int lottery_range(void){ 80103d40: 55 push %ebp struct proc *p; int ticket_number=0; 80103d41: 31 c0 xor %eax,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d43: ba 14 39 11 80 mov $0x80113914,%edx } } return 0; } int lottery_range(void){ 80103d48: 89 e5 mov %esp,%ebp 80103d4a: eb 12 jmp 80103d5e <lottery_range+0x1e> 80103d4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi struct proc *p; int ticket_number=0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d50: 81 c2 94 00 00 00 add $0x94,%edx 80103d56: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103d5c: 74 23 je 80103d81 <lottery_range+0x41> if(p->state == RUNNABLE && p->queuenum==1){ 80103d5e: 83 7a 0c 03 cmpl $0x3,0xc(%edx) 80103d62: 75 ec jne 80103d50 <lottery_range+0x10> 80103d64: 83 ba 80 00 00 00 01 cmpl $0x1,0x80(%edx) 80103d6b: 75 e3 jne 80103d50 <lottery_range+0x10> ticket_number+=p->tickets; 80103d6d: 03 82 84 00 00 00 add 0x84(%edx),%eax } int lottery_range(void){ struct proc *p; int ticket_number=0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d73: 81 c2 94 00 00 00 add $0x94,%edx 80103d79: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103d7f: 75 dd jne 80103d5e <lottery_range+0x1e> if(p->state == RUNNABLE && p->queuenum==1){ ticket_number+=p->tickets; } } return ticket_number; // returning total number of tickets for runnable processes } 80103d81: 5d pop %ebp 80103d82: c3 ret 80103d83: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103d89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103d90 <foundTicket>: struct proc* foundTicket(int goldenTicket){ 80103d90: 55 push %ebp struct proc *p; int count=0; 80103d91: 31 d2 xor %edx,%edx for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { 80103d93: b8 14 39 11 80 mov $0x80113914,%eax } return ticket_number; // returning total number of tickets for runnable processes } struct proc* foundTicket(int goldenTicket){ 80103d98: 89 e5 mov %esp,%ebp 80103d9a: 8b 4d 08 mov 0x8(%ebp),%ecx 80103d9d: eb 0d jmp 80103dac <foundTicket+0x1c> 80103d9f: 90 nop struct proc *p; int count=0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { 80103da0: 05 94 00 00 00 add $0x94,%eax 80103da5: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80103daa: 74 24 je 80103dd0 <foundTicket+0x40> if (p->state == RUNNABLE && p->queuenum == 1) { 80103dac: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80103db0: 75 ee jne 80103da0 <foundTicket+0x10> 80103db2: 83 b8 80 00 00 00 01 cmpl $0x1,0x80(%eax) 80103db9: 75 e5 jne 80103da0 <foundTicket+0x10> if (count + p->tickets < goldenTicket) 80103dbb: 03 90 84 00 00 00 add 0x84(%eax),%edx 80103dc1: 39 ca cmp %ecx,%edx 80103dc3: 7c db jl 80103da0 <foundTicket+0x10> else return p; } } return '\0'; } 80103dc5: 5d pop %ebp 80103dc6: c3 ret 80103dc7: 89 f6 mov %esi,%esi 80103dc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi count += p->tickets; else return p; } } return '\0'; 80103dd0: 31 c0 xor %eax,%eax } 80103dd2: 5d pop %ebp 80103dd3: c3 ret 80103dd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103dda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80103de0 <processWithMaxPriority>: /////2///// struct proc* processWithMaxPriority(){ 80103de0: 55 push %ebp 80103de1: 89 e5 mov %esp,%ebp 80103de3: 53 push %ebx 80103de4: 83 ec 20 sub $0x20,%esp struct proc* p; struct proc* pmax = '\0'; float _maxHRRN=-1; uint currentTick; acquire(&tickslock); 80103de7: 68 20 5e 11 80 push $0x80115e20 80103dec: e8 3f 13 00 00 call 80105130 <acquire> currentTick = ticks; release(&tickslock); 80103df1: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) struct proc* p; struct proc* pmax = '\0'; float _maxHRRN=-1; uint currentTick; acquire(&tickslock); currentTick = ticks; 80103df8: 8b 1d 60 66 11 80 mov 0x80116660,%ebx release(&tickslock); 80103dfe: e8 dd 13 00 00 call 801051e0 <release> /////2///// struct proc* processWithMaxPriority(){ struct proc* p; struct proc* pmax = '\0'; float _maxHRRN=-1; 80103e03: d9 e8 fld1 uint currentTick; acquire(&tickslock); currentTick = ticks; release(&tickslock); 80103e05: 83 c4 10 add $0x10,%esp /////2///// struct proc* processWithMaxPriority(){ struct proc* p; struct proc* pmax = '\0'; 80103e08: 31 c0 xor %eax,%eax float _maxHRRN=-1; uint currentTick; acquire(&tickslock); currentTick = ticks; release(&tickslock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e0a: ba 14 39 11 80 mov $0x80113914,%edx /////2///// struct proc* processWithMaxPriority(){ struct proc* p; struct proc* pmax = '\0'; float _maxHRRN=-1; 80103e0f: d9 e0 fchs 80103e11: eb 1b jmp 80103e2e <processWithMaxPriority+0x4e> 80103e13: 90 nop 80103e14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103e18: dd d8 fstp %st(0) 80103e1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi uint currentTick; acquire(&tickslock); currentTick = ticks; release(&tickslock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e20: 81 c2 94 00 00 00 add $0x94,%edx 80103e26: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103e2c: 74 4a je 80103e78 <processWithMaxPriority+0x98> if((p->queuenum == 2) && (((float)(currentTick - p->createTime) /(float) p->executionCycle) > _maxHRRN) && p->state == RUNNABLE){ 80103e2e: 83 ba 80 00 00 00 02 cmpl $0x2,0x80(%edx) 80103e35: 75 e9 jne 80103e20 <processWithMaxPriority+0x40> 80103e37: 89 d9 mov %ebx,%ecx 80103e39: 2b 8a 8c 00 00 00 sub 0x8c(%edx),%ecx 80103e3f: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) 80103e46: 89 4d e8 mov %ecx,-0x18(%ebp) 80103e49: df 6d e8 fildll -0x18(%ebp) 80103e4c: db 82 90 00 00 00 fildl 0x90(%edx) 80103e52: de f9 fdivrp %st,%st(1) 80103e54: db e9 fucomi %st(1),%st 80103e56: 76 c0 jbe 80103e18 <processWithMaxPriority+0x38> _maxHRRN = (float)((float)(currentTick - p->createTime) / (float)p->executionCycle); 80103e58: 83 7a 0c 03 cmpl $0x3,0xc(%edx) 80103e5c: db c9 fcmovne %st(1),%st 80103e5e: dd d9 fstp %st(1) 80103e60: 0f 44 c2 cmove %edx,%eax float _maxHRRN=-1; uint currentTick; acquire(&tickslock); currentTick = ticks; release(&tickslock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e63: 81 c2 94 00 00 00 add $0x94,%edx 80103e69: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103e6f: 75 bd jne 80103e2e <processWithMaxPriority+0x4e> 80103e71: dd d8 fstp %st(0) 80103e73: eb 05 jmp 80103e7a <processWithMaxPriority+0x9a> 80103e75: 8d 76 00 lea 0x0(%esi),%esi 80103e78: dd d8 fstp %st(0) } } return pmax; } 80103e7a: 8b 5d fc mov -0x4(%ebp),%ebx 80103e7d: c9 leave 80103e7e: c3 ret 80103e7f: 90 nop 80103e80 <choseWithSRTF>: struct proc* samepr[1000]; int count_samepr = 0; struct proc* p; struct proc* minp='\0'; float _min = -1; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e80: b8 14 39 11 80 mov $0x80113914,%eax 80103e85: eb 15 jmp 80103e9c <choseWithSRTF+0x1c> 80103e87: 89 f6 mov %esi,%esi 80103e89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103e90: 05 94 00 00 00 add $0x94,%eax 80103e95: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80103e9a: 74 17 je 80103eb3 <choseWithSRTF+0x33> if((p->queuenum == 3) && (p->state == RUNNABLE)){ 80103e9c: 83 b8 80 00 00 00 03 cmpl $0x3,0x80(%eax) 80103ea3: 75 eb jne 80103e90 <choseWithSRTF+0x10> 80103ea5: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80103ea9: 75 e5 jne 80103e90 <choseWithSRTF+0x10> _min = p->priority; 80103eab: d9 80 88 00 00 00 flds 0x88(%eax) minp = p; break; 80103eb1: eb 06 jmp 80103eb9 <choseWithSRTF+0x39> int randNum; struct proc* samepr[1000]; int count_samepr = 0; struct proc* p; struct proc* minp='\0'; float _min = -1; 80103eb3: d9 e8 fld1 struct proc* choseWithSRTF(){ int randNum; struct proc* samepr[1000]; int count_samepr = 0; struct proc* p; struct proc* minp='\0'; 80103eb5: 31 c0 xor %eax,%eax float _min = -1; 80103eb7: d9 e0 fchs struct proc* choseWithSRTF(){ int randNum; struct proc* samepr[1000]; int count_samepr = 0; struct proc* p; struct proc* minp='\0'; 80103eb9: ba 14 39 11 80 mov $0x80113914,%edx 80103ebe: eb 16 jmp 80103ed6 <choseWithSRTF+0x56> 80103ec0: dd d9 fstp %st(1) 80103ec2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi _min = p->priority; minp = p; break; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103ec8: 81 c2 94 00 00 00 add $0x94,%edx 80103ece: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103ed4: 74 32 je 80103f08 <choseWithSRTF+0x88> if((p->queuenum == 3) && (p->state == RUNNABLE) && (p->priority < _min)){ 80103ed6: 83 ba 80 00 00 00 03 cmpl $0x3,0x80(%edx) 80103edd: 75 e9 jne 80103ec8 <choseWithSRTF+0x48> 80103edf: 83 7a 0c 03 cmpl $0x3,0xc(%edx) 80103ee3: 75 e3 jne 80103ec8 <choseWithSRTF+0x48> 80103ee5: d9 82 88 00 00 00 flds 0x88(%edx) 80103eeb: d9 c9 fxch %st(1) 80103eed: db e9 fucomi %st(1),%st 80103eef: 76 cf jbe 80103ec0 <choseWithSRTF+0x40> 80103ef1: dd d8 fstp %st(0) 80103ef3: 89 d0 mov %edx,%eax _min = p->priority; minp = p; break; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103ef5: 81 c2 94 00 00 00 add $0x94,%edx 80103efb: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103f01: 75 d3 jne 80103ed6 <choseWithSRTF+0x56> 80103f03: 90 nop 80103f04: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return pmax; } ////////3//////// struct proc* choseWithSRTF(){ 80103f08: 55 push %ebp 80103f09: ba 14 39 11 80 mov $0x80113914,%edx 80103f0e: 31 c9 xor %ecx,%ecx 80103f10: 89 e5 mov %esp,%ebp 80103f12: 81 ec a8 0f 00 00 sub $0xfa8,%esp 80103f18: eb 14 jmp 80103f2e <choseWithSRTF+0xae> 80103f1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi _min = p->priority; minp = p; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103f20: 81 c2 94 00 00 00 add $0x94,%edx 80103f26: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103f2c: 74 42 je 80103f70 <choseWithSRTF+0xf0> if((p->queuenum == 3) && (p->state == RUNNABLE) && (p->priority == _min)){ 80103f2e: 83 ba 80 00 00 00 03 cmpl $0x3,0x80(%edx) 80103f35: 75 e9 jne 80103f20 <choseWithSRTF+0xa0> 80103f37: 83 7a 0c 03 cmpl $0x3,0xc(%edx) 80103f3b: 75 e3 jne 80103f20 <choseWithSRTF+0xa0> 80103f3d: d9 82 88 00 00 00 flds 0x88(%edx) 80103f43: d9 c9 fxch %st(1) 80103f45: db e9 fucomi %st(1),%st 80103f47: dd d9 fstp %st(1) 80103f49: 7a d5 jp 80103f20 <choseWithSRTF+0xa0> 80103f4b: 75 d3 jne 80103f20 <choseWithSRTF+0xa0> samepr[count_samepr]=p; 80103f4d: 89 94 8d 60 f0 ff ff mov %edx,-0xfa0(%ebp,%ecx,4) _min = p->priority; minp = p; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103f54: 81 c2 94 00 00 00 add $0x94,%edx if((p->queuenum == 3) && (p->state == RUNNABLE) && (p->priority == _min)){ samepr[count_samepr]=p; count_samepr++; 80103f5a: 83 c1 01 add $0x1,%ecx _min = p->priority; minp = p; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103f5d: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 80103f63: 75 c9 jne 80103f2e <choseWithSRTF+0xae> 80103f65: dd d8 fstp %st(0) 80103f67: eb 09 jmp 80103f72 <choseWithSRTF+0xf2> 80103f69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103f70: dd d8 fstp %st(0) static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767 */ { next = next * 1103515245 + 12345; 80103f72: 69 15 08 b0 10 80 6d imul $0x41c64e6d,0x8010b008,%edx 80103f79: 4e c6 41 80103f7c: 81 c2 39 30 00 00 add $0x3039,%edx count_samepr++; } } randNum = rand() % count_samepr; if(count_samepr == 1){ 80103f82: 83 f9 01 cmp $0x1,%ecx static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767 */ { next = next * 1103515245 + 12345; 80103f85: 89 15 08 b0 10 80 mov %edx,0x8010b008 count_samepr++; } } randNum = rand() % count_samepr; if(count_samepr == 1){ 80103f8b: 74 14 je 80103fa1 <choseWithSRTF+0x121> if(minp->priority >= 0.1) minp->priority -= 0.1; return minp; } else{ if(samepr[randNum]->priority >= 0.1) 80103f8d: 89 d0 mov %edx,%eax 80103f8f: c1 e8 10 shr $0x10,%eax 80103f92: 25 ff 7f 00 00 and $0x7fff,%eax 80103f97: 99 cltd 80103f98: f7 f9 idiv %ecx 80103f9a: 8b 84 95 60 f0 ff ff mov -0xfa0(%ebp,%edx,4),%eax 80103fa1: d9 80 88 00 00 00 flds 0x88(%eax) 80103fa7: dd 05 40 88 10 80 fldl 0x80108840 80103fad: d9 c9 fxch %st(1) 80103faf: db e9 fucomi %st(1),%st 80103fb1: 72 0a jb 80103fbd <choseWithSRTF+0x13d> samepr[randNum]->priority -= 0.1; 80103fb3: de e1 fsubp %st,%st(1) 80103fb5: d9 98 88 00 00 00 fstps 0x88(%eax) 80103fbb: eb 04 jmp 80103fc1 <choseWithSRTF+0x141> 80103fbd: dd d8 fstp %st(0) 80103fbf: dd d8 fstp %st(0) return samepr[randNum]; } } 80103fc1: c9 leave 80103fc2: c3 ret 80103fc3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103fc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103fd0 <scheduler>: void scheduler(void) { 80103fd0: 55 push %ebp 80103fd1: 89 e5 mov %esp,%ebp 80103fd3: 57 push %edi 80103fd4: 56 push %esi 80103fd5: 53 push %ebx //cprintf("1\n"); //struct proc *p; //struct proc *p1; struct proc *chosen = '\0'; 80103fd6: 31 ff xor %edi,%edi } void scheduler(void) { 80103fd8: 83 ec 0c sub $0xc,%esp //cprintf("1\n"); //struct proc *p; //struct proc *p1; struct proc *chosen = '\0'; struct cpu *c = mycpu(); 80103fdb: e8 e0 f9 ff ff call 801039c0 <mycpu> //cprintf("#####%s\n",chosen->name); chosen->executionCycle += 1; c->proc = chosen; switchuvm(chosen); chosen->state = RUNNING; swtch(&(c->scheduler), chosen->context); 80103fe0: 8d 70 04 lea 0x4(%eax),%esi { //cprintf("1\n"); //struct proc *p; //struct proc *p1; struct proc *chosen = '\0'; struct cpu *c = mycpu(); 80103fe3: 89 c3 mov %eax,%ebx c->proc = 0; 80103fe5: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax) 80103fec: 00 00 00 80103fef: 90 nop } static inline void sti(void) { asm volatile("sti"); 80103ff0: fb sti int total_no_tickets=0; for(;;){ // cprintf("3\n"); sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); 80103ff1: 83 ec 0c sub $0xc,%esp 80103ff4: 68 e0 38 11 80 push $0x801138e0 80103ff9: e8 32 11 00 00 call 80105130 <acquire> 80103ffe: 83 c4 10 add $0x10,%esp // - eventually that process transfers control // via swtch back to the scheduler. int checkNotEmpty(int queueNum){ struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104001: ba 14 39 11 80 mov $0x80113914,%edx 80104006: eb 1a jmp 80104022 <scheduler+0x52> 80104008: 90 nop 80104009: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104010: 81 c2 94 00 00 00 add $0x94,%edx 80104016: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 8010401c: 0f 84 be 00 00 00 je 801040e0 <scheduler+0x110> //cprintf("jj\n"); //cprintf("%d",p->queuenum); if(p->queuenum == queueNum && (p->state == RUNNABLE)){ 80104022: 83 ba 80 00 00 00 01 cmpl $0x1,0x80(%edx) 80104029: 75 e5 jne 80104010 <scheduler+0x40> 8010402b: 83 7a 0c 03 cmpl $0x3,0xc(%edx) 8010402f: 75 df jne 80104010 <scheduler+0x40> 80104031: 31 c9 xor %ecx,%ecx 80104033: b8 14 39 11 80 mov $0x80113914,%eax 80104038: eb 12 jmp 8010404c <scheduler+0x7c> 8010403a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } int lottery_range(void){ struct proc *p; int ticket_number=0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104040: 05 94 00 00 00 add $0x94,%eax 80104045: 3d 14 5e 11 80 cmp $0x80115e14,%eax 8010404a: 74 24 je 80104070 <scheduler+0xa0> if(p->state == RUNNABLE && p->queuenum==1){ 8010404c: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80104050: 75 ee jne 80104040 <scheduler+0x70> 80104052: 83 b8 80 00 00 00 01 cmpl $0x1,0x80(%eax) 80104059: 75 e5 jne 80104040 <scheduler+0x70> ticket_number+=p->tickets; 8010405b: 03 88 84 00 00 00 add 0x84(%eax),%ecx } int lottery_range(void){ struct proc *p; int ticket_number=0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104061: 05 94 00 00 00 add $0x94,%eax 80104066: 3d 14 5e 11 80 cmp $0x80115e14,%eax 8010406b: 75 df jne 8010404c <scheduler+0x7c> 8010406d: 8d 76 00 lea 0x0(%esi),%esi static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767 */ { next = next * 1103515245 + 12345; 80104070: 69 05 08 b0 10 80 6d imul $0x41c64e6d,0x8010b008,%eax 80104077: 4e c6 41 struct proc* foundTicket(int goldenTicket){ struct proc *p; int count=0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { 8010407a: bf 14 39 11 80 mov $0x80113914,%edi static unsigned long int next = 1; int rand(void) /* RAND_MAX assumed to be 32767 */ { next = next * 1103515245 + 12345; 8010407f: 05 39 30 00 00 add $0x3039,%eax 80104084: a3 08 b0 10 80 mov %eax,0x8010b008 //if(p->state != RUNNABLE) //continue; //chosen = '\0'; if(checkNotEmpty(1)){ total_no_tickets = lottery_range(); golden_ticket=rand()%total_no_tickets; 80104089: c1 e8 10 shr $0x10,%eax 8010408c: 25 ff 7f 00 00 and $0x7fff,%eax 80104091: 99 cltd 80104092: f7 f9 idiv %ecx } struct proc* foundTicket(int goldenTicket){ struct proc *p; int count=0; 80104094: 31 c0 xor %eax,%eax 80104096: eb 16 jmp 801040ae <scheduler+0xde> 80104098: 90 nop 80104099: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { 801040a0: 81 c7 94 00 00 00 add $0x94,%edi 801040a6: 81 ff 14 5e 11 80 cmp $0x80115e14,%edi 801040ac: 74 2a je 801040d8 <scheduler+0x108> if (p->state == RUNNABLE && p->queuenum == 1) { 801040ae: 83 7f 0c 03 cmpl $0x3,0xc(%edi) 801040b2: 75 ec jne 801040a0 <scheduler+0xd0> 801040b4: 83 bf 80 00 00 00 01 cmpl $0x1,0x80(%edi) 801040bb: 75 e3 jne 801040a0 <scheduler+0xd0> if (count + p->tickets < goldenTicket) 801040bd: 03 87 84 00 00 00 add 0x84(%edi),%eax 801040c3: 39 c2 cmp %eax,%edx 801040c5: 7e 4b jle 80104112 <scheduler+0x142> struct proc* foundTicket(int goldenTicket){ struct proc *p; int count=0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { 801040c7: 81 c7 94 00 00 00 add $0x94,%edi 801040cd: 81 ff 14 5e 11 80 cmp $0x80115e14,%edi 801040d3: 75 d9 jne 801040ae <scheduler+0xde> 801040d5: 8d 76 00 lea 0x0(%esi),%esi // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("#####%s\n",chosen->name); chosen->executionCycle += 1; 801040d8: a1 90 00 00 00 mov 0x90,%eax 801040dd: 0f 0b ud2 801040df: 90 nop // - eventually that process transfers control // via swtch back to the scheduler. int checkNotEmpty(int queueNum){ struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801040e0: b8 14 39 11 80 mov $0x80113914,%eax 801040e5: eb 15 jmp 801040fc <scheduler+0x12c> 801040e7: 89 f6 mov %esi,%esi 801040e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801040f0: 05 94 00 00 00 add $0x94,%eax 801040f5: 3d 14 5e 11 80 cmp $0x80115e14,%eax 801040fa: 74 61 je 8010415d <scheduler+0x18d> //cprintf("jj\n"); //cprintf("%d",p->queuenum); if(p->queuenum == queueNum && (p->state == RUNNABLE)){ 801040fc: 83 b8 80 00 00 00 02 cmpl $0x2,0x80(%eax) 80104103: 75 eb jne 801040f0 <scheduler+0x120> 80104105: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80104109: 75 e5 jne 801040f0 <scheduler+0x120> total_no_tickets = lottery_range(); golden_ticket=rand()%total_no_tickets; chosen = foundTicket(golden_ticket); } else if(checkNotEmpty(2)){ chosen = processWithMaxPriority(); 8010410b: e8 d0 fc ff ff call 80103de0 <processWithMaxPriority> 80104110: 89 c7 mov %eax,%edi // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("#####%s\n",chosen->name); chosen->executionCycle += 1; 80104112: 83 87 90 00 00 00 01 addl $0x1,0x90(%edi) c->proc = chosen; switchuvm(chosen); 80104119: 83 ec 0c sub $0xc,%esp // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("#####%s\n",chosen->name); chosen->executionCycle += 1; c->proc = chosen; 8010411c: 89 bb ac 00 00 00 mov %edi,0xac(%ebx) switchuvm(chosen); 80104122: 57 push %edi 80104123: e8 88 38 00 00 call 801079b0 <switchuvm> chosen->state = RUNNING; 80104128: c7 47 0c 04 00 00 00 movl $0x4,0xc(%edi) swtch(&(c->scheduler), chosen->context); 8010412f: 58 pop %eax 80104130: 5a pop %edx 80104131: ff 77 1c pushl 0x1c(%edi) 80104134: 56 push %esi 80104135: e8 51 13 00 00 call 8010548b <swtch> switchkvm(); 8010413a: e8 51 38 00 00 call 80107990 <switchkvm> // Process is done running for now. // It should have changed its p->state before coming back. c->proc = 0; 8010413f: c7 83 ac 00 00 00 00 movl $0x0,0xac(%ebx) 80104146: 00 00 00 release(&ptable.lock); 80104149: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 80104150: e8 8b 10 00 00 call 801051e0 <release> //} } 80104155: 83 c4 10 add $0x10,%esp 80104158: e9 93 fe ff ff jmp 80103ff0 <scheduler+0x20> // - eventually that process transfers control // via swtch back to the scheduler. int checkNotEmpty(int queueNum){ struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 8010415d: b8 14 39 11 80 mov $0x80113914,%eax 80104162: eb 10 jmp 80104174 <scheduler+0x1a4> 80104164: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104168: 05 94 00 00 00 add $0x94,%eax 8010416d: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80104172: 74 9e je 80104112 <scheduler+0x142> //cprintf("jj\n"); //cprintf("%d",p->queuenum); if(p->queuenum == queueNum && (p->state == RUNNABLE)){ 80104174: 83 b8 80 00 00 00 03 cmpl $0x3,0x80(%eax) 8010417b: 75 eb jne 80104168 <scheduler+0x198> 8010417d: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80104181: 75 e5 jne 80104168 <scheduler+0x198> } else if(checkNotEmpty(2)){ chosen = processWithMaxPriority(); } else if(checkNotEmpty(3)){ chosen = choseWithSRTF(); 80104183: e8 f8 fc ff ff call 80103e80 <choseWithSRTF> 80104188: 89 c7 mov %eax,%edi 8010418a: eb 86 jmp 80104112 <scheduler+0x142> 8010418c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104190 <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) { 80104190: 55 push %ebp 80104191: 89 e5 mov %esp,%ebp 80104193: 56 push %esi 80104194: 53 push %ebx // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80104195: e8 b6 0e 00 00 call 80105050 <pushcli> c = mycpu(); 8010419a: e8 21 f8 ff ff call 801039c0 <mycpu> p = c->proc; 8010419f: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 801041a5: e8 e6 0e 00 00 call 80105090 <popcli> sched(void) { int intena; struct proc *p = myproc(); if(!holding(&ptable.lock)) 801041aa: 83 ec 0c sub $0xc,%esp 801041ad: 68 e0 38 11 80 push $0x801138e0 801041b2: e8 49 0f 00 00 call 80105100 <holding> 801041b7: 83 c4 10 add $0x10,%esp 801041ba: 85 c0 test %eax,%eax 801041bc: 74 4f je 8010420d <sched+0x7d> panic("sched ptable.lock"); if(mycpu()->ncli != 1) 801041be: e8 fd f7 ff ff call 801039c0 <mycpu> 801041c3: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax) 801041ca: 75 68 jne 80104234 <sched+0xa4> panic("sched locks"); if(p->state == RUNNING) 801041cc: 83 7b 0c 04 cmpl $0x4,0xc(%ebx) 801041d0: 74 55 je 80104227 <sched+0x97> static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 801041d2: 9c pushf 801041d3: 58 pop %eax panic("sched running"); if(readeflags()&FL_IF) 801041d4: f6 c4 02 test $0x2,%ah 801041d7: 75 41 jne 8010421a <sched+0x8a> panic("sched interruptible"); intena = mycpu()->intena; 801041d9: e8 e2 f7 ff ff call 801039c0 <mycpu> swtch(&p->context, mycpu()->scheduler); 801041de: 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; 801041e1: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi swtch(&p->context, mycpu()->scheduler); 801041e7: e8 d4 f7 ff ff call 801039c0 <mycpu> 801041ec: 83 ec 08 sub $0x8,%esp 801041ef: ff 70 04 pushl 0x4(%eax) 801041f2: 53 push %ebx 801041f3: e8 93 12 00 00 call 8010548b <swtch> mycpu()->intena = intena; 801041f8: e8 c3 f7 ff ff call 801039c0 <mycpu> } 801041fd: 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; 80104200: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax) } 80104206: 8d 65 f8 lea -0x8(%ebp),%esp 80104209: 5b pop %ebx 8010420a: 5e pop %esi 8010420b: 5d pop %ebp 8010420c: c3 ret { int intena; struct proc *p = myproc(); if(!holding(&ptable.lock)) panic("sched ptable.lock"); 8010420d: 83 ec 0c sub $0xc,%esp 80104210: 68 f8 85 10 80 push $0x801085f8 80104215: e8 56 c1 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"); 8010421a: 83 ec 0c sub $0xc,%esp 8010421d: 68 24 86 10 80 push $0x80108624 80104222: e8 49 c1 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"); 80104227: 83 ec 0c sub $0xc,%esp 8010422a: 68 16 86 10 80 push $0x80108616 8010422f: e8 3c c1 ff ff call 80100370 <panic> int intena; struct proc *p = myproc(); if(!holding(&ptable.lock)) panic("sched ptable.lock"); if(mycpu()->ncli != 1) panic("sched locks"); 80104234: 83 ec 0c sub $0xc,%esp 80104237: 68 0a 86 10 80 push $0x8010860a 8010423c: e8 2f c1 ff ff call 80100370 <panic> 80104241: eb 0d jmp 80104250 <exit> 80104243: 90 nop 80104244: 90 nop 80104245: 90 nop 80104246: 90 nop 80104247: 90 nop 80104248: 90 nop 80104249: 90 nop 8010424a: 90 nop 8010424b: 90 nop 8010424c: 90 nop 8010424d: 90 nop 8010424e: 90 nop 8010424f: 90 nop 80104250 <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) { 80104250: 55 push %ebp 80104251: 89 e5 mov %esp,%ebp 80104253: 57 push %edi 80104254: 56 push %esi 80104255: 53 push %ebx 80104256: 83 ec 0c sub $0xc,%esp // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80104259: e8 f2 0d 00 00 call 80105050 <pushcli> c = mycpu(); 8010425e: e8 5d f7 ff ff call 801039c0 <mycpu> p = c->proc; 80104263: 8b b0 ac 00 00 00 mov 0xac(%eax),%esi popcli(); 80104269: e8 22 0e 00 00 call 80105090 <popcli> { struct proc *curproc = myproc(); struct proc *p; int fd; if(curproc == initproc) 8010426e: 39 35 b8 b5 10 80 cmp %esi,0x8010b5b8 80104274: 8d 5e 28 lea 0x28(%esi),%ebx 80104277: 8d 7e 68 lea 0x68(%esi),%edi 8010427a: 0f 84 f1 00 00 00 je 80104371 <exit+0x121> panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd]){ 80104280: 8b 03 mov (%ebx),%eax 80104282: 85 c0 test %eax,%eax 80104284: 74 12 je 80104298 <exit+0x48> fileclose(curproc->ofile[fd]); 80104286: 83 ec 0c sub $0xc,%esp 80104289: 50 push %eax 8010428a: e8 01 ce ff ff call 80101090 <fileclose> curproc->ofile[fd] = 0; 8010428f: c7 03 00 00 00 00 movl $0x0,(%ebx) 80104295: 83 c4 10 add $0x10,%esp 80104298: 83 c3 04 add $0x4,%ebx if(curproc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ 8010429b: 39 df cmp %ebx,%edi 8010429d: 75 e1 jne 80104280 <exit+0x30> fileclose(curproc->ofile[fd]); curproc->ofile[fd] = 0; } } begin_op(); 8010429f: e8 fc ea ff ff call 80102da0 <begin_op> iput(curproc->cwd); 801042a4: 83 ec 0c sub $0xc,%esp 801042a7: ff 76 68 pushl 0x68(%esi) 801042aa: e8 41 d7 ff ff call 801019f0 <iput> end_op(); 801042af: e8 5c eb ff ff call 80102e10 <end_op> curproc->cwd = 0; 801042b4: c7 46 68 00 00 00 00 movl $0x0,0x68(%esi) acquire(&ptable.lock); 801042bb: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 801042c2: e8 69 0e 00 00 call 80105130 <acquire> // Parent might be sleeping in wait(). wakeup1(curproc->parent); 801042c7: 8b 56 14 mov 0x14(%esi),%edx 801042ca: 83 c4 10 add $0x10,%esp static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801042cd: b8 14 39 11 80 mov $0x80113914,%eax 801042d2: eb 10 jmp 801042e4 <exit+0x94> 801042d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801042d8: 05 94 00 00 00 add $0x94,%eax 801042dd: 3d 14 5e 11 80 cmp $0x80115e14,%eax 801042e2: 74 1e je 80104302 <exit+0xb2> if(p->state == SLEEPING && p->chan == chan) 801042e4: 83 78 0c 02 cmpl $0x2,0xc(%eax) 801042e8: 75 ee jne 801042d8 <exit+0x88> 801042ea: 3b 50 20 cmp 0x20(%eax),%edx 801042ed: 75 e9 jne 801042d8 <exit+0x88> p->state = RUNNABLE; 801042ef: 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++) 801042f6: 05 94 00 00 00 add $0x94,%eax 801042fb: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80104300: 75 e2 jne 801042e4 <exit+0x94> wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == curproc){ p->parent = initproc; 80104302: 8b 0d b8 b5 10 80 mov 0x8010b5b8,%ecx 80104308: ba 14 39 11 80 mov $0x80113914,%edx 8010430d: eb 0f jmp 8010431e <exit+0xce> 8010430f: 90 nop // Parent might be sleeping in wait(). wakeup1(curproc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104310: 81 c2 94 00 00 00 add $0x94,%edx 80104316: 81 fa 14 5e 11 80 cmp $0x80115e14,%edx 8010431c: 74 3a je 80104358 <exit+0x108> if(p->parent == curproc){ 8010431e: 39 72 14 cmp %esi,0x14(%edx) 80104321: 75 ed jne 80104310 <exit+0xc0> p->parent = initproc; if(p->state == ZOMBIE) 80104323: 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; 80104327: 89 4a 14 mov %ecx,0x14(%edx) if(p->state == ZOMBIE) 8010432a: 75 e4 jne 80104310 <exit+0xc0> 8010432c: b8 14 39 11 80 mov $0x80113914,%eax 80104331: eb 11 jmp 80104344 <exit+0xf4> 80104333: 90 nop 80104334: 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++) 80104338: 05 94 00 00 00 add $0x94,%eax 8010433d: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80104342: 74 cc je 80104310 <exit+0xc0> if(p->state == SLEEPING && p->chan == chan) 80104344: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80104348: 75 ee jne 80104338 <exit+0xe8> 8010434a: 3b 48 20 cmp 0x20(%eax),%ecx 8010434d: 75 e9 jne 80104338 <exit+0xe8> p->state = RUNNABLE; 8010434f: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 80104356: eb e0 jmp 80104338 <exit+0xe8> wakeup1(initproc); } } // Jump into the scheduler, never to return. curproc->state = ZOMBIE; 80104358: c7 46 0c 05 00 00 00 movl $0x5,0xc(%esi) sched(); 8010435f: e8 2c fe ff ff call 80104190 <sched> panic("zombie exit"); 80104364: 83 ec 0c sub $0xc,%esp 80104367: 68 45 86 10 80 push $0x80108645 8010436c: e8 ff bf ff ff call 80100370 <panic> struct proc *curproc = myproc(); struct proc *p; int fd; if(curproc == initproc) panic("init exiting"); 80104371: 83 ec 0c sub $0xc,%esp 80104374: 68 38 86 10 80 push $0x80108638 80104379: e8 f2 bf ff ff call 80100370 <panic> 8010437e: 66 90 xchg %ax,%ax 80104380 <yield>: } // Give up the CPU for one scheduling round. void yield(void) { 80104380: 55 push %ebp 80104381: 89 e5 mov %esp,%ebp 80104383: 53 push %ebx 80104384: 83 ec 10 sub $0x10,%esp acquire(&ptable.lock); //DOC: yieldlock 80104387: 68 e0 38 11 80 push $0x801138e0 8010438c: e8 9f 0d 00 00 call 80105130 <acquire> // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80104391: e8 ba 0c 00 00 call 80105050 <pushcli> c = mycpu(); 80104396: e8 25 f6 ff ff call 801039c0 <mycpu> p = c->proc; 8010439b: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 801043a1: e8 ea 0c 00 00 call 80105090 <popcli> // Give up the CPU for one scheduling round. void yield(void) { acquire(&ptable.lock); //DOC: yieldlock myproc()->state = RUNNABLE; 801043a6: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) sched(); 801043ad: e8 de fd ff ff call 80104190 <sched> release(&ptable.lock); 801043b2: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 801043b9: e8 22 0e 00 00 call 801051e0 <release> } 801043be: 83 c4 10 add $0x10,%esp 801043c1: 8b 5d fc mov -0x4(%ebp),%ebx 801043c4: c9 leave 801043c5: c3 ret 801043c6: 8d 76 00 lea 0x0(%esi),%esi 801043c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801043d0 <sleep>: // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { 801043d0: 55 push %ebp 801043d1: 89 e5 mov %esp,%ebp 801043d3: 57 push %edi 801043d4: 56 push %esi 801043d5: 53 push %ebx 801043d6: 83 ec 0c sub $0xc,%esp 801043d9: 8b 7d 08 mov 0x8(%ebp),%edi 801043dc: 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(); 801043df: e8 6c 0c 00 00 call 80105050 <pushcli> c = mycpu(); 801043e4: e8 d7 f5 ff ff call 801039c0 <mycpu> p = c->proc; 801043e9: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 801043ef: e8 9c 0c 00 00 call 80105090 <popcli> void sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); if(p == 0) 801043f4: 85 db test %ebx,%ebx 801043f6: 0f 84 87 00 00 00 je 80104483 <sleep+0xb3> panic("sleep"); if(lk == 0) 801043fc: 85 f6 test %esi,%esi 801043fe: 74 76 je 80104476 <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 80104400: 81 fe e0 38 11 80 cmp $0x801138e0,%esi 80104406: 74 50 je 80104458 <sleep+0x88> acquire(&ptable.lock); //DOC: sleeplock1 80104408: 83 ec 0c sub $0xc,%esp 8010440b: 68 e0 38 11 80 push $0x801138e0 80104410: e8 1b 0d 00 00 call 80105130 <acquire> release(lk); 80104415: 89 34 24 mov %esi,(%esp) 80104418: e8 c3 0d 00 00 call 801051e0 <release> } // Go to sleep. p->chan = chan; 8010441d: 89 7b 20 mov %edi,0x20(%ebx) p->state = SLEEPING; 80104420: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) sched(); 80104427: e8 64 fd ff ff call 80104190 <sched> // Tidy up. p->chan = 0; 8010442c: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); 80104433: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 8010443a: e8 a1 0d 00 00 call 801051e0 <release> acquire(lk); 8010443f: 89 75 08 mov %esi,0x8(%ebp) 80104442: 83 c4 10 add $0x10,%esp } } 80104445: 8d 65 f4 lea -0xc(%ebp),%esp 80104448: 5b pop %ebx 80104449: 5e pop %esi 8010444a: 5f pop %edi 8010444b: 5d pop %ebp p->chan = 0; // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); acquire(lk); 8010444c: e9 df 0c 00 00 jmp 80105130 <acquire> 80104451: 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; 80104458: 89 7b 20 mov %edi,0x20(%ebx) p->state = SLEEPING; 8010445b: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) sched(); 80104462: e8 29 fd ff ff call 80104190 <sched> // Tidy up. p->chan = 0; 80104467: 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); } } 8010446e: 8d 65 f4 lea -0xc(%ebp),%esp 80104471: 5b pop %ebx 80104472: 5e pop %esi 80104473: 5f pop %edi 80104474: 5d pop %ebp 80104475: c3 ret if(p == 0) panic("sleep"); if(lk == 0) panic("sleep without lk"); 80104476: 83 ec 0c sub $0xc,%esp 80104479: 68 57 86 10 80 push $0x80108657 8010447e: e8 ed be ff ff call 80100370 <panic> sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); if(p == 0) panic("sleep"); 80104483: 83 ec 0c sub $0xc,%esp 80104486: 68 51 86 10 80 push $0x80108651 8010448b: e8 e0 be ff ff call 80100370 <panic> 80104490 <wait>: // Wait for a child process to exit and return its pid. // Return -1 if this process has no children. int wait(void) { 80104490: 55 push %ebp 80104491: 89 e5 mov %esp,%ebp 80104493: 56 push %esi 80104494: 53 push %ebx // while reading proc from the cpu structure struct proc* myproc(void) { struct cpu *c; struct proc *p; pushcli(); 80104495: e8 b6 0b 00 00 call 80105050 <pushcli> c = mycpu(); 8010449a: e8 21 f5 ff ff call 801039c0 <mycpu> p = c->proc; 8010449f: 8b b0 ac 00 00 00 mov 0xac(%eax),%esi popcli(); 801044a5: e8 e6 0b 00 00 call 80105090 <popcli> { struct proc *p; int havekids, pid; struct proc *curproc = myproc(); acquire(&ptable.lock); 801044aa: 83 ec 0c sub $0xc,%esp 801044ad: 68 e0 38 11 80 push $0x801138e0 801044b2: e8 79 0c 00 00 call 80105130 <acquire> 801044b7: 83 c4 10 add $0x10,%esp for(;;){ // Scan through table looking for exited children. havekids = 0; 801044ba: 31 c0 xor %eax,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801044bc: bb 14 39 11 80 mov $0x80113914,%ebx 801044c1: eb 13 jmp 801044d6 <wait+0x46> 801044c3: 90 nop 801044c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801044c8: 81 c3 94 00 00 00 add $0x94,%ebx 801044ce: 81 fb 14 5e 11 80 cmp $0x80115e14,%ebx 801044d4: 74 22 je 801044f8 <wait+0x68> if(p->parent != curproc) 801044d6: 39 73 14 cmp %esi,0x14(%ebx) 801044d9: 75 ed jne 801044c8 <wait+0x38> continue; havekids = 1; if(p->state == ZOMBIE){ 801044db: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) 801044df: 74 35 je 80104516 <wait+0x86> acquire(&ptable.lock); for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801044e1: 81 c3 94 00 00 00 add $0x94,%ebx if(p->parent != curproc) continue; havekids = 1; 801044e7: 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++){ 801044ec: 81 fb 14 5e 11 80 cmp $0x80115e14,%ebx 801044f2: 75 e2 jne 801044d6 <wait+0x46> 801044f4: 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){ 801044f8: 85 c0 test %eax,%eax 801044fa: 74 70 je 8010456c <wait+0xdc> 801044fc: 8b 46 24 mov 0x24(%esi),%eax 801044ff: 85 c0 test %eax,%eax 80104501: 75 69 jne 8010456c <wait+0xdc> release(&ptable.lock); return -1; } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep 80104503: 83 ec 08 sub $0x8,%esp 80104506: 68 e0 38 11 80 push $0x801138e0 8010450b: 56 push %esi 8010450c: e8 bf fe ff ff call 801043d0 <sleep> } 80104511: 83 c4 10 add $0x10,%esp 80104514: eb a4 jmp 801044ba <wait+0x2a> continue; havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; kfree(p->kstack); 80104516: 83 ec 0c sub $0xc,%esp 80104519: ff 73 08 pushl 0x8(%ebx) if(p->parent != curproc) continue; havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; 8010451c: 8b 73 10 mov 0x10(%ebx),%esi kfree(p->kstack); 8010451f: e8 0c e0 ff ff call 80102530 <kfree> p->kstack = 0; freevm(p->pgdir); 80104524: 5a pop %edx 80104525: ff 73 04 pushl 0x4(%ebx) havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; kfree(p->kstack); p->kstack = 0; 80104528: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) freevm(p->pgdir); 8010452f: e8 fc 37 00 00 call 80107d30 <freevm> p->pid = 0; 80104534: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) p->parent = 0; 8010453b: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) p->name[0] = 0; 80104542: c6 43 6c 00 movb $0x0,0x6c(%ebx) p->killed = 0; 80104546: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) p->state = UNUSED; 8010454d: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) release(&ptable.lock); 80104554: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 8010455b: e8 80 0c 00 00 call 801051e0 <release> return pid; 80104560: 83 c4 10 add $0x10,%esp } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80104563: 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; 80104566: 89 f0 mov %esi,%eax } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 80104568: 5b pop %ebx 80104569: 5e pop %esi 8010456a: 5d pop %ebp 8010456b: c3 ret } } // No point waiting if we don't have any children. if(!havekids || curproc->killed){ release(&ptable.lock); 8010456c: 83 ec 0c sub $0xc,%esp 8010456f: 68 e0 38 11 80 push $0x801138e0 80104574: e8 67 0c 00 00 call 801051e0 <release> return -1; 80104579: 83 c4 10 add $0x10,%esp } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(curproc, &ptable.lock); //DOC: wait-sleep } } 8010457c: 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; 8010457f: 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 } } 80104584: 5b pop %ebx 80104585: 5e pop %esi 80104586: 5d pop %ebp 80104587: c3 ret 80104588: 90 nop 80104589: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104590 <wakeup>: } // Wake up all processes sleeping on chan. void wakeup(void *chan) { 80104590: 55 push %ebp 80104591: 89 e5 mov %esp,%ebp 80104593: 53 push %ebx 80104594: 83 ec 10 sub $0x10,%esp 80104597: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ptable.lock); 8010459a: 68 e0 38 11 80 push $0x801138e0 8010459f: e8 8c 0b 00 00 call 80105130 <acquire> 801045a4: 83 c4 10 add $0x10,%esp static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801045a7: b8 14 39 11 80 mov $0x80113914,%eax 801045ac: eb 0e jmp 801045bc <wakeup+0x2c> 801045ae: 66 90 xchg %ax,%ax 801045b0: 05 94 00 00 00 add $0x94,%eax 801045b5: 3d 14 5e 11 80 cmp $0x80115e14,%eax 801045ba: 74 1e je 801045da <wakeup+0x4a> if(p->state == SLEEPING && p->chan == chan) 801045bc: 83 78 0c 02 cmpl $0x2,0xc(%eax) 801045c0: 75 ee jne 801045b0 <wakeup+0x20> 801045c2: 3b 58 20 cmp 0x20(%eax),%ebx 801045c5: 75 e9 jne 801045b0 <wakeup+0x20> p->state = RUNNABLE; 801045c7: 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++) 801045ce: 05 94 00 00 00 add $0x94,%eax 801045d3: 3d 14 5e 11 80 cmp $0x80115e14,%eax 801045d8: 75 e2 jne 801045bc <wakeup+0x2c> void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 801045da: c7 45 08 e0 38 11 80 movl $0x801138e0,0x8(%ebp) } 801045e1: 8b 5d fc mov -0x4(%ebp),%ebx 801045e4: c9 leave void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 801045e5: e9 f6 0b 00 00 jmp 801051e0 <release> 801045ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801045f0 <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) { 801045f0: 55 push %ebp 801045f1: 89 e5 mov %esp,%ebp 801045f3: 53 push %ebx 801045f4: 83 ec 10 sub $0x10,%esp 801045f7: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 801045fa: 68 e0 38 11 80 push $0x801138e0 801045ff: e8 2c 0b 00 00 call 80105130 <acquire> 80104604: 83 c4 10 add $0x10,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104607: b8 14 39 11 80 mov $0x80113914,%eax 8010460c: eb 0e jmp 8010461c <kill+0x2c> 8010460e: 66 90 xchg %ax,%ax 80104610: 05 94 00 00 00 add $0x94,%eax 80104615: 3d 14 5e 11 80 cmp $0x80115e14,%eax 8010461a: 74 3c je 80104658 <kill+0x68> if(p->pid == pid){ 8010461c: 39 58 10 cmp %ebx,0x10(%eax) 8010461f: 75 ef jne 80104610 <kill+0x20> p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) 80104621: 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; 80104625: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) // Wake process from sleep if necessary. if(p->state == SLEEPING) 8010462c: 74 1a je 80104648 <kill+0x58> p->state = RUNNABLE; release(&ptable.lock); 8010462e: 83 ec 0c sub $0xc,%esp 80104631: 68 e0 38 11 80 push $0x801138e0 80104636: e8 a5 0b 00 00 call 801051e0 <release> return 0; 8010463b: 83 c4 10 add $0x10,%esp 8010463e: 31 c0 xor %eax,%eax } } release(&ptable.lock); return -1; } 80104640: 8b 5d fc mov -0x4(%ebp),%ebx 80104643: c9 leave 80104644: c3 ret 80104645: 8d 76 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; 80104648: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 8010464f: eb dd jmp 8010462e <kill+0x3e> 80104651: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); return 0; } } release(&ptable.lock); 80104658: 83 ec 0c sub $0xc,%esp 8010465b: 68 e0 38 11 80 push $0x801138e0 80104660: e8 7b 0b 00 00 call 801051e0 <release> return -1; 80104665: 83 c4 10 add $0x10,%esp 80104668: b8 ff ff ff ff mov $0xffffffff,%eax } 8010466d: 8b 5d fc mov -0x4(%ebp),%ebx 80104670: c9 leave 80104671: c3 ret 80104672: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104679: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104680 <findch>: return chname; } int findch(int pid){ 80104680: 55 push %ebp 80104681: 89 e5 mov %esp,%ebp 80104683: 57 push %edi 80104684: 56 push %esi 80104685: 53 push %ebx r2 = 1; int i = 0; 80104686: 31 db xor %ebx,%ebx return chname; } int findch(int pid){ 80104688: 83 ec 28 sub $0x28,%esp r2 = 1; 8010468b: c7 05 c0 38 11 80 01 movl $0x1,0x801138c0 80104692: 00 00 00 return chname; } int findch(int pid){ 80104695: 8b 7d 08 mov 0x8(%ebp),%edi int i = 0; int j = 0; int r = 1; struct proc *p; int name = 0; acquire(&ptable.lock); 80104698: 68 e0 38 11 80 push $0x801138e0 8010469d: e8 8e 0a 00 00 call 80105130 <acquire> 801046a2: 8b 35 c0 38 11 80 mov 0x801138c0,%esi 801046a8: 83 c4 10 add $0x10,%esp 801046ab: 31 d2 xor %edx,%edx r2 = 1; int i = 0; int j = 0; int r = 1; struct proc *p; int name = 0; 801046ad: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801046b4: b9 14 39 11 80 mov $0x80113914,%ecx 801046b9: eb 13 jmp 801046ce <findch+0x4e> 801046bb: 90 nop 801046bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801046c0: 81 c1 94 00 00 00 add $0x94,%ecx 801046c6: 81 f9 14 5e 11 80 cmp $0x80115e14,%ecx 801046cc: 74 48 je 80104716 <findch+0x96> if(p->parent->pid == pid){ 801046ce: 8b 41 14 mov 0x14(%ecx),%eax 801046d1: 39 78 10 cmp %edi,0x10(%eax) 801046d4: 75 ea jne 801046c0 <findch+0x40> for(j=0;j<i;j++){ 801046d6: 85 db test %ebx,%ebx 801046d8: b8 01 00 00 00 mov $0x1,%eax 801046dd: 74 15 je 801046f4 <findch+0x74> 801046df: 31 d2 xor %edx,%edx 801046e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi r *= 10; 801046e8: 8d 04 80 lea (%eax,%eax,4),%eax struct proc *p; int name = 0; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent->pid == pid){ for(j=0;j<i;j++){ 801046eb: 83 c2 01 add $0x1,%edx r *= 10; 801046ee: 01 c0 add %eax,%eax struct proc *p; int name = 0; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent->pid == pid){ for(j=0;j<i;j++){ 801046f0: 39 da cmp %ebx,%edx 801046f2: 75 f4 jne 801046e8 <findch+0x68> r *= 10; } r2 *= 10; name += r * p->pid; 801046f4: 0f af 41 10 imul 0x10(%ecx),%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent->pid == pid){ for(j=0;j<i;j++){ r *= 10; } r2 *= 10; 801046f8: 8d 34 b6 lea (%esi,%esi,4),%esi int j = 0; int r = 1; struct proc *p; int name = 0; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801046fb: 81 c1 94 00 00 00 add $0x94,%ecx for(j=0;j<i;j++){ r *= 10; } r2 *= 10; name += r * p->pid; i = i + 1; 80104701: 83 c3 01 add $0x1,%ebx 80104704: ba 01 00 00 00 mov $0x1,%edx for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent->pid == pid){ for(j=0;j<i;j++){ r *= 10; } r2 *= 10; 80104709: 01 f6 add %esi,%esi name += r * p->pid; 8010470b: 01 45 e4 add %eax,-0x1c(%ebp) int j = 0; int r = 1; struct proc *p; int name = 0; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 8010470e: 81 f9 14 5e 11 80 cmp $0x80115e14,%ecx 80104714: 75 b8 jne 801046ce <findch+0x4e> 80104716: 84 d2 test %dl,%dl 80104718: 75 18 jne 80104732 <findch+0xb2> name += r * p->pid; i = i + 1; r = 1; } } release(&ptable.lock); 8010471a: 83 ec 0c sub $0xc,%esp 8010471d: 68 e0 38 11 80 push $0x801138e0 80104722: e8 b9 0a 00 00 call 801051e0 <release> return name; } 80104727: 8b 45 e4 mov -0x1c(%ebp),%eax 8010472a: 8d 65 f4 lea -0xc(%ebp),%esp 8010472d: 5b pop %ebx 8010472e: 5e pop %esi 8010472f: 5f pop %edi 80104730: 5d pop %ebp 80104731: c3 ret 80104732: 89 35 c0 38 11 80 mov %esi,0x801138c0 80104738: eb e0 jmp 8010471a <findch+0x9a> 8010473a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104740 <getchildren>: //getchildren of a parent ////////////////////////////////////////////////////////////////////////PART 3/////////////////////////////////////////////////////////////////////// int r2; int getchildren(int pid) { 80104740: 55 push %ebp 80104741: 89 e5 mov %esp,%ebp 80104743: 57 push %edi 80104744: 56 push %esi 80104745: 53 push %ebx 80104746: 81 ec 28 01 00 00 sub $0x128,%esp 8010474c: 8b 7d 08 mov 0x8(%ebp),%edi int chname = 0; struct proc *p; int queue[NPROC], front = -1,rear = -1; int delete_item; acquire(&ptable.lock); 8010474f: 68 e0 38 11 80 push $0x801138e0 80104754: e8 d7 09 00 00 call 80105130 <acquire> 80104759: 83 c4 10 add $0x10,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 8010475c: b8 14 39 11 80 mov $0x80113914,%eax 80104761: eb 11 jmp 80104774 <getchildren+0x34> 80104763: 90 nop 80104764: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104768: 05 94 00 00 00 add $0x94,%eax 8010476d: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80104772: 74 18 je 8010478c <getchildren+0x4c> if(p->pid == pid) 80104774: 39 78 10 cmp %edi,0x10(%eax) 80104777: 75 ef jne 80104768 <getchildren+0x28> p->visited = 1; 80104779: c7 40 7c 01 00 00 00 movl $0x1,0x7c(%eax) int chname = 0; struct proc *p; int queue[NPROC], front = -1,rear = -1; int delete_item; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104780: 05 94 00 00 00 add $0x94,%eax 80104785: 3d 14 5e 11 80 cmp $0x80115e14,%eax 8010478a: 75 e8 jne 80104774 <getchildren+0x34> if(p->pid == pid) p->visited = 1; } release(&ptable.lock); 8010478c: 83 ec 0c sub $0xc,%esp if(rear != NPROC - 1) { if(front == -1) front = 0; rear = rear+1; queue[rear] = pid; 8010478f: 31 f6 xor %esi,%esi 80104791: 31 db xor %ebx,%ebx acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid) p->visited = 1; } release(&ptable.lock); 80104793: 68 e0 38 11 80 push $0x801138e0 80104798: e8 43 0a 00 00 call 801051e0 <release> if(rear != NPROC - 1) { if(front == -1) front = 0; rear = rear+1; queue[rear] = pid; 8010479d: 89 bd e8 fe ff ff mov %edi,-0x118(%ebp) 801047a3: 83 c4 10 add $0x10,%esp 801047a6: c7 85 e4 fe ff ff 00 movl $0x0,-0x11c(%ebp) 801047ad: 00 00 00 } while((front != -1) && (front <= rear)){ delete_item = queue[front]; front = front+1; chname = findch(delete_item) + (chname * r2); 801047b0: 83 ec 0c sub $0xc,%esp queue[rear] = pid; } while((front != -1) && (front <= rear)){ delete_item = queue[front]; front = front+1; 801047b3: 83 85 e4 fe ff ff 01 addl $0x1,-0x11c(%ebp) chname = findch(delete_item) + (chname * r2); 801047ba: 57 push %edi 801047bb: e8 c0 fe ff ff call 80104680 <findch> 801047c0: 0f af 1d c0 38 11 80 imul 0x801138c0,%ebx acquire(&ptable.lock); 801047c7: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) } while((front != -1) && (front <= rear)){ delete_item = queue[front]; front = front+1; chname = findch(delete_item) + (chname * r2); 801047ce: 01 c3 add %eax,%ebx acquire(&ptable.lock); 801047d0: e8 5b 09 00 00 call 80105130 <acquire> 801047d5: 83 c4 10 add $0x10,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801047d8: b8 14 39 11 80 mov $0x80113914,%eax 801047dd: eb 0d jmp 801047ec <getchildren+0xac> 801047df: 90 nop 801047e0: 05 94 00 00 00 add $0x94,%eax 801047e5: 3d 14 5e 11 80 cmp $0x80115e14,%eax 801047ea: 74 33 je 8010481f <getchildren+0xdf> if((p->parent->pid == delete_item) && (p->visited != 1)){ 801047ec: 8b 48 14 mov 0x14(%eax),%ecx 801047ef: 39 79 10 cmp %edi,0x10(%ecx) 801047f2: 75 ec jne 801047e0 <getchildren+0xa0> 801047f4: 83 78 7c 01 cmpl $0x1,0x7c(%eax) 801047f8: 74 e6 je 801047e0 <getchildren+0xa0> if(rear != NPROC - 1) 801047fa: 83 fe 3f cmp $0x3f,%esi 801047fd: 74 0d je 8010480c <getchildren+0xcc> { if(front == -1) front = 0; rear = rear+1; queue[rear] = p->pid; 801047ff: 8b 48 10 mov 0x10(%eax),%ecx if((p->parent->pid == delete_item) && (p->visited != 1)){ if(rear != NPROC - 1) { if(front == -1) front = 0; rear = rear+1; 80104802: 83 c6 01 add $0x1,%esi queue[rear] = p->pid; 80104805: 89 8c b5 e8 fe ff ff mov %ecx,-0x118(%ebp,%esi,4) } p->visited = 1; 8010480c: c7 40 7c 01 00 00 00 movl $0x1,0x7c(%eax) while((front != -1) && (front <= rear)){ delete_item = queue[front]; front = front+1; chname = findch(delete_item) + (chname * r2); acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104813: 05 94 00 00 00 add $0x94,%eax 80104818: 3d 14 5e 11 80 cmp $0x80115e14,%eax 8010481d: 75 cd jne 801047ec <getchildren+0xac> } p->visited = 1; } } release(&ptable.lock); 8010481f: 83 ec 0c sub $0xc,%esp 80104822: 68 e0 38 11 80 push $0x801138e0 80104827: e8 b4 09 00 00 call 801051e0 <release> front = 0; rear = rear+1; queue[rear] = pid; } while((front != -1) && (front <= rear)){ 8010482c: 8b 85 e4 fe ff ff mov -0x11c(%ebp),%eax 80104832: 83 c4 10 add $0x10,%esp 80104835: 39 c6 cmp %eax,%esi 80104837: 7c 0c jl 80104845 <getchildren+0x105> 80104839: 8b bc 85 e8 fe ff ff mov -0x118(%ebp,%eax,4),%edi 80104840: e9 6b ff ff ff jmp 801047b0 <getchildren+0x70> } release(&ptable.lock); } return chname; } 80104845: 8d 65 f4 lea -0xc(%ebp),%esp 80104848: 89 d8 mov %ebx,%eax 8010484a: 5b pop %ebx 8010484b: 5e pop %esi 8010484c: 5f pop %edi 8010484d: 5d pop %ebp 8010484e: c3 ret 8010484f: 90 nop 80104850 <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) { 80104850: 55 push %ebp 80104851: 89 e5 mov %esp,%ebp 80104853: 57 push %edi 80104854: 56 push %esi 80104855: 53 push %ebx 80104856: 8d 75 e8 lea -0x18(%ebp),%esi 80104859: bb 80 39 11 80 mov $0x80113980,%ebx 8010485e: 83 ec 3c sub $0x3c,%esp 80104861: eb 27 jmp 8010488a <procdump+0x3a> 80104863: 90 nop 80104864: 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"); 80104868: 83 ec 0c sub $0xc,%esp 8010486b: 68 90 86 10 80 push $0x80108690 80104870: e8 eb bd ff ff call 80100660 <cprintf> 80104875: 83 c4 10 add $0x10,%esp 80104878: 81 c3 94 00 00 00 add $0x94,%ebx int i; struct proc *p; char *state; uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 8010487e: 81 fb 80 5e 11 80 cmp $0x80115e80,%ebx 80104884: 0f 84 7e 00 00 00 je 80104908 <procdump+0xb8> if(p->state == UNUSED) 8010488a: 8b 43 a0 mov -0x60(%ebx),%eax 8010488d: 85 c0 test %eax,%eax 8010488f: 74 e7 je 80104878 <procdump+0x28> continue; if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80104891: 83 f8 05 cmp $0x5,%eax state = states[p->state]; else state = "???"; 80104894: ba 68 86 10 80 mov $0x80108668,%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]) 80104899: 77 11 ja 801048ac <procdump+0x5c> 8010489b: 8b 14 85 24 88 10 80 mov -0x7fef77dc(,%eax,4),%edx state = states[p->state]; else state = "???"; 801048a2: b8 68 86 10 80 mov $0x80108668,%eax 801048a7: 85 d2 test %edx,%edx 801048a9: 0f 44 d0 cmove %eax,%edx cprintf("%d %s %s", p->pid, state, p->name); 801048ac: 53 push %ebx 801048ad: 52 push %edx 801048ae: ff 73 a4 pushl -0x5c(%ebx) 801048b1: 68 6c 86 10 80 push $0x8010866c 801048b6: e8 a5 bd ff ff call 80100660 <cprintf> if(p->state == SLEEPING){ 801048bb: 83 c4 10 add $0x10,%esp 801048be: 83 7b a0 02 cmpl $0x2,-0x60(%ebx) 801048c2: 75 a4 jne 80104868 <procdump+0x18> getcallerpcs((uint*)p->context->ebp+2, pc); 801048c4: 8d 45 c0 lea -0x40(%ebp),%eax 801048c7: 83 ec 08 sub $0x8,%esp 801048ca: 8d 7d c0 lea -0x40(%ebp),%edi 801048cd: 50 push %eax 801048ce: 8b 43 b0 mov -0x50(%ebx),%eax 801048d1: 8b 40 0c mov 0xc(%eax),%eax 801048d4: 83 c0 08 add $0x8,%eax 801048d7: 50 push %eax 801048d8: e8 13 07 00 00 call 80104ff0 <getcallerpcs> 801048dd: 83 c4 10 add $0x10,%esp for(i=0; i<10 && pc[i] != 0; i++) 801048e0: 8b 17 mov (%edi),%edx 801048e2: 85 d2 test %edx,%edx 801048e4: 74 82 je 80104868 <procdump+0x18> cprintf(" %p", pc[i]); 801048e6: 83 ec 08 sub $0x8,%esp 801048e9: 83 c7 04 add $0x4,%edi 801048ec: 52 push %edx 801048ed: 68 a1 80 10 80 push $0x801080a1 801048f2: e8 69 bd 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++) 801048f7: 83 c4 10 add $0x10,%esp 801048fa: 39 f7 cmp %esi,%edi 801048fc: 75 e2 jne 801048e0 <procdump+0x90> 801048fe: e9 65 ff ff ff jmp 80104868 <procdump+0x18> 80104903: 90 nop 80104904: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cprintf(" %p", pc[i]); } cprintf("\n"); } } 80104908: 8d 65 f4 lea -0xc(%ebp),%esp 8010490b: 5b pop %ebx 8010490c: 5e pop %esi 8010490d: 5f pop %edi 8010490e: 5d pop %ebp 8010490f: c3 ret 80104910 <set>: int set(char * path) { 80104910: 55 push %ebp int i=0; int j; char temp[100]; struct inode *ip; int size; while(path[i]!='\0'){ 80104911: 31 c0 xor %eax,%eax } } int set(char * path) { 80104913: 89 e5 mov %esp,%ebp 80104915: 57 push %edi 80104916: 56 push %esi 80104917: 53 push %ebx 80104918: 81 ec 8c 00 00 00 sub $0x8c,%esp 8010491e: 8b 4d 08 mov 0x8(%ebp),%ecx int i=0; int j; char temp[100]; struct inode *ip; int size; while(path[i]!='\0'){ 80104921: 0f b6 11 movzbl (%ecx),%edx 80104924: 84 d2 test %dl,%dl 80104926: 74 19 je 80104941 <set+0x31> 80104928: 90 nop 80104929: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi add_path[i]=path[i]; 80104930: 88 90 20 0f 11 80 mov %dl,-0x7feef0e0(%eax) i++; 80104936: 83 c0 01 add $0x1,%eax int i=0; int j; char temp[100]; struct inode *ip; int size; while(path[i]!='\0'){ 80104939: 0f b6 14 01 movzbl (%ecx,%eax,1),%edx 8010493d: 84 d2 test %dl,%dl 8010493f: 75 ef jne 80104930 <set+0x20> add_path[i]=path[i]; i++; } add_path[i]='\0'; size=get_size_string(add_path); 80104941: 83 ec 0c sub $0xc,%esp int size; while(path[i]!='\0'){ add_path[i]=path[i]; i++; } add_path[i]='\0'; 80104944: c6 80 20 0f 11 80 00 movb $0x0,-0x7feef0e0(%eax) 8010494b: 8d 7d 84 lea -0x7c(%ebp),%edi size=get_size_string(add_path); 8010494e: 68 20 0f 11 80 push $0x80110f20 80104953: e8 98 c0 ff ff call 801009f0 <get_size_string> for(j=0;j<size;j++){ 80104958: 83 c4 10 add $0x10,%esp 8010495b: 31 c9 xor %ecx,%ecx 8010495d: 85 c0 test %eax,%eax while(path[i]!='\0'){ add_path[i]=path[i]; i++; } add_path[i]='\0'; size=get_size_string(add_path); 8010495f: 89 c6 mov %eax,%esi for(j=0;j<size;j++){ 80104961: c7 85 74 ff ff ff 00 movl $0x0,-0x8c(%ebp) 80104968: 00 00 00 8010496b: 7e 53 jle 801049c0 <set+0xb0> 8010496d: 8d 76 00 lea 0x0(%esi),%esi 80104970: 89 cb mov %ecx,%ebx 80104972: 31 c0 xor %eax,%eax 80104974: eb 17 jmp 8010498d <set+0x7d> 80104976: 8d 76 00 lea 0x0(%esi),%esi 80104979: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi while(add_path[j]!=':'){ temp[ii]=add_path[j]; ii++; j++; 80104980: 83 c3 01 add $0x1,%ebx } add_path[i]='\0'; size=get_size_string(add_path); for(j=0;j<size;j++){ while(add_path[j]!=':'){ temp[ii]=add_path[j]; 80104983: 88 14 07 mov %dl,(%edi,%eax,1) ii++; 80104986: 83 c0 01 add $0x1,%eax j++; if(j>=size) 80104989: 39 de cmp %ebx,%esi 8010498b: 7e 0d jle 8010499a <set+0x8a> i++; } add_path[i]='\0'; size=get_size_string(add_path); for(j=0;j<size;j++){ while(add_path[j]!=':'){ 8010498d: 0f b6 94 01 20 0f 11 movzbl -0x7feef0e0(%ecx,%eax,1),%edx 80104994: 80 80104995: 80 fa 3a cmp $0x3a,%dl 80104998: 75 e6 jne 80104980 <set+0x70> break; } temp[ii]='\0'; ii++; ii=0; ip=namei(temp); 8010499a: 83 ec 0c sub $0xc,%esp ii++; j++; if(j>=size) break; } temp[ii]='\0'; 8010499d: c6 44 05 84 00 movb $0x0,-0x7c(%ebp,%eax,1) ii++; ii=0; ip=namei(temp); 801049a2: 57 push %edi 801049a3: e8 68 d7 ff ff call 80102110 <namei> if(ip == 0){ 801049a8: 83 c4 10 add $0x10,%esp 801049ab: 85 c0 test %eax,%eax 801049ad: 74 1b je 801049ca <set+0xba> add_path[i]=path[i]; i++; } add_path[i]='\0'; size=get_size_string(add_path); for(j=0;j<size;j++){ 801049af: 8d 4b 01 lea 0x1(%ebx),%ecx 801049b2: 39 ce cmp %ecx,%esi 801049b4: 7f ba jg 80104970 <set+0x60> if(ip == 0){ cprintf("%s directory doesn't exist!\n",temp); error=1; } } if(error) 801049b6: 8b 85 74 ff ff ff mov -0x8c(%ebp),%eax 801049bc: 85 c0 test %eax,%eax 801049be: 75 27 jne 801049e7 <set+0xd7> exit(); return 0; } 801049c0: 8d 65 f4 lea -0xc(%ebp),%esp 801049c3: 31 c0 xor %eax,%eax 801049c5: 5b pop %ebx 801049c6: 5e pop %esi 801049c7: 5f pop %edi 801049c8: 5d pop %ebp 801049c9: c3 ret temp[ii]='\0'; ii++; ii=0; ip=namei(temp); if(ip == 0){ cprintf("%s directory doesn't exist!\n",temp); 801049ca: 83 ec 08 sub $0x8,%esp 801049cd: 57 push %edi 801049ce: 68 75 86 10 80 push $0x80108675 801049d3: e8 88 bc ff ff call 80100660 <cprintf> 801049d8: 83 c4 10 add $0x10,%esp error=1; 801049db: c7 85 74 ff ff ff 01 movl $0x1,-0x8c(%ebp) 801049e2: 00 00 00 801049e5: eb c8 jmp 801049af <set+0x9f> } } if(error) exit(); 801049e7: e8 64 f8 ff ff call 80104250 <exit> 801049ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801049f0 <count>: return 0; } int count(int num) { 801049f0: 55 push %ebp 801049f1: 89 e5 mov %esp,%ebp 801049f3: 56 push %esi 801049f4: 53 push %ebx 801049f5: 8b 4d 08 mov 0x8(%ebp),%ecx int c=0; while(num/10 > 0){ 801049f8: 83 f9 09 cmp $0x9,%ecx 801049fb: 7e 32 jle 80104a2f <count+0x3f> 801049fd: 31 db xor %ebx,%ebx num = num / 10; 801049ff: be 67 66 66 66 mov $0x66666667,%esi 80104a04: eb 0c jmp 80104a12 <count+0x22> 80104a06: 8d 76 00 lea 0x0(%esi),%esi 80104a09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c += 1; 80104a10: 89 c3 mov %eax,%ebx int count(int num) { int c=0; while(num/10 > 0){ num = num / 10; 80104a12: 89 c8 mov %ecx,%eax 80104a14: c1 f9 1f sar $0x1f,%ecx 80104a17: f7 ee imul %esi c += 1; 80104a19: 8d 43 01 lea 0x1(%ebx),%eax int count(int num) { int c=0; while(num/10 > 0){ num = num / 10; 80104a1c: c1 fa 02 sar $0x2,%edx 80104a1f: 29 ca sub %ecx,%edx } int count(int num) { int c=0; while(num/10 > 0){ 80104a21: 83 fa 09 cmp $0x9,%edx num = num / 10; 80104a24: 89 d1 mov %edx,%ecx } int count(int num) { int c=0; while(num/10 > 0){ 80104a26: 7f e8 jg 80104a10 <count+0x20> 80104a28: 8d 43 02 lea 0x2(%ebx),%eax num = num / 10; c += 1; } return c+1; } 80104a2b: 5b pop %ebx 80104a2c: 5e pop %esi 80104a2d: 5d pop %ebp 80104a2e: c3 ret } int count(int num) { int c=0; while(num/10 > 0){ 80104a2f: b8 01 00 00 00 mov $0x1,%eax 80104a34: eb f5 jmp 80104a2b <count+0x3b> 80104a36: 8d 76 00 lea 0x0(%esi),%esi 80104a39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104a40 <chqueue>: return c+1; } int chqueue(int pid,int queuenum){ 80104a40: 55 push %ebp 80104a41: 89 e5 mov %esp,%ebp 80104a43: 53 push %ebx 80104a44: 83 ec 10 sub $0x10,%esp 80104a47: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 80104a4a: 68 e0 38 11 80 push $0x801138e0 80104a4f: e8 dc 06 00 00 call 80105130 <acquire> 80104a54: 83 c4 10 add $0x10,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104a57: b8 14 39 11 80 mov $0x80113914,%eax 80104a5c: eb 0e jmp 80104a6c <chqueue+0x2c> 80104a5e: 66 90 xchg %ax,%ax 80104a60: 05 94 00 00 00 add $0x94,%eax 80104a65: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80104a6a: 74 0e je 80104a7a <chqueue+0x3a> if(p->pid == pid){ 80104a6c: 39 58 10 cmp %ebx,0x10(%eax) 80104a6f: 75 ef jne 80104a60 <chqueue+0x20> p->queuenum = queuenum; 80104a71: 8b 55 0c mov 0xc(%ebp),%edx 80104a74: 89 90 80 00 00 00 mov %edx,0x80(%eax) break; } } release(&ptable.lock); 80104a7a: 83 ec 0c sub $0xc,%esp 80104a7d: 68 e0 38 11 80 push $0x801138e0 80104a82: e8 59 07 00 00 call 801051e0 <release> return 0; } 80104a87: 31 c0 xor %eax,%eax 80104a89: 8b 5d fc mov -0x4(%ebp),%ebx 80104a8c: c9 leave 80104a8d: c3 ret 80104a8e: 66 90 xchg %ax,%ax 80104a90 <setLottery>: int setLottery(int pid,int tickets){ 80104a90: 55 push %ebp 80104a91: 89 e5 mov %esp,%ebp 80104a93: 53 push %ebx 80104a94: 83 ec 10 sub $0x10,%esp 80104a97: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 80104a9a: 68 e0 38 11 80 push $0x801138e0 80104a9f: e8 8c 06 00 00 call 80105130 <acquire> 80104aa4: 83 c4 10 add $0x10,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104aa7: b8 14 39 11 80 mov $0x80113914,%eax 80104aac: eb 0e jmp 80104abc <setLottery+0x2c> 80104aae: 66 90 xchg %ax,%ax 80104ab0: 05 94 00 00 00 add $0x94,%eax 80104ab5: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80104aba: 74 0e je 80104aca <setLottery+0x3a> if(p->pid == pid){ 80104abc: 39 58 10 cmp %ebx,0x10(%eax) 80104abf: 75 ef jne 80104ab0 <setLottery+0x20> p->tickets =tickets; 80104ac1: 8b 55 0c mov 0xc(%ebp),%edx 80104ac4: 89 90 84 00 00 00 mov %edx,0x84(%eax) break; } } release(&ptable.lock); 80104aca: 83 ec 0c sub $0xc,%esp 80104acd: 68 e0 38 11 80 push $0x801138e0 80104ad2: e8 09 07 00 00 call 801051e0 <release> return 0; } 80104ad7: 31 c0 xor %eax,%eax 80104ad9: 8b 5d fc mov -0x4(%ebp),%ebx 80104adc: c9 leave 80104add: c3 ret 80104ade: 66 90 xchg %ax,%ax 80104ae0 <reverse>: void reverse(char* str, int len) { 80104ae0: 55 push %ebp 80104ae1: 89 e5 mov %esp,%ebp 80104ae3: 56 push %esi 80104ae4: 53 push %ebx int i = 0, j = len - 1, temp; 80104ae5: 8b 45 0c mov 0xc(%ebp),%eax return 0; } void reverse(char* str, int len) { 80104ae8: 8b 4d 08 mov 0x8(%ebp),%ecx int i = 0, j = len - 1, temp; 80104aeb: 83 e8 01 sub $0x1,%eax while (i < j) { 80104aee: 85 c0 test %eax,%eax 80104af0: 7e 20 jle 80104b12 <reverse+0x32> 80104af2: 31 d2 xor %edx,%edx 80104af4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi temp = str[i]; 80104af8: 0f b6 34 11 movzbl (%ecx,%edx,1),%esi str[i] = str[j]; 80104afc: 0f b6 1c 01 movzbl (%ecx,%eax,1),%ebx 80104b00: 88 1c 11 mov %bl,(%ecx,%edx,1) str[j] = temp; 80104b03: 89 f3 mov %esi,%ebx i++; 80104b05: 83 c2 01 add $0x1,%edx { int i = 0, j = len - 1, temp; while (i < j) { temp = str[i]; str[i] = str[j]; str[j] = temp; 80104b08: 88 1c 01 mov %bl,(%ecx,%eax,1) i++; j--; 80104b0b: 83 e8 01 sub $0x1,%eax } void reverse(char* str, int len) { int i = 0, j = len - 1, temp; while (i < j) { 80104b0e: 39 c2 cmp %eax,%edx 80104b10: 7c e6 jl 80104af8 <reverse+0x18> str[i] = str[j]; str[j] = temp; i++; j--; } } 80104b12: 5b pop %ebx 80104b13: 5e pop %esi 80104b14: 5d pop %ebp 80104b15: c3 ret 80104b16: 8d 76 00 lea 0x0(%esi),%esi 80104b19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104b20 <intToStr>: // Converts a given integer x to string str[]. // d is the number of digits required in the output. // If d is more than the number of digits in x, // then 0s are added at the beginning. int intToStr(int x, char str[], int d) { 80104b20: 55 push %ebp 80104b21: 89 e5 mov %esp,%ebp 80104b23: 57 push %edi 80104b24: 56 push %esi 80104b25: 8b 4d 08 mov 0x8(%ebp),%ecx 80104b28: 53 push %ebx int i = 0; while (x) { 80104b29: 31 db xor %ebx,%ebx // Converts a given integer x to string str[]. // d is the number of digits required in the output. // If d is more than the number of digits in x, // then 0s are added at the beginning. int intToStr(int x, char str[], int d) { 80104b2b: 8b 75 0c mov 0xc(%ebp),%esi int i = 0; while (x) { 80104b2e: 85 c9 test %ecx,%ecx 80104b30: 0f 84 81 00 00 00 je 80104bb7 <intToStr+0x97> str[i++] = (x % 10) + '0'; 80104b36: bf 67 66 66 66 mov $0x66666667,%edi 80104b3b: 90 nop 80104b3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104b40: 89 c8 mov %ecx,%eax 80104b42: 83 c3 01 add $0x1,%ebx 80104b45: f7 ef imul %edi 80104b47: 89 c8 mov %ecx,%eax 80104b49: c1 f8 1f sar $0x1f,%eax 80104b4c: c1 fa 02 sar $0x2,%edx 80104b4f: 29 c2 sub %eax,%edx 80104b51: 8d 04 92 lea (%edx,%edx,4),%eax 80104b54: 01 c0 add %eax,%eax 80104b56: 29 c1 sub %eax,%ecx 80104b58: 83 c1 30 add $0x30,%ecx // If d is more than the number of digits in x, // then 0s are added at the beginning. int intToStr(int x, char str[], int d) { int i = 0; while (x) { 80104b5b: 85 d2 test %edx,%edx str[i++] = (x % 10) + '0'; 80104b5d: 88 4c 1e ff mov %cl,-0x1(%esi,%ebx,1) x = x / 10; 80104b61: 89 d1 mov %edx,%ecx // If d is more than the number of digits in x, // then 0s are added at the beginning. int intToStr(int x, char str[], int d) { int i = 0; while (x) { 80104b63: 75 db jne 80104b40 <intToStr+0x20> x = x / 10; } // If number of digits required is more, then // add 0s at the beginning while (i < d) 80104b65: 3b 5d 10 cmp 0x10(%ebp),%ebx 80104b68: 7d 12 jge 80104b7c <intToStr+0x5c> 80104b6a: 8b 45 10 mov 0x10(%ebp),%eax 80104b6d: 8d 76 00 lea 0x0(%esi),%esi str[i++] = '0'; 80104b70: 83 c3 01 add $0x1,%ebx x = x / 10; } // If number of digits required is more, then // add 0s at the beginning while (i < d) 80104b73: 39 d8 cmp %ebx,%eax str[i++] = '0'; 80104b75: c6 44 1e ff 30 movb $0x30,-0x1(%esi,%ebx,1) x = x / 10; } // If number of digits required is more, then // add 0s at the beginning while (i < d) 80104b7a: 7f f4 jg 80104b70 <intToStr+0x50> } void reverse(char* str, int len) { int i = 0, j = len - 1, temp; 80104b7c: 8d 43 ff lea -0x1(%ebx),%eax while (i < j) { 80104b7f: 31 c9 xor %ecx,%ecx 80104b81: 85 c0 test %eax,%eax 80104b83: 7e 25 jle 80104baa <intToStr+0x8a> 80104b85: 89 df mov %ebx,%edi 80104b87: 89 f6 mov %esi,%esi 80104b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi temp = str[i]; 80104b90: 0f b6 1c 0e movzbl (%esi,%ecx,1),%ebx str[i] = str[j]; 80104b94: 0f b6 14 06 movzbl (%esi,%eax,1),%edx 80104b98: 88 14 0e mov %dl,(%esi,%ecx,1) str[j] = temp; 80104b9b: 88 1c 06 mov %bl,(%esi,%eax,1) i++; 80104b9e: 83 c1 01 add $0x1,%ecx j--; 80104ba1: 83 e8 01 sub $0x1,%eax } void reverse(char* str, int len) { int i = 0, j = len - 1, temp; while (i < j) { 80104ba4: 39 c1 cmp %eax,%ecx 80104ba6: 7c e8 jl 80104b90 <intToStr+0x70> 80104ba8: 89 fb mov %edi,%ebx 80104baa: 89 d8 mov %ebx,%eax // add 0s at the beginning while (i < d) str[i++] = '0'; reverse(str, i); str[i] = '\0'; 80104bac: c6 04 06 00 movb $0x0,(%esi,%eax,1) return i; } 80104bb0: 89 d8 mov %ebx,%eax 80104bb2: 5b pop %ebx 80104bb3: 5e pop %esi 80104bb4: 5f pop %edi 80104bb5: 5d pop %ebp 80104bb6: c3 ret x = x / 10; } // If number of digits required is more, then // add 0s at the beginning while (i < d) 80104bb7: 8b 45 10 mov 0x10(%ebp),%eax 80104bba: 85 c0 test %eax,%eax 80104bbc: 7f ac jg 80104b6a <intToStr+0x4a> 80104bbe: 31 c0 xor %eax,%eax 80104bc0: eb ea jmp 80104bac <intToStr+0x8c> 80104bc2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104bc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104bd0 <power>: str[i] = '\0'; return i; } int power(int x, unsigned int y) { 80104bd0: 55 push %ebp 80104bd1: 89 e5 mov %esp,%ebp 80104bd3: 57 push %edi 80104bd4: 56 push %esi 80104bd5: 53 push %ebx if (y == 0) 80104bd6: be 01 00 00 00 mov $0x1,%esi str[i] = '\0'; return i; } int power(int x, unsigned int y) { 80104bdb: 83 ec 0c sub $0xc,%esp 80104bde: 8b 5d 0c mov 0xc(%ebp),%ebx 80104be1: 8b 7d 08 mov 0x8(%ebp),%edi if (y == 0) 80104be4: 85 db test %ebx,%ebx 80104be6: 75 1e jne 80104c06 <power+0x36> 80104be8: eb 3a jmp 80104c24 <power+0x54> 80104bea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return 1; else if (y%2 == 0) return power(x, y/2)*power(x, y/2); 80104bf0: 83 ec 08 sub $0x8,%esp 80104bf3: d1 eb shr %ebx 80104bf5: 53 push %ebx 80104bf6: 57 push %edi 80104bf7: e8 d4 ff ff ff call 80104bd0 <power> 80104bfc: 83 c4 10 add $0x10,%esp 80104bff: 0f af f0 imul %eax,%esi return i; } int power(int x, unsigned int y) { if (y == 0) 80104c02: 85 db test %ebx,%ebx 80104c04: 74 1e je 80104c24 <power+0x54> return 1; else if (y%2 == 0) 80104c06: f6 c3 01 test $0x1,%bl 80104c09: 74 e5 je 80104bf0 <power+0x20> return power(x, y/2)*power(x, y/2); else return x*power(x, y/2)*power(x, y/2); 80104c0b: 83 ec 08 sub $0x8,%esp 80104c0e: d1 eb shr %ebx 80104c10: 53 push %ebx 80104c11: 57 push %edi 80104c12: e8 b9 ff ff ff call 80104bd0 <power> 80104c17: 0f af c7 imul %edi,%eax 80104c1a: 83 c4 10 add $0x10,%esp 80104c1d: 0f af f0 imul %eax,%esi return i; } int power(int x, unsigned int y) { if (y == 0) 80104c20: 85 db test %ebx,%ebx 80104c22: 75 e2 jne 80104c06 <power+0x36> return 1; else if (y%2 == 0) return power(x, y/2)*power(x, y/2); else return x*power(x, y/2)*power(x, y/2); } 80104c24: 8d 65 f4 lea -0xc(%ebp),%esp 80104c27: 89 f0 mov %esi,%eax 80104c29: 5b pop %ebx 80104c2a: 5e pop %esi 80104c2b: 5f pop %edi 80104c2c: 5d pop %ebp 80104c2d: c3 ret 80104c2e: 66 90 xchg %ax,%ax 80104c30 <ftoa>: // Converts a floating-point/double number to a string. void ftoa(float n, char* res, int afterpoint) { 80104c30: 55 push %ebp 80104c31: 89 e5 mov %esp,%ebp 80104c33: 57 push %edi 80104c34: 56 push %esi 80104c35: 53 push %ebx 80104c36: 83 ec 2c sub $0x2c,%esp // Extract integer part int ipart = (int)n; 80104c39: d9 7d e6 fnstcw -0x1a(%ebp) 80104c3c: 0f b7 45 e6 movzwl -0x1a(%ebp),%eax return x*power(x, y/2)*power(x, y/2); } // Converts a floating-point/double number to a string. void ftoa(float n, char* res, int afterpoint) { 80104c40: d9 45 08 flds 0x8(%ebp) 80104c43: 8b 75 0c mov 0xc(%ebp),%esi 80104c46: 8b 7d 10 mov 0x10(%ebp),%edi // Extract floating part float fpart = n - (float)ipart; // convert integer part to string int i = intToStr(ipart, res, 0); 80104c49: 6a 00 push $0x0 return x*power(x, y/2)*power(x, y/2); } // Converts a floating-point/double number to a string. void ftoa(float n, char* res, int afterpoint) { 80104c4b: d9 55 dc fsts -0x24(%ebp) // Extract integer part int ipart = (int)n; 80104c4e: b4 0c mov $0xc,%ah // Extract floating part float fpart = n - (float)ipart; // convert integer part to string int i = intToStr(ipart, res, 0); 80104c50: 56 push %esi // Converts a floating-point/double number to a string. void ftoa(float n, char* res, int afterpoint) { // Extract integer part int ipart = (int)n; 80104c51: 66 89 45 e4 mov %ax,-0x1c(%ebp) 80104c55: d9 6d e4 fldcw -0x1c(%ebp) 80104c58: db 5d e0 fistpl -0x20(%ebp) 80104c5b: d9 6d e6 fldcw -0x1a(%ebp) 80104c5e: 8b 5d e0 mov -0x20(%ebp),%ebx // Extract floating part float fpart = n - (float)ipart; // convert integer part to string int i = intToStr(ipart, res, 0); 80104c61: 53 push %ebx 80104c62: e8 b9 fe ff ff call 80104b20 <intToStr> // check for display option after point if (afterpoint != 0) { 80104c67: 83 c4 0c add $0xc,%esp 80104c6a: 85 ff test %edi,%edi 80104c6c: 75 12 jne 80104c80 <ftoa+0x50> // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); intToStr((int)fpart, res + i + 1, afterpoint); } } 80104c6e: 8d 65 f4 lea -0xc(%ebp),%esp 80104c71: 5b pop %ebx 80104c72: 5e pop %esi 80104c73: 5f pop %edi 80104c74: 5d pop %ebp 80104c75: c3 ret 80104c76: 8d 76 00 lea 0x0(%esi),%esi 80104c79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi res[i] = '.'; // add dot // Get the value of fraction part upto given no. // of points after dot. The third parameter // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); 80104c80: 83 ec 08 sub $0x8,%esp // convert integer part to string int i = intToStr(ipart, res, 0); // check for display option after point if (afterpoint != 0) { res[i] = '.'; // add dot 80104c83: c6 04 06 2e movb $0x2e,(%esi,%eax,1) 80104c87: 89 c2 mov %eax,%edx // Get the value of fraction part upto given no. // of points after dot. The third parameter // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); 80104c89: 57 push %edi 80104c8a: 6a 0a push $0xa 80104c8c: e8 3f ff ff ff call 80104bd0 <power> intToStr((int)fpart, res + i + 1, afterpoint); 80104c91: d9 7d e6 fnstcw -0x1a(%ebp) { // Extract integer part int ipart = (int)n; // Extract floating part float fpart = n - (float)ipart; 80104c94: 89 5d d4 mov %ebx,-0x2c(%ebp) res[i] = '.'; // add dot // Get the value of fraction part upto given no. // of points after dot. The third parameter // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); 80104c97: 89 45 d8 mov %eax,-0x28(%ebp) intToStr((int)fpart, res + i + 1, afterpoint); 80104c9a: 8d 44 16 01 lea 0x1(%esi,%edx,1),%eax { // Extract integer part int ipart = (int)n; // Extract floating part float fpart = n - (float)ipart; 80104c9e: db 45 d4 fildl -0x2c(%ebp) // Get the value of fraction part upto given no. // of points after dot. The third parameter // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); intToStr((int)fpart, res + i + 1, afterpoint); 80104ca1: 89 7d 10 mov %edi,0x10(%ebp) res[i] = '.'; // add dot // Get the value of fraction part upto given no. // of points after dot. The third parameter // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); 80104ca4: 83 c4 10 add $0x10,%esp intToStr((int)fpart, res + i + 1, afterpoint); 80104ca7: 89 45 0c mov %eax,0xc(%ebp) 80104caa: 0f b7 45 e6 movzwl -0x1a(%ebp),%eax { // Extract integer part int ipart = (int)n; // Extract floating part float fpart = n - (float)ipart; 80104cae: d8 6d dc fsubrs -0x24(%ebp) // Get the value of fraction part upto given no. // of points after dot. The third parameter // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); intToStr((int)fpart, res + i + 1, afterpoint); 80104cb1: b4 0c mov $0xc,%ah 80104cb3: 66 89 45 e4 mov %ax,-0x1c(%ebp) 80104cb7: db 45 d8 fildl -0x28(%ebp) 80104cba: de c9 fmulp %st,%st(1) 80104cbc: d9 6d e4 fldcw -0x1c(%ebp) 80104cbf: db 5d 08 fistpl 0x8(%ebp) 80104cc2: d9 6d e6 fldcw -0x1a(%ebp) } } 80104cc5: 8d 65 f4 lea -0xc(%ebp),%esp 80104cc8: 5b pop %ebx 80104cc9: 5e pop %esi 80104cca: 5f pop %edi 80104ccb: 5d pop %ebp // Get the value of fraction part upto given no. // of points after dot. The third parameter // is needed to handle cases like 233.007 fpart = fpart * power(10, afterpoint); intToStr((int)fpart, res + i + 1, afterpoint); 80104ccc: e9 4f fe ff ff jmp 80104b20 <intToStr> 80104cd1: eb 0d jmp 80104ce0 <chprSRPF> 80104cd3: 90 nop 80104cd4: 90 nop 80104cd5: 90 nop 80104cd6: 90 nop 80104cd7: 90 nop 80104cd8: 90 nop 80104cd9: 90 nop 80104cda: 90 nop 80104cdb: 90 nop 80104cdc: 90 nop 80104cdd: 90 nop 80104cde: 90 nop 80104cdf: 90 nop 80104ce0 <chprSRPF>: } } int chprSRPF(int pid,int priority){ 80104ce0: 55 push %ebp 80104ce1: 89 e5 mov %esp,%ebp 80104ce3: 53 push %ebx 80104ce4: 83 ec 10 sub $0x10,%esp 80104ce7: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 80104cea: 68 e0 38 11 80 push $0x801138e0 80104cef: e8 3c 04 00 00 call 80105130 <acquire> 80104cf4: 83 c4 10 add $0x10,%esp for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104cf7: b8 14 39 11 80 mov $0x80113914,%eax 80104cfc: eb 0e jmp 80104d0c <chprSRPF+0x2c> 80104cfe: 66 90 xchg %ax,%ax 80104d00: 05 94 00 00 00 add $0x94,%eax 80104d05: 3d 14 5e 11 80 cmp $0x80115e14,%eax 80104d0a: 74 0e je 80104d1a <chprSRPF+0x3a> if(p->pid == pid){ 80104d0c: 39 58 10 cmp %ebx,0x10(%eax) 80104d0f: 75 ef jne 80104d00 <chprSRPF+0x20> p->priority = priority; 80104d11: db 45 0c fildl 0xc(%ebp) 80104d14: d9 98 88 00 00 00 fstps 0x88(%eax) break; } } release(&ptable.lock); 80104d1a: 83 ec 0c sub $0xc,%esp 80104d1d: 68 e0 38 11 80 push $0x801138e0 80104d22: e8 b9 04 00 00 call 801051e0 <release> return 0; } 80104d27: 31 c0 xor %eax,%eax 80104d29: 8b 5d fc mov -0x4(%ebp),%ebx 80104d2c: c9 leave 80104d2d: c3 ret 80104d2e: 66 90 xchg %ax,%ax 80104d30 <printinfo>: int printinfo(void){ 80104d30: 55 push %ebp 80104d31: 89 e5 mov %esp,%ebp 80104d33: 57 push %edi 80104d34: 56 push %esi 80104d35: 53 push %ebx 80104d36: 83 ec 58 sub $0x58,%esp } static inline void sti(void) { asm volatile("sti"); 80104d39: fb sti struct proc *p; sti(); cprintf("name \t \t pid \t \t state \t \t priority \t \t createTime \t \t lotteryTicket \t \t executionCycle \t \t HRRN \t \t queueNum\n"); 80104d3a: 68 e4 86 10 80 push $0x801086e4 80104d3f: bb 80 39 11 80 mov $0x80113980,%ebx 80104d44: 8d 7d c0 lea -0x40(%ebp),%edi 80104d47: 8d 75 d4 lea -0x2c(%ebp),%esi 80104d4a: e8 11 b9 ff ff call 80100660 <cprintf> float currentTime; acquire(&tickslock); 80104d4f: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) 80104d56: e8 d5 03 00 00 call 80105130 <acquire> currentTime = ticks; 80104d5b: a1 60 66 11 80 mov 0x80116660,%eax 80104d60: 31 d2 xor %edx,%edx release(&tickslock); 80104d62: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) struct proc *p; sti(); cprintf("name \t \t pid \t \t state \t \t priority \t \t createTime \t \t lotteryTicket \t \t executionCycle \t \t HRRN \t \t queueNum\n"); float currentTime; acquire(&tickslock); currentTime = ticks; 80104d69: 89 55 ac mov %edx,-0x54(%ebp) 80104d6c: 89 45 a8 mov %eax,-0x58(%ebp) 80104d6f: df 6d a8 fildll -0x58(%ebp) 80104d72: d9 5d b0 fstps -0x50(%ebp) release(&tickslock); 80104d75: e8 66 04 00 00 call 801051e0 <release> acquire(&ptable.lock); 80104d7a: c7 04 24 e0 38 11 80 movl $0x801138e0,(%esp) 80104d81: e8 aa 03 00 00 call 80105130 <acquire> 80104d86: 83 c4 10 add $0x10,%esp 80104d89: eb 25 jmp 80104db0 <printinfo+0x80> 80104d8b: 90 nop 80104d8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ftoa((float)((currentTime - p->createTime) / (p->executionCycle)),buffer2, 2); if ( p->state == SLEEPING ) /////////////////////////////////////////hrrn//////////////////////////////////////////// cprintf("%s \t \t %d \t \t SLEEPING \t \t %s \t \t %d \t \t %d \t \t %d \t \t %s \t \t %d \n", p->name, p->pid, buffer1, p->createTime, p->tickets, p->executionCycle, buffer2, p->queuenum); else if ( p->state == RUNNING ) 80104d90: 83 f8 04 cmp $0x4,%eax 80104d93: 0f 84 a7 00 00 00 je 80104e40 <printinfo+0x110> cprintf("%s \t \t %d \t \t RUNNING \t \t %s \t \t %d \t \t %d \t \t %d \t \t %s \t \t %d \n", p->name, p->pid, buffer1, p->createTime, p->tickets, p->executionCycle, buffer2, p->queuenum); else if ( p->state == RUNNABLE ) 80104d99: 83 f8 03 cmp $0x3,%eax 80104d9c: 0f 84 ce 00 00 00 je 80104e70 <printinfo+0x140> 80104da2: 81 c3 94 00 00 00 add $0x94,%ebx float currentTime; acquire(&tickslock); currentTime = ticks; release(&tickslock); acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104da8: 81 fb 80 5e 11 80 cmp $0x80115e80,%ebx 80104dae: 74 70 je 80104e20 <printinfo+0xf0> char buffer1[20]; char buffer2[20]; ftoa(p->priority, buffer1, 2); 80104db0: 83 ec 04 sub $0x4,%esp 80104db3: 6a 02 push $0x2 80104db5: 57 push %edi 80104db6: ff 73 1c pushl 0x1c(%ebx) 80104db9: e8 72 fe ff ff call 80104c30 <ftoa> ftoa((float)((currentTime - p->createTime) / (p->executionCycle)),buffer2, 2); 80104dbe: 8b 43 20 mov 0x20(%ebx),%eax 80104dc1: 31 d2 xor %edx,%edx 80104dc3: 83 c4 0c add $0xc,%esp 80104dc6: 89 55 ac mov %edx,-0x54(%ebp) 80104dc9: 6a 02 push $0x2 80104dcb: 56 push %esi 80104dcc: 89 45 a8 mov %eax,-0x58(%ebp) 80104dcf: df 6d a8 fildll -0x58(%ebp) 80104dd2: 83 ec 04 sub $0x4,%esp 80104dd5: d8 6d b0 fsubrs -0x50(%ebp) 80104dd8: db 43 24 fildl 0x24(%ebx) 80104ddb: de f9 fdivrp %st,%st(1) 80104ddd: d9 1c 24 fstps (%esp) 80104de0: e8 4b fe ff ff call 80104c30 <ftoa> if ( p->state == SLEEPING ) 80104de5: 8b 43 a0 mov -0x60(%ebx),%eax 80104de8: 83 c4 10 add $0x10,%esp 80104deb: 83 f8 02 cmp $0x2,%eax 80104dee: 75 a0 jne 80104d90 <printinfo+0x60> /////////////////////////////////////////hrrn//////////////////////////////////////////// cprintf("%s \t \t %d \t \t SLEEPING \t \t %s \t \t %d \t \t %d \t \t %d \t \t %s \t \t %d \n", p->name, p->pid, buffer1, p->createTime, p->tickets, p->executionCycle, 80104df0: 83 ec 0c sub $0xc,%esp 80104df3: ff 73 14 pushl 0x14(%ebx) 80104df6: 56 push %esi 80104df7: ff 73 24 pushl 0x24(%ebx) 80104dfa: ff 73 18 pushl 0x18(%ebx) 80104dfd: ff 73 20 pushl 0x20(%ebx) 80104e00: 57 push %edi 80104e01: ff 73 a4 pushl -0x5c(%ebx) 80104e04: 53 push %ebx 80104e05: 68 54 87 10 80 push $0x80108754 80104e0a: 81 c3 94 00 00 00 add $0x94,%ebx 80104e10: e8 4b b8 ff ff call 80100660 <cprintf> 80104e15: 83 c4 30 add $0x30,%esp float currentTime; acquire(&tickslock); currentTime = ticks; release(&tickslock); acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104e18: 81 fb 80 5e 11 80 cmp $0x80115e80,%ebx 80104e1e: 75 90 jne 80104db0 <printinfo+0x80> else if ( p->state == RUNNABLE ) cprintf("%s \t \t %d \t \t RUNNABLE \t \t %s \t \t %d \t \t %d \t \t %d \t \t %s \t \t %d \n", p->name, p->pid, buffer1, p->createTime, p->tickets, p->executionCycle, buffer2, p->queuenum); } release(&ptable.lock); 80104e20: 83 ec 0c sub $0xc,%esp 80104e23: 68 e0 38 11 80 push $0x801138e0 80104e28: e8 b3 03 00 00 call 801051e0 <release> return 0; } 80104e2d: 8d 65 f4 lea -0xc(%ebp),%esp 80104e30: 31 c0 xor %eax,%eax 80104e32: 5b pop %ebx 80104e33: 5e pop %esi 80104e34: 5f pop %edi 80104e35: 5d pop %ebp 80104e36: c3 ret 80104e37: 89 f6 mov %esi,%esi 80104e39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if ( p->state == SLEEPING ) /////////////////////////////////////////hrrn//////////////////////////////////////////// cprintf("%s \t \t %d \t \t SLEEPING \t \t %s \t \t %d \t \t %d \t \t %d \t \t %s \t \t %d \n", p->name, p->pid, buffer1, p->createTime, p->tickets, p->executionCycle, buffer2, p->queuenum); else if ( p->state == RUNNING ) cprintf("%s \t \t %d \t \t RUNNING \t \t %s \t \t %d \t \t %d \t \t %d \t \t %s \t \t %d \n", p->name, p->pid, buffer1, p->createTime, p->tickets, p->executionCycle, 80104e40: 83 ec 0c sub $0xc,%esp 80104e43: ff 73 14 pushl 0x14(%ebx) 80104e46: 56 push %esi 80104e47: ff 73 24 pushl 0x24(%ebx) 80104e4a: ff 73 18 pushl 0x18(%ebx) 80104e4d: ff 73 20 pushl 0x20(%ebx) 80104e50: 57 push %edi 80104e51: ff 73 a4 pushl -0x5c(%ebx) 80104e54: 53 push %ebx 80104e55: 68 98 87 10 80 push $0x80108798 80104e5a: e8 01 b8 ff ff call 80100660 <cprintf> 80104e5f: 83 c4 30 add $0x30,%esp 80104e62: e9 3b ff ff ff jmp 80104da2 <printinfo+0x72> 80104e67: 89 f6 mov %esi,%esi 80104e69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi buffer2, p->queuenum); else if ( p->state == RUNNABLE ) cprintf("%s \t \t %d \t \t RUNNABLE \t \t %s \t \t %d \t \t %d \t \t %d \t \t %s \t \t %d \n", p->name, p->pid, buffer1, p->createTime, p->tickets, p->executionCycle, 80104e70: 83 ec 0c sub $0xc,%esp 80104e73: ff 73 14 pushl 0x14(%ebx) 80104e76: 56 push %esi 80104e77: ff 73 24 pushl 0x24(%ebx) 80104e7a: ff 73 18 pushl 0x18(%ebx) 80104e7d: ff 73 20 pushl 0x20(%ebx) 80104e80: 57 push %edi 80104e81: ff 73 a4 pushl -0x5c(%ebx) 80104e84: 53 push %ebx 80104e85: 68 dc 87 10 80 push $0x801087dc 80104e8a: e8 d1 b7 ff ff call 80100660 <cprintf> 80104e8f: 83 c4 30 add $0x30,%esp 80104e92: e9 0b ff ff ff jmp 80104da2 <printinfo+0x72> 80104e97: 66 90 xchg %ax,%ax 80104e99: 66 90 xchg %ax,%ax 80104e9b: 66 90 xchg %ax,%ax 80104e9d: 66 90 xchg %ax,%ax 80104e9f: 90 nop 80104ea0 <initsleeplock>: #include "spinlock.h" #include "sleeplock.h" void initsleeplock(struct sleeplock *lk, char *name) { 80104ea0: 55 push %ebp 80104ea1: 89 e5 mov %esp,%ebp 80104ea3: 53 push %ebx 80104ea4: 83 ec 0c sub $0xc,%esp 80104ea7: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&lk->lk, "sleep lock"); 80104eaa: 68 48 88 10 80 push $0x80108848 80104eaf: 8d 43 04 lea 0x4(%ebx),%eax 80104eb2: 50 push %eax 80104eb3: e8 18 01 00 00 call 80104fd0 <initlock> lk->name = name; 80104eb8: 8b 45 0c mov 0xc(%ebp),%eax lk->locked = 0; 80104ebb: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; } 80104ec1: 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; 80104ec4: 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; 80104ecb: 89 43 38 mov %eax,0x38(%ebx) lk->locked = 0; lk->pid = 0; } 80104ece: 8b 5d fc mov -0x4(%ebp),%ebx 80104ed1: c9 leave 80104ed2: c3 ret 80104ed3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104ed9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104ee0 <acquiresleep>: void acquiresleep(struct sleeplock *lk) { 80104ee0: 55 push %ebp 80104ee1: 89 e5 mov %esp,%ebp 80104ee3: 56 push %esi 80104ee4: 53 push %ebx 80104ee5: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80104ee8: 83 ec 0c sub $0xc,%esp 80104eeb: 8d 73 04 lea 0x4(%ebx),%esi 80104eee: 56 push %esi 80104eef: e8 3c 02 00 00 call 80105130 <acquire> while (lk->locked) { 80104ef4: 8b 13 mov (%ebx),%edx 80104ef6: 83 c4 10 add $0x10,%esp 80104ef9: 85 d2 test %edx,%edx 80104efb: 74 16 je 80104f13 <acquiresleep+0x33> 80104efd: 8d 76 00 lea 0x0(%esi),%esi sleep(lk, &lk->lk); 80104f00: 83 ec 08 sub $0x8,%esp 80104f03: 56 push %esi 80104f04: 53 push %ebx 80104f05: e8 c6 f4 ff ff call 801043d0 <sleep> void acquiresleep(struct sleeplock *lk) { acquire(&lk->lk); while (lk->locked) { 80104f0a: 8b 03 mov (%ebx),%eax 80104f0c: 83 c4 10 add $0x10,%esp 80104f0f: 85 c0 test %eax,%eax 80104f11: 75 ed jne 80104f00 <acquiresleep+0x20> sleep(lk, &lk->lk); } lk->locked = 1; 80104f13: c7 03 01 00 00 00 movl $0x1,(%ebx) lk->pid = myproc()->pid; 80104f19: e8 12 eb ff ff call 80103a30 <myproc> 80104f1e: 8b 40 10 mov 0x10(%eax),%eax 80104f21: 89 43 3c mov %eax,0x3c(%ebx) release(&lk->lk); 80104f24: 89 75 08 mov %esi,0x8(%ebp) } 80104f27: 8d 65 f8 lea -0x8(%ebp),%esp 80104f2a: 5b pop %ebx 80104f2b: 5e pop %esi 80104f2c: 5d pop %ebp while (lk->locked) { sleep(lk, &lk->lk); } lk->locked = 1; lk->pid = myproc()->pid; release(&lk->lk); 80104f2d: e9 ae 02 00 00 jmp 801051e0 <release> 80104f32: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104f39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104f40 <releasesleep>: } void releasesleep(struct sleeplock *lk) { 80104f40: 55 push %ebp 80104f41: 89 e5 mov %esp,%ebp 80104f43: 56 push %esi 80104f44: 53 push %ebx 80104f45: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80104f48: 83 ec 0c sub $0xc,%esp 80104f4b: 8d 73 04 lea 0x4(%ebx),%esi 80104f4e: 56 push %esi 80104f4f: e8 dc 01 00 00 call 80105130 <acquire> lk->locked = 0; 80104f54: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 80104f5a: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) wakeup(lk); 80104f61: 89 1c 24 mov %ebx,(%esp) 80104f64: e8 27 f6 ff ff call 80104590 <wakeup> release(&lk->lk); 80104f69: 89 75 08 mov %esi,0x8(%ebp) 80104f6c: 83 c4 10 add $0x10,%esp } 80104f6f: 8d 65 f8 lea -0x8(%ebp),%esp 80104f72: 5b pop %ebx 80104f73: 5e pop %esi 80104f74: 5d pop %ebp { acquire(&lk->lk); lk->locked = 0; lk->pid = 0; wakeup(lk); release(&lk->lk); 80104f75: e9 66 02 00 00 jmp 801051e0 <release> 80104f7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104f80 <holdingsleep>: } int holdingsleep(struct sleeplock *lk) { 80104f80: 55 push %ebp 80104f81: 89 e5 mov %esp,%ebp 80104f83: 57 push %edi 80104f84: 56 push %esi 80104f85: 53 push %ebx 80104f86: 31 ff xor %edi,%edi 80104f88: 83 ec 18 sub $0x18,%esp 80104f8b: 8b 5d 08 mov 0x8(%ebp),%ebx int r; acquire(&lk->lk); 80104f8e: 8d 73 04 lea 0x4(%ebx),%esi 80104f91: 56 push %esi 80104f92: e8 99 01 00 00 call 80105130 <acquire> r = lk->locked && (lk->pid == myproc()->pid); 80104f97: 8b 03 mov (%ebx),%eax 80104f99: 83 c4 10 add $0x10,%esp 80104f9c: 85 c0 test %eax,%eax 80104f9e: 74 13 je 80104fb3 <holdingsleep+0x33> 80104fa0: 8b 5b 3c mov 0x3c(%ebx),%ebx 80104fa3: e8 88 ea ff ff call 80103a30 <myproc> 80104fa8: 39 58 10 cmp %ebx,0x10(%eax) 80104fab: 0f 94 c0 sete %al 80104fae: 0f b6 c0 movzbl %al,%eax 80104fb1: 89 c7 mov %eax,%edi release(&lk->lk); 80104fb3: 83 ec 0c sub $0xc,%esp 80104fb6: 56 push %esi 80104fb7: e8 24 02 00 00 call 801051e0 <release> return r; } 80104fbc: 8d 65 f4 lea -0xc(%ebp),%esp 80104fbf: 89 f8 mov %edi,%eax 80104fc1: 5b pop %ebx 80104fc2: 5e pop %esi 80104fc3: 5f pop %edi 80104fc4: 5d pop %ebp 80104fc5: c3 ret 80104fc6: 66 90 xchg %ax,%ax 80104fc8: 66 90 xchg %ax,%ax 80104fca: 66 90 xchg %ax,%ax 80104fcc: 66 90 xchg %ax,%ax 80104fce: 66 90 xchg %ax,%ax 80104fd0 <initlock>: #include "proc.h" #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { 80104fd0: 55 push %ebp 80104fd1: 89 e5 mov %esp,%ebp 80104fd3: 8b 45 08 mov 0x8(%ebp),%eax lk->name = name; 80104fd6: 8b 55 0c mov 0xc(%ebp),%edx lk->locked = 0; 80104fd9: c7 00 00 00 00 00 movl $0x0,(%eax) #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { lk->name = name; 80104fdf: 89 50 04 mov %edx,0x4(%eax) lk->locked = 0; lk->cpu = 0; 80104fe2: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } 80104fe9: 5d pop %ebp 80104fea: c3 ret 80104feb: 90 nop 80104fec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104ff0 <getcallerpcs>: } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104ff0: 55 push %ebp 80104ff1: 89 e5 mov %esp,%ebp 80104ff3: 53 push %ebx uint *ebp; int i; ebp = (uint*)v - 2; 80104ff4: 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[]) { 80104ff7: 8b 4d 0c mov 0xc(%ebp),%ecx uint *ebp; int i; ebp = (uint*)v - 2; 80104ffa: 8d 50 f8 lea -0x8(%eax),%edx for(i = 0; i < 10; i++){ 80104ffd: 31 c0 xor %eax,%eax 80104fff: 90 nop if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 80105000: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 80105006: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 8010500c: 77 1a ja 80105028 <getcallerpcs+0x38> break; pcs[i] = ebp[1]; // saved %eip 8010500e: 8b 5a 04 mov 0x4(%edx),%ebx 80105011: 89 1c 81 mov %ebx,(%ecx,%eax,4) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80105014: 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 80105017: 8b 12 mov (%edx),%edx { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80105019: 83 f8 0a cmp $0xa,%eax 8010501c: 75 e2 jne 80105000 <getcallerpcs+0x10> pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) pcs[i] = 0; } 8010501e: 5b pop %ebx 8010501f: 5d pop %ebp 80105020: c3 ret 80105021: 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; 80105028: 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++) 8010502f: 83 c0 01 add $0x1,%eax 80105032: 83 f8 0a cmp $0xa,%eax 80105035: 74 e7 je 8010501e <getcallerpcs+0x2e> pcs[i] = 0; 80105037: 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++) 8010503e: 83 c0 01 add $0x1,%eax 80105041: 83 f8 0a cmp $0xa,%eax 80105044: 75 e2 jne 80105028 <getcallerpcs+0x38> 80105046: eb d6 jmp 8010501e <getcallerpcs+0x2e> 80105048: 90 nop 80105049: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105050 <pushcli>: // it takes two popcli to undo two pushcli. Also, if interrupts // are off, then pushcli, popcli leaves them off. void pushcli(void) { 80105050: 55 push %ebp 80105051: 89 e5 mov %esp,%ebp 80105053: 53 push %ebx 80105054: 83 ec 04 sub $0x4,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80105057: 9c pushf 80105058: 5b pop %ebx } static inline void cli(void) { asm volatile("cli"); 80105059: fa cli int eflags; eflags = readeflags(); cli(); if(mycpu()->ncli == 0) 8010505a: e8 61 e9 ff ff call 801039c0 <mycpu> 8010505f: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax 80105065: 85 c0 test %eax,%eax 80105067: 75 11 jne 8010507a <pushcli+0x2a> mycpu()->intena = eflags & FL_IF; 80105069: 81 e3 00 02 00 00 and $0x200,%ebx 8010506f: e8 4c e9 ff ff call 801039c0 <mycpu> 80105074: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax) mycpu()->ncli += 1; 8010507a: e8 41 e9 ff ff call 801039c0 <mycpu> 8010507f: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax) } 80105086: 83 c4 04 add $0x4,%esp 80105089: 5b pop %ebx 8010508a: 5d pop %ebp 8010508b: c3 ret 8010508c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105090 <popcli>: void popcli(void) { 80105090: 55 push %ebp 80105091: 89 e5 mov %esp,%ebp 80105093: 83 ec 08 sub $0x8,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80105096: 9c pushf 80105097: 58 pop %eax if(readeflags()&FL_IF) 80105098: f6 c4 02 test $0x2,%ah 8010509b: 75 52 jne 801050ef <popcli+0x5f> panic("popcli - interruptible"); if(--mycpu()->ncli < 0) 8010509d: e8 1e e9 ff ff call 801039c0 <mycpu> 801050a2: 8b 88 a4 00 00 00 mov 0xa4(%eax),%ecx 801050a8: 8d 51 ff lea -0x1(%ecx),%edx 801050ab: 85 d2 test %edx,%edx 801050ad: 89 90 a4 00 00 00 mov %edx,0xa4(%eax) 801050b3: 78 2d js 801050e2 <popcli+0x52> panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 801050b5: e8 06 e9 ff ff call 801039c0 <mycpu> 801050ba: 8b 90 a4 00 00 00 mov 0xa4(%eax),%edx 801050c0: 85 d2 test %edx,%edx 801050c2: 74 0c je 801050d0 <popcli+0x40> sti(); } 801050c4: c9 leave 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 { if(readeflags()&FL_IF) panic("popcli - interruptible"); if(--mycpu()->ncli < 0) panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 801050d0: e8 eb e8 ff ff call 801039c0 <mycpu> 801050d5: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax 801050db: 85 c0 test %eax,%eax 801050dd: 74 e5 je 801050c4 <popcli+0x34> } static inline void sti(void) { asm volatile("sti"); 801050df: fb sti sti(); } 801050e0: c9 leave 801050e1: c3 ret popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); if(--mycpu()->ncli < 0) panic("popcli"); 801050e2: 83 ec 0c sub $0xc,%esp 801050e5: 68 6a 88 10 80 push $0x8010886a 801050ea: e8 81 b2 ff ff call 80100370 <panic> void popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); 801050ef: 83 ec 0c sub $0xc,%esp 801050f2: 68 53 88 10 80 push $0x80108853 801050f7: e8 74 b2 ff ff call 80100370 <panic> 801050fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105100 <holding>: } // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 80105100: 55 push %ebp 80105101: 89 e5 mov %esp,%ebp 80105103: 56 push %esi 80105104: 53 push %ebx 80105105: 8b 75 08 mov 0x8(%ebp),%esi 80105108: 31 db xor %ebx,%ebx int r; pushcli(); 8010510a: e8 41 ff ff ff call 80105050 <pushcli> r = lock->locked && lock->cpu == mycpu(); 8010510f: 8b 06 mov (%esi),%eax 80105111: 85 c0 test %eax,%eax 80105113: 74 10 je 80105125 <holding+0x25> 80105115: 8b 5e 08 mov 0x8(%esi),%ebx 80105118: e8 a3 e8 ff ff call 801039c0 <mycpu> 8010511d: 39 c3 cmp %eax,%ebx 8010511f: 0f 94 c3 sete %bl 80105122: 0f b6 db movzbl %bl,%ebx popcli(); 80105125: e8 66 ff ff ff call 80105090 <popcli> return r; } 8010512a: 89 d8 mov %ebx,%eax 8010512c: 5b pop %ebx 8010512d: 5e pop %esi 8010512e: 5d pop %ebp 8010512f: c3 ret 80105130 <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) { 80105130: 55 push %ebp 80105131: 89 e5 mov %esp,%ebp 80105133: 53 push %ebx 80105134: 83 ec 04 sub $0x4,%esp pushcli(); // disable interrupts to avoid deadlock. 80105137: e8 14 ff ff ff call 80105050 <pushcli> if(holding(lk)) 8010513c: 8b 5d 08 mov 0x8(%ebp),%ebx 8010513f: 83 ec 0c sub $0xc,%esp 80105142: 53 push %ebx 80105143: e8 b8 ff ff ff call 80105100 <holding> 80105148: 83 c4 10 add $0x10,%esp 8010514b: 85 c0 test %eax,%eax 8010514d: 0f 85 7d 00 00 00 jne 801051d0 <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" : 80105153: ba 01 00 00 00 mov $0x1,%edx 80105158: eb 09 jmp 80105163 <acquire+0x33> 8010515a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105160: 8b 5d 08 mov 0x8(%ebp),%ebx 80105163: 89 d0 mov %edx,%eax 80105165: f0 87 03 lock xchg %eax,(%ebx) panic("acquire"); // The xchg is atomic. while(xchg(&lk->locked, 1) != 0) 80105168: 85 c0 test %eax,%eax 8010516a: 75 f4 jne 80105160 <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(); 8010516c: f0 83 0c 24 00 lock orl $0x0,(%esp) // Record info about lock acquisition for debugging. lk->cpu = mycpu(); 80105171: 8b 5d 08 mov 0x8(%ebp),%ebx 80105174: e8 47 e8 ff ff call 801039c0 <mycpu> getcallerpcs(void *v, uint pcs[]) { uint *ebp; int i; ebp = (uint*)v - 2; 80105179: 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); 8010517b: 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(); 8010517e: 89 43 08 mov %eax,0x8(%ebx) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80105181: 31 c0 xor %eax,%eax 80105183: 90 nop 80105184: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 80105188: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 8010518e: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 80105194: 77 1a ja 801051b0 <acquire+0x80> break; pcs[i] = ebp[1]; // saved %eip 80105196: 8b 5a 04 mov 0x4(%edx),%ebx 80105199: 89 1c 81 mov %ebx,(%ecx,%eax,4) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 8010519c: 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 8010519f: 8b 12 mov (%edx),%edx { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 801051a1: 83 f8 0a cmp $0xa,%eax 801051a4: 75 e2 jne 80105188 <acquire+0x58> __sync_synchronize(); // Record info about lock acquisition for debugging. lk->cpu = mycpu(); getcallerpcs(&lk, lk->pcs); } 801051a6: 8b 5d fc mov -0x4(%ebp),%ebx 801051a9: c9 leave 801051aa: c3 ret 801051ab: 90 nop 801051ac: 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; 801051b0: 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++) 801051b7: 83 c0 01 add $0x1,%eax 801051ba: 83 f8 0a cmp $0xa,%eax 801051bd: 74 e7 je 801051a6 <acquire+0x76> pcs[i] = 0; 801051bf: 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++) 801051c6: 83 c0 01 add $0x1,%eax 801051c9: 83 f8 0a cmp $0xa,%eax 801051cc: 75 e2 jne 801051b0 <acquire+0x80> 801051ce: eb d6 jmp 801051a6 <acquire+0x76> void acquire(struct spinlock *lk) { pushcli(); // disable interrupts to avoid deadlock. if(holding(lk)) panic("acquire"); 801051d0: 83 ec 0c sub $0xc,%esp 801051d3: 68 71 88 10 80 push $0x80108871 801051d8: e8 93 b1 ff ff call 80100370 <panic> 801051dd: 8d 76 00 lea 0x0(%esi),%esi 801051e0 <release>: } // Release the lock. void release(struct spinlock *lk) { 801051e0: 55 push %ebp 801051e1: 89 e5 mov %esp,%ebp 801051e3: 53 push %ebx 801051e4: 83 ec 10 sub $0x10,%esp 801051e7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holding(lk)) 801051ea: 53 push %ebx 801051eb: e8 10 ff ff ff call 80105100 <holding> 801051f0: 83 c4 10 add $0x10,%esp 801051f3: 85 c0 test %eax,%eax 801051f5: 74 22 je 80105219 <release+0x39> panic("release"); lk->pcs[0] = 0; 801051f7: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) lk->cpu = 0; 801051fe: 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(); 80105205: 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) : ); 8010520a: c7 03 00 00 00 00 movl $0x0,(%ebx) popcli(); } 80105210: 8b 5d fc mov -0x4(%ebp),%ebx 80105213: 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(); 80105214: e9 77 fe ff ff jmp 80105090 <popcli> // Release the lock. void release(struct spinlock *lk) { if(!holding(lk)) panic("release"); 80105219: 83 ec 0c sub $0xc,%esp 8010521c: 68 79 88 10 80 push $0x80108879 80105221: e8 4a b1 ff ff call 80100370 <panic> 80105226: 66 90 xchg %ax,%ax 80105228: 66 90 xchg %ax,%ax 8010522a: 66 90 xchg %ax,%ax 8010522c: 66 90 xchg %ax,%ax 8010522e: 66 90 xchg %ax,%ax 80105230 <memset>: #include "types.h" #include "x86.h" void* memset(void *dst, int c, uint n) { 80105230: 55 push %ebp 80105231: 89 e5 mov %esp,%ebp 80105233: 57 push %edi 80105234: 53 push %ebx 80105235: 8b 55 08 mov 0x8(%ebp),%edx 80105238: 8b 4d 10 mov 0x10(%ebp),%ecx if ((int)dst%4 == 0 && n%4 == 0){ 8010523b: f6 c2 03 test $0x3,%dl 8010523e: 75 05 jne 80105245 <memset+0x15> 80105240: f6 c1 03 test $0x3,%cl 80105243: 74 13 je 80105258 <memset+0x28> } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 80105245: 89 d7 mov %edx,%edi 80105247: 8b 45 0c mov 0xc(%ebp),%eax 8010524a: fc cld 8010524b: 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; } 8010524d: 5b pop %ebx 8010524e: 89 d0 mov %edx,%eax 80105250: 5f pop %edi 80105251: 5d pop %ebp 80105252: c3 ret 80105253: 90 nop 80105254: 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; 80105258: 0f b6 7d 0c movzbl 0xc(%ebp),%edi } static inline void stosl(void *addr, int data, int cnt) { asm volatile("cld; rep stosl" : 8010525c: c1 e9 02 shr $0x2,%ecx 8010525f: 89 fb mov %edi,%ebx 80105261: 89 f8 mov %edi,%eax 80105263: c1 e3 18 shl $0x18,%ebx 80105266: c1 e0 10 shl $0x10,%eax 80105269: 09 d8 or %ebx,%eax 8010526b: 09 f8 or %edi,%eax 8010526d: c1 e7 08 shl $0x8,%edi 80105270: 09 f8 or %edi,%eax 80105272: 89 d7 mov %edx,%edi 80105274: fc cld 80105275: 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; } 80105277: 5b pop %ebx 80105278: 89 d0 mov %edx,%eax 8010527a: 5f pop %edi 8010527b: 5d pop %ebp 8010527c: c3 ret 8010527d: 8d 76 00 lea 0x0(%esi),%esi 80105280 <memcmp>: int memcmp(const void *v1, const void *v2, uint n) { 80105280: 55 push %ebp 80105281: 89 e5 mov %esp,%ebp 80105283: 57 push %edi 80105284: 56 push %esi 80105285: 8b 45 10 mov 0x10(%ebp),%eax 80105288: 53 push %ebx 80105289: 8b 75 0c mov 0xc(%ebp),%esi 8010528c: 8b 5d 08 mov 0x8(%ebp),%ebx const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 8010528f: 85 c0 test %eax,%eax 80105291: 74 29 je 801052bc <memcmp+0x3c> if(*s1 != *s2) 80105293: 0f b6 13 movzbl (%ebx),%edx 80105296: 0f b6 0e movzbl (%esi),%ecx 80105299: 38 d1 cmp %dl,%cl 8010529b: 75 2b jne 801052c8 <memcmp+0x48> 8010529d: 8d 78 ff lea -0x1(%eax),%edi 801052a0: 31 c0 xor %eax,%eax 801052a2: eb 14 jmp 801052b8 <memcmp+0x38> 801052a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801052a8: 0f b6 54 03 01 movzbl 0x1(%ebx,%eax,1),%edx 801052ad: 83 c0 01 add $0x1,%eax 801052b0: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx 801052b4: 38 ca cmp %cl,%dl 801052b6: 75 10 jne 801052c8 <memcmp+0x48> { const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 801052b8: 39 f8 cmp %edi,%eax 801052ba: 75 ec jne 801052a8 <memcmp+0x28> return *s1 - *s2; s1++, s2++; } return 0; } 801052bc: 5b pop %ebx if(*s1 != *s2) return *s1 - *s2; s1++, s2++; } return 0; 801052bd: 31 c0 xor %eax,%eax } 801052bf: 5e pop %esi 801052c0: 5f pop %edi 801052c1: 5d pop %ebp 801052c2: c3 ret 801052c3: 90 nop 801052c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s1 = v1; s2 = v2; while(n-- > 0){ if(*s1 != *s2) return *s1 - *s2; 801052c8: 0f b6 c2 movzbl %dl,%eax s1++, s2++; } return 0; } 801052cb: 5b pop %ebx s1 = v1; s2 = v2; while(n-- > 0){ if(*s1 != *s2) return *s1 - *s2; 801052cc: 29 c8 sub %ecx,%eax s1++, s2++; } return 0; } 801052ce: 5e pop %esi 801052cf: 5f pop %edi 801052d0: 5d pop %ebp 801052d1: c3 ret 801052d2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801052d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801052e0 <memmove>: void* memmove(void *dst, const void *src, uint n) { 801052e0: 55 push %ebp 801052e1: 89 e5 mov %esp,%ebp 801052e3: 56 push %esi 801052e4: 53 push %ebx 801052e5: 8b 45 08 mov 0x8(%ebp),%eax 801052e8: 8b 75 0c mov 0xc(%ebp),%esi 801052eb: 8b 5d 10 mov 0x10(%ebp),%ebx const char *s; char *d; s = src; d = dst; if(s < d && s + n > d){ 801052ee: 39 c6 cmp %eax,%esi 801052f0: 73 2e jae 80105320 <memmove+0x40> 801052f2: 8d 0c 1e lea (%esi,%ebx,1),%ecx 801052f5: 39 c8 cmp %ecx,%eax 801052f7: 73 27 jae 80105320 <memmove+0x40> s += n; d += n; while(n-- > 0) 801052f9: 85 db test %ebx,%ebx 801052fb: 8d 53 ff lea -0x1(%ebx),%edx 801052fe: 74 17 je 80105317 <memmove+0x37> *--d = *--s; 80105300: 29 d9 sub %ebx,%ecx 80105302: 89 cb mov %ecx,%ebx 80105304: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105308: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 8010530c: 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) 8010530f: 83 ea 01 sub $0x1,%edx 80105312: 83 fa ff cmp $0xffffffff,%edx 80105315: 75 f1 jne 80105308 <memmove+0x28> } else while(n-- > 0) *d++ = *s++; return dst; } 80105317: 5b pop %ebx 80105318: 5e pop %esi 80105319: 5d pop %ebp 8010531a: c3 ret 8010531b: 90 nop 8010531c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 80105320: 31 d2 xor %edx,%edx 80105322: 85 db test %ebx,%ebx 80105324: 74 f1 je 80105317 <memmove+0x37> 80105326: 8d 76 00 lea 0x0(%esi),%esi 80105329: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi *d++ = *s++; 80105330: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80105334: 88 0c 10 mov %cl,(%eax,%edx,1) 80105337: 83 c2 01 add $0x1,%edx s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 8010533a: 39 d3 cmp %edx,%ebx 8010533c: 75 f2 jne 80105330 <memmove+0x50> *d++ = *s++; return dst; } 8010533e: 5b pop %ebx 8010533f: 5e pop %esi 80105340: 5d pop %ebp 80105341: c3 ret 80105342: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105350 <memcpy>: // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { 80105350: 55 push %ebp 80105351: 89 e5 mov %esp,%ebp return memmove(dst, src, n); } 80105353: 5d pop %ebp // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { return memmove(dst, src, n); 80105354: eb 8a jmp 801052e0 <memmove> 80105356: 8d 76 00 lea 0x0(%esi),%esi 80105359: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105360 <strncmp>: } int strncmp(const char *p, const char *q, uint n) { 80105360: 55 push %ebp 80105361: 89 e5 mov %esp,%ebp 80105363: 57 push %edi 80105364: 56 push %esi 80105365: 8b 4d 10 mov 0x10(%ebp),%ecx 80105368: 53 push %ebx 80105369: 8b 7d 08 mov 0x8(%ebp),%edi 8010536c: 8b 75 0c mov 0xc(%ebp),%esi while(n > 0 && *p && *p == *q) 8010536f: 85 c9 test %ecx,%ecx 80105371: 74 37 je 801053aa <strncmp+0x4a> 80105373: 0f b6 17 movzbl (%edi),%edx 80105376: 0f b6 1e movzbl (%esi),%ebx 80105379: 84 d2 test %dl,%dl 8010537b: 74 3f je 801053bc <strncmp+0x5c> 8010537d: 38 d3 cmp %dl,%bl 8010537f: 75 3b jne 801053bc <strncmp+0x5c> 80105381: 8d 47 01 lea 0x1(%edi),%eax 80105384: 01 cf add %ecx,%edi 80105386: eb 1b jmp 801053a3 <strncmp+0x43> 80105388: 90 nop 80105389: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105390: 0f b6 10 movzbl (%eax),%edx 80105393: 84 d2 test %dl,%dl 80105395: 74 21 je 801053b8 <strncmp+0x58> 80105397: 0f b6 19 movzbl (%ecx),%ebx 8010539a: 83 c0 01 add $0x1,%eax 8010539d: 89 ce mov %ecx,%esi 8010539f: 38 da cmp %bl,%dl 801053a1: 75 19 jne 801053bc <strncmp+0x5c> 801053a3: 39 c7 cmp %eax,%edi n--, p++, q++; 801053a5: 8d 4e 01 lea 0x1(%esi),%ecx } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 801053a8: 75 e6 jne 80105390 <strncmp+0x30> n--, p++, q++; if(n == 0) return 0; return (uchar)*p - (uchar)*q; } 801053aa: 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; 801053ab: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; } 801053ad: 5e pop %esi 801053ae: 5f pop %edi 801053af: 5d pop %ebp 801053b0: c3 ret 801053b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801053b8: 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; 801053bc: 0f b6 c2 movzbl %dl,%eax 801053bf: 29 d8 sub %ebx,%eax } 801053c1: 5b pop %ebx 801053c2: 5e pop %esi 801053c3: 5f pop %edi 801053c4: 5d pop %ebp 801053c5: c3 ret 801053c6: 8d 76 00 lea 0x0(%esi),%esi 801053c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801053d0 <strncpy>: char* strncpy(char *s, const char *t, int n) { 801053d0: 55 push %ebp 801053d1: 89 e5 mov %esp,%ebp 801053d3: 56 push %esi 801053d4: 53 push %ebx 801053d5: 8b 45 08 mov 0x8(%ebp),%eax 801053d8: 8b 5d 0c mov 0xc(%ebp),%ebx 801053db: 8b 4d 10 mov 0x10(%ebp),%ecx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) 801053de: 89 c2 mov %eax,%edx 801053e0: eb 19 jmp 801053fb <strncpy+0x2b> 801053e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801053e8: 83 c3 01 add $0x1,%ebx 801053eb: 0f b6 4b ff movzbl -0x1(%ebx),%ecx 801053ef: 83 c2 01 add $0x1,%edx 801053f2: 84 c9 test %cl,%cl 801053f4: 88 4a ff mov %cl,-0x1(%edx) 801053f7: 74 09 je 80105402 <strncpy+0x32> 801053f9: 89 f1 mov %esi,%ecx 801053fb: 85 c9 test %ecx,%ecx 801053fd: 8d 71 ff lea -0x1(%ecx),%esi 80105400: 7f e6 jg 801053e8 <strncpy+0x18> ; while(n-- > 0) 80105402: 31 c9 xor %ecx,%ecx 80105404: 85 f6 test %esi,%esi 80105406: 7e 17 jle 8010541f <strncpy+0x4f> 80105408: 90 nop 80105409: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi *s++ = 0; 80105410: c6 04 0a 00 movb $0x0,(%edx,%ecx,1) 80105414: 89 f3 mov %esi,%ebx 80105416: 83 c1 01 add $0x1,%ecx 80105419: 29 cb sub %ecx,%ebx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) ; while(n-- > 0) 8010541b: 85 db test %ebx,%ebx 8010541d: 7f f1 jg 80105410 <strncpy+0x40> *s++ = 0; return os; } 8010541f: 5b pop %ebx 80105420: 5e pop %esi 80105421: 5d pop %ebp 80105422: c3 ret 80105423: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105430 <safestrcpy>: // Like strncpy but guaranteed to NUL-terminate. char* safestrcpy(char *s, const char *t, int n) { 80105430: 55 push %ebp 80105431: 89 e5 mov %esp,%ebp 80105433: 56 push %esi 80105434: 53 push %ebx 80105435: 8b 4d 10 mov 0x10(%ebp),%ecx 80105438: 8b 45 08 mov 0x8(%ebp),%eax 8010543b: 8b 55 0c mov 0xc(%ebp),%edx char *os; os = s; if(n <= 0) 8010543e: 85 c9 test %ecx,%ecx 80105440: 7e 26 jle 80105468 <safestrcpy+0x38> 80105442: 8d 74 0a ff lea -0x1(%edx,%ecx,1),%esi 80105446: 89 c1 mov %eax,%ecx 80105448: eb 17 jmp 80105461 <safestrcpy+0x31> 8010544a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return os; while(--n > 0 && (*s++ = *t++) != 0) 80105450: 83 c2 01 add $0x1,%edx 80105453: 0f b6 5a ff movzbl -0x1(%edx),%ebx 80105457: 83 c1 01 add $0x1,%ecx 8010545a: 84 db test %bl,%bl 8010545c: 88 59 ff mov %bl,-0x1(%ecx) 8010545f: 74 04 je 80105465 <safestrcpy+0x35> 80105461: 39 f2 cmp %esi,%edx 80105463: 75 eb jne 80105450 <safestrcpy+0x20> ; *s = 0; 80105465: c6 01 00 movb $0x0,(%ecx) return os; } 80105468: 5b pop %ebx 80105469: 5e pop %esi 8010546a: 5d pop %ebp 8010546b: c3 ret 8010546c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105470 <strlen>: int strlen(const char *s) { 80105470: 55 push %ebp int n; for(n = 0; s[n]; n++) 80105471: 31 c0 xor %eax,%eax return os; } int strlen(const char *s) { 80105473: 89 e5 mov %esp,%ebp 80105475: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) 80105478: 80 3a 00 cmpb $0x0,(%edx) 8010547b: 74 0c je 80105489 <strlen+0x19> 8010547d: 8d 76 00 lea 0x0(%esi),%esi 80105480: 83 c0 01 add $0x1,%eax 80105483: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 80105487: 75 f7 jne 80105480 <strlen+0x10> ; return n; } 80105489: 5d pop %ebp 8010548a: c3 ret 8010548b <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 8010548b: 8b 44 24 04 mov 0x4(%esp),%eax movl 8(%esp), %edx 8010548f: 8b 54 24 08 mov 0x8(%esp),%edx # Save old callee-saved registers pushl %ebp 80105493: 55 push %ebp pushl %ebx 80105494: 53 push %ebx pushl %esi 80105495: 56 push %esi pushl %edi 80105496: 57 push %edi # Switch stacks movl %esp, (%eax) 80105497: 89 20 mov %esp,(%eax) movl %edx, %esp 80105499: 89 d4 mov %edx,%esp # Load new callee-saved registers popl %edi 8010549b: 5f pop %edi popl %esi 8010549c: 5e pop %esi popl %ebx 8010549d: 5b pop %ebx popl %ebp 8010549e: 5d pop %ebp ret 8010549f: c3 ret 801054a0 <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) { 801054a0: 55 push %ebp 801054a1: 89 e5 mov %esp,%ebp 801054a3: 53 push %ebx 801054a4: 83 ec 04 sub $0x4,%esp 801054a7: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *curproc = myproc(); 801054aa: e8 81 e5 ff ff call 80103a30 <myproc> if(addr >= curproc->sz || addr+4 > curproc->sz) 801054af: 8b 00 mov (%eax),%eax 801054b1: 39 d8 cmp %ebx,%eax 801054b3: 76 1b jbe 801054d0 <fetchint+0x30> 801054b5: 8d 53 04 lea 0x4(%ebx),%edx 801054b8: 39 d0 cmp %edx,%eax 801054ba: 72 14 jb 801054d0 <fetchint+0x30> return -1; *ip = *(int*)(addr); 801054bc: 8b 45 0c mov 0xc(%ebp),%eax 801054bf: 8b 13 mov (%ebx),%edx 801054c1: 89 10 mov %edx,(%eax) return 0; 801054c3: 31 c0 xor %eax,%eax } 801054c5: 83 c4 04 add $0x4,%esp 801054c8: 5b pop %ebx 801054c9: 5d pop %ebp 801054ca: c3 ret 801054cb: 90 nop 801054cc: 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; 801054d0: b8 ff ff ff ff mov $0xffffffff,%eax 801054d5: eb ee jmp 801054c5 <fetchint+0x25> 801054d7: 89 f6 mov %esi,%esi 801054d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801054e0 <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) { 801054e0: 55 push %ebp 801054e1: 89 e5 mov %esp,%ebp 801054e3: 53 push %ebx 801054e4: 83 ec 04 sub $0x4,%esp 801054e7: 8b 5d 08 mov 0x8(%ebp),%ebx char *s, *ep; struct proc *curproc = myproc(); 801054ea: e8 41 e5 ff ff call 80103a30 <myproc> if(addr >= curproc->sz) 801054ef: 39 18 cmp %ebx,(%eax) 801054f1: 76 29 jbe 8010551c <fetchstr+0x3c> return -1; *pp = (char*)addr; 801054f3: 8b 4d 0c mov 0xc(%ebp),%ecx 801054f6: 89 da mov %ebx,%edx 801054f8: 89 19 mov %ebx,(%ecx) ep = (char*)curproc->sz; 801054fa: 8b 00 mov (%eax),%eax for(s = *pp; s < ep; s++){ 801054fc: 39 c3 cmp %eax,%ebx 801054fe: 73 1c jae 8010551c <fetchstr+0x3c> if(*s == 0) 80105500: 80 3b 00 cmpb $0x0,(%ebx) 80105503: 75 10 jne 80105515 <fetchstr+0x35> 80105505: eb 29 jmp 80105530 <fetchstr+0x50> 80105507: 89 f6 mov %esi,%esi 80105509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105510: 80 3a 00 cmpb $0x0,(%edx) 80105513: 74 1b je 80105530 <fetchstr+0x50> if(addr >= curproc->sz) return -1; *pp = (char*)addr; ep = (char*)curproc->sz; for(s = *pp; s < ep; s++){ 80105515: 83 c2 01 add $0x1,%edx 80105518: 39 d0 cmp %edx,%eax 8010551a: 77 f4 ja 80105510 <fetchstr+0x30> if(*s == 0) return s - *pp; } return -1; } 8010551c: 83 c4 04 add $0x4,%esp { char *s, *ep; struct proc *curproc = myproc(); if(addr >= curproc->sz) return -1; 8010551f: b8 ff ff ff ff mov $0xffffffff,%eax for(s = *pp; s < ep; s++){ if(*s == 0) return s - *pp; } return -1; } 80105524: 5b pop %ebx 80105525: 5d pop %ebp 80105526: c3 ret 80105527: 89 f6 mov %esi,%esi 80105529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105530: 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; 80105533: 89 d0 mov %edx,%eax 80105535: 29 d8 sub %ebx,%eax } return -1; } 80105537: 5b pop %ebx 80105538: 5d pop %ebp 80105539: c3 ret 8010553a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105540 <argint>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { 80105540: 55 push %ebp 80105541: 89 e5 mov %esp,%ebp 80105543: 56 push %esi 80105544: 53 push %ebx return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 80105545: e8 e6 e4 ff ff call 80103a30 <myproc> 8010554a: 8b 40 18 mov 0x18(%eax),%eax 8010554d: 8b 55 08 mov 0x8(%ebp),%edx 80105550: 8b 40 44 mov 0x44(%eax),%eax 80105553: 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(); 80105556: e8 d5 e4 ff ff call 80103a30 <myproc> if(addr >= curproc->sz || addr+4 > curproc->sz) 8010555b: 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); 8010555d: 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) 80105560: 39 c6 cmp %eax,%esi 80105562: 73 1c jae 80105580 <argint+0x40> 80105564: 8d 53 08 lea 0x8(%ebx),%edx 80105567: 39 d0 cmp %edx,%eax 80105569: 72 15 jb 80105580 <argint+0x40> return -1; *ip = *(int*)(addr); 8010556b: 8b 45 0c mov 0xc(%ebp),%eax 8010556e: 8b 53 04 mov 0x4(%ebx),%edx 80105571: 89 10 mov %edx,(%eax) return 0; 80105573: 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); } 80105575: 5b pop %ebx 80105576: 5e pop %esi 80105577: 5d pop %ebp 80105578: c3 ret 80105579: 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; 80105580: b8 ff ff ff ff mov $0xffffffff,%eax 80105585: eb ee jmp 80105575 <argint+0x35> 80105587: 89 f6 mov %esi,%esi 80105589: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105590 <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) { 80105590: 55 push %ebp 80105591: 89 e5 mov %esp,%ebp 80105593: 56 push %esi 80105594: 53 push %ebx 80105595: 83 ec 10 sub $0x10,%esp 80105598: 8b 5d 10 mov 0x10(%ebp),%ebx int i; struct proc *curproc = myproc(); 8010559b: e8 90 e4 ff ff call 80103a30 <myproc> 801055a0: 89 c6 mov %eax,%esi if(argint(n, &i) < 0) 801055a2: 8d 45 f4 lea -0xc(%ebp),%eax 801055a5: 83 ec 08 sub $0x8,%esp 801055a8: 50 push %eax 801055a9: ff 75 08 pushl 0x8(%ebp) 801055ac: e8 8f ff ff ff call 80105540 <argint> return -1; if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) 801055b1: c1 e8 1f shr $0x1f,%eax 801055b4: 83 c4 10 add $0x10,%esp 801055b7: 84 c0 test %al,%al 801055b9: 75 2d jne 801055e8 <argptr+0x58> 801055bb: 89 d8 mov %ebx,%eax 801055bd: c1 e8 1f shr $0x1f,%eax 801055c0: 84 c0 test %al,%al 801055c2: 75 24 jne 801055e8 <argptr+0x58> 801055c4: 8b 16 mov (%esi),%edx 801055c6: 8b 45 f4 mov -0xc(%ebp),%eax 801055c9: 39 c2 cmp %eax,%edx 801055cb: 76 1b jbe 801055e8 <argptr+0x58> 801055cd: 01 c3 add %eax,%ebx 801055cf: 39 da cmp %ebx,%edx 801055d1: 72 15 jb 801055e8 <argptr+0x58> return -1; *pp = (char*)i; 801055d3: 8b 55 0c mov 0xc(%ebp),%edx 801055d6: 89 02 mov %eax,(%edx) return 0; 801055d8: 31 c0 xor %eax,%eax } 801055da: 8d 65 f8 lea -0x8(%ebp),%esp 801055dd: 5b pop %ebx 801055de: 5e pop %esi 801055df: 5d pop %ebp 801055e0: c3 ret 801055e1: 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; 801055e8: b8 ff ff ff ff mov $0xffffffff,%eax 801055ed: eb eb jmp 801055da <argptr+0x4a> 801055ef: 90 nop 801055f0 <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) { 801055f0: 55 push %ebp 801055f1: 89 e5 mov %esp,%ebp 801055f3: 83 ec 20 sub $0x20,%esp int addr; if(argint(n, &addr) < 0) 801055f6: 8d 45 f4 lea -0xc(%ebp),%eax 801055f9: 50 push %eax 801055fa: ff 75 08 pushl 0x8(%ebp) 801055fd: e8 3e ff ff ff call 80105540 <argint> 80105602: 83 c4 10 add $0x10,%esp 80105605: 85 c0 test %eax,%eax 80105607: 78 17 js 80105620 <argstr+0x30> return -1; return fetchstr(addr, pp); 80105609: 83 ec 08 sub $0x8,%esp 8010560c: ff 75 0c pushl 0xc(%ebp) 8010560f: ff 75 f4 pushl -0xc(%ebp) 80105612: e8 c9 fe ff ff call 801054e0 <fetchstr> 80105617: 83 c4 10 add $0x10,%esp } 8010561a: c9 leave 8010561b: c3 ret 8010561c: 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; 80105620: b8 ff ff ff ff mov $0xffffffff,%eax return fetchstr(addr, pp); } 80105625: c9 leave 80105626: c3 ret 80105627: 89 f6 mov %esi,%esi 80105629: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105630 <syscall>: [SYS_printinfo] sys_printinfo, }; void syscall(void) { 80105630: 55 push %ebp 80105631: 89 e5 mov %esp,%ebp 80105633: 56 push %esi 80105634: 53 push %ebx int num; struct proc *curproc = myproc(); 80105635: e8 f6 e3 ff ff call 80103a30 <myproc> num = curproc->tf->eax; 8010563a: 8b 70 18 mov 0x18(%eax),%esi void syscall(void) { int num; struct proc *curproc = myproc(); 8010563d: 89 c3 mov %eax,%ebx num = curproc->tf->eax; 8010563f: 8b 46 1c mov 0x1c(%esi),%eax if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 80105642: 8d 50 ff lea -0x1(%eax),%edx 80105645: 83 fa 1e cmp $0x1e,%edx 80105648: 77 1e ja 80105668 <syscall+0x38> 8010564a: 8b 14 85 a0 88 10 80 mov -0x7fef7760(,%eax,4),%edx 80105651: 85 d2 test %edx,%edx 80105653: 74 13 je 80105668 <syscall+0x38> curproc->tf->eax = syscalls[num](); 80105655: ff d2 call *%edx 80105657: 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; } } 8010565a: 8d 65 f8 lea -0x8(%ebp),%esp 8010565d: 5b pop %ebx 8010565e: 5e pop %esi 8010565f: 5d pop %ebp 80105660: c3 ret 80105661: 8d b4 26 00 00 00 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", 80105668: 50 push %eax curproc->pid, curproc->name, num); 80105669: 8d 43 6c lea 0x6c(%ebx),%eax 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", 8010566c: 50 push %eax 8010566d: ff 73 10 pushl 0x10(%ebx) 80105670: 68 81 88 10 80 push $0x80108881 80105675: e8 e6 af ff ff call 80100660 <cprintf> curproc->pid, curproc->name, num); curproc->tf->eax = -1; 8010567a: 8b 43 18 mov 0x18(%ebx),%eax 8010567d: 83 c4 10 add $0x10,%esp 80105680: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) } } 80105687: 8d 65 f8 lea -0x8(%ebp),%esp 8010568a: 5b pop %ebx 8010568b: 5e pop %esi 8010568c: 5d pop %ebp 8010568d: c3 ret 8010568e: 66 90 xchg %ax,%ax 80105690 <create>: return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80105690: 55 push %ebp 80105691: 89 e5 mov %esp,%ebp 80105693: 57 push %edi 80105694: 56 push %esi 80105695: 53 push %ebx struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 80105696: 8d 75 da lea -0x26(%ebp),%esi return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80105699: 83 ec 34 sub $0x34,%esp 8010569c: 89 4d d0 mov %ecx,-0x30(%ebp) 8010569f: 8b 4d 08 mov 0x8(%ebp),%ecx struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 801056a2: 56 push %esi 801056a3: 50 push %eax return -1; } static struct inode* create(char *path, short type, short major, short minor) { 801056a4: 89 55 d4 mov %edx,-0x2c(%ebp) 801056a7: 89 4d cc mov %ecx,-0x34(%ebp) struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 801056aa: e8 81 ca ff ff call 80102130 <nameiparent> 801056af: 83 c4 10 add $0x10,%esp 801056b2: 85 c0 test %eax,%eax 801056b4: 0f 84 f6 00 00 00 je 801057b0 <create+0x120> return 0; ilock(dp); 801056ba: 83 ec 0c sub $0xc,%esp 801056bd: 89 c7 mov %eax,%edi 801056bf: 50 push %eax 801056c0: e8 fb c1 ff ff call 801018c0 <ilock> if((ip = dirlookup(dp, name, 0)) != 0){ 801056c5: 83 c4 0c add $0xc,%esp 801056c8: 6a 00 push $0x0 801056ca: 56 push %esi 801056cb: 57 push %edi 801056cc: e8 1f c7 ff ff call 80101df0 <dirlookup> 801056d1: 83 c4 10 add $0x10,%esp 801056d4: 85 c0 test %eax,%eax 801056d6: 89 c3 mov %eax,%ebx 801056d8: 74 56 je 80105730 <create+0xa0> iunlockput(dp); 801056da: 83 ec 0c sub $0xc,%esp 801056dd: 57 push %edi 801056de: e8 6d c4 ff ff call 80101b50 <iunlockput> ilock(ip); 801056e3: 89 1c 24 mov %ebx,(%esp) 801056e6: e8 d5 c1 ff ff call 801018c0 <ilock> if(type == T_FILE && ip->type == T_FILE) 801056eb: 83 c4 10 add $0x10,%esp 801056ee: 66 83 7d d4 02 cmpw $0x2,-0x2c(%ebp) 801056f3: 75 1b jne 80105710 <create+0x80> 801056f5: 66 83 7b 50 02 cmpw $0x2,0x50(%ebx) 801056fa: 89 d8 mov %ebx,%eax 801056fc: 75 12 jne 80105710 <create+0x80> panic("create: dirlink"); iunlockput(dp); return ip; } 801056fe: 8d 65 f4 lea -0xc(%ebp),%esp 80105701: 5b pop %ebx 80105702: 5e pop %esi 80105703: 5f pop %edi 80105704: 5d pop %ebp 80105705: c3 ret 80105706: 8d 76 00 lea 0x0(%esi),%esi 80105709: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if((ip = dirlookup(dp, name, 0)) != 0){ iunlockput(dp); ilock(ip); if(type == T_FILE && ip->type == T_FILE) return ip; iunlockput(ip); 80105710: 83 ec 0c sub $0xc,%esp 80105713: 53 push %ebx 80105714: e8 37 c4 ff ff call 80101b50 <iunlockput> return 0; 80105719: 83 c4 10 add $0x10,%esp panic("create: dirlink"); iunlockput(dp); return ip; } 8010571c: 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; 8010571f: 31 c0 xor %eax,%eax panic("create: dirlink"); iunlockput(dp); return ip; } 80105721: 5b pop %ebx 80105722: 5e pop %esi 80105723: 5f pop %edi 80105724: 5d pop %ebp 80105725: c3 ret 80105726: 8d 76 00 lea 0x0(%esi),%esi 80105729: 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) 80105730: 0f bf 45 d4 movswl -0x2c(%ebp),%eax 80105734: 83 ec 08 sub $0x8,%esp 80105737: 50 push %eax 80105738: ff 37 pushl (%edi) 8010573a: e8 11 c0 ff ff call 80101750 <ialloc> 8010573f: 83 c4 10 add $0x10,%esp 80105742: 85 c0 test %eax,%eax 80105744: 89 c3 mov %eax,%ebx 80105746: 0f 84 cc 00 00 00 je 80105818 <create+0x188> panic("create: ialloc"); ilock(ip); 8010574c: 83 ec 0c sub $0xc,%esp 8010574f: 50 push %eax 80105750: e8 6b c1 ff ff call 801018c0 <ilock> ip->major = major; 80105755: 0f b7 45 d0 movzwl -0x30(%ebp),%eax 80105759: 66 89 43 52 mov %ax,0x52(%ebx) ip->minor = minor; 8010575d: 0f b7 45 cc movzwl -0x34(%ebp),%eax 80105761: 66 89 43 54 mov %ax,0x54(%ebx) ip->nlink = 1; 80105765: b8 01 00 00 00 mov $0x1,%eax 8010576a: 66 89 43 56 mov %ax,0x56(%ebx) iupdate(ip); 8010576e: 89 1c 24 mov %ebx,(%esp) 80105771: e8 9a c0 ff ff call 80101810 <iupdate> if(type == T_DIR){ // Create . and .. entries. 80105776: 83 c4 10 add $0x10,%esp 80105779: 66 83 7d d4 01 cmpw $0x1,-0x2c(%ebp) 8010577e: 74 40 je 801057c0 <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) 80105780: 83 ec 04 sub $0x4,%esp 80105783: ff 73 04 pushl 0x4(%ebx) 80105786: 56 push %esi 80105787: 57 push %edi 80105788: e8 c3 c8 ff ff call 80102050 <dirlink> 8010578d: 83 c4 10 add $0x10,%esp 80105790: 85 c0 test %eax,%eax 80105792: 78 77 js 8010580b <create+0x17b> panic("create: dirlink"); iunlockput(dp); 80105794: 83 ec 0c sub $0xc,%esp 80105797: 57 push %edi 80105798: e8 b3 c3 ff ff call 80101b50 <iunlockput> return ip; 8010579d: 83 c4 10 add $0x10,%esp } 801057a0: 8d 65 f4 lea -0xc(%ebp),%esp if(dirlink(dp, name, ip->inum) < 0) panic("create: dirlink"); iunlockput(dp); return ip; 801057a3: 89 d8 mov %ebx,%eax } 801057a5: 5b pop %ebx 801057a6: 5e pop %esi 801057a7: 5f pop %edi 801057a8: 5d pop %ebp 801057a9: c3 ret 801057aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi { struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) return 0; 801057b0: 31 c0 xor %eax,%eax 801057b2: e9 47 ff ff ff jmp 801056fe <create+0x6e> 801057b7: 89 f6 mov %esi,%esi 801057b9: 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 ".." 801057c0: 66 83 47 56 01 addw $0x1,0x56(%edi) iupdate(dp); 801057c5: 83 ec 0c sub $0xc,%esp 801057c8: 57 push %edi 801057c9: e8 42 c0 ff ff call 80101810 <iupdate> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) 801057ce: 83 c4 0c add $0xc,%esp 801057d1: ff 73 04 pushl 0x4(%ebx) 801057d4: 68 3c 89 10 80 push $0x8010893c 801057d9: 53 push %ebx 801057da: e8 71 c8 ff ff call 80102050 <dirlink> 801057df: 83 c4 10 add $0x10,%esp 801057e2: 85 c0 test %eax,%eax 801057e4: 78 18 js 801057fe <create+0x16e> 801057e6: 83 ec 04 sub $0x4,%esp 801057e9: ff 77 04 pushl 0x4(%edi) 801057ec: 68 3b 89 10 80 push $0x8010893b 801057f1: 53 push %ebx 801057f2: e8 59 c8 ff ff call 80102050 <dirlink> 801057f7: 83 c4 10 add $0x10,%esp 801057fa: 85 c0 test %eax,%eax 801057fc: 79 82 jns 80105780 <create+0xf0> panic("create dots"); 801057fe: 83 ec 0c sub $0xc,%esp 80105801: 68 2f 89 10 80 push $0x8010892f 80105806: e8 65 ab ff ff call 80100370 <panic> } if(dirlink(dp, name, ip->inum) < 0) panic("create: dirlink"); 8010580b: 83 ec 0c sub $0xc,%esp 8010580e: 68 3e 89 10 80 push $0x8010893e 80105813: e8 58 ab ff ff call 80100370 <panic> iunlockput(ip); return 0; } if((ip = ialloc(dp->dev, type)) == 0) panic("create: ialloc"); 80105818: 83 ec 0c sub $0xc,%esp 8010581b: 68 20 89 10 80 push $0x80108920 80105820: e8 4b ab ff ff call 80100370 <panic> 80105825: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105829: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105830 <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) 80105830: 55 push %ebp 80105831: 89 e5 mov %esp,%ebp 80105833: 56 push %esi 80105834: 53 push %ebx 80105835: 89 c6 mov %eax,%esi { int fd; struct file *f; if(argint(n, &fd) < 0) 80105837: 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) 8010583a: 89 d3 mov %edx,%ebx 8010583c: 83 ec 18 sub $0x18,%esp { int fd; struct file *f; if(argint(n, &fd) < 0) 8010583f: 50 push %eax 80105840: 6a 00 push $0x0 80105842: e8 f9 fc ff ff call 80105540 <argint> 80105847: 83 c4 10 add $0x10,%esp 8010584a: 85 c0 test %eax,%eax 8010584c: 78 32 js 80105880 <argfd.constprop.0+0x50> return -1; if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) 8010584e: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) 80105852: 77 2c ja 80105880 <argfd.constprop.0+0x50> 80105854: e8 d7 e1 ff ff call 80103a30 <myproc> 80105859: 8b 55 f4 mov -0xc(%ebp),%edx 8010585c: 8b 44 90 28 mov 0x28(%eax,%edx,4),%eax 80105860: 85 c0 test %eax,%eax 80105862: 74 1c je 80105880 <argfd.constprop.0+0x50> return -1; if(pfd) 80105864: 85 f6 test %esi,%esi 80105866: 74 02 je 8010586a <argfd.constprop.0+0x3a> *pfd = fd; 80105868: 89 16 mov %edx,(%esi) if(pf) 8010586a: 85 db test %ebx,%ebx 8010586c: 74 22 je 80105890 <argfd.constprop.0+0x60> *pf = f; 8010586e: 89 03 mov %eax,(%ebx) return 0; 80105870: 31 c0 xor %eax,%eax } 80105872: 8d 65 f8 lea -0x8(%ebp),%esp 80105875: 5b pop %ebx 80105876: 5e pop %esi 80105877: 5d pop %ebp 80105878: c3 ret 80105879: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105880: 8d 65 f8 lea -0x8(%ebp),%esp { int fd; struct file *f; if(argint(n, &fd) < 0) return -1; 80105883: b8 ff ff ff ff mov $0xffffffff,%eax if(pfd) *pfd = fd; if(pf) *pf = f; return 0; } 80105888: 5b pop %ebx 80105889: 5e pop %esi 8010588a: 5d pop %ebp 8010588b: c3 ret 8010588c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; if(pfd) *pfd = fd; if(pf) *pf = f; return 0; 80105890: 31 c0 xor %eax,%eax 80105892: eb de jmp 80105872 <argfd.constprop.0+0x42> 80105894: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010589a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801058a0 <sys_dup>: return -1; } int sys_dup(void) { 801058a0: 55 push %ebp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 801058a1: 31 c0 xor %eax,%eax return -1; } int sys_dup(void) { 801058a3: 89 e5 mov %esp,%ebp 801058a5: 56 push %esi 801058a6: 53 push %ebx struct file *f; int fd; if(argfd(0, 0, &f) < 0) 801058a7: 8d 55 f4 lea -0xc(%ebp),%edx return -1; } int sys_dup(void) { 801058aa: 83 ec 10 sub $0x10,%esp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 801058ad: e8 7e ff ff ff call 80105830 <argfd.constprop.0> 801058b2: 85 c0 test %eax,%eax 801058b4: 78 1a js 801058d0 <sys_dup+0x30> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 801058b6: 31 db xor %ebx,%ebx struct file *f; int fd; if(argfd(0, 0, &f) < 0) return -1; if((fd=fdalloc(f)) < 0) 801058b8: 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(); 801058bb: e8 70 e1 ff ff call 80103a30 <myproc> for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ 801058c0: 8b 54 98 28 mov 0x28(%eax,%ebx,4),%edx 801058c4: 85 d2 test %edx,%edx 801058c6: 74 18 je 801058e0 <sys_dup+0x40> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 801058c8: 83 c3 01 add $0x1,%ebx 801058cb: 83 fb 10 cmp $0x10,%ebx 801058ce: 75 f0 jne 801058c0 <sys_dup+0x20> return -1; if((fd=fdalloc(f)) < 0) return -1; filedup(f); return fd; } 801058d0: 8d 65 f8 lea -0x8(%ebp),%esp { struct file *f; int fd; if(argfd(0, 0, &f) < 0) return -1; 801058d3: b8 ff ff ff ff mov $0xffffffff,%eax if((fd=fdalloc(f)) < 0) return -1; filedup(f); return fd; } 801058d8: 5b pop %ebx 801058d9: 5e pop %esi 801058da: 5d pop %ebp 801058db: c3 ret 801058dc: 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; 801058e0: 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); 801058e4: 83 ec 0c sub $0xc,%esp 801058e7: ff 75 f4 pushl -0xc(%ebp) 801058ea: e8 51 b7 ff ff call 80101040 <filedup> return fd; 801058ef: 83 c4 10 add $0x10,%esp } 801058f2: 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; 801058f5: 89 d8 mov %ebx,%eax } 801058f7: 5b pop %ebx 801058f8: 5e pop %esi 801058f9: 5d pop %ebp 801058fa: c3 ret 801058fb: 90 nop 801058fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105900 <sys_read>: int sys_read(void) { 80105900: 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) 80105901: 31 c0 xor %eax,%eax return fd; } int sys_read(void) { 80105903: 89 e5 mov %esp,%ebp 80105905: 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) 80105908: 8d 55 ec lea -0x14(%ebp),%edx 8010590b: e8 20 ff ff ff call 80105830 <argfd.constprop.0> 80105910: 85 c0 test %eax,%eax 80105912: 78 4c js 80105960 <sys_read+0x60> 80105914: 8d 45 f0 lea -0x10(%ebp),%eax 80105917: 83 ec 08 sub $0x8,%esp 8010591a: 50 push %eax 8010591b: 6a 02 push $0x2 8010591d: e8 1e fc ff ff call 80105540 <argint> 80105922: 83 c4 10 add $0x10,%esp 80105925: 85 c0 test %eax,%eax 80105927: 78 37 js 80105960 <sys_read+0x60> 80105929: 8d 45 f4 lea -0xc(%ebp),%eax 8010592c: 83 ec 04 sub $0x4,%esp 8010592f: ff 75 f0 pushl -0x10(%ebp) 80105932: 50 push %eax 80105933: 6a 01 push $0x1 80105935: e8 56 fc ff ff call 80105590 <argptr> 8010593a: 83 c4 10 add $0x10,%esp 8010593d: 85 c0 test %eax,%eax 8010593f: 78 1f js 80105960 <sys_read+0x60> return -1; return fileread(f, p, n); 80105941: 83 ec 04 sub $0x4,%esp 80105944: ff 75 f0 pushl -0x10(%ebp) 80105947: ff 75 f4 pushl -0xc(%ebp) 8010594a: ff 75 ec pushl -0x14(%ebp) 8010594d: e8 5e b8 ff ff call 801011b0 <fileread> 80105952: 83 c4 10 add $0x10,%esp } 80105955: c9 leave 80105956: c3 ret 80105957: 89 f6 mov %esi,%esi 80105959: 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; 80105960: b8 ff ff ff ff mov $0xffffffff,%eax return fileread(f, p, n); } 80105965: c9 leave 80105966: c3 ret 80105967: 89 f6 mov %esi,%esi 80105969: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105970 <sys_write>: int sys_write(void) { 80105970: 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) 80105971: 31 c0 xor %eax,%eax return fileread(f, p, n); } int sys_write(void) { 80105973: 89 e5 mov %esp,%ebp 80105975: 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) 80105978: 8d 55 ec lea -0x14(%ebp),%edx 8010597b: e8 b0 fe ff ff call 80105830 <argfd.constprop.0> 80105980: 85 c0 test %eax,%eax 80105982: 78 4c js 801059d0 <sys_write+0x60> 80105984: 8d 45 f0 lea -0x10(%ebp),%eax 80105987: 83 ec 08 sub $0x8,%esp 8010598a: 50 push %eax 8010598b: 6a 02 push $0x2 8010598d: e8 ae fb ff ff call 80105540 <argint> 80105992: 83 c4 10 add $0x10,%esp 80105995: 85 c0 test %eax,%eax 80105997: 78 37 js 801059d0 <sys_write+0x60> 80105999: 8d 45 f4 lea -0xc(%ebp),%eax 8010599c: 83 ec 04 sub $0x4,%esp 8010599f: ff 75 f0 pushl -0x10(%ebp) 801059a2: 50 push %eax 801059a3: 6a 01 push $0x1 801059a5: e8 e6 fb ff ff call 80105590 <argptr> 801059aa: 83 c4 10 add $0x10,%esp 801059ad: 85 c0 test %eax,%eax 801059af: 78 1f js 801059d0 <sys_write+0x60> return -1; return filewrite(f, p, n); 801059b1: 83 ec 04 sub $0x4,%esp 801059b4: ff 75 f0 pushl -0x10(%ebp) 801059b7: ff 75 f4 pushl -0xc(%ebp) 801059ba: ff 75 ec pushl -0x14(%ebp) 801059bd: e8 7e b8 ff ff call 80101240 <filewrite> 801059c2: 83 c4 10 add $0x10,%esp } 801059c5: c9 leave 801059c6: c3 ret 801059c7: 89 f6 mov %esi,%esi 801059c9: 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; 801059d0: b8 ff ff ff ff mov $0xffffffff,%eax return filewrite(f, p, n); } 801059d5: c9 leave 801059d6: c3 ret 801059d7: 89 f6 mov %esi,%esi 801059d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801059e0 <sys_close>: int sys_close(void) { 801059e0: 55 push %ebp 801059e1: 89 e5 mov %esp,%ebp 801059e3: 83 ec 18 sub $0x18,%esp int fd; struct file *f; if(argfd(0, &fd, &f) < 0) 801059e6: 8d 55 f4 lea -0xc(%ebp),%edx 801059e9: 8d 45 f0 lea -0x10(%ebp),%eax 801059ec: e8 3f fe ff ff call 80105830 <argfd.constprop.0> 801059f1: 85 c0 test %eax,%eax 801059f3: 78 2b js 80105a20 <sys_close+0x40> return -1; myproc()->ofile[fd] = 0; 801059f5: e8 36 e0 ff ff call 80103a30 <myproc> 801059fa: 8b 55 f0 mov -0x10(%ebp),%edx fileclose(f); 801059fd: 83 ec 0c sub $0xc,%esp int fd; struct file *f; if(argfd(0, &fd, &f) < 0) return -1; myproc()->ofile[fd] = 0; 80105a00: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4) 80105a07: 00 fileclose(f); 80105a08: ff 75 f4 pushl -0xc(%ebp) 80105a0b: e8 80 b6 ff ff call 80101090 <fileclose> return 0; 80105a10: 83 c4 10 add $0x10,%esp 80105a13: 31 c0 xor %eax,%eax } 80105a15: c9 leave 80105a16: c3 ret 80105a17: 89 f6 mov %esi,%esi 80105a19: 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; 80105a20: b8 ff ff ff ff mov $0xffffffff,%eax myproc()->ofile[fd] = 0; fileclose(f); return 0; } 80105a25: c9 leave 80105a26: c3 ret 80105a27: 89 f6 mov %esi,%esi 80105a29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105a30 <sys_fstat>: int sys_fstat(void) { 80105a30: 55 push %ebp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80105a31: 31 c0 xor %eax,%eax return 0; } int sys_fstat(void) { 80105a33: 89 e5 mov %esp,%ebp 80105a35: 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) 80105a38: 8d 55 f0 lea -0x10(%ebp),%edx 80105a3b: e8 f0 fd ff ff call 80105830 <argfd.constprop.0> 80105a40: 85 c0 test %eax,%eax 80105a42: 78 2c js 80105a70 <sys_fstat+0x40> 80105a44: 8d 45 f4 lea -0xc(%ebp),%eax 80105a47: 83 ec 04 sub $0x4,%esp 80105a4a: 6a 14 push $0x14 80105a4c: 50 push %eax 80105a4d: 6a 01 push $0x1 80105a4f: e8 3c fb ff ff call 80105590 <argptr> 80105a54: 83 c4 10 add $0x10,%esp 80105a57: 85 c0 test %eax,%eax 80105a59: 78 15 js 80105a70 <sys_fstat+0x40> return -1; return filestat(f, st); 80105a5b: 83 ec 08 sub $0x8,%esp 80105a5e: ff 75 f4 pushl -0xc(%ebp) 80105a61: ff 75 f0 pushl -0x10(%ebp) 80105a64: e8 f7 b6 ff ff call 80101160 <filestat> 80105a69: 83 c4 10 add $0x10,%esp } 80105a6c: c9 leave 80105a6d: c3 ret 80105a6e: 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; 80105a70: b8 ff ff ff ff mov $0xffffffff,%eax return filestat(f, st); } 80105a75: c9 leave 80105a76: c3 ret 80105a77: 89 f6 mov %esi,%esi 80105a79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105a80 <sys_link>: // Create the path new as a link to the same inode as old. int sys_link(void) { 80105a80: 55 push %ebp 80105a81: 89 e5 mov %esp,%ebp 80105a83: 57 push %edi 80105a84: 56 push %esi 80105a85: 53 push %ebx char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80105a86: 8d 45 d4 lea -0x2c(%ebp),%eax } // Create the path new as a link to the same inode as old. int sys_link(void) { 80105a89: 83 ec 34 sub $0x34,%esp char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80105a8c: 50 push %eax 80105a8d: 6a 00 push $0x0 80105a8f: e8 5c fb ff ff call 801055f0 <argstr> 80105a94: 83 c4 10 add $0x10,%esp 80105a97: 85 c0 test %eax,%eax 80105a99: 0f 88 fb 00 00 00 js 80105b9a <sys_link+0x11a> 80105a9f: 8d 45 d0 lea -0x30(%ebp),%eax 80105aa2: 83 ec 08 sub $0x8,%esp 80105aa5: 50 push %eax 80105aa6: 6a 01 push $0x1 80105aa8: e8 43 fb ff ff call 801055f0 <argstr> 80105aad: 83 c4 10 add $0x10,%esp 80105ab0: 85 c0 test %eax,%eax 80105ab2: 0f 88 e2 00 00 00 js 80105b9a <sys_link+0x11a> return -1; begin_op(); 80105ab8: e8 e3 d2 ff ff call 80102da0 <begin_op> if((ip = namei(old)) == 0){ 80105abd: 83 ec 0c sub $0xc,%esp 80105ac0: ff 75 d4 pushl -0x2c(%ebp) 80105ac3: e8 48 c6 ff ff call 80102110 <namei> 80105ac8: 83 c4 10 add $0x10,%esp 80105acb: 85 c0 test %eax,%eax 80105acd: 89 c3 mov %eax,%ebx 80105acf: 0f 84 f3 00 00 00 je 80105bc8 <sys_link+0x148> end_op(); return -1; } ilock(ip); 80105ad5: 83 ec 0c sub $0xc,%esp 80105ad8: 50 push %eax 80105ad9: e8 e2 bd ff ff call 801018c0 <ilock> if(ip->type == T_DIR){ 80105ade: 83 c4 10 add $0x10,%esp 80105ae1: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80105ae6: 0f 84 c4 00 00 00 je 80105bb0 <sys_link+0x130> iunlockput(ip); end_op(); return -1; } ip->nlink++; 80105aec: 66 83 43 56 01 addw $0x1,0x56(%ebx) iupdate(ip); 80105af1: 83 ec 0c sub $0xc,%esp iunlock(ip); if((dp = nameiparent(new, name)) == 0) 80105af4: 8d 7d da lea -0x26(%ebp),%edi end_op(); return -1; } ip->nlink++; iupdate(ip); 80105af7: 53 push %ebx 80105af8: e8 13 bd ff ff call 80101810 <iupdate> iunlock(ip); 80105afd: 89 1c 24 mov %ebx,(%esp) 80105b00: e8 9b be ff ff call 801019a0 <iunlock> if((dp = nameiparent(new, name)) == 0) 80105b05: 58 pop %eax 80105b06: 5a pop %edx 80105b07: 57 push %edi 80105b08: ff 75 d0 pushl -0x30(%ebp) 80105b0b: e8 20 c6 ff ff call 80102130 <nameiparent> 80105b10: 83 c4 10 add $0x10,%esp 80105b13: 85 c0 test %eax,%eax 80105b15: 89 c6 mov %eax,%esi 80105b17: 74 5b je 80105b74 <sys_link+0xf4> goto bad; ilock(dp); 80105b19: 83 ec 0c sub $0xc,%esp 80105b1c: 50 push %eax 80105b1d: e8 9e bd ff ff call 801018c0 <ilock> if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ 80105b22: 83 c4 10 add $0x10,%esp 80105b25: 8b 03 mov (%ebx),%eax 80105b27: 39 06 cmp %eax,(%esi) 80105b29: 75 3d jne 80105b68 <sys_link+0xe8> 80105b2b: 83 ec 04 sub $0x4,%esp 80105b2e: ff 73 04 pushl 0x4(%ebx) 80105b31: 57 push %edi 80105b32: 56 push %esi 80105b33: e8 18 c5 ff ff call 80102050 <dirlink> 80105b38: 83 c4 10 add $0x10,%esp 80105b3b: 85 c0 test %eax,%eax 80105b3d: 78 29 js 80105b68 <sys_link+0xe8> iunlockput(dp); goto bad; } iunlockput(dp); 80105b3f: 83 ec 0c sub $0xc,%esp 80105b42: 56 push %esi 80105b43: e8 08 c0 ff ff call 80101b50 <iunlockput> iput(ip); 80105b48: 89 1c 24 mov %ebx,(%esp) 80105b4b: e8 a0 be ff ff call 801019f0 <iput> end_op(); 80105b50: e8 bb d2 ff ff call 80102e10 <end_op> return 0; 80105b55: 83 c4 10 add $0x10,%esp 80105b58: 31 c0 xor %eax,%eax ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; } 80105b5a: 8d 65 f4 lea -0xc(%ebp),%esp 80105b5d: 5b pop %ebx 80105b5e: 5e pop %esi 80105b5f: 5f pop %edi 80105b60: 5d pop %ebp 80105b61: c3 ret 80105b62: 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); 80105b68: 83 ec 0c sub $0xc,%esp 80105b6b: 56 push %esi 80105b6c: e8 df bf ff ff call 80101b50 <iunlockput> goto bad; 80105b71: 83 c4 10 add $0x10,%esp end_op(); return 0; bad: ilock(ip); 80105b74: 83 ec 0c sub $0xc,%esp 80105b77: 53 push %ebx 80105b78: e8 43 bd ff ff call 801018c0 <ilock> ip->nlink--; 80105b7d: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80105b82: 89 1c 24 mov %ebx,(%esp) 80105b85: e8 86 bc ff ff call 80101810 <iupdate> iunlockput(ip); 80105b8a: 89 1c 24 mov %ebx,(%esp) 80105b8d: e8 be bf ff ff call 80101b50 <iunlockput> end_op(); 80105b92: e8 79 d2 ff ff call 80102e10 <end_op> return -1; 80105b97: 83 c4 10 add $0x10,%esp } 80105b9a: 8d 65 f4 lea -0xc(%ebp),%esp ilock(ip); ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; 80105b9d: b8 ff ff ff ff mov $0xffffffff,%eax } 80105ba2: 5b pop %ebx 80105ba3: 5e pop %esi 80105ba4: 5f pop %edi 80105ba5: 5d pop %ebp 80105ba6: c3 ret 80105ba7: 89 f6 mov %esi,%esi 80105ba9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi return -1; } ilock(ip); if(ip->type == T_DIR){ iunlockput(ip); 80105bb0: 83 ec 0c sub $0xc,%esp 80105bb3: 53 push %ebx 80105bb4: e8 97 bf ff ff call 80101b50 <iunlockput> end_op(); 80105bb9: e8 52 d2 ff ff call 80102e10 <end_op> return -1; 80105bbe: 83 c4 10 add $0x10,%esp 80105bc1: b8 ff ff ff ff mov $0xffffffff,%eax 80105bc6: eb 92 jmp 80105b5a <sys_link+0xda> if(argstr(0, &old) < 0 || argstr(1, &new) < 0) return -1; begin_op(); if((ip = namei(old)) == 0){ end_op(); 80105bc8: e8 43 d2 ff ff call 80102e10 <end_op> return -1; 80105bcd: b8 ff ff ff ff mov $0xffffffff,%eax 80105bd2: eb 86 jmp 80105b5a <sys_link+0xda> 80105bd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105bda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80105be0 <sys_unlink>: } //PAGEBREAK! int sys_unlink(void) { 80105be0: 55 push %ebp 80105be1: 89 e5 mov %esp,%ebp 80105be3: 57 push %edi 80105be4: 56 push %esi 80105be5: 53 push %ebx struct inode *ip, *dp; struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) 80105be6: 8d 45 c0 lea -0x40(%ebp),%eax } //PAGEBREAK! int sys_unlink(void) { 80105be9: 83 ec 54 sub $0x54,%esp struct inode *ip, *dp; struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) 80105bec: 50 push %eax 80105bed: 6a 00 push $0x0 80105bef: e8 fc f9 ff ff call 801055f0 <argstr> 80105bf4: 83 c4 10 add $0x10,%esp 80105bf7: 85 c0 test %eax,%eax 80105bf9: 0f 88 82 01 00 00 js 80105d81 <sys_unlink+0x1a1> return -1; begin_op(); if((dp = nameiparent(path, name)) == 0){ 80105bff: 8d 5d ca lea -0x36(%ebp),%ebx uint off; if(argstr(0, &path) < 0) return -1; begin_op(); 80105c02: e8 99 d1 ff ff call 80102da0 <begin_op> if((dp = nameiparent(path, name)) == 0){ 80105c07: 83 ec 08 sub $0x8,%esp 80105c0a: 53 push %ebx 80105c0b: ff 75 c0 pushl -0x40(%ebp) 80105c0e: e8 1d c5 ff ff call 80102130 <nameiparent> 80105c13: 83 c4 10 add $0x10,%esp 80105c16: 85 c0 test %eax,%eax 80105c18: 89 45 b4 mov %eax,-0x4c(%ebp) 80105c1b: 0f 84 6a 01 00 00 je 80105d8b <sys_unlink+0x1ab> end_op(); return -1; } ilock(dp); 80105c21: 8b 75 b4 mov -0x4c(%ebp),%esi 80105c24: 83 ec 0c sub $0xc,%esp 80105c27: 56 push %esi 80105c28: e8 93 bc ff ff call 801018c0 <ilock> // Cannot unlink "." or "..". if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) 80105c2d: 58 pop %eax 80105c2e: 5a pop %edx 80105c2f: 68 3c 89 10 80 push $0x8010893c 80105c34: 53 push %ebx 80105c35: e8 96 c1 ff ff call 80101dd0 <namecmp> 80105c3a: 83 c4 10 add $0x10,%esp 80105c3d: 85 c0 test %eax,%eax 80105c3f: 0f 84 fc 00 00 00 je 80105d41 <sys_unlink+0x161> 80105c45: 83 ec 08 sub $0x8,%esp 80105c48: 68 3b 89 10 80 push $0x8010893b 80105c4d: 53 push %ebx 80105c4e: e8 7d c1 ff ff call 80101dd0 <namecmp> 80105c53: 83 c4 10 add $0x10,%esp 80105c56: 85 c0 test %eax,%eax 80105c58: 0f 84 e3 00 00 00 je 80105d41 <sys_unlink+0x161> goto bad; if((ip = dirlookup(dp, name, &off)) == 0) 80105c5e: 8d 45 c4 lea -0x3c(%ebp),%eax 80105c61: 83 ec 04 sub $0x4,%esp 80105c64: 50 push %eax 80105c65: 53 push %ebx 80105c66: 56 push %esi 80105c67: e8 84 c1 ff ff call 80101df0 <dirlookup> 80105c6c: 83 c4 10 add $0x10,%esp 80105c6f: 85 c0 test %eax,%eax 80105c71: 89 c3 mov %eax,%ebx 80105c73: 0f 84 c8 00 00 00 je 80105d41 <sys_unlink+0x161> goto bad; ilock(ip); 80105c79: 83 ec 0c sub $0xc,%esp 80105c7c: 50 push %eax 80105c7d: e8 3e bc ff ff call 801018c0 <ilock> if(ip->nlink < 1) 80105c82: 83 c4 10 add $0x10,%esp 80105c85: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) 80105c8a: 0f 8e 24 01 00 00 jle 80105db4 <sys_unlink+0x1d4> panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ 80105c90: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80105c95: 8d 75 d8 lea -0x28(%ebp),%esi 80105c98: 74 66 je 80105d00 <sys_unlink+0x120> iunlockput(ip); goto bad; } memset(&de, 0, sizeof(de)); 80105c9a: 83 ec 04 sub $0x4,%esp 80105c9d: 6a 10 push $0x10 80105c9f: 6a 00 push $0x0 80105ca1: 56 push %esi 80105ca2: e8 89 f5 ff ff call 80105230 <memset> if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80105ca7: 6a 10 push $0x10 80105ca9: ff 75 c4 pushl -0x3c(%ebp) 80105cac: 56 push %esi 80105cad: ff 75 b4 pushl -0x4c(%ebp) 80105cb0: e8 eb bf ff ff call 80101ca0 <writei> 80105cb5: 83 c4 20 add $0x20,%esp 80105cb8: 83 f8 10 cmp $0x10,%eax 80105cbb: 0f 85 e6 00 00 00 jne 80105da7 <sys_unlink+0x1c7> panic("unlink: writei"); if(ip->type == T_DIR){ 80105cc1: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80105cc6: 0f 84 9c 00 00 00 je 80105d68 <sys_unlink+0x188> dp->nlink--; iupdate(dp); } iunlockput(dp); 80105ccc: 83 ec 0c sub $0xc,%esp 80105ccf: ff 75 b4 pushl -0x4c(%ebp) 80105cd2: e8 79 be ff ff call 80101b50 <iunlockput> ip->nlink--; 80105cd7: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80105cdc: 89 1c 24 mov %ebx,(%esp) 80105cdf: e8 2c bb ff ff call 80101810 <iupdate> iunlockput(ip); 80105ce4: 89 1c 24 mov %ebx,(%esp) 80105ce7: e8 64 be ff ff call 80101b50 <iunlockput> end_op(); 80105cec: e8 1f d1 ff ff call 80102e10 <end_op> return 0; 80105cf1: 83 c4 10 add $0x10,%esp 80105cf4: 31 c0 xor %eax,%eax bad: iunlockput(dp); end_op(); return -1; } 80105cf6: 8d 65 f4 lea -0xc(%ebp),%esp 80105cf9: 5b pop %ebx 80105cfa: 5e pop %esi 80105cfb: 5f pop %edi 80105cfc: 5d pop %ebp 80105cfd: c3 ret 80105cfe: 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)){ 80105d00: 83 7b 58 20 cmpl $0x20,0x58(%ebx) 80105d04: 76 94 jbe 80105c9a <sys_unlink+0xba> 80105d06: bf 20 00 00 00 mov $0x20,%edi 80105d0b: eb 0f jmp 80105d1c <sys_unlink+0x13c> 80105d0d: 8d 76 00 lea 0x0(%esi),%esi 80105d10: 83 c7 10 add $0x10,%edi 80105d13: 3b 7b 58 cmp 0x58(%ebx),%edi 80105d16: 0f 83 7e ff ff ff jae 80105c9a <sys_unlink+0xba> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80105d1c: 6a 10 push $0x10 80105d1e: 57 push %edi 80105d1f: 56 push %esi 80105d20: 53 push %ebx 80105d21: e8 7a be ff ff call 80101ba0 <readi> 80105d26: 83 c4 10 add $0x10,%esp 80105d29: 83 f8 10 cmp $0x10,%eax 80105d2c: 75 6c jne 80105d9a <sys_unlink+0x1ba> panic("isdirempty: readi"); if(de.inum != 0) 80105d2e: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80105d33: 74 db je 80105d10 <sys_unlink+0x130> ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ iunlockput(ip); 80105d35: 83 ec 0c sub $0xc,%esp 80105d38: 53 push %ebx 80105d39: e8 12 be ff ff call 80101b50 <iunlockput> goto bad; 80105d3e: 83 c4 10 add $0x10,%esp end_op(); return 0; bad: iunlockput(dp); 80105d41: 83 ec 0c sub $0xc,%esp 80105d44: ff 75 b4 pushl -0x4c(%ebp) 80105d47: e8 04 be ff ff call 80101b50 <iunlockput> end_op(); 80105d4c: e8 bf d0 ff ff call 80102e10 <end_op> return -1; 80105d51: 83 c4 10 add $0x10,%esp } 80105d54: 8d 65 f4 lea -0xc(%ebp),%esp return 0; bad: iunlockput(dp); end_op(); return -1; 80105d57: b8 ff ff ff ff mov $0xffffffff,%eax } 80105d5c: 5b pop %ebx 80105d5d: 5e pop %esi 80105d5e: 5f pop %edi 80105d5f: 5d pop %ebp 80105d60: c3 ret 80105d61: 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--; 80105d68: 8b 45 b4 mov -0x4c(%ebp),%eax iupdate(dp); 80105d6b: 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--; 80105d6e: 66 83 68 56 01 subw $0x1,0x56(%eax) iupdate(dp); 80105d73: 50 push %eax 80105d74: e8 97 ba ff ff call 80101810 <iupdate> 80105d79: 83 c4 10 add $0x10,%esp 80105d7c: e9 4b ff ff ff jmp 80105ccc <sys_unlink+0xec> struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) return -1; 80105d81: b8 ff ff ff ff mov $0xffffffff,%eax 80105d86: e9 6b ff ff ff jmp 80105cf6 <sys_unlink+0x116> begin_op(); if((dp = nameiparent(path, name)) == 0){ end_op(); 80105d8b: e8 80 d0 ff ff call 80102e10 <end_op> return -1; 80105d90: b8 ff ff ff ff mov $0xffffffff,%eax 80105d95: e9 5c ff ff ff jmp 80105cf6 <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"); 80105d9a: 83 ec 0c sub $0xc,%esp 80105d9d: 68 60 89 10 80 push $0x80108960 80105da2: e8 c9 a5 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"); 80105da7: 83 ec 0c sub $0xc,%esp 80105daa: 68 72 89 10 80 push $0x80108972 80105daf: e8 bc a5 ff ff call 80100370 <panic> if((ip = dirlookup(dp, name, &off)) == 0) goto bad; ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); 80105db4: 83 ec 0c sub $0xc,%esp 80105db7: 68 4e 89 10 80 push $0x8010894e 80105dbc: e8 af a5 ff ff call 80100370 <panic> 80105dc1: eb 0d jmp 80105dd0 <sys_open> 80105dc3: 90 nop 80105dc4: 90 nop 80105dc5: 90 nop 80105dc6: 90 nop 80105dc7: 90 nop 80105dc8: 90 nop 80105dc9: 90 nop 80105dca: 90 nop 80105dcb: 90 nop 80105dcc: 90 nop 80105dcd: 90 nop 80105dce: 90 nop 80105dcf: 90 nop 80105dd0 <sys_open>: return ip; } int sys_open(void) { 80105dd0: 55 push %ebp 80105dd1: 89 e5 mov %esp,%ebp 80105dd3: 57 push %edi 80105dd4: 56 push %esi 80105dd5: 53 push %ebx char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80105dd6: 8d 45 e0 lea -0x20(%ebp),%eax return ip; } int sys_open(void) { 80105dd9: 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) 80105ddc: 50 push %eax 80105ddd: 6a 00 push $0x0 80105ddf: e8 0c f8 ff ff call 801055f0 <argstr> 80105de4: 83 c4 10 add $0x10,%esp 80105de7: 85 c0 test %eax,%eax 80105de9: 0f 88 9e 00 00 00 js 80105e8d <sys_open+0xbd> 80105def: 8d 45 e4 lea -0x1c(%ebp),%eax 80105df2: 83 ec 08 sub $0x8,%esp 80105df5: 50 push %eax 80105df6: 6a 01 push $0x1 80105df8: e8 43 f7 ff ff call 80105540 <argint> 80105dfd: 83 c4 10 add $0x10,%esp 80105e00: 85 c0 test %eax,%eax 80105e02: 0f 88 85 00 00 00 js 80105e8d <sys_open+0xbd> return -1; begin_op(); 80105e08: e8 93 cf ff ff call 80102da0 <begin_op> if(omode & O_CREATE){ 80105e0d: f6 45 e5 02 testb $0x2,-0x1b(%ebp) 80105e11: 0f 85 89 00 00 00 jne 80105ea0 <sys_open+0xd0> if(ip == 0){ end_op(); return -1; } } else { if((ip = namei(path)) == 0){ 80105e17: 83 ec 0c sub $0xc,%esp 80105e1a: ff 75 e0 pushl -0x20(%ebp) 80105e1d: e8 ee c2 ff ff call 80102110 <namei> 80105e22: 83 c4 10 add $0x10,%esp 80105e25: 85 c0 test %eax,%eax 80105e27: 89 c6 mov %eax,%esi 80105e29: 0f 84 8e 00 00 00 je 80105ebd <sys_open+0xed> end_op(); return -1; } ilock(ip); 80105e2f: 83 ec 0c sub $0xc,%esp 80105e32: 50 push %eax 80105e33: e8 88 ba ff ff call 801018c0 <ilock> if(ip->type == T_DIR && omode != O_RDONLY){ 80105e38: 83 c4 10 add $0x10,%esp 80105e3b: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80105e40: 0f 84 d2 00 00 00 je 80105f18 <sys_open+0x148> end_op(); return -1; } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ 80105e46: e8 85 b1 ff ff call 80100fd0 <filealloc> 80105e4b: 85 c0 test %eax,%eax 80105e4d: 89 c7 mov %eax,%edi 80105e4f: 74 2b je 80105e7c <sys_open+0xac> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80105e51: 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(); 80105e53: e8 d8 db ff ff call 80103a30 <myproc> 80105e58: 90 nop 80105e59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ 80105e60: 8b 54 98 28 mov 0x28(%eax,%ebx,4),%edx 80105e64: 85 d2 test %edx,%edx 80105e66: 74 68 je 80105ed0 <sys_open+0x100> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80105e68: 83 c3 01 add $0x1,%ebx 80105e6b: 83 fb 10 cmp $0x10,%ebx 80105e6e: 75 f0 jne 80105e60 <sys_open+0x90> } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); 80105e70: 83 ec 0c sub $0xc,%esp 80105e73: 57 push %edi 80105e74: e8 17 b2 ff ff call 80101090 <fileclose> 80105e79: 83 c4 10 add $0x10,%esp iunlockput(ip); 80105e7c: 83 ec 0c sub $0xc,%esp 80105e7f: 56 push %esi 80105e80: e8 cb bc ff ff call 80101b50 <iunlockput> end_op(); 80105e85: e8 86 cf ff ff call 80102e10 <end_op> return -1; 80105e8a: 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; } 80105e8d: 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; 80105e90: 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; } 80105e95: 5b pop %ebx 80105e96: 5e pop %esi 80105e97: 5f pop %edi 80105e98: 5d pop %ebp 80105e99: c3 ret 80105e9a: 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); 80105ea0: 83 ec 0c sub $0xc,%esp 80105ea3: 8b 45 e0 mov -0x20(%ebp),%eax 80105ea6: 31 c9 xor %ecx,%ecx 80105ea8: 6a 00 push $0x0 80105eaa: ba 02 00 00 00 mov $0x2,%edx 80105eaf: e8 dc f7 ff ff call 80105690 <create> if(ip == 0){ 80105eb4: 83 c4 10 add $0x10,%esp 80105eb7: 85 c0 test %eax,%eax return -1; begin_op(); if(omode & O_CREATE){ ip = create(path, T_FILE, 0, 0); 80105eb9: 89 c6 mov %eax,%esi if(ip == 0){ 80105ebb: 75 89 jne 80105e46 <sys_open+0x76> end_op(); 80105ebd: e8 4e cf ff ff call 80102e10 <end_op> return -1; 80105ec2: b8 ff ff ff ff mov $0xffffffff,%eax 80105ec7: eb 43 jmp 80105f0c <sys_open+0x13c> 80105ec9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80105ed0: 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; 80105ed3: 89 7c 98 28 mov %edi,0x28(%eax,%ebx,4) fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80105ed7: 56 push %esi 80105ed8: e8 c3 ba ff ff call 801019a0 <iunlock> end_op(); 80105edd: e8 2e cf ff ff call 80102e10 <end_op> f->type = FD_INODE; 80105ee2: c7 07 02 00 00 00 movl $0x2,(%edi) f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80105ee8: 8b 55 e4 mov -0x1c(%ebp),%edx f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80105eeb: 83 c4 10 add $0x10,%esp } iunlock(ip); end_op(); f->type = FD_INODE; f->ip = ip; 80105eee: 89 77 10 mov %esi,0x10(%edi) f->off = 0; 80105ef1: c7 47 14 00 00 00 00 movl $0x0,0x14(%edi) f->readable = !(omode & O_WRONLY); 80105ef8: 89 d0 mov %edx,%eax 80105efa: 83 e0 01 and $0x1,%eax 80105efd: 83 f0 01 xor $0x1,%eax f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80105f00: 83 e2 03 and $0x3,%edx end_op(); f->type = FD_INODE; f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80105f03: 88 47 08 mov %al,0x8(%edi) f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80105f06: 0f 95 47 09 setne 0x9(%edi) return fd; 80105f0a: 89 d8 mov %ebx,%eax } 80105f0c: 8d 65 f4 lea -0xc(%ebp),%esp 80105f0f: 5b pop %ebx 80105f10: 5e pop %esi 80105f11: 5f pop %edi 80105f12: 5d pop %ebp 80105f13: c3 ret 80105f14: 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){ 80105f18: 8b 4d e4 mov -0x1c(%ebp),%ecx 80105f1b: 85 c9 test %ecx,%ecx 80105f1d: 0f 84 23 ff ff ff je 80105e46 <sys_open+0x76> 80105f23: e9 54 ff ff ff jmp 80105e7c <sys_open+0xac> 80105f28: 90 nop 80105f29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105f30 <sys_mkdir>: return fd; } int sys_mkdir(void) { 80105f30: 55 push %ebp 80105f31: 89 e5 mov %esp,%ebp 80105f33: 83 ec 18 sub $0x18,%esp char *path; struct inode *ip; begin_op(); 80105f36: e8 65 ce ff ff call 80102da0 <begin_op> if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ 80105f3b: 8d 45 f4 lea -0xc(%ebp),%eax 80105f3e: 83 ec 08 sub $0x8,%esp 80105f41: 50 push %eax 80105f42: 6a 00 push $0x0 80105f44: e8 a7 f6 ff ff call 801055f0 <argstr> 80105f49: 83 c4 10 add $0x10,%esp 80105f4c: 85 c0 test %eax,%eax 80105f4e: 78 30 js 80105f80 <sys_mkdir+0x50> 80105f50: 83 ec 0c sub $0xc,%esp 80105f53: 8b 45 f4 mov -0xc(%ebp),%eax 80105f56: 31 c9 xor %ecx,%ecx 80105f58: 6a 00 push $0x0 80105f5a: ba 01 00 00 00 mov $0x1,%edx 80105f5f: e8 2c f7 ff ff call 80105690 <create> 80105f64: 83 c4 10 add $0x10,%esp 80105f67: 85 c0 test %eax,%eax 80105f69: 74 15 je 80105f80 <sys_mkdir+0x50> end_op(); return -1; } iunlockput(ip); 80105f6b: 83 ec 0c sub $0xc,%esp 80105f6e: 50 push %eax 80105f6f: e8 dc bb ff ff call 80101b50 <iunlockput> end_op(); 80105f74: e8 97 ce ff ff call 80102e10 <end_op> return 0; 80105f79: 83 c4 10 add $0x10,%esp 80105f7c: 31 c0 xor %eax,%eax } 80105f7e: c9 leave 80105f7f: c3 ret char *path; struct inode *ip; begin_op(); if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ end_op(); 80105f80: e8 8b ce ff ff call 80102e10 <end_op> return -1; 80105f85: b8 ff ff ff ff mov $0xffffffff,%eax } iunlockput(ip); end_op(); return 0; } 80105f8a: c9 leave 80105f8b: c3 ret 80105f8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105f90 <sys_mknod>: int sys_mknod(void) { 80105f90: 55 push %ebp 80105f91: 89 e5 mov %esp,%ebp 80105f93: 83 ec 18 sub $0x18,%esp struct inode *ip; char *path; int major, minor; begin_op(); 80105f96: e8 05 ce ff ff call 80102da0 <begin_op> if((argstr(0, &path)) < 0 || 80105f9b: 8d 45 ec lea -0x14(%ebp),%eax 80105f9e: 83 ec 08 sub $0x8,%esp 80105fa1: 50 push %eax 80105fa2: 6a 00 push $0x0 80105fa4: e8 47 f6 ff ff call 801055f0 <argstr> 80105fa9: 83 c4 10 add $0x10,%esp 80105fac: 85 c0 test %eax,%eax 80105fae: 78 60 js 80106010 <sys_mknod+0x80> argint(1, &major) < 0 || 80105fb0: 8d 45 f0 lea -0x10(%ebp),%eax 80105fb3: 83 ec 08 sub $0x8,%esp 80105fb6: 50 push %eax 80105fb7: 6a 01 push $0x1 80105fb9: e8 82 f5 ff ff call 80105540 <argint> struct inode *ip; char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || 80105fbe: 83 c4 10 add $0x10,%esp 80105fc1: 85 c0 test %eax,%eax 80105fc3: 78 4b js 80106010 <sys_mknod+0x80> argint(1, &major) < 0 || argint(2, &minor) < 0 || 80105fc5: 8d 45 f4 lea -0xc(%ebp),%eax 80105fc8: 83 ec 08 sub $0x8,%esp 80105fcb: 50 push %eax 80105fcc: 6a 02 push $0x2 80105fce: e8 6d f5 ff ff call 80105540 <argint> char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || 80105fd3: 83 c4 10 add $0x10,%esp 80105fd6: 85 c0 test %eax,%eax 80105fd8: 78 36 js 80106010 <sys_mknod+0x80> argint(2, &minor) < 0 || 80105fda: 0f bf 45 f4 movswl -0xc(%ebp),%eax 80105fde: 83 ec 0c sub $0xc,%esp 80105fe1: 0f bf 4d f0 movswl -0x10(%ebp),%ecx 80105fe5: ba 03 00 00 00 mov $0x3,%edx 80105fea: 50 push %eax 80105feb: 8b 45 ec mov -0x14(%ebp),%eax 80105fee: e8 9d f6 ff ff call 80105690 <create> 80105ff3: 83 c4 10 add $0x10,%esp 80105ff6: 85 c0 test %eax,%eax 80105ff8: 74 16 je 80106010 <sys_mknod+0x80> (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); return -1; } iunlockput(ip); 80105ffa: 83 ec 0c sub $0xc,%esp 80105ffd: 50 push %eax 80105ffe: e8 4d bb ff ff call 80101b50 <iunlockput> end_op(); 80106003: e8 08 ce ff ff call 80102e10 <end_op> return 0; 80106008: 83 c4 10 add $0x10,%esp 8010600b: 31 c0 xor %eax,%eax } 8010600d: c9 leave 8010600e: c3 ret 8010600f: 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(); 80106010: e8 fb cd ff ff call 80102e10 <end_op> return -1; 80106015: b8 ff ff ff ff mov $0xffffffff,%eax } iunlockput(ip); end_op(); return 0; } 8010601a: c9 leave 8010601b: c3 ret 8010601c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106020 <sys_chdir>: int sys_chdir(void) { 80106020: 55 push %ebp 80106021: 89 e5 mov %esp,%ebp 80106023: 56 push %esi 80106024: 53 push %ebx 80106025: 83 ec 10 sub $0x10,%esp char *path; struct inode *ip; struct proc *curproc = myproc(); 80106028: e8 03 da ff ff call 80103a30 <myproc> 8010602d: 89 c6 mov %eax,%esi begin_op(); 8010602f: e8 6c cd ff ff call 80102da0 <begin_op> if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ 80106034: 8d 45 f4 lea -0xc(%ebp),%eax 80106037: 83 ec 08 sub $0x8,%esp 8010603a: 50 push %eax 8010603b: 6a 00 push $0x0 8010603d: e8 ae f5 ff ff call 801055f0 <argstr> 80106042: 83 c4 10 add $0x10,%esp 80106045: 85 c0 test %eax,%eax 80106047: 78 77 js 801060c0 <sys_chdir+0xa0> 80106049: 83 ec 0c sub $0xc,%esp 8010604c: ff 75 f4 pushl -0xc(%ebp) 8010604f: e8 bc c0 ff ff call 80102110 <namei> 80106054: 83 c4 10 add $0x10,%esp 80106057: 85 c0 test %eax,%eax 80106059: 89 c3 mov %eax,%ebx 8010605b: 74 63 je 801060c0 <sys_chdir+0xa0> end_op(); return -1; } ilock(ip); 8010605d: 83 ec 0c sub $0xc,%esp 80106060: 50 push %eax 80106061: e8 5a b8 ff ff call 801018c0 <ilock> if(ip->type != T_DIR){ 80106066: 83 c4 10 add $0x10,%esp 80106069: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 8010606e: 75 30 jne 801060a0 <sys_chdir+0x80> iunlockput(ip); end_op(); return -1; } iunlock(ip); 80106070: 83 ec 0c sub $0xc,%esp 80106073: 53 push %ebx 80106074: e8 27 b9 ff ff call 801019a0 <iunlock> iput(curproc->cwd); 80106079: 58 pop %eax 8010607a: ff 76 68 pushl 0x68(%esi) 8010607d: e8 6e b9 ff ff call 801019f0 <iput> end_op(); 80106082: e8 89 cd ff ff call 80102e10 <end_op> curproc->cwd = ip; 80106087: 89 5e 68 mov %ebx,0x68(%esi) return 0; 8010608a: 83 c4 10 add $0x10,%esp 8010608d: 31 c0 xor %eax,%eax } 8010608f: 8d 65 f8 lea -0x8(%ebp),%esp 80106092: 5b pop %ebx 80106093: 5e pop %esi 80106094: 5d pop %ebp 80106095: c3 ret 80106096: 8d 76 00 lea 0x0(%esi),%esi 80106099: 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); 801060a0: 83 ec 0c sub $0xc,%esp 801060a3: 53 push %ebx 801060a4: e8 a7 ba ff ff call 80101b50 <iunlockput> end_op(); 801060a9: e8 62 cd ff ff call 80102e10 <end_op> return -1; 801060ae: 83 c4 10 add $0x10,%esp 801060b1: b8 ff ff ff ff mov $0xffffffff,%eax 801060b6: eb d7 jmp 8010608f <sys_chdir+0x6f> 801060b8: 90 nop 801060b9: 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(); 801060c0: e8 4b cd ff ff call 80102e10 <end_op> return -1; 801060c5: b8 ff ff ff ff mov $0xffffffff,%eax 801060ca: eb c3 jmp 8010608f <sys_chdir+0x6f> 801060cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801060d0 <sys_exec>: return 0; } int sys_exec(void) { 801060d0: 55 push %ebp 801060d1: 89 e5 mov %esp,%ebp 801060d3: 57 push %edi 801060d4: 56 push %esi 801060d5: 53 push %ebx char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 801060d6: 8d 85 5c ff ff ff lea -0xa4(%ebp),%eax return 0; } int sys_exec(void) { 801060dc: 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){ 801060e2: 50 push %eax 801060e3: 6a 00 push $0x0 801060e5: e8 06 f5 ff ff call 801055f0 <argstr> 801060ea: 83 c4 10 add $0x10,%esp 801060ed: 85 c0 test %eax,%eax 801060ef: 0f 88 ab 00 00 00 js 801061a0 <sys_exec+0xd0> 801060f5: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax 801060fb: 83 ec 08 sub $0x8,%esp 801060fe: 50 push %eax 801060ff: 6a 01 push $0x1 80106101: e8 3a f4 ff ff call 80105540 <argint> 80106106: 83 c4 10 add $0x10,%esp 80106109: 85 c0 test %eax,%eax 8010610b: 0f 88 8f 00 00 00 js 801061a0 <sys_exec+0xd0> return -1; } cprintf("1\n"); 80106111: 83 ec 0c sub $0xc,%esp 80106114: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi 8010611a: 8d bd 64 ff ff ff lea -0x9c(%ebp),%edi 80106120: 68 81 89 10 80 push $0x80108981 cprintf("%s\n",path); memset(argv, 0, sizeof(argv)); 80106125: 31 db xor %ebx,%ebx uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; } cprintf("1\n"); 80106127: e8 34 a5 ff ff call 80100660 <cprintf> cprintf("%s\n",path); 8010612c: 58 pop %eax 8010612d: 5a pop %edx 8010612e: ff b5 5c ff ff ff pushl -0xa4(%ebp) 80106134: 68 84 89 10 80 push $0x80108984 80106139: e8 22 a5 ff ff call 80100660 <cprintf> memset(argv, 0, sizeof(argv)); 8010613e: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 80106144: 83 c4 0c add $0xc,%esp 80106147: 68 80 00 00 00 push $0x80 8010614c: 6a 00 push $0x0 8010614e: 50 push %eax 8010614f: e8 dc f0 ff ff call 80105230 <memset> 80106154: 83 c4 10 add $0x10,%esp 80106157: 89 f6 mov %esi,%esi 80106159: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi for(i=0;; i++){ if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) 80106160: 8b 85 60 ff ff ff mov -0xa0(%ebp),%eax 80106166: 83 ec 08 sub $0x8,%esp 80106169: 57 push %edi 8010616a: 8d 04 98 lea (%eax,%ebx,4),%eax 8010616d: 50 push %eax 8010616e: e8 2d f3 ff ff call 801054a0 <fetchint> 80106173: 83 c4 10 add $0x10,%esp 80106176: 85 c0 test %eax,%eax 80106178: 78 26 js 801061a0 <sys_exec+0xd0> return -1; if(uarg == 0){ 8010617a: 8b 85 64 ff ff ff mov -0x9c(%ebp),%eax 80106180: 85 c0 test %eax,%eax 80106182: 74 2c je 801061b0 <sys_exec+0xe0> argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) 80106184: 83 ec 08 sub $0x8,%esp 80106187: 56 push %esi 80106188: 50 push %eax 80106189: e8 52 f3 ff ff call 801054e0 <fetchstr> 8010618e: 83 c4 10 add $0x10,%esp 80106191: 85 c0 test %eax,%eax 80106193: 78 0b js 801061a0 <sys_exec+0xd0> return -1; } cprintf("1\n"); cprintf("%s\n",path); memset(argv, 0, sizeof(argv)); for(i=0;; i++){ 80106195: 83 c3 01 add $0x1,%ebx 80106198: 83 c6 04 add $0x4,%esi if(i >= NELEM(argv)) 8010619b: 83 fb 20 cmp $0x20,%ebx 8010619e: 75 c0 jne 80106160 <sys_exec+0x90> } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); } 801061a0: 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; 801061a3: b8 ff ff ff ff mov $0xffffffff,%eax } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); } 801061a8: 5b pop %ebx 801061a9: 5e pop %esi 801061aa: 5f pop %edi 801061ab: 5d pop %ebp 801061ac: c3 ret 801061ad: 8d 76 00 lea 0x0(%esi),%esi break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 801061b0: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 801061b6: 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; 801061b9: c7 84 9d 68 ff ff ff movl $0x0,-0x98(%ebp,%ebx,4) 801061c0: 00 00 00 00 break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 801061c4: 50 push %eax 801061c5: ff b5 5c ff ff ff pushl -0xa4(%ebp) 801061cb: e8 40 a8 ff ff call 80100a10 <exec> 801061d0: 83 c4 10 add $0x10,%esp } 801061d3: 8d 65 f4 lea -0xc(%ebp),%esp 801061d6: 5b pop %ebx 801061d7: 5e pop %esi 801061d8: 5f pop %edi 801061d9: 5d pop %ebp 801061da: c3 ret 801061db: 90 nop 801061dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801061e0 <sys_pipe>: int sys_pipe(void) { 801061e0: 55 push %ebp 801061e1: 89 e5 mov %esp,%ebp 801061e3: 57 push %edi 801061e4: 56 push %esi 801061e5: 53 push %ebx int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 801061e6: 8d 45 dc lea -0x24(%ebp),%eax return exec(path, argv); } int sys_pipe(void) { 801061e9: 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) 801061ec: 6a 08 push $0x8 801061ee: 50 push %eax 801061ef: 6a 00 push $0x0 801061f1: e8 9a f3 ff ff call 80105590 <argptr> 801061f6: 83 c4 10 add $0x10,%esp 801061f9: 85 c0 test %eax,%eax 801061fb: 78 4a js 80106247 <sys_pipe+0x67> return -1; if(pipealloc(&rf, &wf) < 0) 801061fd: 8d 45 e4 lea -0x1c(%ebp),%eax 80106200: 83 ec 08 sub $0x8,%esp 80106203: 50 push %eax 80106204: 8d 45 e0 lea -0x20(%ebp),%eax 80106207: 50 push %eax 80106208: e8 33 d2 ff ff call 80103440 <pipealloc> 8010620d: 83 c4 10 add $0x10,%esp 80106210: 85 c0 test %eax,%eax 80106212: 78 33 js 80106247 <sys_pipe+0x67> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80106214: 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){ 80106216: 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(); 80106219: e8 12 d8 ff ff call 80103a30 <myproc> 8010621e: 66 90 xchg %ax,%ax for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ 80106220: 8b 74 98 28 mov 0x28(%eax,%ebx,4),%esi 80106224: 85 f6 test %esi,%esi 80106226: 74 30 je 80106258 <sys_pipe+0x78> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80106228: 83 c3 01 add $0x1,%ebx 8010622b: 83 fb 10 cmp $0x10,%ebx 8010622e: 75 f0 jne 80106220 <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); 80106230: 83 ec 0c sub $0xc,%esp 80106233: ff 75 e0 pushl -0x20(%ebp) 80106236: e8 55 ae ff ff call 80101090 <fileclose> fileclose(wf); 8010623b: 58 pop %eax 8010623c: ff 75 e4 pushl -0x1c(%ebp) 8010623f: e8 4c ae ff ff call 80101090 <fileclose> return -1; 80106244: 83 c4 10 add $0x10,%esp } fd[0] = fd0; fd[1] = fd1; return 0; } 80106247: 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; 8010624a: b8 ff ff ff ff mov $0xffffffff,%eax } fd[0] = fd0; fd[1] = fd1; return 0; } 8010624f: 5b pop %ebx 80106250: 5e pop %esi 80106251: 5f pop %edi 80106252: 5d pop %ebp 80106253: c3 ret 80106254: 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; 80106258: 8d 73 08 lea 0x8(%ebx),%esi 8010625b: 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){ 8010625f: 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(); 80106262: e8 c9 d7 ff ff call 80103a30 <myproc> for(fd = 0; fd < NOFILE; fd++){ 80106267: 31 d2 xor %edx,%edx 80106269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(curproc->ofile[fd] == 0){ 80106270: 8b 4c 90 28 mov 0x28(%eax,%edx,4),%ecx 80106274: 85 c9 test %ecx,%ecx 80106276: 74 18 je 80106290 <sys_pipe+0xb0> fdalloc(struct file *f) { int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ 80106278: 83 c2 01 add $0x1,%edx 8010627b: 83 fa 10 cmp $0x10,%edx 8010627e: 75 f0 jne 80106270 <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; 80106280: e8 ab d7 ff ff call 80103a30 <myproc> 80106285: c7 44 b0 08 00 00 00 movl $0x0,0x8(%eax,%esi,4) 8010628c: 00 8010628d: eb a1 jmp 80106230 <sys_pipe+0x50> 8010628f: 90 nop int fd; struct proc *curproc = myproc(); for(fd = 0; fd < NOFILE; fd++){ if(curproc->ofile[fd] == 0){ curproc->ofile[fd] = f; 80106290: 89 7c 90 28 mov %edi,0x28(%eax,%edx,4) myproc()->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; } fd[0] = fd0; 80106294: 8b 45 dc mov -0x24(%ebp),%eax 80106297: 89 18 mov %ebx,(%eax) fd[1] = fd1; 80106299: 8b 45 dc mov -0x24(%ebp),%eax 8010629c: 89 50 04 mov %edx,0x4(%eax) return 0; } 8010629f: 8d 65 f4 lea -0xc(%ebp),%esp fileclose(wf); return -1; } fd[0] = fd0; fd[1] = fd1; return 0; 801062a2: 31 c0 xor %eax,%eax } 801062a4: 5b pop %ebx 801062a5: 5e pop %esi 801062a6: 5f pop %edi 801062a7: 5d pop %ebp 801062a8: c3 ret 801062a9: 66 90 xchg %ax,%ax 801062ab: 66 90 xchg %ax,%ax 801062ad: 66 90 xchg %ax,%ax 801062af: 90 nop 801062b0 <sys_fork>: #include "mmu.h" #include "proc.h" int sys_fork(void) { 801062b0: 55 push %ebp 801062b1: 89 e5 mov %esp,%ebp return fork(); } 801062b3: 5d pop %ebp #include "proc.h" int sys_fork(void) { return fork(); 801062b4: e9 27 d9 ff ff jmp 80103be0 <fork> 801062b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801062c0 <sys_exit>: } int sys_exit(void) { 801062c0: 55 push %ebp 801062c1: 89 e5 mov %esp,%ebp 801062c3: 83 ec 08 sub $0x8,%esp exit(); 801062c6: e8 85 df ff ff call 80104250 <exit> return 0; // not reached } 801062cb: 31 c0 xor %eax,%eax 801062cd: c9 leave 801062ce: c3 ret 801062cf: 90 nop 801062d0 <sys_wait>: int sys_wait(void) { 801062d0: 55 push %ebp 801062d1: 89 e5 mov %esp,%ebp return wait(); } 801062d3: 5d pop %ebp } int sys_wait(void) { return wait(); 801062d4: e9 b7 e1 ff ff jmp 80104490 <wait> 801062d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801062e0 <sys_kill>: } int sys_kill(void) { 801062e0: 55 push %ebp 801062e1: 89 e5 mov %esp,%ebp 801062e3: 83 ec 20 sub $0x20,%esp int pid; if(argint(0, &pid) < 0) 801062e6: 8d 45 f4 lea -0xc(%ebp),%eax 801062e9: 50 push %eax 801062ea: 6a 00 push $0x0 801062ec: e8 4f f2 ff ff call 80105540 <argint> 801062f1: 83 c4 10 add $0x10,%esp 801062f4: 85 c0 test %eax,%eax 801062f6: 78 18 js 80106310 <sys_kill+0x30> return -1; return kill(pid); 801062f8: 83 ec 0c sub $0xc,%esp 801062fb: ff 75 f4 pushl -0xc(%ebp) 801062fe: e8 ed e2 ff ff call 801045f0 <kill> 80106303: 83 c4 10 add $0x10,%esp } 80106306: c9 leave 80106307: c3 ret 80106308: 90 nop 80106309: 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; 80106310: b8 ff ff ff ff mov $0xffffffff,%eax return kill(pid); } 80106315: c9 leave 80106316: c3 ret 80106317: 89 f6 mov %esi,%esi 80106319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106320 <sys_getpid>: int sys_getpid(void) { 80106320: 55 push %ebp 80106321: 89 e5 mov %esp,%ebp 80106323: 83 ec 08 sub $0x8,%esp return myproc()->pid; 80106326: e8 05 d7 ff ff call 80103a30 <myproc> 8010632b: 8b 40 10 mov 0x10(%eax),%eax } 8010632e: c9 leave 8010632f: c3 ret 80106330 <sys_get_parent_id>: int sys_get_parent_id(void) { 80106330: 55 push %ebp 80106331: 89 e5 mov %esp,%ebp 80106333: 83 ec 08 sub $0x8,%esp return myproc()->queuenum; 80106336: e8 f5 d6 ff ff call 80103a30 <myproc> 8010633b: 8b 80 80 00 00 00 mov 0x80(%eax),%eax } 80106341: c9 leave 80106342: c3 ret 80106343: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106350 <sys_getchildren>: int sys_getchildren(void) { 80106350: 55 push %ebp 80106351: 89 e5 mov %esp,%ebp 80106353: 83 ec 20 sub $0x20,%esp int pid; if(argint(0, &pid) < 0) 80106356: 8d 45 f4 lea -0xc(%ebp),%eax 80106359: 50 push %eax 8010635a: 6a 00 push $0x0 8010635c: e8 df f1 ff ff call 80105540 <argint> 80106361: 83 c4 10 add $0x10,%esp 80106364: 85 c0 test %eax,%eax 80106366: 78 18 js 80106380 <sys_getchildren+0x30> return -1; return getchildren(pid); 80106368: 83 ec 0c sub $0xc,%esp 8010636b: ff 75 f4 pushl -0xc(%ebp) 8010636e: e8 cd e3 ff ff call 80104740 <getchildren> 80106373: 83 c4 10 add $0x10,%esp } 80106376: c9 leave 80106377: c3 ret 80106378: 90 nop 80106379: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi sys_getchildren(void) { int pid; if(argint(0, &pid) < 0) return -1; 80106380: b8 ff ff ff ff mov $0xffffffff,%eax return getchildren(pid); } 80106385: c9 leave 80106386: c3 ret 80106387: 89 f6 mov %esi,%esi 80106389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106390 <sys_sbrk>: int sys_sbrk(void) { 80106390: 55 push %ebp 80106391: 89 e5 mov %esp,%ebp 80106393: 53 push %ebx int addr; int n; if(argint(0, &n) < 0) 80106394: 8d 45 f4 lea -0xc(%ebp),%eax } int sys_sbrk(void) { 80106397: 83 ec 1c sub $0x1c,%esp int addr; int n; if(argint(0, &n) < 0) 8010639a: 50 push %eax 8010639b: 6a 00 push $0x0 8010639d: e8 9e f1 ff ff call 80105540 <argint> 801063a2: 83 c4 10 add $0x10,%esp 801063a5: 85 c0 test %eax,%eax 801063a7: 78 27 js 801063d0 <sys_sbrk+0x40> return -1; addr = myproc()->sz; 801063a9: e8 82 d6 ff ff call 80103a30 <myproc> if(growproc(n) < 0) 801063ae: 83 ec 0c sub $0xc,%esp int addr; int n; if(argint(0, &n) < 0) return -1; addr = myproc()->sz; 801063b1: 8b 18 mov (%eax),%ebx if(growproc(n) < 0) 801063b3: ff 75 f4 pushl -0xc(%ebp) 801063b6: e8 a5 d7 ff ff call 80103b60 <growproc> 801063bb: 83 c4 10 add $0x10,%esp 801063be: 85 c0 test %eax,%eax 801063c0: 78 0e js 801063d0 <sys_sbrk+0x40> return -1; return addr; 801063c2: 89 d8 mov %ebx,%eax } 801063c4: 8b 5d fc mov -0x4(%ebp),%ebx 801063c7: c9 leave 801063c8: c3 ret 801063c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { int addr; int n; if(argint(0, &n) < 0) return -1; 801063d0: b8 ff ff ff ff mov $0xffffffff,%eax 801063d5: eb ed jmp 801063c4 <sys_sbrk+0x34> 801063d7: 89 f6 mov %esi,%esi 801063d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801063e0 <sys_sleep>: return addr; } int sys_sleep(void) { 801063e0: 55 push %ebp 801063e1: 89 e5 mov %esp,%ebp 801063e3: 53 push %ebx int n; uint ticks0; if(argint(0, &n) < 0) 801063e4: 8d 45 f4 lea -0xc(%ebp),%eax return addr; } int sys_sleep(void) { 801063e7: 83 ec 1c sub $0x1c,%esp int n; uint ticks0; if(argint(0, &n) < 0) 801063ea: 50 push %eax 801063eb: 6a 00 push $0x0 801063ed: e8 4e f1 ff ff call 80105540 <argint> 801063f2: 83 c4 10 add $0x10,%esp 801063f5: 85 c0 test %eax,%eax 801063f7: 0f 88 8a 00 00 00 js 80106487 <sys_sleep+0xa7> return -1; acquire(&tickslock); 801063fd: 83 ec 0c sub $0xc,%esp 80106400: 68 20 5e 11 80 push $0x80115e20 80106405: e8 26 ed ff ff call 80105130 <acquire> ticks0 = ticks; while(ticks - ticks0 < n){ 8010640a: 8b 55 f4 mov -0xc(%ebp),%edx 8010640d: 83 c4 10 add $0x10,%esp uint ticks0; if(argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; 80106410: 8b 1d 60 66 11 80 mov 0x80116660,%ebx while(ticks - ticks0 < n){ 80106416: 85 d2 test %edx,%edx 80106418: 75 27 jne 80106441 <sys_sleep+0x61> 8010641a: eb 54 jmp 80106470 <sys_sleep+0x90> 8010641c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(myproc()->killed){ release(&tickslock); return -1; } sleep(&ticks, &tickslock); 80106420: 83 ec 08 sub $0x8,%esp 80106423: 68 20 5e 11 80 push $0x80115e20 80106428: 68 60 66 11 80 push $0x80116660 8010642d: e8 9e df ff ff call 801043d0 <sleep> if(argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; while(ticks - ticks0 < n){ 80106432: a1 60 66 11 80 mov 0x80116660,%eax 80106437: 83 c4 10 add $0x10,%esp 8010643a: 29 d8 sub %ebx,%eax 8010643c: 3b 45 f4 cmp -0xc(%ebp),%eax 8010643f: 73 2f jae 80106470 <sys_sleep+0x90> if(myproc()->killed){ 80106441: e8 ea d5 ff ff call 80103a30 <myproc> 80106446: 8b 40 24 mov 0x24(%eax),%eax 80106449: 85 c0 test %eax,%eax 8010644b: 74 d3 je 80106420 <sys_sleep+0x40> release(&tickslock); 8010644d: 83 ec 0c sub $0xc,%esp 80106450: 68 20 5e 11 80 push $0x80115e20 80106455: e8 86 ed ff ff call 801051e0 <release> return -1; 8010645a: 83 c4 10 add $0x10,%esp 8010645d: b8 ff ff ff ff mov $0xffffffff,%eax } sleep(&ticks, &tickslock); } release(&tickslock); return 0; } 80106462: 8b 5d fc mov -0x4(%ebp),%ebx 80106465: c9 leave 80106466: c3 ret 80106467: 89 f6 mov %esi,%esi 80106469: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi release(&tickslock); return -1; } sleep(&ticks, &tickslock); } release(&tickslock); 80106470: 83 ec 0c sub $0xc,%esp 80106473: 68 20 5e 11 80 push $0x80115e20 80106478: e8 63 ed ff ff call 801051e0 <release> return 0; 8010647d: 83 c4 10 add $0x10,%esp 80106480: 31 c0 xor %eax,%eax } 80106482: 8b 5d fc mov -0x4(%ebp),%ebx 80106485: c9 leave 80106486: c3 ret { int n; uint ticks0; if(argint(0, &n) < 0) return -1; 80106487: b8 ff ff ff ff mov $0xffffffff,%eax 8010648c: eb d4 jmp 80106462 <sys_sleep+0x82> 8010648e: 66 90 xchg %ax,%ax 80106490 <sys_sleepp>: return 0; } int sys_sleepp(void) { 80106490: 55 push %ebp 80106491: 89 e5 mov %esp,%ebp 80106493: 53 push %ebx struct rtcdate r1; struct rtcdate r2; int n=10; argint(0 , &n); 80106494: 8d 45 c4 lea -0x3c(%ebp),%eax return 0; } int sys_sleepp(void) { 80106497: 83 ec 4c sub $0x4c,%esp struct rtcdate r1; struct rtcdate r2; int n=10; 8010649a: c7 45 c4 0a 00 00 00 movl $0xa,-0x3c(%ebp) argint(0 , &n); 801064a1: 50 push %eax 801064a2: 6a 00 push $0x0 801064a4: e8 97 f0 ff ff call 80105540 <argint> uint ticks0; cmostime(&r1); 801064a9: 8d 45 c8 lea -0x38(%ebp),%eax 801064ac: 89 04 24 mov %eax,(%esp) 801064af: e8 6c c5 ff ff call 80102a20 <cmostime> cprintf("start second:%d\n" , r1.second); 801064b4: 58 pop %eax 801064b5: 5a pop %edx 801064b6: ff 75 c8 pushl -0x38(%ebp) 801064b9: 68 88 89 10 80 push $0x80108988 801064be: e8 9d a1 ff ff call 80100660 <cprintf> cprintf("start mintute:%d\n" , r1.minute); 801064c3: 59 pop %ecx 801064c4: 5b pop %ebx 801064c5: ff 75 cc pushl -0x34(%ebp) 801064c8: 68 99 89 10 80 push $0x80108999 801064cd: e8 8e a1 ff ff call 80100660 <cprintf> acquire(&tickslock); 801064d2: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) 801064d9: e8 52 ec ff ff call 80105130 <acquire> ticks0 = ticks; while(ticks - ticks0 < 100*n){ 801064de: 8b 45 c4 mov -0x3c(%ebp),%eax 801064e1: 83 c4 10 add $0x10,%esp cmostime(&r1); cprintf("start second:%d\n" , r1.second); cprintf("start mintute:%d\n" , r1.minute); acquire(&tickslock); ticks0 = ticks; 801064e4: 8b 1d 60 66 11 80 mov 0x80116660,%ebx while(ticks - ticks0 < 100*n){ 801064ea: 85 c0 test %eax,%eax 801064ec: 75 2d jne 8010651b <sys_sleepp+0x8b> 801064ee: eb 58 jmp 80106548 <sys_sleepp+0xb8> if(myproc()->killed){ release(&tickslock); return -1; } release(&tickslock); 801064f0: 83 ec 0c sub $0xc,%esp 801064f3: 68 20 5e 11 80 push $0x80115e20 801064f8: e8 e3 ec ff ff call 801051e0 <release> acquire(&tickslock); 801064fd: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) 80106504: e8 27 ec ff ff call 80105130 <acquire> acquire(&tickslock); ticks0 = ticks; while(ticks - ticks0 < 100*n){ 80106509: 6b 55 c4 64 imul $0x64,-0x3c(%ebp),%edx 8010650d: a1 60 66 11 80 mov 0x80116660,%eax 80106512: 83 c4 10 add $0x10,%esp 80106515: 29 d8 sub %ebx,%eax 80106517: 39 d0 cmp %edx,%eax 80106519: 73 2d jae 80106548 <sys_sleepp+0xb8> if(myproc()->killed){ 8010651b: e8 10 d5 ff ff call 80103a30 <myproc> 80106520: 8b 40 24 mov 0x24(%eax),%eax 80106523: 85 c0 test %eax,%eax 80106525: 74 c9 je 801064f0 <sys_sleepp+0x60> release(&tickslock); 80106527: 83 ec 0c sub $0xc,%esp 8010652a: 68 20 5e 11 80 push $0x80115e20 8010652f: e8 ac ec ff ff call 801051e0 <release> return -1; 80106534: 83 c4 10 add $0x10,%esp 80106537: b8 ff ff ff ff mov $0xffffffff,%eax } else{ cprintf("ekhtelaf daqiqe:%d sanie:%d\n" , r2.minute - r1.minute -1 ,60 + ( r2.second - r1.second)); } return 0; } 8010653c: 8b 5d fc mov -0x4(%ebp),%ebx 8010653f: c9 leave 80106540: c3 ret 80106541: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; } release(&tickslock); acquire(&tickslock); } release(&tickslock); 80106548: 83 ec 0c sub $0xc,%esp 8010654b: 68 20 5e 11 80 push $0x80115e20 80106550: e8 8b ec ff ff call 801051e0 <release> cmostime(&r2); 80106555: 8d 45 e0 lea -0x20(%ebp),%eax 80106558: 89 04 24 mov %eax,(%esp) 8010655b: e8 c0 c4 ff ff call 80102a20 <cmostime> cprintf("end second:%d\n" , r2.second); 80106560: 5a pop %edx 80106561: 59 pop %ecx 80106562: ff 75 e0 pushl -0x20(%ebp) 80106565: 68 ab 89 10 80 push $0x801089ab 8010656a: e8 f1 a0 ff ff call 80100660 <cprintf> cprintf("end mintute:%d\n" , r2.minute); 8010656f: 5b pop %ebx 80106570: 58 pop %eax 80106571: ff 75 e4 pushl -0x1c(%ebp) 80106574: 68 ba 89 10 80 push $0x801089ba 80106579: e8 e2 a0 ff ff call 80100660 <cprintf> if( r2.second >= r1.second){ 8010657e: 8b 45 e0 mov -0x20(%ebp),%eax 80106581: 8b 55 c8 mov -0x38(%ebp),%edx 80106584: 83 c4 10 add $0x10,%esp 80106587: 39 d0 cmp %edx,%eax 80106589: 73 2d jae 801065b8 <sys_sleepp+0x128> cprintf("ekhtelaf daqiqe:%d sanie:%d\n" , r2.minute - r1.minute , r2.second - r1.second); } else{ cprintf("ekhtelaf daqiqe:%d sanie:%d\n" , r2.minute - r1.minute -1 ,60 + ( r2.second - r1.second)); 8010658b: 83 c0 3c add $0x3c,%eax 8010658e: 83 ec 04 sub $0x4,%esp 80106591: 29 d0 sub %edx,%eax 80106593: 50 push %eax 80106594: 8b 45 e4 mov -0x1c(%ebp),%eax 80106597: 83 e8 01 sub $0x1,%eax 8010659a: 2b 45 cc sub -0x34(%ebp),%eax 8010659d: 50 push %eax 8010659e: 68 ca 89 10 80 push $0x801089ca 801065a3: e8 b8 a0 ff ff call 80100660 <cprintf> 801065a8: 83 c4 10 add $0x10,%esp } return 0; 801065ab: 31 c0 xor %eax,%eax } 801065ad: 8b 5d fc mov -0x4(%ebp),%ebx 801065b0: c9 leave 801065b1: c3 ret 801065b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi release(&tickslock); cmostime(&r2); cprintf("end second:%d\n" , r2.second); cprintf("end mintute:%d\n" , r2.minute); if( r2.second >= r1.second){ cprintf("ekhtelaf daqiqe:%d sanie:%d\n" , r2.minute - r1.minute , r2.second - r1.second); 801065b8: 29 d0 sub %edx,%eax 801065ba: 83 ec 04 sub $0x4,%esp 801065bd: 50 push %eax 801065be: 8b 45 e4 mov -0x1c(%ebp),%eax 801065c1: eb d7 jmp 8010659a <sys_sleepp+0x10a> 801065c3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801065c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801065d0 <sys_uptime>: // return how many clock tick interrupts have occurred // since start. int sys_uptime(void) { 801065d0: 55 push %ebp 801065d1: 89 e5 mov %esp,%ebp 801065d3: 53 push %ebx 801065d4: 83 ec 10 sub $0x10,%esp uint xticks; acquire(&tickslock); 801065d7: 68 20 5e 11 80 push $0x80115e20 801065dc: e8 4f eb ff ff call 80105130 <acquire> xticks = ticks; 801065e1: 8b 1d 60 66 11 80 mov 0x80116660,%ebx release(&tickslock); 801065e7: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) 801065ee: e8 ed eb ff ff call 801051e0 <release> return xticks; } 801065f3: 89 d8 mov %ebx,%eax 801065f5: 8b 5d fc mov -0x4(%ebp),%ebx 801065f8: c9 leave 801065f9: c3 ret 801065fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106600 <sys_cmos>: void sys_cmos(void) { 80106600: 55 push %ebp 80106601: 89 e5 mov %esp,%ebp 80106603: 83 ec 34 sub $0x34,%esp struct rtcdate r; cmostime(&r); 80106606: 8d 45 e0 lea -0x20(%ebp),%eax 80106609: 50 push %eax 8010660a: e8 11 c4 ff ff call 80102a20 <cmostime> cprintf("second:%d\n" , r.second); 8010660f: 58 pop %eax 80106610: 5a pop %edx 80106611: ff 75 e0 pushl -0x20(%ebp) 80106614: 68 af 89 10 80 push $0x801089af 80106619: e8 42 a0 ff ff call 80100660 <cprintf> cprintf("mintute:%d\n" , r.minute); 8010661e: 59 pop %ecx 8010661f: 58 pop %eax 80106620: ff 75 e4 pushl -0x1c(%ebp) 80106623: 68 be 89 10 80 push $0x801089be 80106628: e8 33 a0 ff ff call 80100660 <cprintf> } 8010662d: 83 c4 10 add $0x10,%esp 80106630: c9 leave 80106631: c3 ret 80106632: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106639: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106640 <sys_set>: int sys_set(void) { 80106640: 55 push %ebp 80106641: 89 e5 mov %esp,%ebp 80106643: 83 ec 10 sub $0x10,%esp argstr(0,&spath); 80106646: 68 18 0f 11 80 push $0x80110f18 8010664b: 6a 00 push $0x0 8010664d: e8 9e ef ff ff call 801055f0 <argstr> return set(spath); 80106652: 58 pop %eax 80106653: ff 35 18 0f 11 80 pushl 0x80110f18 80106659: e8 b2 e2 ff ff call 80104910 <set> } 8010665e: c9 leave 8010665f: c3 ret 80106660 <sys_count>: int sys_count(void) { 80106660: 55 push %ebp 80106661: 89 e5 mov %esp,%ebp 80106663: 83 ec 08 sub $0x8,%esp int num,m; num=myproc()->tf->esi; 80106666: e8 c5 d3 ff ff call 80103a30 <myproc> 8010666b: 8b 40 18 mov 0x18(%eax),%eax m=count(num); 8010666e: 83 ec 0c sub $0xc,%esp 80106671: ff 70 04 pushl 0x4(%eax) 80106674: e8 77 e3 ff ff call 801049f0 <count> return m; } 80106679: c9 leave 8010667a: c3 ret 8010667b: 90 nop 8010667c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106680 <sys_chqueue>: int sys_chqueue(void){ 80106680: 55 push %ebp 80106681: 89 e5 mov %esp,%ebp 80106683: 53 push %ebx int pid,queuenum; if(argint(0, &pid) < 0) 80106684: 8d 45 f0 lea -0x10(%ebp),%eax m=count(num); return m; } int sys_chqueue(void){ 80106687: 83 ec 1c sub $0x1c,%esp int pid,queuenum; if(argint(0, &pid) < 0) 8010668a: 50 push %eax 8010668b: 6a 00 push $0x0 8010668d: e8 ae ee ff ff call 80105540 <argint> 80106692: 83 c4 10 add $0x10,%esp 80106695: 85 c0 test %eax,%eax 80106697: 78 42 js 801066db <sys_chqueue+0x5b> return -1; if((argint(1, &queuenum) < 1) && (argint(1, &queuenum) > 3)) 80106699: 8d 5d f4 lea -0xc(%ebp),%ebx 8010669c: 83 ec 08 sub $0x8,%esp 8010669f: 53 push %ebx 801066a0: 6a 01 push $0x1 801066a2: e8 99 ee ff ff call 80105540 <argint> 801066a7: 83 c4 10 add $0x10,%esp 801066aa: 85 c0 test %eax,%eax 801066ac: 7e 1a jle 801066c8 <sys_chqueue+0x48> return -1; return chqueue(pid,queuenum); 801066ae: 83 ec 08 sub $0x8,%esp 801066b1: ff 75 f4 pushl -0xc(%ebp) 801066b4: ff 75 f0 pushl -0x10(%ebp) 801066b7: e8 84 e3 ff ff call 80104a40 <chqueue> 801066bc: 83 c4 10 add $0x10,%esp } 801066bf: 8b 5d fc mov -0x4(%ebp),%ebx 801066c2: c9 leave 801066c3: c3 ret 801066c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int pid,queuenum; if(argint(0, &pid) < 0) return -1; if((argint(1, &queuenum) < 1) && (argint(1, &queuenum) > 3)) 801066c8: 83 ec 08 sub $0x8,%esp 801066cb: 53 push %ebx 801066cc: 6a 01 push $0x1 801066ce: e8 6d ee ff ff call 80105540 <argint> 801066d3: 83 c4 10 add $0x10,%esp 801066d6: 83 f8 03 cmp $0x3,%eax 801066d9: 7e d3 jle 801066ae <sys_chqueue+0x2e> int sys_chqueue(void){ int pid,queuenum; if(argint(0, &pid) < 0) return -1; 801066db: b8 ff ff ff ff mov $0xffffffff,%eax 801066e0: eb dd jmp 801066bf <sys_chqueue+0x3f> 801066e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801066e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801066f0 <sys_setLottery>: } int sys_setLottery(void){ 801066f0: 55 push %ebp 801066f1: 89 e5 mov %esp,%ebp 801066f3: 83 ec 20 sub $0x20,%esp int pid,tickets; if(argint(0, &pid) < 0) 801066f6: 8d 45 f0 lea -0x10(%ebp),%eax 801066f9: 50 push %eax 801066fa: 6a 00 push $0x0 801066fc: e8 3f ee ff ff call 80105540 <argint> 80106701: 83 c4 10 add $0x10,%esp 80106704: 85 c0 test %eax,%eax 80106706: 78 28 js 80106730 <sys_setLottery+0x40> return -1; argint(1, &tickets); 80106708: 8d 45 f4 lea -0xc(%ebp),%eax 8010670b: 83 ec 08 sub $0x8,%esp 8010670e: 50 push %eax 8010670f: 6a 01 push $0x1 80106711: e8 2a ee ff ff call 80105540 <argint> return setLottery(pid,tickets); 80106716: 58 pop %eax 80106717: 5a pop %edx 80106718: ff 75 f4 pushl -0xc(%ebp) 8010671b: ff 75 f0 pushl -0x10(%ebp) 8010671e: e8 6d e3 ff ff call 80104a90 <setLottery> 80106723: 83 c4 10 add $0x10,%esp } 80106726: c9 leave 80106727: c3 ret 80106728: 90 nop 80106729: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi int sys_setLottery(void){ int pid,tickets; if(argint(0, &pid) < 0) return -1; 80106730: b8 ff ff ff ff mov $0xffffffff,%eax return setLottery(pid,tickets); } 80106735: c9 leave 80106736: c3 ret 80106737: 89 f6 mov %esi,%esi 80106739: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106740 <sys_chprSRPF>: int sys_chprSRPF(void){ 80106740: 55 push %ebp 80106741: 89 e5 mov %esp,%ebp 80106743: 83 ec 20 sub $0x20,%esp int pid,priority; if(argint(0, &pid) < 0) 80106746: 8d 45 f0 lea -0x10(%ebp),%eax 80106749: 50 push %eax 8010674a: 6a 00 push $0x0 8010674c: e8 ef ed ff ff call 80105540 <argint> 80106751: 83 c4 10 add $0x10,%esp 80106754: 85 c0 test %eax,%eax 80106756: 78 28 js 80106780 <sys_chprSRPF+0x40> return -1; argint(1, &priority); 80106758: 8d 45 f4 lea -0xc(%ebp),%eax 8010675b: 83 ec 08 sub $0x8,%esp 8010675e: 50 push %eax 8010675f: 6a 01 push $0x1 80106761: e8 da ed ff ff call 80105540 <argint> return chprSRPF(pid,priority); 80106766: 58 pop %eax 80106767: 5a pop %edx 80106768: ff 75 f4 pushl -0xc(%ebp) 8010676b: ff 75 f0 pushl -0x10(%ebp) 8010676e: e8 6d e5 ff ff call 80104ce0 <chprSRPF> 80106773: 83 c4 10 add $0x10,%esp } 80106776: c9 leave 80106777: c3 ret 80106778: 90 nop 80106779: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi int sys_chprSRPF(void){ int pid,priority; if(argint(0, &pid) < 0) return -1; 80106780: b8 ff ff ff ff mov $0xffffffff,%eax argint(1, &priority); return chprSRPF(pid,priority); } 80106785: c9 leave 80106786: c3 ret 80106787: 89 f6 mov %esi,%esi 80106789: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106790 <sys_printinfo>: int sys_printinfo(void){ 80106790: 55 push %ebp 80106791: 89 e5 mov %esp,%ebp return printinfo(); } 80106793: 5d pop %ebp } int sys_printinfo(void){ return printinfo(); 80106794: e9 97 e5 ff ff jmp 80104d30 <printinfo> 80106799 <alltraps>: # vectors.S sends all traps here. .globl alltraps alltraps: # Build trap frame. pushl %ds 80106799: 1e push %ds pushl %es 8010679a: 06 push %es pushl %fs 8010679b: 0f a0 push %fs pushl %gs 8010679d: 0f a8 push %gs pushal 8010679f: 60 pusha # Set up data segments. movw $(SEG_KDATA<<3), %ax 801067a0: 66 b8 10 00 mov $0x10,%ax movw %ax, %ds 801067a4: 8e d8 mov %eax,%ds movw %ax, %es 801067a6: 8e c0 mov %eax,%es # Call trap(tf), where tf=%esp pushl %esp 801067a8: 54 push %esp call trap 801067a9: e8 e2 00 00 00 call 80106890 <trap> addl $4, %esp 801067ae: 83 c4 04 add $0x4,%esp 801067b1 <trapret>: # Return falls through to trapret... .globl trapret trapret: popal 801067b1: 61 popa popl %gs 801067b2: 0f a9 pop %gs popl %fs 801067b4: 0f a1 pop %fs popl %es 801067b6: 07 pop %es popl %ds 801067b7: 1f pop %ds addl $0x8, %esp # trapno and errcode 801067b8: 83 c4 08 add $0x8,%esp iret 801067bb: cf iret 801067bc: 66 90 xchg %ax,%ax 801067be: 66 90 xchg %ax,%ax 801067c0 <tvinit>: void tvinit(void) { int i; for(i = 0; i < 256; i++) 801067c0: 31 c0 xor %eax,%eax 801067c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); 801067c8: 8b 14 85 0c b0 10 80 mov -0x7fef4ff4(,%eax,4),%edx 801067cf: b9 08 00 00 00 mov $0x8,%ecx 801067d4: c6 04 c5 64 5e 11 80 movb $0x0,-0x7feea19c(,%eax,8) 801067db: 00 801067dc: 66 89 0c c5 62 5e 11 mov %cx,-0x7feea19e(,%eax,8) 801067e3: 80 801067e4: c6 04 c5 65 5e 11 80 movb $0x8e,-0x7feea19b(,%eax,8) 801067eb: 8e 801067ec: 66 89 14 c5 60 5e 11 mov %dx,-0x7feea1a0(,%eax,8) 801067f3: 80 801067f4: c1 ea 10 shr $0x10,%edx 801067f7: 66 89 14 c5 66 5e 11 mov %dx,-0x7feea19a(,%eax,8) 801067fe: 80 void tvinit(void) { int i; for(i = 0; i < 256; i++) 801067ff: 83 c0 01 add $0x1,%eax 80106802: 3d 00 01 00 00 cmp $0x100,%eax 80106807: 75 bf jne 801067c8 <tvinit+0x8> struct spinlock tickslock; uint ticks; void tvinit(void) { 80106809: 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); 8010680a: ba 08 00 00 00 mov $0x8,%edx struct spinlock tickslock; uint ticks; void tvinit(void) { 8010680f: 89 e5 mov %esp,%ebp 80106811: 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); 80106814: a1 0c b1 10 80 mov 0x8010b10c,%eax initlock(&tickslock, "time"); 80106819: 68 e7 89 10 80 push $0x801089e7 8010681e: 68 20 5e 11 80 push $0x80115e20 { 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); 80106823: 66 89 15 62 60 11 80 mov %dx,0x80116062 8010682a: c6 05 64 60 11 80 00 movb $0x0,0x80116064 80106831: 66 a3 60 60 11 80 mov %ax,0x80116060 80106837: c1 e8 10 shr $0x10,%eax 8010683a: c6 05 65 60 11 80 ef movb $0xef,0x80116065 80106841: 66 a3 66 60 11 80 mov %ax,0x80116066 initlock(&tickslock, "time"); 80106847: e8 84 e7 ff ff call 80104fd0 <initlock> } 8010684c: 83 c4 10 add $0x10,%esp 8010684f: c9 leave 80106850: c3 ret 80106851: eb 0d jmp 80106860 <idtinit> 80106853: 90 nop 80106854: 90 nop 80106855: 90 nop 80106856: 90 nop 80106857: 90 nop 80106858: 90 nop 80106859: 90 nop 8010685a: 90 nop 8010685b: 90 nop 8010685c: 90 nop 8010685d: 90 nop 8010685e: 90 nop 8010685f: 90 nop 80106860 <idtinit>: void idtinit(void) { 80106860: 55 push %ebp static inline void lidt(struct gatedesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 80106861: b8 ff 07 00 00 mov $0x7ff,%eax 80106866: 89 e5 mov %esp,%ebp 80106868: 83 ec 10 sub $0x10,%esp 8010686b: 66 89 45 fa mov %ax,-0x6(%ebp) pd[1] = (uint)p; 8010686f: b8 60 5e 11 80 mov $0x80115e60,%eax 80106874: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 80106878: c1 e8 10 shr $0x10,%eax 8010687b: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lidt (%0)" : : "r" (pd)); 8010687f: 8d 45 fa lea -0x6(%ebp),%eax 80106882: 0f 01 18 lidtl (%eax) lidt(idt, sizeof(idt)); } 80106885: c9 leave 80106886: c3 ret 80106887: 89 f6 mov %esi,%esi 80106889: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106890 <trap>: //PAGEBREAK: 41 void trap(struct trapframe *tf) { 80106890: 55 push %ebp 80106891: 89 e5 mov %esp,%ebp 80106893: 57 push %edi 80106894: 56 push %esi 80106895: 53 push %ebx 80106896: 83 ec 1c sub $0x1c,%esp 80106899: 8b 7d 08 mov 0x8(%ebp),%edi if(tf->trapno == T_SYSCALL){ 8010689c: 8b 47 30 mov 0x30(%edi),%eax 8010689f: 83 f8 40 cmp $0x40,%eax 801068a2: 0f 84 98 01 00 00 je 80106a40 <trap+0x1b0> if(myproc()->killed) exit(); return; } switch(tf->trapno){ 801068a8: 83 e8 20 sub $0x20,%eax 801068ab: 83 f8 1f cmp $0x1f,%eax 801068ae: 77 10 ja 801068c0 <trap+0x30> 801068b0: ff 24 85 b0 8a 10 80 jmp *-0x7fef7550(,%eax,4) 801068b7: 89 f6 mov %esi,%esi 801068b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi lapiceoi(); break; //PAGEBREAK: 13 default: cprintf("hiiiiiiiiiiiiiiiiiiiiiiiiiiii\n"); 801068c0: 83 ec 0c sub $0xc,%esp 801068c3: 68 18 8a 10 80 push $0x80108a18 801068c8: e8 93 9d ff ff call 80100660 <cprintf> if(myproc() == 0 || (tf->cs&3) == 0){ 801068cd: e8 5e d1 ff ff call 80103a30 <myproc> 801068d2: 83 c4 10 add $0x10,%esp 801068d5: 85 c0 test %eax,%eax 801068d7: 0f 84 d7 01 00 00 je 80106ab4 <trap+0x224> 801068dd: f6 47 3c 03 testb $0x3,0x3c(%edi) 801068e1: 0f 84 cd 01 00 00 je 80106ab4 <trap+0x224> static inline uint rcr2(void) { uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); 801068e7: 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 " 801068ea: 8b 57 38 mov 0x38(%edi),%edx 801068ed: 89 4d d8 mov %ecx,-0x28(%ebp) 801068f0: 89 55 dc mov %edx,-0x24(%ebp) 801068f3: e8 18 d1 ff ff call 80103a10 <cpuid> 801068f8: 8b 77 34 mov 0x34(%edi),%esi 801068fb: 8b 5f 30 mov 0x30(%edi),%ebx 801068fe: 89 45 e4 mov %eax,-0x1c(%ebp) "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 80106901: e8 2a d1 ff ff call 80103a30 <myproc> 80106906: 89 45 e0 mov %eax,-0x20(%ebp) 80106909: e8 22 d1 ff ff call 80103a30 <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 " 8010690e: 8b 4d d8 mov -0x28(%ebp),%ecx 80106911: 8b 55 dc mov -0x24(%ebp),%edx 80106914: 51 push %ecx 80106915: 52 push %edx "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 80106916: 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 " 80106919: ff 75 e4 pushl -0x1c(%ebp) 8010691c: 56 push %esi 8010691d: 53 push %ebx "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 8010691e: 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 " 80106921: 52 push %edx 80106922: ff 70 10 pushl 0x10(%eax) 80106925: 68 6c 8a 10 80 push $0x80108a6c 8010692a: e8 31 9d 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; 8010692f: 83 c4 20 add $0x20,%esp 80106932: e8 f9 d0 ff ff call 80103a30 <myproc> 80106937: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) 8010693e: 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) 80106940: e8 eb d0 ff ff call 80103a30 <myproc> 80106945: 85 c0 test %eax,%eax 80106947: 74 0c je 80106955 <trap+0xc5> 80106949: e8 e2 d0 ff ff call 80103a30 <myproc> 8010694e: 8b 50 24 mov 0x24(%eax),%edx 80106951: 85 d2 test %edx,%edx 80106953: 75 4b jne 801069a0 <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 && 80106955: e8 d6 d0 ff ff call 80103a30 <myproc> 8010695a: 85 c0 test %eax,%eax 8010695c: 74 0b je 80106969 <trap+0xd9> 8010695e: e8 cd d0 ff ff call 80103a30 <myproc> 80106963: 83 78 0c 04 cmpl $0x4,0xc(%eax) 80106967: 74 4f je 801069b8 <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) 80106969: e8 c2 d0 ff ff call 80103a30 <myproc> 8010696e: 85 c0 test %eax,%eax 80106970: 74 1d je 8010698f <trap+0xff> 80106972: e8 b9 d0 ff ff call 80103a30 <myproc> 80106977: 8b 40 24 mov 0x24(%eax),%eax 8010697a: 85 c0 test %eax,%eax 8010697c: 74 11 je 8010698f <trap+0xff> 8010697e: 0f b7 47 3c movzwl 0x3c(%edi),%eax 80106982: 83 e0 03 and $0x3,%eax 80106985: 66 83 f8 03 cmp $0x3,%ax 80106989: 0f 84 da 00 00 00 je 80106a69 <trap+0x1d9> exit(); } 8010698f: 8d 65 f4 lea -0xc(%ebp),%esp 80106992: 5b pop %ebx 80106993: 5e pop %esi 80106994: 5f pop %edi 80106995: 5d pop %ebp 80106996: c3 ret 80106997: 89 f6 mov %esi,%esi 80106999: 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) 801069a0: 0f b7 47 3c movzwl 0x3c(%edi),%eax 801069a4: 83 e0 03 and $0x3,%eax 801069a7: 66 83 f8 03 cmp $0x3,%ax 801069ab: 75 a8 jne 80106955 <trap+0xc5> exit(); 801069ad: e8 9e d8 ff ff call 80104250 <exit> 801069b2: eb a1 jmp 80106955 <trap+0xc5> 801069b4: 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 && 801069b8: 83 7f 30 20 cmpl $0x20,0x30(%edi) 801069bc: 75 ab jne 80106969 <trap+0xd9> tf->trapno == T_IRQ0+IRQ_TIMER) yield(); 801069be: e8 bd d9 ff ff call 80104380 <yield> 801069c3: eb a4 jmp 80106969 <trap+0xd9> 801069c5: 8d 76 00 lea 0x0(%esi),%esi return; } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ 801069c8: e8 43 d0 ff ff call 80103a10 <cpuid> 801069cd: 85 c0 test %eax,%eax 801069cf: 0f 84 ab 00 00 00 je 80106a80 <trap+0x1f0> } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); lapiceoi(); 801069d5: e8 86 bf ff ff call 80102960 <lapiceoi> break; 801069da: e9 61 ff ff ff jmp 80106940 <trap+0xb0> 801069df: 90 nop case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; case T_IRQ0 + IRQ_KBD: kbdintr(); 801069e0: e8 3b be ff ff call 80102820 <kbdintr> lapiceoi(); 801069e5: e8 76 bf ff ff call 80102960 <lapiceoi> break; 801069ea: e9 51 ff ff ff jmp 80106940 <trap+0xb0> 801069ef: 90 nop case T_IRQ0 + IRQ_COM1: uartintr(); 801069f0: e8 5b 02 00 00 call 80106c50 <uartintr> lapiceoi(); 801069f5: e8 66 bf ff ff call 80102960 <lapiceoi> break; 801069fa: e9 41 ff ff ff jmp 80106940 <trap+0xb0> 801069ff: 90 nop case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", 80106a00: 0f b7 5f 3c movzwl 0x3c(%edi),%ebx 80106a04: 8b 77 38 mov 0x38(%edi),%esi 80106a07: e8 04 d0 ff ff call 80103a10 <cpuid> 80106a0c: 56 push %esi 80106a0d: 53 push %ebx 80106a0e: 50 push %eax 80106a0f: 68 f4 89 10 80 push $0x801089f4 80106a14: e8 47 9c ff ff call 80100660 <cprintf> cpuid(), tf->cs, tf->eip); lapiceoi(); 80106a19: e8 42 bf ff ff call 80102960 <lapiceoi> break; 80106a1e: 83 c4 10 add $0x10,%esp 80106a21: e9 1a ff ff ff jmp 80106940 <trap+0xb0> 80106a26: 8d 76 00 lea 0x0(%esi),%esi 80106a29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi release(&tickslock); } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); 80106a30: e8 6b b8 ff ff call 801022a0 <ideintr> 80106a35: eb 9e jmp 801069d5 <trap+0x145> 80106a37: 89 f6 mov %esi,%esi 80106a39: 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) 80106a40: e8 eb cf ff ff call 80103a30 <myproc> 80106a45: 8b 58 24 mov 0x24(%eax),%ebx 80106a48: 85 db test %ebx,%ebx 80106a4a: 75 2c jne 80106a78 <trap+0x1e8> exit(); myproc()->tf = tf; 80106a4c: e8 df cf ff ff call 80103a30 <myproc> 80106a51: 89 78 18 mov %edi,0x18(%eax) syscall(); 80106a54: e8 d7 eb ff ff call 80105630 <syscall> if(myproc()->killed) 80106a59: e8 d2 cf ff ff call 80103a30 <myproc> 80106a5e: 8b 48 24 mov 0x24(%eax),%ecx 80106a61: 85 c9 test %ecx,%ecx 80106a63: 0f 84 26 ff ff ff je 8010698f <trap+0xff> yield(); // Check if the process has been killed since we yielded if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) exit(); } 80106a69: 8d 65 f4 lea -0xc(%ebp),%esp 80106a6c: 5b pop %ebx 80106a6d: 5e pop %esi 80106a6e: 5f pop %edi 80106a6f: 5d pop %ebp if(myproc()->killed) exit(); myproc()->tf = tf; syscall(); if(myproc()->killed) exit(); 80106a70: e9 db d7 ff ff jmp 80104250 <exit> 80106a75: 8d 76 00 lea 0x0(%esi),%esi void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ if(myproc()->killed) exit(); 80106a78: e8 d3 d7 ff ff call 80104250 <exit> 80106a7d: eb cd jmp 80106a4c <trap+0x1bc> 80106a7f: 90 nop } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ acquire(&tickslock); 80106a80: 83 ec 0c sub $0xc,%esp 80106a83: 68 20 5e 11 80 push $0x80115e20 80106a88: e8 a3 e6 ff ff call 80105130 <acquire> ticks++; wakeup(&ticks); 80106a8d: c7 04 24 60 66 11 80 movl $0x80116660,(%esp) switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpuid() == 0){ acquire(&tickslock); ticks++; 80106a94: 83 05 60 66 11 80 01 addl $0x1,0x80116660 wakeup(&ticks); 80106a9b: e8 f0 da ff ff call 80104590 <wakeup> release(&tickslock); 80106aa0: c7 04 24 20 5e 11 80 movl $0x80115e20,(%esp) 80106aa7: e8 34 e7 ff ff call 801051e0 <release> 80106aac: 83 c4 10 add $0x10,%esp 80106aaf: e9 21 ff ff ff jmp 801069d5 <trap+0x145> 80106ab4: 0f 20 d6 mov %cr2,%esi //PAGEBREAK: 13 default: cprintf("hiiiiiiiiiiiiiiiiiiiiiiiiiiii\n"); 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", 80106ab7: 8b 5f 38 mov 0x38(%edi),%ebx 80106aba: e8 51 cf ff ff call 80103a10 <cpuid> 80106abf: 83 ec 0c sub $0xc,%esp 80106ac2: 56 push %esi 80106ac3: 53 push %ebx 80106ac4: 50 push %eax 80106ac5: ff 77 30 pushl 0x30(%edi) 80106ac8: 68 38 8a 10 80 push $0x80108a38 80106acd: e8 8e 9b ff ff call 80100660 <cprintf> tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); 80106ad2: 83 c4 14 add $0x14,%esp 80106ad5: 68 ec 89 10 80 push $0x801089ec 80106ada: e8 91 98 ff ff call 80100370 <panic> 80106adf: 90 nop 80106ae0 <uartgetc>: } static int uartgetc(void) { if(!uart) 80106ae0: a1 bc b5 10 80 mov 0x8010b5bc,%eax outb(COM1+0, c); } static int uartgetc(void) { 80106ae5: 55 push %ebp 80106ae6: 89 e5 mov %esp,%ebp if(!uart) 80106ae8: 85 c0 test %eax,%eax 80106aea: 74 1c je 80106b08 <uartgetc+0x28> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80106aec: ba fd 03 00 00 mov $0x3fd,%edx 80106af1: ec in (%dx),%al return -1; if(!(inb(COM1+5) & 0x01)) 80106af2: a8 01 test $0x1,%al 80106af4: 74 12 je 80106b08 <uartgetc+0x28> 80106af6: ba f8 03 00 00 mov $0x3f8,%edx 80106afb: ec in (%dx),%al return -1; return inb(COM1+0); 80106afc: 0f b6 c0 movzbl %al,%eax } 80106aff: 5d pop %ebp 80106b00: c3 ret 80106b01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi static int uartgetc(void) { if(!uart) return -1; 80106b08: b8 ff ff ff ff mov $0xffffffff,%eax if(!(inb(COM1+5) & 0x01)) return -1; return inb(COM1+0); } 80106b0d: 5d pop %ebp 80106b0e: c3 ret 80106b0f: 90 nop 80106b10 <uartputc.part.0>: for(p="xv6...\n"; *p; p++) uartputc(*p); } void uartputc(int c) 80106b10: 55 push %ebp 80106b11: 89 e5 mov %esp,%ebp 80106b13: 57 push %edi 80106b14: 56 push %esi 80106b15: 53 push %ebx 80106b16: 89 c7 mov %eax,%edi 80106b18: bb 80 00 00 00 mov $0x80,%ebx 80106b1d: be fd 03 00 00 mov $0x3fd,%esi 80106b22: 83 ec 0c sub $0xc,%esp 80106b25: eb 1b jmp 80106b42 <uartputc.part.0+0x32> 80106b27: 89 f6 mov %esi,%esi 80106b29: 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); 80106b30: 83 ec 0c sub $0xc,%esp 80106b33: 6a 0a push $0xa 80106b35: e8 46 be ff ff call 80102980 <microdelay> { int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 80106b3a: 83 c4 10 add $0x10,%esp 80106b3d: 83 eb 01 sub $0x1,%ebx 80106b40: 74 07 je 80106b49 <uartputc.part.0+0x39> 80106b42: 89 f2 mov %esi,%edx 80106b44: ec in (%dx),%al 80106b45: a8 20 test $0x20,%al 80106b47: 74 e7 je 80106b30 <uartputc.part.0+0x20> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80106b49: ba f8 03 00 00 mov $0x3f8,%edx 80106b4e: 89 f8 mov %edi,%eax 80106b50: ee out %al,(%dx) microdelay(10); outb(COM1+0, c); } 80106b51: 8d 65 f4 lea -0xc(%ebp),%esp 80106b54: 5b pop %ebx 80106b55: 5e pop %esi 80106b56: 5f pop %edi 80106b57: 5d pop %ebp 80106b58: c3 ret 80106b59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106b60 <uartinit>: static int uart; // is there a uart? void uartinit(void) { 80106b60: 55 push %ebp 80106b61: 31 c9 xor %ecx,%ecx 80106b63: 89 c8 mov %ecx,%eax 80106b65: 89 e5 mov %esp,%ebp 80106b67: 57 push %edi 80106b68: 56 push %esi 80106b69: 53 push %ebx 80106b6a: bb fa 03 00 00 mov $0x3fa,%ebx 80106b6f: 89 da mov %ebx,%edx 80106b71: 83 ec 0c sub $0xc,%esp 80106b74: ee out %al,(%dx) 80106b75: bf fb 03 00 00 mov $0x3fb,%edi 80106b7a: b8 80 ff ff ff mov $0xffffff80,%eax 80106b7f: 89 fa mov %edi,%edx 80106b81: ee out %al,(%dx) 80106b82: b8 0c 00 00 00 mov $0xc,%eax 80106b87: ba f8 03 00 00 mov $0x3f8,%edx 80106b8c: ee out %al,(%dx) 80106b8d: be f9 03 00 00 mov $0x3f9,%esi 80106b92: 89 c8 mov %ecx,%eax 80106b94: 89 f2 mov %esi,%edx 80106b96: ee out %al,(%dx) 80106b97: b8 03 00 00 00 mov $0x3,%eax 80106b9c: 89 fa mov %edi,%edx 80106b9e: ee out %al,(%dx) 80106b9f: ba fc 03 00 00 mov $0x3fc,%edx 80106ba4: 89 c8 mov %ecx,%eax 80106ba6: ee out %al,(%dx) 80106ba7: b8 01 00 00 00 mov $0x1,%eax 80106bac: 89 f2 mov %esi,%edx 80106bae: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80106baf: ba fd 03 00 00 mov $0x3fd,%edx 80106bb4: 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) 80106bb5: 3c ff cmp $0xff,%al 80106bb7: 74 5a je 80106c13 <uartinit+0xb3> return; uart = 1; 80106bb9: c7 05 bc b5 10 80 01 movl $0x1,0x8010b5bc 80106bc0: 00 00 00 80106bc3: 89 da mov %ebx,%edx 80106bc5: ec in (%dx),%al 80106bc6: ba f8 03 00 00 mov $0x3f8,%edx 80106bcb: ec in (%dx),%al // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); 80106bcc: 83 ec 08 sub $0x8,%esp 80106bcf: bb 30 8b 10 80 mov $0x80108b30,%ebx 80106bd4: 6a 00 push $0x0 80106bd6: 6a 04 push $0x4 80106bd8: e8 13 b9 ff ff call 801024f0 <ioapicenable> 80106bdd: 83 c4 10 add $0x10,%esp 80106be0: b8 78 00 00 00 mov $0x78,%eax 80106be5: eb 13 jmp 80106bfa <uartinit+0x9a> 80106be7: 89 f6 mov %esi,%esi 80106be9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi // Announce that we're here. for(p="xv6...\n"; *p; p++) 80106bf0: 83 c3 01 add $0x1,%ebx 80106bf3: 0f be 03 movsbl (%ebx),%eax 80106bf6: 84 c0 test %al,%al 80106bf8: 74 19 je 80106c13 <uartinit+0xb3> void uartputc(int c) { int i; if(!uart) 80106bfa: 8b 15 bc b5 10 80 mov 0x8010b5bc,%edx 80106c00: 85 d2 test %edx,%edx 80106c02: 74 ec je 80106bf0 <uartinit+0x90> inb(COM1+2); inb(COM1+0); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) 80106c04: 83 c3 01 add $0x1,%ebx 80106c07: e8 04 ff ff ff call 80106b10 <uartputc.part.0> 80106c0c: 0f be 03 movsbl (%ebx),%eax 80106c0f: 84 c0 test %al,%al 80106c11: 75 e7 jne 80106bfa <uartinit+0x9a> uartputc(*p); } 80106c13: 8d 65 f4 lea -0xc(%ebp),%esp 80106c16: 5b pop %ebx 80106c17: 5e pop %esi 80106c18: 5f pop %edi 80106c19: 5d pop %ebp 80106c1a: c3 ret 80106c1b: 90 nop 80106c1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106c20 <uartputc>: void uartputc(int c) { int i; if(!uart) 80106c20: 8b 15 bc b5 10 80 mov 0x8010b5bc,%edx uartputc(*p); } void uartputc(int c) { 80106c26: 55 push %ebp 80106c27: 89 e5 mov %esp,%ebp int i; if(!uart) 80106c29: 85 d2 test %edx,%edx uartputc(*p); } void uartputc(int c) { 80106c2b: 8b 45 08 mov 0x8(%ebp),%eax int i; if(!uart) 80106c2e: 74 10 je 80106c40 <uartputc+0x20> return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) microdelay(10); outb(COM1+0, c); } 80106c30: 5d pop %ebp 80106c31: e9 da fe ff ff jmp 80106b10 <uartputc.part.0> 80106c36: 8d 76 00 lea 0x0(%esi),%esi 80106c39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106c40: 5d pop %ebp 80106c41: c3 ret 80106c42: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106c49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106c50 <uartintr>: return inb(COM1+0); } void uartintr(void) { 80106c50: 55 push %ebp 80106c51: 89 e5 mov %esp,%ebp 80106c53: 83 ec 14 sub $0x14,%esp consoleintr(uartgetc); 80106c56: 68 e0 6a 10 80 push $0x80106ae0 80106c5b: e8 90 9b ff ff call 801007f0 <consoleintr> } 80106c60: 83 c4 10 add $0x10,%esp 80106c63: c9 leave 80106c64: c3 ret 80106c65 <vector0>: # generated by vectors.pl - do not edit # handlers .globl alltraps .globl vector0 vector0: pushl $0 80106c65: 6a 00 push $0x0 pushl $0 80106c67: 6a 00 push $0x0 jmp alltraps 80106c69: e9 2b fb ff ff jmp 80106799 <alltraps> 80106c6e <vector1>: .globl vector1 vector1: pushl $0 80106c6e: 6a 00 push $0x0 pushl $1 80106c70: 6a 01 push $0x1 jmp alltraps 80106c72: e9 22 fb ff ff jmp 80106799 <alltraps> 80106c77 <vector2>: .globl vector2 vector2: pushl $0 80106c77: 6a 00 push $0x0 pushl $2 80106c79: 6a 02 push $0x2 jmp alltraps 80106c7b: e9 19 fb ff ff jmp 80106799 <alltraps> 80106c80 <vector3>: .globl vector3 vector3: pushl $0 80106c80: 6a 00 push $0x0 pushl $3 80106c82: 6a 03 push $0x3 jmp alltraps 80106c84: e9 10 fb ff ff jmp 80106799 <alltraps> 80106c89 <vector4>: .globl vector4 vector4: pushl $0 80106c89: 6a 00 push $0x0 pushl $4 80106c8b: 6a 04 push $0x4 jmp alltraps 80106c8d: e9 07 fb ff ff jmp 80106799 <alltraps> 80106c92 <vector5>: .globl vector5 vector5: pushl $0 80106c92: 6a 00 push $0x0 pushl $5 80106c94: 6a 05 push $0x5 jmp alltraps 80106c96: e9 fe fa ff ff jmp 80106799 <alltraps> 80106c9b <vector6>: .globl vector6 vector6: pushl $0 80106c9b: 6a 00 push $0x0 pushl $6 80106c9d: 6a 06 push $0x6 jmp alltraps 80106c9f: e9 f5 fa ff ff jmp 80106799 <alltraps> 80106ca4 <vector7>: .globl vector7 vector7: pushl $0 80106ca4: 6a 00 push $0x0 pushl $7 80106ca6: 6a 07 push $0x7 jmp alltraps 80106ca8: e9 ec fa ff ff jmp 80106799 <alltraps> 80106cad <vector8>: .globl vector8 vector8: pushl $8 80106cad: 6a 08 push $0x8 jmp alltraps 80106caf: e9 e5 fa ff ff jmp 80106799 <alltraps> 80106cb4 <vector9>: .globl vector9 vector9: pushl $0 80106cb4: 6a 00 push $0x0 pushl $9 80106cb6: 6a 09 push $0x9 jmp alltraps 80106cb8: e9 dc fa ff ff jmp 80106799 <alltraps> 80106cbd <vector10>: .globl vector10 vector10: pushl $10 80106cbd: 6a 0a push $0xa jmp alltraps 80106cbf: e9 d5 fa ff ff jmp 80106799 <alltraps> 80106cc4 <vector11>: .globl vector11 vector11: pushl $11 80106cc4: 6a 0b push $0xb jmp alltraps 80106cc6: e9 ce fa ff ff jmp 80106799 <alltraps> 80106ccb <vector12>: .globl vector12 vector12: pushl $12 80106ccb: 6a 0c push $0xc jmp alltraps 80106ccd: e9 c7 fa ff ff jmp 80106799 <alltraps> 80106cd2 <vector13>: .globl vector13 vector13: pushl $13 80106cd2: 6a 0d push $0xd jmp alltraps 80106cd4: e9 c0 fa ff ff jmp 80106799 <alltraps> 80106cd9 <vector14>: .globl vector14 vector14: pushl $14 80106cd9: 6a 0e push $0xe jmp alltraps 80106cdb: e9 b9 fa ff ff jmp 80106799 <alltraps> 80106ce0 <vector15>: .globl vector15 vector15: pushl $0 80106ce0: 6a 00 push $0x0 pushl $15 80106ce2: 6a 0f push $0xf jmp alltraps 80106ce4: e9 b0 fa ff ff jmp 80106799 <alltraps> 80106ce9 <vector16>: .globl vector16 vector16: pushl $0 80106ce9: 6a 00 push $0x0 pushl $16 80106ceb: 6a 10 push $0x10 jmp alltraps 80106ced: e9 a7 fa ff ff jmp 80106799 <alltraps> 80106cf2 <vector17>: .globl vector17 vector17: pushl $17 80106cf2: 6a 11 push $0x11 jmp alltraps 80106cf4: e9 a0 fa ff ff jmp 80106799 <alltraps> 80106cf9 <vector18>: .globl vector18 vector18: pushl $0 80106cf9: 6a 00 push $0x0 pushl $18 80106cfb: 6a 12 push $0x12 jmp alltraps 80106cfd: e9 97 fa ff ff jmp 80106799 <alltraps> 80106d02 <vector19>: .globl vector19 vector19: pushl $0 80106d02: 6a 00 push $0x0 pushl $19 80106d04: 6a 13 push $0x13 jmp alltraps 80106d06: e9 8e fa ff ff jmp 80106799 <alltraps> 80106d0b <vector20>: .globl vector20 vector20: pushl $0 80106d0b: 6a 00 push $0x0 pushl $20 80106d0d: 6a 14 push $0x14 jmp alltraps 80106d0f: e9 85 fa ff ff jmp 80106799 <alltraps> 80106d14 <vector21>: .globl vector21 vector21: pushl $0 80106d14: 6a 00 push $0x0 pushl $21 80106d16: 6a 15 push $0x15 jmp alltraps 80106d18: e9 7c fa ff ff jmp 80106799 <alltraps> 80106d1d <vector22>: .globl vector22 vector22: pushl $0 80106d1d: 6a 00 push $0x0 pushl $22 80106d1f: 6a 16 push $0x16 jmp alltraps 80106d21: e9 73 fa ff ff jmp 80106799 <alltraps> 80106d26 <vector23>: .globl vector23 vector23: pushl $0 80106d26: 6a 00 push $0x0 pushl $23 80106d28: 6a 17 push $0x17 jmp alltraps 80106d2a: e9 6a fa ff ff jmp 80106799 <alltraps> 80106d2f <vector24>: .globl vector24 vector24: pushl $0 80106d2f: 6a 00 push $0x0 pushl $24 80106d31: 6a 18 push $0x18 jmp alltraps 80106d33: e9 61 fa ff ff jmp 80106799 <alltraps> 80106d38 <vector25>: .globl vector25 vector25: pushl $0 80106d38: 6a 00 push $0x0 pushl $25 80106d3a: 6a 19 push $0x19 jmp alltraps 80106d3c: e9 58 fa ff ff jmp 80106799 <alltraps> 80106d41 <vector26>: .globl vector26 vector26: pushl $0 80106d41: 6a 00 push $0x0 pushl $26 80106d43: 6a 1a push $0x1a jmp alltraps 80106d45: e9 4f fa ff ff jmp 80106799 <alltraps> 80106d4a <vector27>: .globl vector27 vector27: pushl $0 80106d4a: 6a 00 push $0x0 pushl $27 80106d4c: 6a 1b push $0x1b jmp alltraps 80106d4e: e9 46 fa ff ff jmp 80106799 <alltraps> 80106d53 <vector28>: .globl vector28 vector28: pushl $0 80106d53: 6a 00 push $0x0 pushl $28 80106d55: 6a 1c push $0x1c jmp alltraps 80106d57: e9 3d fa ff ff jmp 80106799 <alltraps> 80106d5c <vector29>: .globl vector29 vector29: pushl $0 80106d5c: 6a 00 push $0x0 pushl $29 80106d5e: 6a 1d push $0x1d jmp alltraps 80106d60: e9 34 fa ff ff jmp 80106799 <alltraps> 80106d65 <vector30>: .globl vector30 vector30: pushl $0 80106d65: 6a 00 push $0x0 pushl $30 80106d67: 6a 1e push $0x1e jmp alltraps 80106d69: e9 2b fa ff ff jmp 80106799 <alltraps> 80106d6e <vector31>: .globl vector31 vector31: pushl $0 80106d6e: 6a 00 push $0x0 pushl $31 80106d70: 6a 1f push $0x1f jmp alltraps 80106d72: e9 22 fa ff ff jmp 80106799 <alltraps> 80106d77 <vector32>: .globl vector32 vector32: pushl $0 80106d77: 6a 00 push $0x0 pushl $32 80106d79: 6a 20 push $0x20 jmp alltraps 80106d7b: e9 19 fa ff ff jmp 80106799 <alltraps> 80106d80 <vector33>: .globl vector33 vector33: pushl $0 80106d80: 6a 00 push $0x0 pushl $33 80106d82: 6a 21 push $0x21 jmp alltraps 80106d84: e9 10 fa ff ff jmp 80106799 <alltraps> 80106d89 <vector34>: .globl vector34 vector34: pushl $0 80106d89: 6a 00 push $0x0 pushl $34 80106d8b: 6a 22 push $0x22 jmp alltraps 80106d8d: e9 07 fa ff ff jmp 80106799 <alltraps> 80106d92 <vector35>: .globl vector35 vector35: pushl $0 80106d92: 6a 00 push $0x0 pushl $35 80106d94: 6a 23 push $0x23 jmp alltraps 80106d96: e9 fe f9 ff ff jmp 80106799 <alltraps> 80106d9b <vector36>: .globl vector36 vector36: pushl $0 80106d9b: 6a 00 push $0x0 pushl $36 80106d9d: 6a 24 push $0x24 jmp alltraps 80106d9f: e9 f5 f9 ff ff jmp 80106799 <alltraps> 80106da4 <vector37>: .globl vector37 vector37: pushl $0 80106da4: 6a 00 push $0x0 pushl $37 80106da6: 6a 25 push $0x25 jmp alltraps 80106da8: e9 ec f9 ff ff jmp 80106799 <alltraps> 80106dad <vector38>: .globl vector38 vector38: pushl $0 80106dad: 6a 00 push $0x0 pushl $38 80106daf: 6a 26 push $0x26 jmp alltraps 80106db1: e9 e3 f9 ff ff jmp 80106799 <alltraps> 80106db6 <vector39>: .globl vector39 vector39: pushl $0 80106db6: 6a 00 push $0x0 pushl $39 80106db8: 6a 27 push $0x27 jmp alltraps 80106dba: e9 da f9 ff ff jmp 80106799 <alltraps> 80106dbf <vector40>: .globl vector40 vector40: pushl $0 80106dbf: 6a 00 push $0x0 pushl $40 80106dc1: 6a 28 push $0x28 jmp alltraps 80106dc3: e9 d1 f9 ff ff jmp 80106799 <alltraps> 80106dc8 <vector41>: .globl vector41 vector41: pushl $0 80106dc8: 6a 00 push $0x0 pushl $41 80106dca: 6a 29 push $0x29 jmp alltraps 80106dcc: e9 c8 f9 ff ff jmp 80106799 <alltraps> 80106dd1 <vector42>: .globl vector42 vector42: pushl $0 80106dd1: 6a 00 push $0x0 pushl $42 80106dd3: 6a 2a push $0x2a jmp alltraps 80106dd5: e9 bf f9 ff ff jmp 80106799 <alltraps> 80106dda <vector43>: .globl vector43 vector43: pushl $0 80106dda: 6a 00 push $0x0 pushl $43 80106ddc: 6a 2b push $0x2b jmp alltraps 80106dde: e9 b6 f9 ff ff jmp 80106799 <alltraps> 80106de3 <vector44>: .globl vector44 vector44: pushl $0 80106de3: 6a 00 push $0x0 pushl $44 80106de5: 6a 2c push $0x2c jmp alltraps 80106de7: e9 ad f9 ff ff jmp 80106799 <alltraps> 80106dec <vector45>: .globl vector45 vector45: pushl $0 80106dec: 6a 00 push $0x0 pushl $45 80106dee: 6a 2d push $0x2d jmp alltraps 80106df0: e9 a4 f9 ff ff jmp 80106799 <alltraps> 80106df5 <vector46>: .globl vector46 vector46: pushl $0 80106df5: 6a 00 push $0x0 pushl $46 80106df7: 6a 2e push $0x2e jmp alltraps 80106df9: e9 9b f9 ff ff jmp 80106799 <alltraps> 80106dfe <vector47>: .globl vector47 vector47: pushl $0 80106dfe: 6a 00 push $0x0 pushl $47 80106e00: 6a 2f push $0x2f jmp alltraps 80106e02: e9 92 f9 ff ff jmp 80106799 <alltraps> 80106e07 <vector48>: .globl vector48 vector48: pushl $0 80106e07: 6a 00 push $0x0 pushl $48 80106e09: 6a 30 push $0x30 jmp alltraps 80106e0b: e9 89 f9 ff ff jmp 80106799 <alltraps> 80106e10 <vector49>: .globl vector49 vector49: pushl $0 80106e10: 6a 00 push $0x0 pushl $49 80106e12: 6a 31 push $0x31 jmp alltraps 80106e14: e9 80 f9 ff ff jmp 80106799 <alltraps> 80106e19 <vector50>: .globl vector50 vector50: pushl $0 80106e19: 6a 00 push $0x0 pushl $50 80106e1b: 6a 32 push $0x32 jmp alltraps 80106e1d: e9 77 f9 ff ff jmp 80106799 <alltraps> 80106e22 <vector51>: .globl vector51 vector51: pushl $0 80106e22: 6a 00 push $0x0 pushl $51 80106e24: 6a 33 push $0x33 jmp alltraps 80106e26: e9 6e f9 ff ff jmp 80106799 <alltraps> 80106e2b <vector52>: .globl vector52 vector52: pushl $0 80106e2b: 6a 00 push $0x0 pushl $52 80106e2d: 6a 34 push $0x34 jmp alltraps 80106e2f: e9 65 f9 ff ff jmp 80106799 <alltraps> 80106e34 <vector53>: .globl vector53 vector53: pushl $0 80106e34: 6a 00 push $0x0 pushl $53 80106e36: 6a 35 push $0x35 jmp alltraps 80106e38: e9 5c f9 ff ff jmp 80106799 <alltraps> 80106e3d <vector54>: .globl vector54 vector54: pushl $0 80106e3d: 6a 00 push $0x0 pushl $54 80106e3f: 6a 36 push $0x36 jmp alltraps 80106e41: e9 53 f9 ff ff jmp 80106799 <alltraps> 80106e46 <vector55>: .globl vector55 vector55: pushl $0 80106e46: 6a 00 push $0x0 pushl $55 80106e48: 6a 37 push $0x37 jmp alltraps 80106e4a: e9 4a f9 ff ff jmp 80106799 <alltraps> 80106e4f <vector56>: .globl vector56 vector56: pushl $0 80106e4f: 6a 00 push $0x0 pushl $56 80106e51: 6a 38 push $0x38 jmp alltraps 80106e53: e9 41 f9 ff ff jmp 80106799 <alltraps> 80106e58 <vector57>: .globl vector57 vector57: pushl $0 80106e58: 6a 00 push $0x0 pushl $57 80106e5a: 6a 39 push $0x39 jmp alltraps 80106e5c: e9 38 f9 ff ff jmp 80106799 <alltraps> 80106e61 <vector58>: .globl vector58 vector58: pushl $0 80106e61: 6a 00 push $0x0 pushl $58 80106e63: 6a 3a push $0x3a jmp alltraps 80106e65: e9 2f f9 ff ff jmp 80106799 <alltraps> 80106e6a <vector59>: .globl vector59 vector59: pushl $0 80106e6a: 6a 00 push $0x0 pushl $59 80106e6c: 6a 3b push $0x3b jmp alltraps 80106e6e: e9 26 f9 ff ff jmp 80106799 <alltraps> 80106e73 <vector60>: .globl vector60 vector60: pushl $0 80106e73: 6a 00 push $0x0 pushl $60 80106e75: 6a 3c push $0x3c jmp alltraps 80106e77: e9 1d f9 ff ff jmp 80106799 <alltraps> 80106e7c <vector61>: .globl vector61 vector61: pushl $0 80106e7c: 6a 00 push $0x0 pushl $61 80106e7e: 6a 3d push $0x3d jmp alltraps 80106e80: e9 14 f9 ff ff jmp 80106799 <alltraps> 80106e85 <vector62>: .globl vector62 vector62: pushl $0 80106e85: 6a 00 push $0x0 pushl $62 80106e87: 6a 3e push $0x3e jmp alltraps 80106e89: e9 0b f9 ff ff jmp 80106799 <alltraps> 80106e8e <vector63>: .globl vector63 vector63: pushl $0 80106e8e: 6a 00 push $0x0 pushl $63 80106e90: 6a 3f push $0x3f jmp alltraps 80106e92: e9 02 f9 ff ff jmp 80106799 <alltraps> 80106e97 <vector64>: .globl vector64 vector64: pushl $0 80106e97: 6a 00 push $0x0 pushl $64 80106e99: 6a 40 push $0x40 jmp alltraps 80106e9b: e9 f9 f8 ff ff jmp 80106799 <alltraps> 80106ea0 <vector65>: .globl vector65 vector65: pushl $0 80106ea0: 6a 00 push $0x0 pushl $65 80106ea2: 6a 41 push $0x41 jmp alltraps 80106ea4: e9 f0 f8 ff ff jmp 80106799 <alltraps> 80106ea9 <vector66>: .globl vector66 vector66: pushl $0 80106ea9: 6a 00 push $0x0 pushl $66 80106eab: 6a 42 push $0x42 jmp alltraps 80106ead: e9 e7 f8 ff ff jmp 80106799 <alltraps> 80106eb2 <vector67>: .globl vector67 vector67: pushl $0 80106eb2: 6a 00 push $0x0 pushl $67 80106eb4: 6a 43 push $0x43 jmp alltraps 80106eb6: e9 de f8 ff ff jmp 80106799 <alltraps> 80106ebb <vector68>: .globl vector68 vector68: pushl $0 80106ebb: 6a 00 push $0x0 pushl $68 80106ebd: 6a 44 push $0x44 jmp alltraps 80106ebf: e9 d5 f8 ff ff jmp 80106799 <alltraps> 80106ec4 <vector69>: .globl vector69 vector69: pushl $0 80106ec4: 6a 00 push $0x0 pushl $69 80106ec6: 6a 45 push $0x45 jmp alltraps 80106ec8: e9 cc f8 ff ff jmp 80106799 <alltraps> 80106ecd <vector70>: .globl vector70 vector70: pushl $0 80106ecd: 6a 00 push $0x0 pushl $70 80106ecf: 6a 46 push $0x46 jmp alltraps 80106ed1: e9 c3 f8 ff ff jmp 80106799 <alltraps> 80106ed6 <vector71>: .globl vector71 vector71: pushl $0 80106ed6: 6a 00 push $0x0 pushl $71 80106ed8: 6a 47 push $0x47 jmp alltraps 80106eda: e9 ba f8 ff ff jmp 80106799 <alltraps> 80106edf <vector72>: .globl vector72 vector72: pushl $0 80106edf: 6a 00 push $0x0 pushl $72 80106ee1: 6a 48 push $0x48 jmp alltraps 80106ee3: e9 b1 f8 ff ff jmp 80106799 <alltraps> 80106ee8 <vector73>: .globl vector73 vector73: pushl $0 80106ee8: 6a 00 push $0x0 pushl $73 80106eea: 6a 49 push $0x49 jmp alltraps 80106eec: e9 a8 f8 ff ff jmp 80106799 <alltraps> 80106ef1 <vector74>: .globl vector74 vector74: pushl $0 80106ef1: 6a 00 push $0x0 pushl $74 80106ef3: 6a 4a push $0x4a jmp alltraps 80106ef5: e9 9f f8 ff ff jmp 80106799 <alltraps> 80106efa <vector75>: .globl vector75 vector75: pushl $0 80106efa: 6a 00 push $0x0 pushl $75 80106efc: 6a 4b push $0x4b jmp alltraps 80106efe: e9 96 f8 ff ff jmp 80106799 <alltraps> 80106f03 <vector76>: .globl vector76 vector76: pushl $0 80106f03: 6a 00 push $0x0 pushl $76 80106f05: 6a 4c push $0x4c jmp alltraps 80106f07: e9 8d f8 ff ff jmp 80106799 <alltraps> 80106f0c <vector77>: .globl vector77 vector77: pushl $0 80106f0c: 6a 00 push $0x0 pushl $77 80106f0e: 6a 4d push $0x4d jmp alltraps 80106f10: e9 84 f8 ff ff jmp 80106799 <alltraps> 80106f15 <vector78>: .globl vector78 vector78: pushl $0 80106f15: 6a 00 push $0x0 pushl $78 80106f17: 6a 4e push $0x4e jmp alltraps 80106f19: e9 7b f8 ff ff jmp 80106799 <alltraps> 80106f1e <vector79>: .globl vector79 vector79: pushl $0 80106f1e: 6a 00 push $0x0 pushl $79 80106f20: 6a 4f push $0x4f jmp alltraps 80106f22: e9 72 f8 ff ff jmp 80106799 <alltraps> 80106f27 <vector80>: .globl vector80 vector80: pushl $0 80106f27: 6a 00 push $0x0 pushl $80 80106f29: 6a 50 push $0x50 jmp alltraps 80106f2b: e9 69 f8 ff ff jmp 80106799 <alltraps> 80106f30 <vector81>: .globl vector81 vector81: pushl $0 80106f30: 6a 00 push $0x0 pushl $81 80106f32: 6a 51 push $0x51 jmp alltraps 80106f34: e9 60 f8 ff ff jmp 80106799 <alltraps> 80106f39 <vector82>: .globl vector82 vector82: pushl $0 80106f39: 6a 00 push $0x0 pushl $82 80106f3b: 6a 52 push $0x52 jmp alltraps 80106f3d: e9 57 f8 ff ff jmp 80106799 <alltraps> 80106f42 <vector83>: .globl vector83 vector83: pushl $0 80106f42: 6a 00 push $0x0 pushl $83 80106f44: 6a 53 push $0x53 jmp alltraps 80106f46: e9 4e f8 ff ff jmp 80106799 <alltraps> 80106f4b <vector84>: .globl vector84 vector84: pushl $0 80106f4b: 6a 00 push $0x0 pushl $84 80106f4d: 6a 54 push $0x54 jmp alltraps 80106f4f: e9 45 f8 ff ff jmp 80106799 <alltraps> 80106f54 <vector85>: .globl vector85 vector85: pushl $0 80106f54: 6a 00 push $0x0 pushl $85 80106f56: 6a 55 push $0x55 jmp alltraps 80106f58: e9 3c f8 ff ff jmp 80106799 <alltraps> 80106f5d <vector86>: .globl vector86 vector86: pushl $0 80106f5d: 6a 00 push $0x0 pushl $86 80106f5f: 6a 56 push $0x56 jmp alltraps 80106f61: e9 33 f8 ff ff jmp 80106799 <alltraps> 80106f66 <vector87>: .globl vector87 vector87: pushl $0 80106f66: 6a 00 push $0x0 pushl $87 80106f68: 6a 57 push $0x57 jmp alltraps 80106f6a: e9 2a f8 ff ff jmp 80106799 <alltraps> 80106f6f <vector88>: .globl vector88 vector88: pushl $0 80106f6f: 6a 00 push $0x0 pushl $88 80106f71: 6a 58 push $0x58 jmp alltraps 80106f73: e9 21 f8 ff ff jmp 80106799 <alltraps> 80106f78 <vector89>: .globl vector89 vector89: pushl $0 80106f78: 6a 00 push $0x0 pushl $89 80106f7a: 6a 59 push $0x59 jmp alltraps 80106f7c: e9 18 f8 ff ff jmp 80106799 <alltraps> 80106f81 <vector90>: .globl vector90 vector90: pushl $0 80106f81: 6a 00 push $0x0 pushl $90 80106f83: 6a 5a push $0x5a jmp alltraps 80106f85: e9 0f f8 ff ff jmp 80106799 <alltraps> 80106f8a <vector91>: .globl vector91 vector91: pushl $0 80106f8a: 6a 00 push $0x0 pushl $91 80106f8c: 6a 5b push $0x5b jmp alltraps 80106f8e: e9 06 f8 ff ff jmp 80106799 <alltraps> 80106f93 <vector92>: .globl vector92 vector92: pushl $0 80106f93: 6a 00 push $0x0 pushl $92 80106f95: 6a 5c push $0x5c jmp alltraps 80106f97: e9 fd f7 ff ff jmp 80106799 <alltraps> 80106f9c <vector93>: .globl vector93 vector93: pushl $0 80106f9c: 6a 00 push $0x0 pushl $93 80106f9e: 6a 5d push $0x5d jmp alltraps 80106fa0: e9 f4 f7 ff ff jmp 80106799 <alltraps> 80106fa5 <vector94>: .globl vector94 vector94: pushl $0 80106fa5: 6a 00 push $0x0 pushl $94 80106fa7: 6a 5e push $0x5e jmp alltraps 80106fa9: e9 eb f7 ff ff jmp 80106799 <alltraps> 80106fae <vector95>: .globl vector95 vector95: pushl $0 80106fae: 6a 00 push $0x0 pushl $95 80106fb0: 6a 5f push $0x5f jmp alltraps 80106fb2: e9 e2 f7 ff ff jmp 80106799 <alltraps> 80106fb7 <vector96>: .globl vector96 vector96: pushl $0 80106fb7: 6a 00 push $0x0 pushl $96 80106fb9: 6a 60 push $0x60 jmp alltraps 80106fbb: e9 d9 f7 ff ff jmp 80106799 <alltraps> 80106fc0 <vector97>: .globl vector97 vector97: pushl $0 80106fc0: 6a 00 push $0x0 pushl $97 80106fc2: 6a 61 push $0x61 jmp alltraps 80106fc4: e9 d0 f7 ff ff jmp 80106799 <alltraps> 80106fc9 <vector98>: .globl vector98 vector98: pushl $0 80106fc9: 6a 00 push $0x0 pushl $98 80106fcb: 6a 62 push $0x62 jmp alltraps 80106fcd: e9 c7 f7 ff ff jmp 80106799 <alltraps> 80106fd2 <vector99>: .globl vector99 vector99: pushl $0 80106fd2: 6a 00 push $0x0 pushl $99 80106fd4: 6a 63 push $0x63 jmp alltraps 80106fd6: e9 be f7 ff ff jmp 80106799 <alltraps> 80106fdb <vector100>: .globl vector100 vector100: pushl $0 80106fdb: 6a 00 push $0x0 pushl $100 80106fdd: 6a 64 push $0x64 jmp alltraps 80106fdf: e9 b5 f7 ff ff jmp 80106799 <alltraps> 80106fe4 <vector101>: .globl vector101 vector101: pushl $0 80106fe4: 6a 00 push $0x0 pushl $101 80106fe6: 6a 65 push $0x65 jmp alltraps 80106fe8: e9 ac f7 ff ff jmp 80106799 <alltraps> 80106fed <vector102>: .globl vector102 vector102: pushl $0 80106fed: 6a 00 push $0x0 pushl $102 80106fef: 6a 66 push $0x66 jmp alltraps 80106ff1: e9 a3 f7 ff ff jmp 80106799 <alltraps> 80106ff6 <vector103>: .globl vector103 vector103: pushl $0 80106ff6: 6a 00 push $0x0 pushl $103 80106ff8: 6a 67 push $0x67 jmp alltraps 80106ffa: e9 9a f7 ff ff jmp 80106799 <alltraps> 80106fff <vector104>: .globl vector104 vector104: pushl $0 80106fff: 6a 00 push $0x0 pushl $104 80107001: 6a 68 push $0x68 jmp alltraps 80107003: e9 91 f7 ff ff jmp 80106799 <alltraps> 80107008 <vector105>: .globl vector105 vector105: pushl $0 80107008: 6a 00 push $0x0 pushl $105 8010700a: 6a 69 push $0x69 jmp alltraps 8010700c: e9 88 f7 ff ff jmp 80106799 <alltraps> 80107011 <vector106>: .globl vector106 vector106: pushl $0 80107011: 6a 00 push $0x0 pushl $106 80107013: 6a 6a push $0x6a jmp alltraps 80107015: e9 7f f7 ff ff jmp 80106799 <alltraps> 8010701a <vector107>: .globl vector107 vector107: pushl $0 8010701a: 6a 00 push $0x0 pushl $107 8010701c: 6a 6b push $0x6b jmp alltraps 8010701e: e9 76 f7 ff ff jmp 80106799 <alltraps> 80107023 <vector108>: .globl vector108 vector108: pushl $0 80107023: 6a 00 push $0x0 pushl $108 80107025: 6a 6c push $0x6c jmp alltraps 80107027: e9 6d f7 ff ff jmp 80106799 <alltraps> 8010702c <vector109>: .globl vector109 vector109: pushl $0 8010702c: 6a 00 push $0x0 pushl $109 8010702e: 6a 6d push $0x6d jmp alltraps 80107030: e9 64 f7 ff ff jmp 80106799 <alltraps> 80107035 <vector110>: .globl vector110 vector110: pushl $0 80107035: 6a 00 push $0x0 pushl $110 80107037: 6a 6e push $0x6e jmp alltraps 80107039: e9 5b f7 ff ff jmp 80106799 <alltraps> 8010703e <vector111>: .globl vector111 vector111: pushl $0 8010703e: 6a 00 push $0x0 pushl $111 80107040: 6a 6f push $0x6f jmp alltraps 80107042: e9 52 f7 ff ff jmp 80106799 <alltraps> 80107047 <vector112>: .globl vector112 vector112: pushl $0 80107047: 6a 00 push $0x0 pushl $112 80107049: 6a 70 push $0x70 jmp alltraps 8010704b: e9 49 f7 ff ff jmp 80106799 <alltraps> 80107050 <vector113>: .globl vector113 vector113: pushl $0 80107050: 6a 00 push $0x0 pushl $113 80107052: 6a 71 push $0x71 jmp alltraps 80107054: e9 40 f7 ff ff jmp 80106799 <alltraps> 80107059 <vector114>: .globl vector114 vector114: pushl $0 80107059: 6a 00 push $0x0 pushl $114 8010705b: 6a 72 push $0x72 jmp alltraps 8010705d: e9 37 f7 ff ff jmp 80106799 <alltraps> 80107062 <vector115>: .globl vector115 vector115: pushl $0 80107062: 6a 00 push $0x0 pushl $115 80107064: 6a 73 push $0x73 jmp alltraps 80107066: e9 2e f7 ff ff jmp 80106799 <alltraps> 8010706b <vector116>: .globl vector116 vector116: pushl $0 8010706b: 6a 00 push $0x0 pushl $116 8010706d: 6a 74 push $0x74 jmp alltraps 8010706f: e9 25 f7 ff ff jmp 80106799 <alltraps> 80107074 <vector117>: .globl vector117 vector117: pushl $0 80107074: 6a 00 push $0x0 pushl $117 80107076: 6a 75 push $0x75 jmp alltraps 80107078: e9 1c f7 ff ff jmp 80106799 <alltraps> 8010707d <vector118>: .globl vector118 vector118: pushl $0 8010707d: 6a 00 push $0x0 pushl $118 8010707f: 6a 76 push $0x76 jmp alltraps 80107081: e9 13 f7 ff ff jmp 80106799 <alltraps> 80107086 <vector119>: .globl vector119 vector119: pushl $0 80107086: 6a 00 push $0x0 pushl $119 80107088: 6a 77 push $0x77 jmp alltraps 8010708a: e9 0a f7 ff ff jmp 80106799 <alltraps> 8010708f <vector120>: .globl vector120 vector120: pushl $0 8010708f: 6a 00 push $0x0 pushl $120 80107091: 6a 78 push $0x78 jmp alltraps 80107093: e9 01 f7 ff ff jmp 80106799 <alltraps> 80107098 <vector121>: .globl vector121 vector121: pushl $0 80107098: 6a 00 push $0x0 pushl $121 8010709a: 6a 79 push $0x79 jmp alltraps 8010709c: e9 f8 f6 ff ff jmp 80106799 <alltraps> 801070a1 <vector122>: .globl vector122 vector122: pushl $0 801070a1: 6a 00 push $0x0 pushl $122 801070a3: 6a 7a push $0x7a jmp alltraps 801070a5: e9 ef f6 ff ff jmp 80106799 <alltraps> 801070aa <vector123>: .globl vector123 vector123: pushl $0 801070aa: 6a 00 push $0x0 pushl $123 801070ac: 6a 7b push $0x7b jmp alltraps 801070ae: e9 e6 f6 ff ff jmp 80106799 <alltraps> 801070b3 <vector124>: .globl vector124 vector124: pushl $0 801070b3: 6a 00 push $0x0 pushl $124 801070b5: 6a 7c push $0x7c jmp alltraps 801070b7: e9 dd f6 ff ff jmp 80106799 <alltraps> 801070bc <vector125>: .globl vector125 vector125: pushl $0 801070bc: 6a 00 push $0x0 pushl $125 801070be: 6a 7d push $0x7d jmp alltraps 801070c0: e9 d4 f6 ff ff jmp 80106799 <alltraps> 801070c5 <vector126>: .globl vector126 vector126: pushl $0 801070c5: 6a 00 push $0x0 pushl $126 801070c7: 6a 7e push $0x7e jmp alltraps 801070c9: e9 cb f6 ff ff jmp 80106799 <alltraps> 801070ce <vector127>: .globl vector127 vector127: pushl $0 801070ce: 6a 00 push $0x0 pushl $127 801070d0: 6a 7f push $0x7f jmp alltraps 801070d2: e9 c2 f6 ff ff jmp 80106799 <alltraps> 801070d7 <vector128>: .globl vector128 vector128: pushl $0 801070d7: 6a 00 push $0x0 pushl $128 801070d9: 68 80 00 00 00 push $0x80 jmp alltraps 801070de: e9 b6 f6 ff ff jmp 80106799 <alltraps> 801070e3 <vector129>: .globl vector129 vector129: pushl $0 801070e3: 6a 00 push $0x0 pushl $129 801070e5: 68 81 00 00 00 push $0x81 jmp alltraps 801070ea: e9 aa f6 ff ff jmp 80106799 <alltraps> 801070ef <vector130>: .globl vector130 vector130: pushl $0 801070ef: 6a 00 push $0x0 pushl $130 801070f1: 68 82 00 00 00 push $0x82 jmp alltraps 801070f6: e9 9e f6 ff ff jmp 80106799 <alltraps> 801070fb <vector131>: .globl vector131 vector131: pushl $0 801070fb: 6a 00 push $0x0 pushl $131 801070fd: 68 83 00 00 00 push $0x83 jmp alltraps 80107102: e9 92 f6 ff ff jmp 80106799 <alltraps> 80107107 <vector132>: .globl vector132 vector132: pushl $0 80107107: 6a 00 push $0x0 pushl $132 80107109: 68 84 00 00 00 push $0x84 jmp alltraps 8010710e: e9 86 f6 ff ff jmp 80106799 <alltraps> 80107113 <vector133>: .globl vector133 vector133: pushl $0 80107113: 6a 00 push $0x0 pushl $133 80107115: 68 85 00 00 00 push $0x85 jmp alltraps 8010711a: e9 7a f6 ff ff jmp 80106799 <alltraps> 8010711f <vector134>: .globl vector134 vector134: pushl $0 8010711f: 6a 00 push $0x0 pushl $134 80107121: 68 86 00 00 00 push $0x86 jmp alltraps 80107126: e9 6e f6 ff ff jmp 80106799 <alltraps> 8010712b <vector135>: .globl vector135 vector135: pushl $0 8010712b: 6a 00 push $0x0 pushl $135 8010712d: 68 87 00 00 00 push $0x87 jmp alltraps 80107132: e9 62 f6 ff ff jmp 80106799 <alltraps> 80107137 <vector136>: .globl vector136 vector136: pushl $0 80107137: 6a 00 push $0x0 pushl $136 80107139: 68 88 00 00 00 push $0x88 jmp alltraps 8010713e: e9 56 f6 ff ff jmp 80106799 <alltraps> 80107143 <vector137>: .globl vector137 vector137: pushl $0 80107143: 6a 00 push $0x0 pushl $137 80107145: 68 89 00 00 00 push $0x89 jmp alltraps 8010714a: e9 4a f6 ff ff jmp 80106799 <alltraps> 8010714f <vector138>: .globl vector138 vector138: pushl $0 8010714f: 6a 00 push $0x0 pushl $138 80107151: 68 8a 00 00 00 push $0x8a jmp alltraps 80107156: e9 3e f6 ff ff jmp 80106799 <alltraps> 8010715b <vector139>: .globl vector139 vector139: pushl $0 8010715b: 6a 00 push $0x0 pushl $139 8010715d: 68 8b 00 00 00 push $0x8b jmp alltraps 80107162: e9 32 f6 ff ff jmp 80106799 <alltraps> 80107167 <vector140>: .globl vector140 vector140: pushl $0 80107167: 6a 00 push $0x0 pushl $140 80107169: 68 8c 00 00 00 push $0x8c jmp alltraps 8010716e: e9 26 f6 ff ff jmp 80106799 <alltraps> 80107173 <vector141>: .globl vector141 vector141: pushl $0 80107173: 6a 00 push $0x0 pushl $141 80107175: 68 8d 00 00 00 push $0x8d jmp alltraps 8010717a: e9 1a f6 ff ff jmp 80106799 <alltraps> 8010717f <vector142>: .globl vector142 vector142: pushl $0 8010717f: 6a 00 push $0x0 pushl $142 80107181: 68 8e 00 00 00 push $0x8e jmp alltraps 80107186: e9 0e f6 ff ff jmp 80106799 <alltraps> 8010718b <vector143>: .globl vector143 vector143: pushl $0 8010718b: 6a 00 push $0x0 pushl $143 8010718d: 68 8f 00 00 00 push $0x8f jmp alltraps 80107192: e9 02 f6 ff ff jmp 80106799 <alltraps> 80107197 <vector144>: .globl vector144 vector144: pushl $0 80107197: 6a 00 push $0x0 pushl $144 80107199: 68 90 00 00 00 push $0x90 jmp alltraps 8010719e: e9 f6 f5 ff ff jmp 80106799 <alltraps> 801071a3 <vector145>: .globl vector145 vector145: pushl $0 801071a3: 6a 00 push $0x0 pushl $145 801071a5: 68 91 00 00 00 push $0x91 jmp alltraps 801071aa: e9 ea f5 ff ff jmp 80106799 <alltraps> 801071af <vector146>: .globl vector146 vector146: pushl $0 801071af: 6a 00 push $0x0 pushl $146 801071b1: 68 92 00 00 00 push $0x92 jmp alltraps 801071b6: e9 de f5 ff ff jmp 80106799 <alltraps> 801071bb <vector147>: .globl vector147 vector147: pushl $0 801071bb: 6a 00 push $0x0 pushl $147 801071bd: 68 93 00 00 00 push $0x93 jmp alltraps 801071c2: e9 d2 f5 ff ff jmp 80106799 <alltraps> 801071c7 <vector148>: .globl vector148 vector148: pushl $0 801071c7: 6a 00 push $0x0 pushl $148 801071c9: 68 94 00 00 00 push $0x94 jmp alltraps 801071ce: e9 c6 f5 ff ff jmp 80106799 <alltraps> 801071d3 <vector149>: .globl vector149 vector149: pushl $0 801071d3: 6a 00 push $0x0 pushl $149 801071d5: 68 95 00 00 00 push $0x95 jmp alltraps 801071da: e9 ba f5 ff ff jmp 80106799 <alltraps> 801071df <vector150>: .globl vector150 vector150: pushl $0 801071df: 6a 00 push $0x0 pushl $150 801071e1: 68 96 00 00 00 push $0x96 jmp alltraps 801071e6: e9 ae f5 ff ff jmp 80106799 <alltraps> 801071eb <vector151>: .globl vector151 vector151: pushl $0 801071eb: 6a 00 push $0x0 pushl $151 801071ed: 68 97 00 00 00 push $0x97 jmp alltraps 801071f2: e9 a2 f5 ff ff jmp 80106799 <alltraps> 801071f7 <vector152>: .globl vector152 vector152: pushl $0 801071f7: 6a 00 push $0x0 pushl $152 801071f9: 68 98 00 00 00 push $0x98 jmp alltraps 801071fe: e9 96 f5 ff ff jmp 80106799 <alltraps> 80107203 <vector153>: .globl vector153 vector153: pushl $0 80107203: 6a 00 push $0x0 pushl $153 80107205: 68 99 00 00 00 push $0x99 jmp alltraps 8010720a: e9 8a f5 ff ff jmp 80106799 <alltraps> 8010720f <vector154>: .globl vector154 vector154: pushl $0 8010720f: 6a 00 push $0x0 pushl $154 80107211: 68 9a 00 00 00 push $0x9a jmp alltraps 80107216: e9 7e f5 ff ff jmp 80106799 <alltraps> 8010721b <vector155>: .globl vector155 vector155: pushl $0 8010721b: 6a 00 push $0x0 pushl $155 8010721d: 68 9b 00 00 00 push $0x9b jmp alltraps 80107222: e9 72 f5 ff ff jmp 80106799 <alltraps> 80107227 <vector156>: .globl vector156 vector156: pushl $0 80107227: 6a 00 push $0x0 pushl $156 80107229: 68 9c 00 00 00 push $0x9c jmp alltraps 8010722e: e9 66 f5 ff ff jmp 80106799 <alltraps> 80107233 <vector157>: .globl vector157 vector157: pushl $0 80107233: 6a 00 push $0x0 pushl $157 80107235: 68 9d 00 00 00 push $0x9d jmp alltraps 8010723a: e9 5a f5 ff ff jmp 80106799 <alltraps> 8010723f <vector158>: .globl vector158 vector158: pushl $0 8010723f: 6a 00 push $0x0 pushl $158 80107241: 68 9e 00 00 00 push $0x9e jmp alltraps 80107246: e9 4e f5 ff ff jmp 80106799 <alltraps> 8010724b <vector159>: .globl vector159 vector159: pushl $0 8010724b: 6a 00 push $0x0 pushl $159 8010724d: 68 9f 00 00 00 push $0x9f jmp alltraps 80107252: e9 42 f5 ff ff jmp 80106799 <alltraps> 80107257 <vector160>: .globl vector160 vector160: pushl $0 80107257: 6a 00 push $0x0 pushl $160 80107259: 68 a0 00 00 00 push $0xa0 jmp alltraps 8010725e: e9 36 f5 ff ff jmp 80106799 <alltraps> 80107263 <vector161>: .globl vector161 vector161: pushl $0 80107263: 6a 00 push $0x0 pushl $161 80107265: 68 a1 00 00 00 push $0xa1 jmp alltraps 8010726a: e9 2a f5 ff ff jmp 80106799 <alltraps> 8010726f <vector162>: .globl vector162 vector162: pushl $0 8010726f: 6a 00 push $0x0 pushl $162 80107271: 68 a2 00 00 00 push $0xa2 jmp alltraps 80107276: e9 1e f5 ff ff jmp 80106799 <alltraps> 8010727b <vector163>: .globl vector163 vector163: pushl $0 8010727b: 6a 00 push $0x0 pushl $163 8010727d: 68 a3 00 00 00 push $0xa3 jmp alltraps 80107282: e9 12 f5 ff ff jmp 80106799 <alltraps> 80107287 <vector164>: .globl vector164 vector164: pushl $0 80107287: 6a 00 push $0x0 pushl $164 80107289: 68 a4 00 00 00 push $0xa4 jmp alltraps 8010728e: e9 06 f5 ff ff jmp 80106799 <alltraps> 80107293 <vector165>: .globl vector165 vector165: pushl $0 80107293: 6a 00 push $0x0 pushl $165 80107295: 68 a5 00 00 00 push $0xa5 jmp alltraps 8010729a: e9 fa f4 ff ff jmp 80106799 <alltraps> 8010729f <vector166>: .globl vector166 vector166: pushl $0 8010729f: 6a 00 push $0x0 pushl $166 801072a1: 68 a6 00 00 00 push $0xa6 jmp alltraps 801072a6: e9 ee f4 ff ff jmp 80106799 <alltraps> 801072ab <vector167>: .globl vector167 vector167: pushl $0 801072ab: 6a 00 push $0x0 pushl $167 801072ad: 68 a7 00 00 00 push $0xa7 jmp alltraps 801072b2: e9 e2 f4 ff ff jmp 80106799 <alltraps> 801072b7 <vector168>: .globl vector168 vector168: pushl $0 801072b7: 6a 00 push $0x0 pushl $168 801072b9: 68 a8 00 00 00 push $0xa8 jmp alltraps 801072be: e9 d6 f4 ff ff jmp 80106799 <alltraps> 801072c3 <vector169>: .globl vector169 vector169: pushl $0 801072c3: 6a 00 push $0x0 pushl $169 801072c5: 68 a9 00 00 00 push $0xa9 jmp alltraps 801072ca: e9 ca f4 ff ff jmp 80106799 <alltraps> 801072cf <vector170>: .globl vector170 vector170: pushl $0 801072cf: 6a 00 push $0x0 pushl $170 801072d1: 68 aa 00 00 00 push $0xaa jmp alltraps 801072d6: e9 be f4 ff ff jmp 80106799 <alltraps> 801072db <vector171>: .globl vector171 vector171: pushl $0 801072db: 6a 00 push $0x0 pushl $171 801072dd: 68 ab 00 00 00 push $0xab jmp alltraps 801072e2: e9 b2 f4 ff ff jmp 80106799 <alltraps> 801072e7 <vector172>: .globl vector172 vector172: pushl $0 801072e7: 6a 00 push $0x0 pushl $172 801072e9: 68 ac 00 00 00 push $0xac jmp alltraps 801072ee: e9 a6 f4 ff ff jmp 80106799 <alltraps> 801072f3 <vector173>: .globl vector173 vector173: pushl $0 801072f3: 6a 00 push $0x0 pushl $173 801072f5: 68 ad 00 00 00 push $0xad jmp alltraps 801072fa: e9 9a f4 ff ff jmp 80106799 <alltraps> 801072ff <vector174>: .globl vector174 vector174: pushl $0 801072ff: 6a 00 push $0x0 pushl $174 80107301: 68 ae 00 00 00 push $0xae jmp alltraps 80107306: e9 8e f4 ff ff jmp 80106799 <alltraps> 8010730b <vector175>: .globl vector175 vector175: pushl $0 8010730b: 6a 00 push $0x0 pushl $175 8010730d: 68 af 00 00 00 push $0xaf jmp alltraps 80107312: e9 82 f4 ff ff jmp 80106799 <alltraps> 80107317 <vector176>: .globl vector176 vector176: pushl $0 80107317: 6a 00 push $0x0 pushl $176 80107319: 68 b0 00 00 00 push $0xb0 jmp alltraps 8010731e: e9 76 f4 ff ff jmp 80106799 <alltraps> 80107323 <vector177>: .globl vector177 vector177: pushl $0 80107323: 6a 00 push $0x0 pushl $177 80107325: 68 b1 00 00 00 push $0xb1 jmp alltraps 8010732a: e9 6a f4 ff ff jmp 80106799 <alltraps> 8010732f <vector178>: .globl vector178 vector178: pushl $0 8010732f: 6a 00 push $0x0 pushl $178 80107331: 68 b2 00 00 00 push $0xb2 jmp alltraps 80107336: e9 5e f4 ff ff jmp 80106799 <alltraps> 8010733b <vector179>: .globl vector179 vector179: pushl $0 8010733b: 6a 00 push $0x0 pushl $179 8010733d: 68 b3 00 00 00 push $0xb3 jmp alltraps 80107342: e9 52 f4 ff ff jmp 80106799 <alltraps> 80107347 <vector180>: .globl vector180 vector180: pushl $0 80107347: 6a 00 push $0x0 pushl $180 80107349: 68 b4 00 00 00 push $0xb4 jmp alltraps 8010734e: e9 46 f4 ff ff jmp 80106799 <alltraps> 80107353 <vector181>: .globl vector181 vector181: pushl $0 80107353: 6a 00 push $0x0 pushl $181 80107355: 68 b5 00 00 00 push $0xb5 jmp alltraps 8010735a: e9 3a f4 ff ff jmp 80106799 <alltraps> 8010735f <vector182>: .globl vector182 vector182: pushl $0 8010735f: 6a 00 push $0x0 pushl $182 80107361: 68 b6 00 00 00 push $0xb6 jmp alltraps 80107366: e9 2e f4 ff ff jmp 80106799 <alltraps> 8010736b <vector183>: .globl vector183 vector183: pushl $0 8010736b: 6a 00 push $0x0 pushl $183 8010736d: 68 b7 00 00 00 push $0xb7 jmp alltraps 80107372: e9 22 f4 ff ff jmp 80106799 <alltraps> 80107377 <vector184>: .globl vector184 vector184: pushl $0 80107377: 6a 00 push $0x0 pushl $184 80107379: 68 b8 00 00 00 push $0xb8 jmp alltraps 8010737e: e9 16 f4 ff ff jmp 80106799 <alltraps> 80107383 <vector185>: .globl vector185 vector185: pushl $0 80107383: 6a 00 push $0x0 pushl $185 80107385: 68 b9 00 00 00 push $0xb9 jmp alltraps 8010738a: e9 0a f4 ff ff jmp 80106799 <alltraps> 8010738f <vector186>: .globl vector186 vector186: pushl $0 8010738f: 6a 00 push $0x0 pushl $186 80107391: 68 ba 00 00 00 push $0xba jmp alltraps 80107396: e9 fe f3 ff ff jmp 80106799 <alltraps> 8010739b <vector187>: .globl vector187 vector187: pushl $0 8010739b: 6a 00 push $0x0 pushl $187 8010739d: 68 bb 00 00 00 push $0xbb jmp alltraps 801073a2: e9 f2 f3 ff ff jmp 80106799 <alltraps> 801073a7 <vector188>: .globl vector188 vector188: pushl $0 801073a7: 6a 00 push $0x0 pushl $188 801073a9: 68 bc 00 00 00 push $0xbc jmp alltraps 801073ae: e9 e6 f3 ff ff jmp 80106799 <alltraps> 801073b3 <vector189>: .globl vector189 vector189: pushl $0 801073b3: 6a 00 push $0x0 pushl $189 801073b5: 68 bd 00 00 00 push $0xbd jmp alltraps 801073ba: e9 da f3 ff ff jmp 80106799 <alltraps> 801073bf <vector190>: .globl vector190 vector190: pushl $0 801073bf: 6a 00 push $0x0 pushl $190 801073c1: 68 be 00 00 00 push $0xbe jmp alltraps 801073c6: e9 ce f3 ff ff jmp 80106799 <alltraps> 801073cb <vector191>: .globl vector191 vector191: pushl $0 801073cb: 6a 00 push $0x0 pushl $191 801073cd: 68 bf 00 00 00 push $0xbf jmp alltraps 801073d2: e9 c2 f3 ff ff jmp 80106799 <alltraps> 801073d7 <vector192>: .globl vector192 vector192: pushl $0 801073d7: 6a 00 push $0x0 pushl $192 801073d9: 68 c0 00 00 00 push $0xc0 jmp alltraps 801073de: e9 b6 f3 ff ff jmp 80106799 <alltraps> 801073e3 <vector193>: .globl vector193 vector193: pushl $0 801073e3: 6a 00 push $0x0 pushl $193 801073e5: 68 c1 00 00 00 push $0xc1 jmp alltraps 801073ea: e9 aa f3 ff ff jmp 80106799 <alltraps> 801073ef <vector194>: .globl vector194 vector194: pushl $0 801073ef: 6a 00 push $0x0 pushl $194 801073f1: 68 c2 00 00 00 push $0xc2 jmp alltraps 801073f6: e9 9e f3 ff ff jmp 80106799 <alltraps> 801073fb <vector195>: .globl vector195 vector195: pushl $0 801073fb: 6a 00 push $0x0 pushl $195 801073fd: 68 c3 00 00 00 push $0xc3 jmp alltraps 80107402: e9 92 f3 ff ff jmp 80106799 <alltraps> 80107407 <vector196>: .globl vector196 vector196: pushl $0 80107407: 6a 00 push $0x0 pushl $196 80107409: 68 c4 00 00 00 push $0xc4 jmp alltraps 8010740e: e9 86 f3 ff ff jmp 80106799 <alltraps> 80107413 <vector197>: .globl vector197 vector197: pushl $0 80107413: 6a 00 push $0x0 pushl $197 80107415: 68 c5 00 00 00 push $0xc5 jmp alltraps 8010741a: e9 7a f3 ff ff jmp 80106799 <alltraps> 8010741f <vector198>: .globl vector198 vector198: pushl $0 8010741f: 6a 00 push $0x0 pushl $198 80107421: 68 c6 00 00 00 push $0xc6 jmp alltraps 80107426: e9 6e f3 ff ff jmp 80106799 <alltraps> 8010742b <vector199>: .globl vector199 vector199: pushl $0 8010742b: 6a 00 push $0x0 pushl $199 8010742d: 68 c7 00 00 00 push $0xc7 jmp alltraps 80107432: e9 62 f3 ff ff jmp 80106799 <alltraps> 80107437 <vector200>: .globl vector200 vector200: pushl $0 80107437: 6a 00 push $0x0 pushl $200 80107439: 68 c8 00 00 00 push $0xc8 jmp alltraps 8010743e: e9 56 f3 ff ff jmp 80106799 <alltraps> 80107443 <vector201>: .globl vector201 vector201: pushl $0 80107443: 6a 00 push $0x0 pushl $201 80107445: 68 c9 00 00 00 push $0xc9 jmp alltraps 8010744a: e9 4a f3 ff ff jmp 80106799 <alltraps> 8010744f <vector202>: .globl vector202 vector202: pushl $0 8010744f: 6a 00 push $0x0 pushl $202 80107451: 68 ca 00 00 00 push $0xca jmp alltraps 80107456: e9 3e f3 ff ff jmp 80106799 <alltraps> 8010745b <vector203>: .globl vector203 vector203: pushl $0 8010745b: 6a 00 push $0x0 pushl $203 8010745d: 68 cb 00 00 00 push $0xcb jmp alltraps 80107462: e9 32 f3 ff ff jmp 80106799 <alltraps> 80107467 <vector204>: .globl vector204 vector204: pushl $0 80107467: 6a 00 push $0x0 pushl $204 80107469: 68 cc 00 00 00 push $0xcc jmp alltraps 8010746e: e9 26 f3 ff ff jmp 80106799 <alltraps> 80107473 <vector205>: .globl vector205 vector205: pushl $0 80107473: 6a 00 push $0x0 pushl $205 80107475: 68 cd 00 00 00 push $0xcd jmp alltraps 8010747a: e9 1a f3 ff ff jmp 80106799 <alltraps> 8010747f <vector206>: .globl vector206 vector206: pushl $0 8010747f: 6a 00 push $0x0 pushl $206 80107481: 68 ce 00 00 00 push $0xce jmp alltraps 80107486: e9 0e f3 ff ff jmp 80106799 <alltraps> 8010748b <vector207>: .globl vector207 vector207: pushl $0 8010748b: 6a 00 push $0x0 pushl $207 8010748d: 68 cf 00 00 00 push $0xcf jmp alltraps 80107492: e9 02 f3 ff ff jmp 80106799 <alltraps> 80107497 <vector208>: .globl vector208 vector208: pushl $0 80107497: 6a 00 push $0x0 pushl $208 80107499: 68 d0 00 00 00 push $0xd0 jmp alltraps 8010749e: e9 f6 f2 ff ff jmp 80106799 <alltraps> 801074a3 <vector209>: .globl vector209 vector209: pushl $0 801074a3: 6a 00 push $0x0 pushl $209 801074a5: 68 d1 00 00 00 push $0xd1 jmp alltraps 801074aa: e9 ea f2 ff ff jmp 80106799 <alltraps> 801074af <vector210>: .globl vector210 vector210: pushl $0 801074af: 6a 00 push $0x0 pushl $210 801074b1: 68 d2 00 00 00 push $0xd2 jmp alltraps 801074b6: e9 de f2 ff ff jmp 80106799 <alltraps> 801074bb <vector211>: .globl vector211 vector211: pushl $0 801074bb: 6a 00 push $0x0 pushl $211 801074bd: 68 d3 00 00 00 push $0xd3 jmp alltraps 801074c2: e9 d2 f2 ff ff jmp 80106799 <alltraps> 801074c7 <vector212>: .globl vector212 vector212: pushl $0 801074c7: 6a 00 push $0x0 pushl $212 801074c9: 68 d4 00 00 00 push $0xd4 jmp alltraps 801074ce: e9 c6 f2 ff ff jmp 80106799 <alltraps> 801074d3 <vector213>: .globl vector213 vector213: pushl $0 801074d3: 6a 00 push $0x0 pushl $213 801074d5: 68 d5 00 00 00 push $0xd5 jmp alltraps 801074da: e9 ba f2 ff ff jmp 80106799 <alltraps> 801074df <vector214>: .globl vector214 vector214: pushl $0 801074df: 6a 00 push $0x0 pushl $214 801074e1: 68 d6 00 00 00 push $0xd6 jmp alltraps 801074e6: e9 ae f2 ff ff jmp 80106799 <alltraps> 801074eb <vector215>: .globl vector215 vector215: pushl $0 801074eb: 6a 00 push $0x0 pushl $215 801074ed: 68 d7 00 00 00 push $0xd7 jmp alltraps 801074f2: e9 a2 f2 ff ff jmp 80106799 <alltraps> 801074f7 <vector216>: .globl vector216 vector216: pushl $0 801074f7: 6a 00 push $0x0 pushl $216 801074f9: 68 d8 00 00 00 push $0xd8 jmp alltraps 801074fe: e9 96 f2 ff ff jmp 80106799 <alltraps> 80107503 <vector217>: .globl vector217 vector217: pushl $0 80107503: 6a 00 push $0x0 pushl $217 80107505: 68 d9 00 00 00 push $0xd9 jmp alltraps 8010750a: e9 8a f2 ff ff jmp 80106799 <alltraps> 8010750f <vector218>: .globl vector218 vector218: pushl $0 8010750f: 6a 00 push $0x0 pushl $218 80107511: 68 da 00 00 00 push $0xda jmp alltraps 80107516: e9 7e f2 ff ff jmp 80106799 <alltraps> 8010751b <vector219>: .globl vector219 vector219: pushl $0 8010751b: 6a 00 push $0x0 pushl $219 8010751d: 68 db 00 00 00 push $0xdb jmp alltraps 80107522: e9 72 f2 ff ff jmp 80106799 <alltraps> 80107527 <vector220>: .globl vector220 vector220: pushl $0 80107527: 6a 00 push $0x0 pushl $220 80107529: 68 dc 00 00 00 push $0xdc jmp alltraps 8010752e: e9 66 f2 ff ff jmp 80106799 <alltraps> 80107533 <vector221>: .globl vector221 vector221: pushl $0 80107533: 6a 00 push $0x0 pushl $221 80107535: 68 dd 00 00 00 push $0xdd jmp alltraps 8010753a: e9 5a f2 ff ff jmp 80106799 <alltraps> 8010753f <vector222>: .globl vector222 vector222: pushl $0 8010753f: 6a 00 push $0x0 pushl $222 80107541: 68 de 00 00 00 push $0xde jmp alltraps 80107546: e9 4e f2 ff ff jmp 80106799 <alltraps> 8010754b <vector223>: .globl vector223 vector223: pushl $0 8010754b: 6a 00 push $0x0 pushl $223 8010754d: 68 df 00 00 00 push $0xdf jmp alltraps 80107552: e9 42 f2 ff ff jmp 80106799 <alltraps> 80107557 <vector224>: .globl vector224 vector224: pushl $0 80107557: 6a 00 push $0x0 pushl $224 80107559: 68 e0 00 00 00 push $0xe0 jmp alltraps 8010755e: e9 36 f2 ff ff jmp 80106799 <alltraps> 80107563 <vector225>: .globl vector225 vector225: pushl $0 80107563: 6a 00 push $0x0 pushl $225 80107565: 68 e1 00 00 00 push $0xe1 jmp alltraps 8010756a: e9 2a f2 ff ff jmp 80106799 <alltraps> 8010756f <vector226>: .globl vector226 vector226: pushl $0 8010756f: 6a 00 push $0x0 pushl $226 80107571: 68 e2 00 00 00 push $0xe2 jmp alltraps 80107576: e9 1e f2 ff ff jmp 80106799 <alltraps> 8010757b <vector227>: .globl vector227 vector227: pushl $0 8010757b: 6a 00 push $0x0 pushl $227 8010757d: 68 e3 00 00 00 push $0xe3 jmp alltraps 80107582: e9 12 f2 ff ff jmp 80106799 <alltraps> 80107587 <vector228>: .globl vector228 vector228: pushl $0 80107587: 6a 00 push $0x0 pushl $228 80107589: 68 e4 00 00 00 push $0xe4 jmp alltraps 8010758e: e9 06 f2 ff ff jmp 80106799 <alltraps> 80107593 <vector229>: .globl vector229 vector229: pushl $0 80107593: 6a 00 push $0x0 pushl $229 80107595: 68 e5 00 00 00 push $0xe5 jmp alltraps 8010759a: e9 fa f1 ff ff jmp 80106799 <alltraps> 8010759f <vector230>: .globl vector230 vector230: pushl $0 8010759f: 6a 00 push $0x0 pushl $230 801075a1: 68 e6 00 00 00 push $0xe6 jmp alltraps 801075a6: e9 ee f1 ff ff jmp 80106799 <alltraps> 801075ab <vector231>: .globl vector231 vector231: pushl $0 801075ab: 6a 00 push $0x0 pushl $231 801075ad: 68 e7 00 00 00 push $0xe7 jmp alltraps 801075b2: e9 e2 f1 ff ff jmp 80106799 <alltraps> 801075b7 <vector232>: .globl vector232 vector232: pushl $0 801075b7: 6a 00 push $0x0 pushl $232 801075b9: 68 e8 00 00 00 push $0xe8 jmp alltraps 801075be: e9 d6 f1 ff ff jmp 80106799 <alltraps> 801075c3 <vector233>: .globl vector233 vector233: pushl $0 801075c3: 6a 00 push $0x0 pushl $233 801075c5: 68 e9 00 00 00 push $0xe9 jmp alltraps 801075ca: e9 ca f1 ff ff jmp 80106799 <alltraps> 801075cf <vector234>: .globl vector234 vector234: pushl $0 801075cf: 6a 00 push $0x0 pushl $234 801075d1: 68 ea 00 00 00 push $0xea jmp alltraps 801075d6: e9 be f1 ff ff jmp 80106799 <alltraps> 801075db <vector235>: .globl vector235 vector235: pushl $0 801075db: 6a 00 push $0x0 pushl $235 801075dd: 68 eb 00 00 00 push $0xeb jmp alltraps 801075e2: e9 b2 f1 ff ff jmp 80106799 <alltraps> 801075e7 <vector236>: .globl vector236 vector236: pushl $0 801075e7: 6a 00 push $0x0 pushl $236 801075e9: 68 ec 00 00 00 push $0xec jmp alltraps 801075ee: e9 a6 f1 ff ff jmp 80106799 <alltraps> 801075f3 <vector237>: .globl vector237 vector237: pushl $0 801075f3: 6a 00 push $0x0 pushl $237 801075f5: 68 ed 00 00 00 push $0xed jmp alltraps 801075fa: e9 9a f1 ff ff jmp 80106799 <alltraps> 801075ff <vector238>: .globl vector238 vector238: pushl $0 801075ff: 6a 00 push $0x0 pushl $238 80107601: 68 ee 00 00 00 push $0xee jmp alltraps 80107606: e9 8e f1 ff ff jmp 80106799 <alltraps> 8010760b <vector239>: .globl vector239 vector239: pushl $0 8010760b: 6a 00 push $0x0 pushl $239 8010760d: 68 ef 00 00 00 push $0xef jmp alltraps 80107612: e9 82 f1 ff ff jmp 80106799 <alltraps> 80107617 <vector240>: .globl vector240 vector240: pushl $0 80107617: 6a 00 push $0x0 pushl $240 80107619: 68 f0 00 00 00 push $0xf0 jmp alltraps 8010761e: e9 76 f1 ff ff jmp 80106799 <alltraps> 80107623 <vector241>: .globl vector241 vector241: pushl $0 80107623: 6a 00 push $0x0 pushl $241 80107625: 68 f1 00 00 00 push $0xf1 jmp alltraps 8010762a: e9 6a f1 ff ff jmp 80106799 <alltraps> 8010762f <vector242>: .globl vector242 vector242: pushl $0 8010762f: 6a 00 push $0x0 pushl $242 80107631: 68 f2 00 00 00 push $0xf2 jmp alltraps 80107636: e9 5e f1 ff ff jmp 80106799 <alltraps> 8010763b <vector243>: .globl vector243 vector243: pushl $0 8010763b: 6a 00 push $0x0 pushl $243 8010763d: 68 f3 00 00 00 push $0xf3 jmp alltraps 80107642: e9 52 f1 ff ff jmp 80106799 <alltraps> 80107647 <vector244>: .globl vector244 vector244: pushl $0 80107647: 6a 00 push $0x0 pushl $244 80107649: 68 f4 00 00 00 push $0xf4 jmp alltraps 8010764e: e9 46 f1 ff ff jmp 80106799 <alltraps> 80107653 <vector245>: .globl vector245 vector245: pushl $0 80107653: 6a 00 push $0x0 pushl $245 80107655: 68 f5 00 00 00 push $0xf5 jmp alltraps 8010765a: e9 3a f1 ff ff jmp 80106799 <alltraps> 8010765f <vector246>: .globl vector246 vector246: pushl $0 8010765f: 6a 00 push $0x0 pushl $246 80107661: 68 f6 00 00 00 push $0xf6 jmp alltraps 80107666: e9 2e f1 ff ff jmp 80106799 <alltraps> 8010766b <vector247>: .globl vector247 vector247: pushl $0 8010766b: 6a 00 push $0x0 pushl $247 8010766d: 68 f7 00 00 00 push $0xf7 jmp alltraps 80107672: e9 22 f1 ff ff jmp 80106799 <alltraps> 80107677 <vector248>: .globl vector248 vector248: pushl $0 80107677: 6a 00 push $0x0 pushl $248 80107679: 68 f8 00 00 00 push $0xf8 jmp alltraps 8010767e: e9 16 f1 ff ff jmp 80106799 <alltraps> 80107683 <vector249>: .globl vector249 vector249: pushl $0 80107683: 6a 00 push $0x0 pushl $249 80107685: 68 f9 00 00 00 push $0xf9 jmp alltraps 8010768a: e9 0a f1 ff ff jmp 80106799 <alltraps> 8010768f <vector250>: .globl vector250 vector250: pushl $0 8010768f: 6a 00 push $0x0 pushl $250 80107691: 68 fa 00 00 00 push $0xfa jmp alltraps 80107696: e9 fe f0 ff ff jmp 80106799 <alltraps> 8010769b <vector251>: .globl vector251 vector251: pushl $0 8010769b: 6a 00 push $0x0 pushl $251 8010769d: 68 fb 00 00 00 push $0xfb jmp alltraps 801076a2: e9 f2 f0 ff ff jmp 80106799 <alltraps> 801076a7 <vector252>: .globl vector252 vector252: pushl $0 801076a7: 6a 00 push $0x0 pushl $252 801076a9: 68 fc 00 00 00 push $0xfc jmp alltraps 801076ae: e9 e6 f0 ff ff jmp 80106799 <alltraps> 801076b3 <vector253>: .globl vector253 vector253: pushl $0 801076b3: 6a 00 push $0x0 pushl $253 801076b5: 68 fd 00 00 00 push $0xfd jmp alltraps 801076ba: e9 da f0 ff ff jmp 80106799 <alltraps> 801076bf <vector254>: .globl vector254 vector254: pushl $0 801076bf: 6a 00 push $0x0 pushl $254 801076c1: 68 fe 00 00 00 push $0xfe jmp alltraps 801076c6: e9 ce f0 ff ff jmp 80106799 <alltraps> 801076cb <vector255>: .globl vector255 vector255: pushl $0 801076cb: 6a 00 push $0x0 pushl $255 801076cd: 68 ff 00 00 00 push $0xff jmp alltraps 801076d2: e9 c2 f0 ff ff jmp 80106799 <alltraps> 801076d7: 66 90 xchg %ax,%ax 801076d9: 66 90 xchg %ax,%ax 801076db: 66 90 xchg %ax,%ax 801076dd: 66 90 xchg %ax,%ax 801076df: 90 nop 801076e0 <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) { 801076e0: 55 push %ebp 801076e1: 89 e5 mov %esp,%ebp 801076e3: 57 push %edi 801076e4: 56 push %esi 801076e5: 53 push %ebx 801076e6: 89 d3 mov %edx,%ebx pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 801076e8: c1 ea 16 shr $0x16,%edx 801076eb: 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) { 801076ee: 83 ec 0c sub $0xc,%esp pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ 801076f1: 8b 07 mov (%edi),%eax 801076f3: a8 01 test $0x1,%al 801076f5: 74 29 je 80107720 <walkpgdir+0x40> pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); 801076f7: 25 00 f0 ff ff and $0xfffff000,%eax 801076fc: 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)]; } 80107702: 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)]; 80107705: c1 eb 0a shr $0xa,%ebx 80107708: 81 e3 fc 0f 00 00 and $0xffc,%ebx 8010770e: 8d 04 1e lea (%esi,%ebx,1),%eax } 80107711: 5b pop %ebx 80107712: 5e pop %esi 80107713: 5f pop %edi 80107714: 5d pop %ebp 80107715: c3 ret 80107716: 8d 76 00 lea 0x0(%esi),%esi 80107719: 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) 80107720: 85 c9 test %ecx,%ecx 80107722: 74 2c je 80107750 <walkpgdir+0x70> 80107724: e8 b7 af ff ff call 801026e0 <kalloc> 80107729: 85 c0 test %eax,%eax 8010772b: 89 c6 mov %eax,%esi 8010772d: 74 21 je 80107750 <walkpgdir+0x70> return 0; // Make sure all those PTE_P bits are zero. memset(pgtab, 0, PGSIZE); 8010772f: 83 ec 04 sub $0x4,%esp 80107732: 68 00 10 00 00 push $0x1000 80107737: 6a 00 push $0x0 80107739: 50 push %eax 8010773a: e8 f1 da ff ff call 80105230 <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; 8010773f: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80107745: 83 c4 10 add $0x10,%esp 80107748: 83 c8 07 or $0x7,%eax 8010774b: 89 07 mov %eax,(%edi) 8010774d: eb b3 jmp 80107702 <walkpgdir+0x22> 8010774f: 90 nop } return &pgtab[PTX(va)]; } 80107750: 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; 80107753: 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)]; } 80107755: 5b pop %ebx 80107756: 5e pop %esi 80107757: 5f pop %edi 80107758: 5d pop %ebp 80107759: c3 ret 8010775a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107760 <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) { 80107760: 55 push %ebp 80107761: 89 e5 mov %esp,%ebp 80107763: 57 push %edi 80107764: 56 push %esi 80107765: 53 push %ebx char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 80107766: 89 d3 mov %edx,%ebx 80107768: 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) { 8010776e: 83 ec 1c sub $0x1c,%esp 80107771: 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); 80107774: 8d 44 0a ff lea -0x1(%edx,%ecx,1),%eax 80107778: 8b 7d 08 mov 0x8(%ebp),%edi 8010777b: 25 00 f0 ff ff and $0xfffff000,%eax 80107780: 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; 80107783: 8b 45 0c mov 0xc(%ebp),%eax 80107786: 29 df sub %ebx,%edi 80107788: 83 c8 01 or $0x1,%eax 8010778b: 89 45 dc mov %eax,-0x24(%ebp) 8010778e: eb 15 jmp 801077a5 <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) 80107790: f6 00 01 testb $0x1,(%eax) 80107793: 75 45 jne 801077da <mappages+0x7a> panic("remap"); *pte = pa | perm | PTE_P; 80107795: 0b 75 dc or -0x24(%ebp),%esi if(a == last) 80107798: 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; 8010779b: 89 30 mov %esi,(%eax) if(a == last) 8010779d: 74 31 je 801077d0 <mappages+0x70> break; a += PGSIZE; 8010779f: 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) 801077a5: 8b 45 e4 mov -0x1c(%ebp),%eax 801077a8: b9 01 00 00 00 mov $0x1,%ecx 801077ad: 89 da mov %ebx,%edx 801077af: 8d 34 3b lea (%ebx,%edi,1),%esi 801077b2: e8 29 ff ff ff call 801076e0 <walkpgdir> 801077b7: 85 c0 test %eax,%eax 801077b9: 75 d5 jne 80107790 <mappages+0x30> break; a += PGSIZE; pa += PGSIZE; } return 0; } 801077bb: 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; 801077be: b8 ff ff ff ff mov $0xffffffff,%eax break; a += PGSIZE; pa += PGSIZE; } return 0; } 801077c3: 5b pop %ebx 801077c4: 5e pop %esi 801077c5: 5f pop %edi 801077c6: 5d pop %ebp 801077c7: c3 ret 801077c8: 90 nop 801077c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801077d0: 8d 65 f4 lea -0xc(%ebp),%esp if(a == last) break; a += PGSIZE; pa += PGSIZE; } return 0; 801077d3: 31 c0 xor %eax,%eax } 801077d5: 5b pop %ebx 801077d6: 5e pop %esi 801077d7: 5f pop %edi 801077d8: 5d pop %ebp 801077d9: 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"); 801077da: 83 ec 0c sub $0xc,%esp 801077dd: 68 38 8b 10 80 push $0x80108b38 801077e2: e8 89 8b ff ff call 80100370 <panic> 801077e7: 89 f6 mov %esi,%esi 801077e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801077f0 <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) 801077f0: 55 push %ebp 801077f1: 89 e5 mov %esp,%ebp 801077f3: 57 push %edi 801077f4: 56 push %esi 801077f5: 53 push %ebx uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 801077f6: 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) 801077fc: 89 c7 mov %eax,%edi uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 801077fe: 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) 80107804: 83 ec 1c sub $0x1c,%esp 80107807: 89 4d e0 mov %ecx,-0x20(%ebp) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 8010780a: 39 d3 cmp %edx,%ebx 8010780c: 73 66 jae 80107874 <deallocuvm.part.0+0x84> 8010780e: 89 d6 mov %edx,%esi 80107810: eb 3d jmp 8010784f <deallocuvm.part.0+0x5f> 80107812: 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){ 80107818: 8b 10 mov (%eax),%edx 8010781a: f6 c2 01 test $0x1,%dl 8010781d: 74 26 je 80107845 <deallocuvm.part.0+0x55> pa = PTE_ADDR(*pte); if(pa == 0) 8010781f: 81 e2 00 f0 ff ff and $0xfffff000,%edx 80107825: 74 58 je 8010787f <deallocuvm.part.0+0x8f> panic("kfree"); char *v = P2V(pa); kfree(v); 80107827: 83 ec 0c sub $0xc,%esp 8010782a: 81 c2 00 00 00 80 add $0x80000000,%edx 80107830: 89 45 e4 mov %eax,-0x1c(%ebp) 80107833: 52 push %edx 80107834: e8 f7 ac ff ff call 80102530 <kfree> *pte = 0; 80107839: 8b 45 e4 mov -0x1c(%ebp),%eax 8010783c: 83 c4 10 add $0x10,%esp 8010783f: c7 00 00 00 00 00 movl $0x0,(%eax) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 80107845: 81 c3 00 10 00 00 add $0x1000,%ebx 8010784b: 39 f3 cmp %esi,%ebx 8010784d: 73 25 jae 80107874 <deallocuvm.part.0+0x84> pte = walkpgdir(pgdir, (char*)a, 0); 8010784f: 31 c9 xor %ecx,%ecx 80107851: 89 da mov %ebx,%edx 80107853: 89 f8 mov %edi,%eax 80107855: e8 86 fe ff ff call 801076e0 <walkpgdir> if(!pte) 8010785a: 85 c0 test %eax,%eax 8010785c: 75 ba jne 80107818 <deallocuvm.part.0+0x28> a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; 8010785e: 81 e3 00 00 c0 ff and $0xffc00000,%ebx 80107864: 81 c3 00 f0 3f 00 add $0x3ff000,%ebx if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 8010786a: 81 c3 00 10 00 00 add $0x1000,%ebx 80107870: 39 f3 cmp %esi,%ebx 80107872: 72 db jb 8010784f <deallocuvm.part.0+0x5f> kfree(v); *pte = 0; } } return newsz; } 80107874: 8b 45 e0 mov -0x20(%ebp),%eax 80107877: 8d 65 f4 lea -0xc(%ebp),%esp 8010787a: 5b pop %ebx 8010787b: 5e pop %esi 8010787c: 5f pop %edi 8010787d: 5d pop %ebp 8010787e: 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"); 8010787f: 83 ec 0c sub $0xc,%esp 80107882: 68 c6 82 10 80 push $0x801082c6 80107887: e8 e4 8a ff ff call 80100370 <panic> 8010788c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80107890 <seginit>: // Set up CPU's kernel segment descriptors. // Run once on entry on each CPU. void seginit(void) { 80107890: 55 push %ebp 80107891: 89 e5 mov %esp,%ebp 80107893: 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()]; 80107896: e8 75 c1 ff ff call 80103a10 <cpuid> c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 8010789b: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax 801078a1: 31 c9 xor %ecx,%ecx 801078a3: ba ff ff ff ff mov $0xffffffff,%edx 801078a8: 66 89 90 78 38 11 80 mov %dx,-0x7feec788(%eax) 801078af: 66 89 88 7a 38 11 80 mov %cx,-0x7feec786(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801078b6: ba ff ff ff ff mov $0xffffffff,%edx 801078bb: 31 c9 xor %ecx,%ecx 801078bd: 66 89 90 80 38 11 80 mov %dx,-0x7feec780(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801078c4: 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); 801078c9: 66 89 88 82 38 11 80 mov %cx,-0x7feec77e(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801078d0: 31 c9 xor %ecx,%ecx 801078d2: 66 89 90 88 38 11 80 mov %dx,-0x7feec778(%eax) 801078d9: 66 89 88 8a 38 11 80 mov %cx,-0x7feec776(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801078e0: ba ff ff ff ff mov $0xffffffff,%edx 801078e5: 31 c9 xor %ecx,%ecx 801078e7: 66 89 90 90 38 11 80 mov %dx,-0x7feec770(%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); 801078ee: c6 80 7c 38 11 80 00 movb $0x0,-0x7feec784(%eax) static inline void lgdt(struct segdesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 801078f5: ba 2f 00 00 00 mov $0x2f,%edx 801078fa: c6 80 7d 38 11 80 9a movb $0x9a,-0x7feec783(%eax) 80107901: c6 80 7e 38 11 80 cf movb $0xcf,-0x7feec782(%eax) 80107908: c6 80 7f 38 11 80 00 movb $0x0,-0x7feec781(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 8010790f: c6 80 84 38 11 80 00 movb $0x0,-0x7feec77c(%eax) 80107916: c6 80 85 38 11 80 92 movb $0x92,-0x7feec77b(%eax) 8010791d: c6 80 86 38 11 80 cf movb $0xcf,-0x7feec77a(%eax) 80107924: c6 80 87 38 11 80 00 movb $0x0,-0x7feec779(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 8010792b: c6 80 8c 38 11 80 00 movb $0x0,-0x7feec774(%eax) 80107932: c6 80 8d 38 11 80 fa movb $0xfa,-0x7feec773(%eax) 80107939: c6 80 8e 38 11 80 cf movb $0xcf,-0x7feec772(%eax) 80107940: c6 80 8f 38 11 80 00 movb $0x0,-0x7feec771(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 80107947: 66 89 88 92 38 11 80 mov %cx,-0x7feec76e(%eax) 8010794e: c6 80 94 38 11 80 00 movb $0x0,-0x7feec76c(%eax) 80107955: c6 80 95 38 11 80 f2 movb $0xf2,-0x7feec76b(%eax) 8010795c: c6 80 96 38 11 80 cf movb $0xcf,-0x7feec76a(%eax) 80107963: c6 80 97 38 11 80 00 movb $0x0,-0x7feec769(%eax) lgdt(c->gdt, sizeof(c->gdt)); 8010796a: 05 70 38 11 80 add $0x80113870,%eax 8010796f: 66 89 55 f2 mov %dx,-0xe(%ebp) pd[1] = (uint)p; 80107973: 66 89 45 f4 mov %ax,-0xc(%ebp) pd[2] = (uint)p >> 16; 80107977: c1 e8 10 shr $0x10,%eax 8010797a: 66 89 45 f6 mov %ax,-0xa(%ebp) asm volatile("lgdt (%0)" : : "r" (pd)); 8010797e: 8d 45 f2 lea -0xe(%ebp),%eax 80107981: 0f 01 10 lgdtl (%eax) } 80107984: c9 leave 80107985: c3 ret 80107986: 8d 76 00 lea 0x0(%esi),%esi 80107989: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80107990 <switchkvm>: } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 80107990: a1 64 66 11 80 mov 0x80116664,%eax // Switch h/w page table register to the kernel-only page table, // for when no process is running. void switchkvm(void) { 80107995: 55 push %ebp 80107996: 89 e5 mov %esp,%ebp 80107998: 05 00 00 00 80 add $0x80000000,%eax 8010799d: 0f 22 d8 mov %eax,%cr3 lcr3(V2P(kpgdir)); // switch to the kernel page table } 801079a0: 5d pop %ebp 801079a1: c3 ret 801079a2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801079a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801079b0 <switchuvm>: // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { 801079b0: 55 push %ebp 801079b1: 89 e5 mov %esp,%ebp 801079b3: 57 push %edi 801079b4: 56 push %esi 801079b5: 53 push %ebx 801079b6: 83 ec 1c sub $0x1c,%esp 801079b9: 8b 75 08 mov 0x8(%ebp),%esi if(p == 0) 801079bc: 85 f6 test %esi,%esi 801079be: 0f 84 cd 00 00 00 je 80107a91 <switchuvm+0xe1> panic("switchuvm: no process"); if(p->kstack == 0) 801079c4: 8b 46 08 mov 0x8(%esi),%eax 801079c7: 85 c0 test %eax,%eax 801079c9: 0f 84 dc 00 00 00 je 80107aab <switchuvm+0xfb> panic("switchuvm: no kstack"); if(p->pgdir == 0) 801079cf: 8b 7e 04 mov 0x4(%esi),%edi 801079d2: 85 ff test %edi,%edi 801079d4: 0f 84 c4 00 00 00 je 80107a9e <switchuvm+0xee> panic("switchuvm: no pgdir"); pushcli(); 801079da: e8 71 d6 ff ff call 80105050 <pushcli> mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, 801079df: e8 dc bf ff ff call 801039c0 <mycpu> 801079e4: 89 c3 mov %eax,%ebx 801079e6: e8 d5 bf ff ff call 801039c0 <mycpu> 801079eb: 89 c7 mov %eax,%edi 801079ed: e8 ce bf ff ff call 801039c0 <mycpu> 801079f2: 89 45 e4 mov %eax,-0x1c(%ebp) 801079f5: 83 c7 08 add $0x8,%edi 801079f8: e8 c3 bf ff ff call 801039c0 <mycpu> 801079fd: 8b 4d e4 mov -0x1c(%ebp),%ecx 80107a00: 83 c0 08 add $0x8,%eax 80107a03: ba 67 00 00 00 mov $0x67,%edx 80107a08: c1 e8 18 shr $0x18,%eax 80107a0b: 66 89 93 98 00 00 00 mov %dx,0x98(%ebx) 80107a12: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx) 80107a19: c6 83 9d 00 00 00 99 movb $0x99,0x9d(%ebx) 80107a20: c6 83 9e 00 00 00 40 movb $0x40,0x9e(%ebx) 80107a27: 83 c1 08 add $0x8,%ecx 80107a2a: 88 83 9f 00 00 00 mov %al,0x9f(%ebx) 80107a30: c1 e9 10 shr $0x10,%ecx 80107a33: 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; 80107a39: 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; 80107a3e: e8 7d bf ff ff call 801039c0 <mycpu> 80107a43: 80 a0 9d 00 00 00 ef andb $0xef,0x9d(%eax) mycpu()->ts.ss0 = SEG_KDATA << 3; 80107a4a: e8 71 bf ff ff call 801039c0 <mycpu> 80107a4f: b9 10 00 00 00 mov $0x10,%ecx 80107a54: 66 89 48 10 mov %cx,0x10(%eax) mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; 80107a58: e8 63 bf ff ff call 801039c0 <mycpu> 80107a5d: 8b 56 08 mov 0x8(%esi),%edx 80107a60: 8d 8a 00 10 00 00 lea 0x1000(%edx),%ecx 80107a66: 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; 80107a69: e8 52 bf ff ff call 801039c0 <mycpu> 80107a6e: 66 89 58 6e mov %bx,0x6e(%eax) } static inline void ltr(ushort sel) { asm volatile("ltr %0" : : "r" (sel)); 80107a72: b8 28 00 00 00 mov $0x28,%eax 80107a77: 0f 00 d8 ltr %ax } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 80107a7a: 8b 46 04 mov 0x4(%esi),%eax 80107a7d: 05 00 00 00 80 add $0x80000000,%eax 80107a82: 0f 22 d8 mov %eax,%cr3 ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space popcli(); } 80107a85: 8d 65 f4 lea -0xc(%ebp),%esp 80107a88: 5b pop %ebx 80107a89: 5e pop %esi 80107a8a: 5f pop %edi 80107a8b: 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(); 80107a8c: e9 ff d5 ff ff jmp 80105090 <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"); 80107a91: 83 ec 0c sub $0xc,%esp 80107a94: 68 3e 8b 10 80 push $0x80108b3e 80107a99: e8 d2 88 ff ff call 80100370 <panic> if(p->kstack == 0) panic("switchuvm: no kstack"); if(p->pgdir == 0) panic("switchuvm: no pgdir"); 80107a9e: 83 ec 0c sub $0xc,%esp 80107aa1: 68 69 8b 10 80 push $0x80108b69 80107aa6: e8 c5 88 ff ff call 80100370 <panic> switchuvm(struct proc *p) { if(p == 0) panic("switchuvm: no process"); if(p->kstack == 0) panic("switchuvm: no kstack"); 80107aab: 83 ec 0c sub $0xc,%esp 80107aae: 68 54 8b 10 80 push $0x80108b54 80107ab3: e8 b8 88 ff ff call 80100370 <panic> 80107ab8: 90 nop 80107ab9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80107ac0 <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) { 80107ac0: 55 push %ebp 80107ac1: 89 e5 mov %esp,%ebp 80107ac3: 57 push %edi 80107ac4: 56 push %esi 80107ac5: 53 push %ebx 80107ac6: 83 ec 1c sub $0x1c,%esp 80107ac9: 8b 75 10 mov 0x10(%ebp),%esi 80107acc: 8b 45 08 mov 0x8(%ebp),%eax 80107acf: 8b 7d 0c mov 0xc(%ebp),%edi char *mem; if(sz >= PGSIZE) 80107ad2: 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) { 80107ad8: 89 45 e4 mov %eax,-0x1c(%ebp) char *mem; if(sz >= PGSIZE) 80107adb: 77 49 ja 80107b26 <inituvm+0x66> panic("inituvm: more than a page"); mem = kalloc(); 80107add: e8 fe ab ff ff call 801026e0 <kalloc> memset(mem, 0, PGSIZE); 80107ae2: 83 ec 04 sub $0x4,%esp { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); 80107ae5: 89 c3 mov %eax,%ebx memset(mem, 0, PGSIZE); 80107ae7: 68 00 10 00 00 push $0x1000 80107aec: 6a 00 push $0x0 80107aee: 50 push %eax 80107aef: e8 3c d7 ff ff call 80105230 <memset> mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); 80107af4: 58 pop %eax 80107af5: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80107afb: b9 00 10 00 00 mov $0x1000,%ecx 80107b00: 5a pop %edx 80107b01: 6a 06 push $0x6 80107b03: 50 push %eax 80107b04: 31 d2 xor %edx,%edx 80107b06: 8b 45 e4 mov -0x1c(%ebp),%eax 80107b09: e8 52 fc ff ff call 80107760 <mappages> memmove(mem, init, sz); 80107b0e: 89 75 10 mov %esi,0x10(%ebp) 80107b11: 89 7d 0c mov %edi,0xc(%ebp) 80107b14: 83 c4 10 add $0x10,%esp 80107b17: 89 5d 08 mov %ebx,0x8(%ebp) } 80107b1a: 8d 65 f4 lea -0xc(%ebp),%esp 80107b1d: 5b pop %ebx 80107b1e: 5e pop %esi 80107b1f: 5f pop %edi 80107b20: 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); 80107b21: e9 ba d7 ff ff jmp 801052e0 <memmove> inituvm(pde_t *pgdir, char *init, uint sz) { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); 80107b26: 83 ec 0c sub $0xc,%esp 80107b29: 68 7d 8b 10 80 push $0x80108b7d 80107b2e: e8 3d 88 ff ff call 80100370 <panic> 80107b33: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107b39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80107b40 <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) { 80107b40: 55 push %ebp 80107b41: 89 e5 mov %esp,%ebp 80107b43: 57 push %edi 80107b44: 56 push %esi 80107b45: 53 push %ebx 80107b46: 83 ec 0c sub $0xc,%esp uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) 80107b49: f7 45 0c ff 0f 00 00 testl $0xfff,0xc(%ebp) 80107b50: 0f 85 91 00 00 00 jne 80107be7 <loaduvm+0xa7> panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ 80107b56: 8b 75 18 mov 0x18(%ebp),%esi 80107b59: 31 db xor %ebx,%ebx 80107b5b: 85 f6 test %esi,%esi 80107b5d: 75 1a jne 80107b79 <loaduvm+0x39> 80107b5f: eb 6f jmp 80107bd0 <loaduvm+0x90> 80107b61: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80107b68: 81 c3 00 10 00 00 add $0x1000,%ebx 80107b6e: 81 ee 00 10 00 00 sub $0x1000,%esi 80107b74: 39 5d 18 cmp %ebx,0x18(%ebp) 80107b77: 76 57 jbe 80107bd0 <loaduvm+0x90> if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) 80107b79: 8b 55 0c mov 0xc(%ebp),%edx 80107b7c: 8b 45 08 mov 0x8(%ebp),%eax 80107b7f: 31 c9 xor %ecx,%ecx 80107b81: 01 da add %ebx,%edx 80107b83: e8 58 fb ff ff call 801076e0 <walkpgdir> 80107b88: 85 c0 test %eax,%eax 80107b8a: 74 4e je 80107bda <loaduvm+0x9a> panic("loaduvm: address should exist"); pa = PTE_ADDR(*pte); 80107b8c: 8b 00 mov (%eax),%eax if(sz - i < PGSIZE) n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) 80107b8e: 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) 80107b91: 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); 80107b96: 25 00 f0 ff ff and $0xfffff000,%eax if(sz - i < PGSIZE) 80107b9b: 81 fe ff 0f 00 00 cmp $0xfff,%esi 80107ba1: 0f 46 fe cmovbe %esi,%edi n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) 80107ba4: 01 d9 add %ebx,%ecx 80107ba6: 05 00 00 00 80 add $0x80000000,%eax 80107bab: 57 push %edi 80107bac: 51 push %ecx 80107bad: 50 push %eax 80107bae: ff 75 10 pushl 0x10(%ebp) 80107bb1: e8 ea 9f ff ff call 80101ba0 <readi> 80107bb6: 83 c4 10 add $0x10,%esp 80107bb9: 39 c7 cmp %eax,%edi 80107bbb: 74 ab je 80107b68 <loaduvm+0x28> return -1; } return 0; } 80107bbd: 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; 80107bc0: b8 ff ff ff ff mov $0xffffffff,%eax } return 0; } 80107bc5: 5b pop %ebx 80107bc6: 5e pop %esi 80107bc7: 5f pop %edi 80107bc8: 5d pop %ebp 80107bc9: c3 ret 80107bca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107bd0: 8d 65 f4 lea -0xc(%ebp),%esp else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) return -1; } return 0; 80107bd3: 31 c0 xor %eax,%eax } 80107bd5: 5b pop %ebx 80107bd6: 5e pop %esi 80107bd7: 5f pop %edi 80107bd8: 5d pop %ebp 80107bd9: 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"); 80107bda: 83 ec 0c sub $0xc,%esp 80107bdd: 68 97 8b 10 80 push $0x80108b97 80107be2: e8 89 87 ff ff call 80100370 <panic> { uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); 80107be7: 83 ec 0c sub $0xc,%esp 80107bea: 68 38 8c 10 80 push $0x80108c38 80107bef: e8 7c 87 ff ff call 80100370 <panic> 80107bf4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107bfa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80107c00 <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) { 80107c00: 55 push %ebp 80107c01: 89 e5 mov %esp,%ebp 80107c03: 57 push %edi 80107c04: 56 push %esi 80107c05: 53 push %ebx 80107c06: 83 ec 0c sub $0xc,%esp 80107c09: 8b 7d 10 mov 0x10(%ebp),%edi char *mem; uint a; if(newsz >= KERNBASE) 80107c0c: 85 ff test %edi,%edi 80107c0e: 0f 88 ca 00 00 00 js 80107cde <allocuvm+0xde> return 0; if(newsz < oldsz) 80107c14: 3b 7d 0c cmp 0xc(%ebp),%edi return oldsz; 80107c17: 8b 45 0c mov 0xc(%ebp),%eax char *mem; uint a; if(newsz >= KERNBASE) return 0; if(newsz < oldsz) 80107c1a: 0f 82 82 00 00 00 jb 80107ca2 <allocuvm+0xa2> return oldsz; a = PGROUNDUP(oldsz); 80107c20: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80107c26: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < newsz; a += PGSIZE){ 80107c2c: 39 df cmp %ebx,%edi 80107c2e: 77 43 ja 80107c73 <allocuvm+0x73> 80107c30: e9 bb 00 00 00 jmp 80107cf0 <allocuvm+0xf0> 80107c35: 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); 80107c38: 83 ec 04 sub $0x4,%esp 80107c3b: 68 00 10 00 00 push $0x1000 80107c40: 6a 00 push $0x0 80107c42: 50 push %eax 80107c43: e8 e8 d5 ff ff call 80105230 <memset> if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ 80107c48: 58 pop %eax 80107c49: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80107c4f: b9 00 10 00 00 mov $0x1000,%ecx 80107c54: 5a pop %edx 80107c55: 6a 06 push $0x6 80107c57: 50 push %eax 80107c58: 89 da mov %ebx,%edx 80107c5a: 8b 45 08 mov 0x8(%ebp),%eax 80107c5d: e8 fe fa ff ff call 80107760 <mappages> 80107c62: 83 c4 10 add $0x10,%esp 80107c65: 85 c0 test %eax,%eax 80107c67: 78 47 js 80107cb0 <allocuvm+0xb0> return 0; if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ 80107c69: 81 c3 00 10 00 00 add $0x1000,%ebx 80107c6f: 39 df cmp %ebx,%edi 80107c71: 76 7d jbe 80107cf0 <allocuvm+0xf0> mem = kalloc(); 80107c73: e8 68 aa ff ff call 801026e0 <kalloc> if(mem == 0){ 80107c78: 85 c0 test %eax,%eax if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ mem = kalloc(); 80107c7a: 89 c6 mov %eax,%esi if(mem == 0){ 80107c7c: 75 ba jne 80107c38 <allocuvm+0x38> cprintf("allocuvm out of memory\n"); 80107c7e: 83 ec 0c sub $0xc,%esp 80107c81: 68 b5 8b 10 80 push $0x80108bb5 80107c86: e8 d5 89 ff ff call 80100660 <cprintf> deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { pte_t *pte; uint a, pa; if(newsz >= oldsz) 80107c8b: 83 c4 10 add $0x10,%esp 80107c8e: 3b 7d 0c cmp 0xc(%ebp),%edi 80107c91: 76 4b jbe 80107cde <allocuvm+0xde> 80107c93: 8b 4d 0c mov 0xc(%ebp),%ecx 80107c96: 8b 45 08 mov 0x8(%ebp),%eax 80107c99: 89 fa mov %edi,%edx 80107c9b: e8 50 fb ff ff call 801077f0 <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; 80107ca0: 31 c0 xor %eax,%eax kfree(mem); return 0; } } return newsz; } 80107ca2: 8d 65 f4 lea -0xc(%ebp),%esp 80107ca5: 5b pop %ebx 80107ca6: 5e pop %esi 80107ca7: 5f pop %edi 80107ca8: 5d pop %ebp 80107ca9: c3 ret 80107caa: 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"); 80107cb0: 83 ec 0c sub $0xc,%esp 80107cb3: 68 cd 8b 10 80 push $0x80108bcd 80107cb8: e8 a3 89 ff ff call 80100660 <cprintf> deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { pte_t *pte; uint a, pa; if(newsz >= oldsz) 80107cbd: 83 c4 10 add $0x10,%esp 80107cc0: 3b 7d 0c cmp 0xc(%ebp),%edi 80107cc3: 76 0d jbe 80107cd2 <allocuvm+0xd2> 80107cc5: 8b 4d 0c mov 0xc(%ebp),%ecx 80107cc8: 8b 45 08 mov 0x8(%ebp),%eax 80107ccb: 89 fa mov %edi,%edx 80107ccd: e8 1e fb ff ff call 801077f0 <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); 80107cd2: 83 ec 0c sub $0xc,%esp 80107cd5: 56 push %esi 80107cd6: e8 55 a8 ff ff call 80102530 <kfree> return 0; 80107cdb: 83 c4 10 add $0x10,%esp } } return newsz; } 80107cde: 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; 80107ce1: 31 c0 xor %eax,%eax } } return newsz; } 80107ce3: 5b pop %ebx 80107ce4: 5e pop %esi 80107ce5: 5f pop %edi 80107ce6: 5d pop %ebp 80107ce7: c3 ret 80107ce8: 90 nop 80107ce9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80107cf0: 8d 65 f4 lea -0xc(%ebp),%esp return 0; if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ 80107cf3: 89 f8 mov %edi,%eax kfree(mem); return 0; } } return newsz; } 80107cf5: 5b pop %ebx 80107cf6: 5e pop %esi 80107cf7: 5f pop %edi 80107cf8: 5d pop %ebp 80107cf9: c3 ret 80107cfa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107d00 <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) { 80107d00: 55 push %ebp 80107d01: 89 e5 mov %esp,%ebp 80107d03: 8b 55 0c mov 0xc(%ebp),%edx 80107d06: 8b 4d 10 mov 0x10(%ebp),%ecx 80107d09: 8b 45 08 mov 0x8(%ebp),%eax pte_t *pte; uint a, pa; if(newsz >= oldsz) 80107d0c: 39 d1 cmp %edx,%ecx 80107d0e: 73 10 jae 80107d20 <deallocuvm+0x20> kfree(v); *pte = 0; } } return newsz; } 80107d10: 5d pop %ebp 80107d11: e9 da fa ff ff jmp 801077f0 <deallocuvm.part.0> 80107d16: 8d 76 00 lea 0x0(%esi),%esi 80107d19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80107d20: 89 d0 mov %edx,%eax 80107d22: 5d pop %ebp 80107d23: c3 ret 80107d24: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107d2a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80107d30 <freevm>: // Free a page table and all the physical memory pages // in the user part. void freevm(pde_t *pgdir) { 80107d30: 55 push %ebp 80107d31: 89 e5 mov %esp,%ebp 80107d33: 57 push %edi 80107d34: 56 push %esi 80107d35: 53 push %ebx 80107d36: 83 ec 0c sub $0xc,%esp 80107d39: 8b 75 08 mov 0x8(%ebp),%esi uint i; if(pgdir == 0) 80107d3c: 85 f6 test %esi,%esi 80107d3e: 74 59 je 80107d99 <freevm+0x69> 80107d40: 31 c9 xor %ecx,%ecx 80107d42: ba 00 00 00 80 mov $0x80000000,%edx 80107d47: 89 f0 mov %esi,%eax 80107d49: e8 a2 fa ff ff call 801077f0 <deallocuvm.part.0> 80107d4e: 89 f3 mov %esi,%ebx 80107d50: 8d be 00 10 00 00 lea 0x1000(%esi),%edi 80107d56: eb 0f jmp 80107d67 <freevm+0x37> 80107d58: 90 nop 80107d59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80107d60: 83 c3 04 add $0x4,%ebx panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80107d63: 39 fb cmp %edi,%ebx 80107d65: 74 23 je 80107d8a <freevm+0x5a> if(pgdir[i] & PTE_P){ 80107d67: 8b 03 mov (%ebx),%eax 80107d69: a8 01 test $0x1,%al 80107d6b: 74 f3 je 80107d60 <freevm+0x30> char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); 80107d6d: 25 00 f0 ff ff and $0xfffff000,%eax 80107d72: 83 ec 0c sub $0xc,%esp 80107d75: 83 c3 04 add $0x4,%ebx 80107d78: 05 00 00 00 80 add $0x80000000,%eax 80107d7d: 50 push %eax 80107d7e: e8 ad a7 ff ff call 80102530 <kfree> 80107d83: 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++){ 80107d86: 39 fb cmp %edi,%ebx 80107d88: 75 dd jne 80107d67 <freevm+0x37> if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80107d8a: 89 75 08 mov %esi,0x8(%ebp) } 80107d8d: 8d 65 f4 lea -0xc(%ebp),%esp 80107d90: 5b pop %ebx 80107d91: 5e pop %esi 80107d92: 5f pop %edi 80107d93: 5d pop %ebp if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80107d94: e9 97 a7 ff ff jmp 80102530 <kfree> freevm(pde_t *pgdir) { uint i; if(pgdir == 0) panic("freevm: no pgdir"); 80107d99: 83 ec 0c sub $0xc,%esp 80107d9c: 68 e9 8b 10 80 push $0x80108be9 80107da1: e8 ca 85 ff ff call 80100370 <panic> 80107da6: 8d 76 00 lea 0x0(%esi),%esi 80107da9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80107db0 <setupkvm>: }; // Set up kernel part of a page table. pde_t* setupkvm(void) { 80107db0: 55 push %ebp 80107db1: 89 e5 mov %esp,%ebp 80107db3: 56 push %esi 80107db4: 53 push %ebx pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) 80107db5: e8 26 a9 ff ff call 801026e0 <kalloc> 80107dba: 85 c0 test %eax,%eax 80107dbc: 74 6a je 80107e28 <setupkvm+0x78> return 0; memset(pgdir, 0, PGSIZE); 80107dbe: 83 ec 04 sub $0x4,%esp 80107dc1: 89 c6 mov %eax,%esi if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80107dc3: bb 20 b4 10 80 mov $0x8010b420,%ebx pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); 80107dc8: 68 00 10 00 00 push $0x1000 80107dcd: 6a 00 push $0x0 80107dcf: 50 push %eax 80107dd0: e8 5b d4 ff ff call 80105230 <memset> 80107dd5: 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, 80107dd8: 8b 43 04 mov 0x4(%ebx),%eax 80107ddb: 8b 4b 08 mov 0x8(%ebx),%ecx 80107dde: 83 ec 08 sub $0x8,%esp 80107de1: 8b 13 mov (%ebx),%edx 80107de3: ff 73 0c pushl 0xc(%ebx) 80107de6: 50 push %eax 80107de7: 29 c1 sub %eax,%ecx 80107de9: 89 f0 mov %esi,%eax 80107deb: e8 70 f9 ff ff call 80107760 <mappages> 80107df0: 83 c4 10 add $0x10,%esp 80107df3: 85 c0 test %eax,%eax 80107df5: 78 19 js 80107e10 <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++) 80107df7: 83 c3 10 add $0x10,%ebx 80107dfa: 81 fb 60 b4 10 80 cmp $0x8010b460,%ebx 80107e00: 75 d6 jne 80107dd8 <setupkvm+0x28> 80107e02: 89 f0 mov %esi,%eax (uint)k->phys_start, k->perm) < 0) { freevm(pgdir); return 0; } return pgdir; } 80107e04: 8d 65 f8 lea -0x8(%ebp),%esp 80107e07: 5b pop %ebx 80107e08: 5e pop %esi 80107e09: 5d pop %ebp 80107e0a: c3 ret 80107e0b: 90 nop 80107e0c: 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); 80107e10: 83 ec 0c sub $0xc,%esp 80107e13: 56 push %esi 80107e14: e8 17 ff ff ff call 80107d30 <freevm> return 0; 80107e19: 83 c4 10 add $0x10,%esp } return pgdir; } 80107e1c: 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; 80107e1f: 31 c0 xor %eax,%eax } return pgdir; } 80107e21: 5b pop %ebx 80107e22: 5e pop %esi 80107e23: 5d pop %ebp 80107e24: c3 ret 80107e25: 8d 76 00 lea 0x0(%esi),%esi { pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) return 0; 80107e28: 31 c0 xor %eax,%eax 80107e2a: eb d8 jmp 80107e04 <setupkvm+0x54> 80107e2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80107e30 <kvmalloc>: // Allocate one page table for the machine for the kernel address // space for scheduler processes. void kvmalloc(void) { 80107e30: 55 push %ebp 80107e31: 89 e5 mov %esp,%ebp 80107e33: 83 ec 08 sub $0x8,%esp kpgdir = setupkvm(); 80107e36: e8 75 ff ff ff call 80107db0 <setupkvm> 80107e3b: a3 64 66 11 80 mov %eax,0x80116664 80107e40: 05 00 00 00 80 add $0x80000000,%eax 80107e45: 0f 22 d8 mov %eax,%cr3 switchkvm(); } 80107e48: c9 leave 80107e49: c3 ret 80107e4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107e50 <clearpteu>: // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80107e50: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80107e51: 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) { 80107e53: 89 e5 mov %esp,%ebp 80107e55: 83 ec 08 sub $0x8,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80107e58: 8b 55 0c mov 0xc(%ebp),%edx 80107e5b: 8b 45 08 mov 0x8(%ebp),%eax 80107e5e: e8 7d f8 ff ff call 801076e0 <walkpgdir> if(pte == 0) 80107e63: 85 c0 test %eax,%eax 80107e65: 74 05 je 80107e6c <clearpteu+0x1c> panic("clearpteu"); *pte &= ~PTE_U; 80107e67: 83 20 fb andl $0xfffffffb,(%eax) } 80107e6a: c9 leave 80107e6b: c3 ret { pte_t *pte; pte = walkpgdir(pgdir, uva, 0); if(pte == 0) panic("clearpteu"); 80107e6c: 83 ec 0c sub $0xc,%esp 80107e6f: 68 fa 8b 10 80 push $0x80108bfa 80107e74: e8 f7 84 ff ff call 80100370 <panic> 80107e79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80107e80 <copyuvm>: // Given a parent process's page table, create a copy // of it for a child. pde_t* copyuvm(pde_t *pgdir, uint sz) { 80107e80: 55 push %ebp 80107e81: 89 e5 mov %esp,%ebp 80107e83: 57 push %edi 80107e84: 56 push %esi 80107e85: 53 push %ebx 80107e86: 83 ec 1c sub $0x1c,%esp pde_t *d; pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) 80107e89: e8 22 ff ff ff call 80107db0 <setupkvm> 80107e8e: 85 c0 test %eax,%eax 80107e90: 89 45 e0 mov %eax,-0x20(%ebp) 80107e93: 0f 84 c5 00 00 00 je 80107f5e <copyuvm+0xde> return 0; for(i = 0; i < sz; i += PGSIZE){ 80107e99: 8b 4d 0c mov 0xc(%ebp),%ecx 80107e9c: 85 c9 test %ecx,%ecx 80107e9e: 0f 84 9c 00 00 00 je 80107f40 <copyuvm+0xc0> 80107ea4: 31 ff xor %edi,%edi 80107ea6: eb 4a jmp 80107ef2 <copyuvm+0x72> 80107ea8: 90 nop 80107ea9: 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); 80107eb0: 83 ec 04 sub $0x4,%esp 80107eb3: 81 c3 00 00 00 80 add $0x80000000,%ebx 80107eb9: 68 00 10 00 00 push $0x1000 80107ebe: 53 push %ebx 80107ebf: 50 push %eax 80107ec0: e8 1b d4 ff ff call 801052e0 <memmove> if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { 80107ec5: 58 pop %eax 80107ec6: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80107ecc: b9 00 10 00 00 mov $0x1000,%ecx 80107ed1: 5a pop %edx 80107ed2: ff 75 e4 pushl -0x1c(%ebp) 80107ed5: 50 push %eax 80107ed6: 89 fa mov %edi,%edx 80107ed8: 8b 45 e0 mov -0x20(%ebp),%eax 80107edb: e8 80 f8 ff ff call 80107760 <mappages> 80107ee0: 83 c4 10 add $0x10,%esp 80107ee3: 85 c0 test %eax,%eax 80107ee5: 78 69 js 80107f50 <copyuvm+0xd0> uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ 80107ee7: 81 c7 00 10 00 00 add $0x1000,%edi 80107eed: 39 7d 0c cmp %edi,0xc(%ebp) 80107ef0: 76 4e jbe 80107f40 <copyuvm+0xc0> if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) 80107ef2: 8b 45 08 mov 0x8(%ebp),%eax 80107ef5: 31 c9 xor %ecx,%ecx 80107ef7: 89 fa mov %edi,%edx 80107ef9: e8 e2 f7 ff ff call 801076e0 <walkpgdir> 80107efe: 85 c0 test %eax,%eax 80107f00: 74 6d je 80107f6f <copyuvm+0xef> panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) 80107f02: 8b 00 mov (%eax),%eax 80107f04: a8 01 test $0x1,%al 80107f06: 74 5a je 80107f62 <copyuvm+0xe2> panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); 80107f08: 89 c3 mov %eax,%ebx flags = PTE_FLAGS(*pte); 80107f0a: 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); 80107f0f: 81 e3 00 f0 ff ff and $0xfffff000,%ebx flags = PTE_FLAGS(*pte); 80107f15: 89 45 e4 mov %eax,-0x1c(%ebp) if((mem = kalloc()) == 0) 80107f18: e8 c3 a7 ff ff call 801026e0 <kalloc> 80107f1d: 85 c0 test %eax,%eax 80107f1f: 89 c6 mov %eax,%esi 80107f21: 75 8d jne 80107eb0 <copyuvm+0x30> } } return d; bad: freevm(d); 80107f23: 83 ec 0c sub $0xc,%esp 80107f26: ff 75 e0 pushl -0x20(%ebp) 80107f29: e8 02 fe ff ff call 80107d30 <freevm> return 0; 80107f2e: 83 c4 10 add $0x10,%esp 80107f31: 31 c0 xor %eax,%eax } 80107f33: 8d 65 f4 lea -0xc(%ebp),%esp 80107f36: 5b pop %ebx 80107f37: 5e pop %esi 80107f38: 5f pop %edi 80107f39: 5d pop %ebp 80107f3a: c3 ret 80107f3b: 90 nop 80107f3c: 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){ 80107f40: 8b 45 e0 mov -0x20(%ebp),%eax return d; bad: freevm(d); return 0; } 80107f43: 8d 65 f4 lea -0xc(%ebp),%esp 80107f46: 5b pop %ebx 80107f47: 5e pop %esi 80107f48: 5f pop %edi 80107f49: 5d pop %ebp 80107f4a: c3 ret 80107f4b: 90 nop 80107f4c: 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); 80107f50: 83 ec 0c sub $0xc,%esp 80107f53: 56 push %esi 80107f54: e8 d7 a5 ff ff call 80102530 <kfree> goto bad; 80107f59: 83 c4 10 add $0x10,%esp 80107f5c: eb c5 jmp 80107f23 <copyuvm+0xa3> pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; 80107f5e: 31 c0 xor %eax,%eax 80107f60: eb d1 jmp 80107f33 <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"); 80107f62: 83 ec 0c sub $0xc,%esp 80107f65: 68 1e 8c 10 80 push $0x80108c1e 80107f6a: e8 01 84 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"); 80107f6f: 83 ec 0c sub $0xc,%esp 80107f72: 68 04 8c 10 80 push $0x80108c04 80107f77: e8 f4 83 ff ff call 80100370 <panic> 80107f7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80107f80 <uva2ka>: //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80107f80: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80107f81: 31 c9 xor %ecx,%ecx //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80107f83: 89 e5 mov %esp,%ebp 80107f85: 83 ec 08 sub $0x8,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80107f88: 8b 55 0c mov 0xc(%ebp),%edx 80107f8b: 8b 45 08 mov 0x8(%ebp),%eax 80107f8e: e8 4d f7 ff ff call 801076e0 <walkpgdir> if((*pte & PTE_P) == 0) 80107f93: 8b 00 mov (%eax),%eax return 0; if((*pte & PTE_U) == 0) 80107f95: 89 c2 mov %eax,%edx 80107f97: 83 e2 05 and $0x5,%edx 80107f9a: 83 fa 05 cmp $0x5,%edx 80107f9d: 75 11 jne 80107fb0 <uva2ka+0x30> return 0; return (char*)P2V(PTE_ADDR(*pte)); 80107f9f: 25 00 f0 ff ff and $0xfffff000,%eax } 80107fa4: 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)); 80107fa5: 05 00 00 00 80 add $0x80000000,%eax } 80107faa: c3 ret 80107fab: 90 nop 80107fac: 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; 80107fb0: 31 c0 xor %eax,%eax return (char*)P2V(PTE_ADDR(*pte)); } 80107fb2: c9 leave 80107fb3: c3 ret 80107fb4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80107fba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80107fc0 <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) { 80107fc0: 55 push %ebp 80107fc1: 89 e5 mov %esp,%ebp 80107fc3: 57 push %edi 80107fc4: 56 push %esi 80107fc5: 53 push %ebx 80107fc6: 83 ec 1c sub $0x1c,%esp 80107fc9: 8b 5d 14 mov 0x14(%ebp),%ebx 80107fcc: 8b 55 0c mov 0xc(%ebp),%edx 80107fcf: 8b 7d 10 mov 0x10(%ebp),%edi char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80107fd2: 85 db test %ebx,%ebx 80107fd4: 75 40 jne 80108016 <copyout+0x56> 80107fd6: eb 70 jmp 80108048 <copyout+0x88> 80107fd8: 90 nop 80107fd9: 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); 80107fe0: 8b 55 e4 mov -0x1c(%ebp),%edx 80107fe3: 89 f1 mov %esi,%ecx 80107fe5: 29 d1 sub %edx,%ecx 80107fe7: 81 c1 00 10 00 00 add $0x1000,%ecx 80107fed: 39 d9 cmp %ebx,%ecx 80107fef: 0f 47 cb cmova %ebx,%ecx if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80107ff2: 29 f2 sub %esi,%edx 80107ff4: 83 ec 04 sub $0x4,%esp 80107ff7: 01 d0 add %edx,%eax 80107ff9: 51 push %ecx 80107ffa: 57 push %edi 80107ffb: 50 push %eax 80107ffc: 89 4d e4 mov %ecx,-0x1c(%ebp) 80107fff: e8 dc d2 ff ff call 801052e0 <memmove> len -= n; buf += n; 80108004: 8b 4d e4 mov -0x1c(%ebp),%ecx { char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80108007: 83 c4 10 add $0x10,%esp if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; 8010800a: 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; 80108010: 01 cf add %ecx,%edi { char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80108012: 29 cb sub %ecx,%ebx 80108014: 74 32 je 80108048 <copyout+0x88> va0 = (uint)PGROUNDDOWN(va); 80108016: 89 d6 mov %edx,%esi pa0 = uva2ka(pgdir, (char*)va0); 80108018: 83 ec 08 sub $0x8,%esp char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); 8010801b: 89 55 e4 mov %edx,-0x1c(%ebp) 8010801e: 81 e6 00 f0 ff ff and $0xfffff000,%esi pa0 = uva2ka(pgdir, (char*)va0); 80108024: 56 push %esi 80108025: ff 75 08 pushl 0x8(%ebp) 80108028: e8 53 ff ff ff call 80107f80 <uva2ka> if(pa0 == 0) 8010802d: 83 c4 10 add $0x10,%esp 80108030: 85 c0 test %eax,%eax 80108032: 75 ac jne 80107fe0 <copyout+0x20> len -= n; buf += n; va = va0 + PGSIZE; } return 0; } 80108034: 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; 80108037: b8 ff ff ff ff mov $0xffffffff,%eax len -= n; buf += n; va = va0 + PGSIZE; } return 0; } 8010803c: 5b pop %ebx 8010803d: 5e pop %esi 8010803e: 5f pop %edi 8010803f: 5d pop %ebp 80108040: c3 ret 80108041: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80108048: 8d 65 f4 lea -0xc(%ebp),%esp memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; } return 0; 8010804b: 31 c0 xor %eax,%eax } 8010804d: 5b pop %ebx 8010804e: 5e pop %esi 8010804f: 5f pop %edi 80108050: 5d pop %ebp 80108051: c3 ret
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 80 .text@150 lbegin: ld c, 41 ld b, 03 lbegin_waitm3: ldff a, (c) and a, b cmp a, b jrnz lbegin_waitm3 ld a, 20 ldff(c), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei ld c, 0f .text@1000 lstatint: xor a, a ldff(41), a ldff(c), a .text@1064 ld a, 20 ldff(41), a ldff a, (c) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
/* See LICENSE file in root folder */ #ifndef ___C3DSMAA_SmaaUbo_H___ #define ___C3DSMAA_SmaaUbo_H___ #include "SmaaConfig.hpp" #include <Castor3D/Buffer/UniformBufferOffset.hpp> #include <Castor3D/Render/PostEffect/PostEffectSurface.hpp> #include <CastorUtils/Math/Point.hpp> #include <ShaderWriter/BaseTypes/Float.hpp> #include <ShaderWriter/BaseTypes/Int.hpp> #include <ShaderWriter/CompositeTypes/StructInstance.hpp> #include <ShaderWriter/VecTypes/Vec4.hpp> namespace smaa { enum Idx : uint32_t { SmaaUboIdx, }; struct SmaaUboConfiguration { castor::Point4f rtMetrics; castor::Point4f predication; castor::Point4f subsampleIndices; castor::Point4f searchSizes; castor::Point4f areaTexPixelSizeAndLocalContrast; castor::Point4f areaTexSizesReprojWS; castor::Point4i maxsSearchSteps; castor::Point4i tweaks; }; struct SmaaData : public sdw::StructInstance { public: SmaaData( sdw::ShaderWriter & writer , ast::expr::ExprPtr expr , bool enabled ); SDW_DeclStructInstance( , SmaaData ); static ast::type::BaseStructPtr makeType( ast::type::TypesCache & cache ); public: // Struct members sdw::Vec4 rtMetrics; sdw::Vec4 predication; sdw::Vec4 subsampleIndices; sdw::Vec4 searchSizes; sdw::Vec4 areaTexPixelSizeAndLocalContrast; sdw::Vec4 areaTexSizesReprojWS; sdw::IVec4 maxsSearchSteps; sdw::IVec4 tweaks; // Computed from members sdw::Float threshold; sdw::Float predicationThreshold; sdw::Float predicationScale; sdw::Float predicationStrength; sdw::Vec2 searchTexSize; sdw::Vec2 searchTexPackedSize; sdw::Vec2 areaTexPixelSize; sdw::Float localContrastAdaptationFactor; sdw::Int cornerRounding; sdw::Float areaTexMaxDistance; sdw::Float areaTexMaxDistanceDiag; sdw::Float areaTexSubtexSize; sdw::Float reprojectionWeightScale; sdw::Int maxSearchSteps; sdw::Int maxSearchStepsDiag; sdw::Int disableCornerDetection; sdw::Int disableDiagonalDetection; sdw::Int enableReprojection; sdw::Float cornerRoundingNorm; sdw::Float depthThreshold; private: using sdw::StructInstance::getMember; using sdw::StructInstance::getMemberArray; }; class SmaaUbo { public: using Configuration = SmaaUboConfiguration; public: SmaaUbo( SmaaUbo const & rhs ) = delete; SmaaUbo & operator=( SmaaUbo const & rhs ) = delete; SmaaUbo( SmaaUbo && rhs ) = default; SmaaUbo & operator=( SmaaUbo && rhs ) = delete; explicit SmaaUbo( castor3d::RenderDevice const & device ); ~SmaaUbo(); void cpuUpdate( castor::Size const & renderSize , SmaaConfig const & config ); void createPassBinding( crg::FramePass & pass , uint32_t binding )const { return m_ubo.createPassBinding( pass, "SMAA", binding ); } void createSizedBinding( ashes::DescriptorSet & descriptorSet , VkDescriptorSetLayoutBinding const & layoutBinding )const { return m_ubo.createSizedBinding( descriptorSet, layoutBinding ); } castor3d::UniformBufferOffsetT< Configuration > const & getUbo()const { return m_ubo; } public: static const castor::String Buffer; static const castor::String Data; private: castor3d::RenderDevice const & m_device; castor3d::UniformBufferOffsetT< Configuration > m_ubo; }; } #define UBO_SMAA( writer, binding, set )\ sdw::Ubo smaaBuffer{ writer\ , smaa::SmaaUbo::Buffer\ , binding\ , set\ , ast::type::MemoryLayout::eStd140\ , true };\ auto c3d_smaaData = smaaBuffer.declStructMember< smaa::SmaaData >( smaa::SmaaUbo::Data );\ smaaBuffer.end() #endif
#include "Enemy_Fast.h" // constructor ------------------------------------------------ Enemy_Fast::Enemy_Fast() : Game_Actor(154, 12,0,0, 50) { // Display ASCII character code 202, color code 2 // 50 points when killed coord.X = rand() % 40 + 1; // randomly set the initial position coord.Y = rand() % 20 + 1; direction = true; show(); } // move function ---------------------------------------------- void Enemy_Fast::move() { if (direction) { // move toward the right moveTo(coord.X + 1, coord.Y); // move right if (coord.X == 40) { // change direction direction = false; } } else { // move toward the left moveTo(coord.X - 1, coord.Y); // left if (coord.X == 1) { // change direction direction = true; } } }
Map_188E7C: dc.w word_188E8E-Map_188E7C dc.w word_188E96-Map_188E7C dc.w word_188E9E-Map_188E7C dc.w word_188EA6-Map_188E7C dc.w word_188EBA-Map_188E7C dc.w word_188ECE-Map_188E7C dc.w word_188ED6-Map_188E7C dc.w word_188EDE-Map_188E7C dc.w word_188EFE-Map_188E7C word_188E8E: dc.w 1 dc.b $F8, 5, 0, 0, $FF, $F8 word_188E96: dc.w 1 dc.b $F8, 5, 0, 4, $FF, $F8 word_188E9E: dc.w 1 dc.b $F8, 5, 0, 8, $FF, $F8 word_188EA6: dc.w 3 dc.b $E8, 4, 0, $C, $FF, $F4 dc.b $F0, $B, 0, $E, $FF, $F4 dc.b $10, 4, 0, $1A, $FF, $F4 word_188EBA: dc.w 3 dc.b $E8, 8, 0, $1C, $FF, $F4 dc.b $F0, $B, 0, $1F, $FF, $F4 dc.b $10, 4, 0, $2B, $FF, $F4 word_188ECE: dc.w 1 dc.b $F4, $E, 0, $2D, $FF, $F0 word_188ED6: dc.w 1 dc.b $F4, $E, 0, $39, $FF, $F0 word_188EDE: dc.w 5 dc.b $E8, 8, 0, $45, $FF, $F8 dc.b $F0, $C, 0, $48, $FF, $E8 dc.b $F0, 8, 0, $4C, 0, 8 dc.b $F8, $F, 0, $4F, $FF, $E0 dc.b $F8, $F, 0, $5F, 0, 0 word_188EFE: dc.w 5 dc.b $E8, 8, 0, $6F, $FF, $F8 dc.b $F0, $C, 0, $72, $FF, $E8 dc.b $F0, 8, 0, $76, 0, 8 dc.b $F8, $F, 0, $79, $FF, $E0 dc.b $F8, $F, 0, $89, 0, 0
/* * Copyright (c) 2015 Nikolay Zapolnov (zapolnov@gmail.com). * * 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 "Log.h" namespace B3D { void Log::write(LogLevel level, const std::ostream& stream) { const auto& logger = Services::logger(); if (logger) logger->write(level, static_cast<const std::ostringstream&>(stream).str()); } }
#include "rtkTestConfiguration.h" #include "rtkCudaCropImageFilter.h" /** * \file rtkcroptest.cxx * \brief Functional test for the classes performing crop filtering * \author Julien Jomier */ int main(int, char **) { constexpr unsigned int Dimension = 3; using PixelType = float; using ImageType = itk::CudaImage<PixelType, Dimension>; ImageType::Pointer image = ImageType::New(); ImageType::RegionType region; ImageType::SizeType size; size[0] = 50; size[1] = 50; size[2] = 50; region.SetSize(size); image->SetRegions(region); image->Allocate(); image->FillBuffer(12.3); using CropImageFilter = rtk::CudaCropImageFilter; CropImageFilter::Pointer crop = CropImageFilter::New(); crop->SetInput(image); ImageType::SizeType upCropSize, lowCropSize; for (unsigned int i = 0; i < ImageType::ImageDimension; i++) { lowCropSize[i] = 1; upCropSize[i] = 10; } crop->SetUpperBoundaryCropSize(upCropSize); crop->SetLowerBoundaryCropSize(lowCropSize); try { crop->Update(); } catch (itk::ExceptionObject & err) { std::cerr << err << std::endl; exit(EXIT_FAILURE); } ImageType::IndexType index; index.Fill(2); if (fabs(crop->GetOutput()->GetPixel(index) - 12.3) > 0.0001) { std::cout << "Output should be 12.3. Value Computed = " << crop->GetOutput()->GetPixel(index) << std::endl; return EXIT_FAILURE; } std::cout << "Done!" << std::endl; std::cout << "\n\nTest PASSED! " << std::endl; return EXIT_SUCCESS; }
; A223270: Rolling cube footprints: number of 2 X n 0..5 arrays starting with 0 where 0..5 label faces of a cube and every array movement to a horizontal, diagonal or antidiagonal neighbor moves across a corresponding cube edge. ; Submitted by Jamie Morken(s3) ; 6,48,576,6144,67584,737280,8060928,88080384,962592768,10519314432,114957484032,1256277934080,13728862961664,150031797583872,1639577995444224,17917641486237696,195807627744116736,2139825549512540160,23384448483912056832,255550005455697739776,2792702395130767736832,30519219335628469567488,333520231329212324118528,3644776869373809619107840,39830862357525271324655616,435279758680164078408695808,4756825664882121309658546176,51983557596822220986346635264,568086882050805649799846559744 mov $3,1 lpb $0 sub $0,1 mul $1,4 mul $3,8 mov $2,$3 add $3,$1 mov $1,$2 lpe mov $0,$3 mul $0,6
* Remove string from RI stack V0.0  1985 Tony Tebby QJUMP * section utils * xdef ut_remst remove string (a1) * include dev8_sbsext_ext_keys * * d1 s total length occupied * a1 c p pointer to RI stack * ut_remst moveq #3,d1 round up to word, including char count add.w (a6,a1.l),d1 get length bclr #0,d1 add.l d1,bv_rip(a6) change RIP but not a1 rts end
#include "repository.hpp" #include <fstream> #include <phosphor-logging/log.hpp> #include <xyz/openbmc_project/Common/File/error.hpp> namespace openpower { namespace pels { namespace fs = std::filesystem; using namespace phosphor::logging; namespace file_error = sdbusplus::xyz::openbmc_project::Common::File::Error; Repository::Repository(const std::filesystem::path& basePath) : _logPath(basePath / "logs") { if (!fs::exists(_logPath)) { fs::create_directories(_logPath); } restore(); } void Repository::restore() { for (auto& dirEntry : fs::directory_iterator(_logPath)) { try { if (!fs::is_regular_file(dirEntry.path())) { continue; } std::ifstream file{dirEntry.path()}; std::vector<uint8_t> data{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()}; file.close(); PEL pel(std::move(data)); if (pel.valid()) { using pelID = LogID::Pel; using obmcID = LogID::Obmc; _idsToPELs.emplace( LogID(pelID(pel.id()), obmcID(pel.obmcLogID())), dirEntry.path()); } else { log<level::ERR>( "Found invalid PEL file while restoring. Removing.", entry("FILENAME=%s", dirEntry.path().c_str())); fs::remove(dirEntry.path()); } } catch (std::exception& e) { log<level::ERR>("Hit exception while restoring PEL File", entry("FILENAME=%s", dirEntry.path().c_str()), entry("ERROR=%s", e.what())); } } } std::string Repository::getPELFilename(uint32_t pelID, const BCDTime& time) { char name[50]; sprintf(name, "%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X_%.8X", time.yearMSB, time.yearLSB, time.month, time.day, time.hour, time.minutes, time.seconds, time.hundredths, pelID); return std::string{name}; } void Repository::add(std::unique_ptr<PEL>& pel) { auto path = _logPath / getPELFilename(pel->id(), pel->commitTime()); std::ofstream file{path, std::ios::binary}; if (!file.good()) { // If this fails, the filesystem is probably full so it isn't like // we could successfully create yet another error log here. auto e = errno; log<level::ERR>("Failed creating PEL file", entry("FILE=%s", path.c_str())); fs::remove(path); log<level::ERR>("Unable to open PEL file for writing", entry("ERRNO=%d", e), entry("PATH=%s", path.c_str())); throw file_error::Open(); } auto data = pel->data(); file.write(reinterpret_cast<const char*>(data.data()), data.size()); if (file.fail()) { // Same note as above about not being able to create an error log // for this case even if we wanted. auto e = errno; log<level::ERR>("Failed writing PEL file", entry("FILE=%s", path.c_str())); file.close(); fs::remove(path); log<level::ERR>("Unable to write PEL file", entry("ERRNO=%d", e), entry("PATH=%s", path.c_str())); throw file_error::Write(); } using pelID = LogID::Pel; using obmcID = LogID::Obmc; _idsToPELs.emplace(LogID(pelID(pel->id()), obmcID(pel->obmcLogID())), path); } void Repository::remove(const LogID& id) { auto pel = findPEL(id); if (pel != _idsToPELs.end()) { fs::remove(pel->second); _idsToPELs.erase(pel); } } std::optional<std::vector<uint8_t>> Repository::getPELData(const LogID& id) { auto pel = findPEL(id); if (pel != _idsToPELs.end()) { std::ifstream file{pel->second.c_str()}; if (!file.good()) { auto e = errno; log<level::ERR>("Unable to open PEL file", entry("ERRNO=%d", e), entry("PATH=%s", pel->second.c_str())); throw file_error::Open(); } std::vector<uint8_t> data{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()}; return data; } return std::nullopt; } } // namespace pels } // namespace openpower
; A265283: Number of ON (black) cells in the n-th iteration of the "Rule 94" elementary cellular automaton starting with a single ON (black) cell. ; 1,3,4,6,6,8,8,10,10,12,12,14,14,16,16,18,18,20,20,22,22,24,24,26,26,28,28,30,30,32,32,34,34,36,36,38,38,40,40,42,42,44,44,46,46,48,48,50,50,52,52,54,54,56,56,58,58,60,60,62,62,64,64,66,66,68,68,70,70,72,72,74,74,76,76,78,78,80,80,82,82,84,84,86,86,88,88,90,90,92,92,94,94,96,96,98,98,100,100,102 mov $1,$0 lpb $1 add $0,1 mod $1,2 lpe add $0,$1 add $0,1
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/pinpoint/model/ApplicationResponse.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace Pinpoint { namespace Model { ApplicationResponse::ApplicationResponse() : m_idHasBeenSet(false), m_nameHasBeenSet(false) { } ApplicationResponse::ApplicationResponse(JsonView jsonValue) : m_idHasBeenSet(false), m_nameHasBeenSet(false) { *this = jsonValue; } ApplicationResponse& ApplicationResponse::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("Id")) { m_id = jsonValue.GetString("Id"); m_idHasBeenSet = true; } if(jsonValue.ValueExists("Name")) { m_name = jsonValue.GetString("Name"); m_nameHasBeenSet = true; } return *this; } JsonValue ApplicationResponse::Jsonize() const { JsonValue payload; if(m_idHasBeenSet) { payload.WithString("Id", m_id); } if(m_nameHasBeenSet) { payload.WithString("Name", m_name); } return payload; } } // namespace Model } // namespace Pinpoint } // namespace Aws
// //Copyright (C) 2002-2005 3Dlabs Inc. Ltd. //Copyright (C) 2013-2016 LunarG, Inc. //Copyright (C) 2015-2016 Google, Inc. // //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 3Dlabs Inc. Ltd. 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 HOLDERS 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. // // // Implement the top-level of interface to the compiler/linker, // as defined in ShaderLang.h // This is the platform independent interface between an OGL driver // and the shading language compiler/linker. // #include <cstring> #include <iostream> #include <sstream> #include <memory> #include "SymbolTable.h" #include "ParseHelper.h" #include "../../hlsl/hlslParseHelper.h" #include "../../hlsl/hlslParseables.h" #include "Scan.h" #include "ScanContext.h" #include "../Include/ShHandle.h" #include "../../OGLCompilersDLL/InitializeDll.h" #include "preprocessor/PpContext.h" #define SH_EXPORTING #include "../Public/ShaderLang.h" #include "reflection.h" #include "iomapper.h" #include "Initialize.h" namespace { // anonymous namespace for file-local functions and symbols using namespace glslang; // Create a language specific version of parseables. TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource source) { switch (source) { case EShSourceGlsl: return new TBuiltIns(); // GLSL builtIns case EShSourceHlsl: return new TBuiltInParseablesHlsl(); // HLSL intrinsics default: infoSink.info.message(EPrefixInternalError, "Unable to determine source language"); return nullptr; } } // Local mapping functions for making arrays of symbol tables.... const int VersionCount = 15; // index range in MapVersionToIndex int MapVersionToIndex(int version) { int index = 0; switch (version) { case 100: index = 0; break; case 110: index = 1; break; case 120: index = 2; break; case 130: index = 3; break; case 140: index = 4; break; case 150: index = 5; break; case 300: index = 6; break; case 330: index = 7; break; case 400: index = 8; break; case 410: index = 9; break; case 420: index = 10; break; case 430: index = 11; break; case 440: index = 12; break; case 310: index = 13; break; case 450: index = 14; break; default: break; } assert(index < VersionCount); return index; } const int SpvVersionCount = 3; // index range in MapSpvVersionToIndex int MapSpvVersionToIndex(const SpvVersion& spvVersion) { int index = 0; if (spvVersion.openGl > 0) index = 1; else if (spvVersion.vulkan > 0) index = 2; assert(index < SpvVersionCount); return index; } const int ProfileCount = 4; // index range in MapProfileToIndex int MapProfileToIndex(EProfile profile) { int index = 0; switch (profile) { case ENoProfile: index = 0; break; case ECoreProfile: index = 1; break; case ECompatibilityProfile: index = 2; break; case EEsProfile: index = 3; break; default: break; } assert(index < ProfileCount); return index; } const int SourceCount = 2; int MapSourceToIndex(EShSource source) { int index = 0; switch (source) { case EShSourceGlsl: index = 0; break; case EShSourceHlsl: index = 1; break; default: break; } assert(index < SourceCount); return index; } // only one of these needed for non-ES; ES needs 2 for different precision defaults of built-ins enum EPrecisionClass { EPcGeneral, EPcFragment, EPcCount }; // A process-global symbol table per version per profile for built-ins common // to multiple stages (languages), and a process-global symbol table per version // per profile per stage for built-ins unique to each stage. They will be sparsely // populated, so they will only be generated as needed. // // Each has a different set of built-ins, and we want to preserve that from // compile to compile. // TSymbolTable* CommonSymbolTable[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EPcCount] = {}; TSymbolTable* SharedSymbolTables[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EShLangCount] = {}; TPoolAllocator* PerProcessGPA = 0; // // Parse and add to the given symbol table the content of the given shader string. // bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink, TSymbolTable& symbolTable) { TIntermediate intermediate(language, version, profile); TParseContext parseContext(symbolTable, intermediate, true, version, profile, spvVersion, language, infoSink); TShader::ForbidInclude includer; TPpContext ppContext(parseContext, "", includer); TScanContext scanContext(parseContext); parseContext.setScanContext(&scanContext); parseContext.setPpContext(&ppContext); // // Push the symbol table to give it an initial scope. This // push should not have a corresponding pop, so that built-ins // are preserved, and the test for an empty table fails. // symbolTable.push(); const char* builtInShaders[2]; size_t builtInLengths[2]; builtInShaders[0] = builtIns.c_str(); builtInLengths[0] = builtIns.size(); if (builtInLengths[0] == 0) return true; TInputScanner input(1, builtInShaders, builtInLengths); if (! parseContext.parseShaderStrings(ppContext, input) != 0) { infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins"); printf("Unable to parse built-ins\n%s\n", infoSink.info.c_str()); printf("%s\n", builtInShaders[0]); return false; } return true; } int CommonIndex(EProfile profile, EShLanguage language) { return (profile == EEsProfile && language == EShLangFragment) ? EPcFragment : EPcGeneral; } // // To initialize per-stage shared tables, with the common table already complete. // void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink, TSymbolTable** commonTable, TSymbolTable** symbolTables) { (*symbolTables[language]).adoptLevels(*commonTable[CommonIndex(profile, language)]); InitializeSymbolTable(builtInParseables.getStageString(language), version, profile, spvVersion, language, infoSink, *symbolTables[language]); builtInParseables.identifyBuiltIns(version, profile, spvVersion, language, *symbolTables[language]); if (profile == EEsProfile && version >= 300) (*symbolTables[language]).setNoBuiltInRedeclarations(); if (version == 110) (*symbolTables[language]).setSeparateNameSpaces(); } // // Initialize the full set of shareable symbol tables; // The common (cross-stage) and those shareable per-stage. // bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TSymbolTable** symbolTables, int version, EProfile profile, const SpvVersion& spvVersion, EShSource source) { std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source)); builtInParseables->initialize(version, profile, spvVersion); // do the common tables InitializeSymbolTable(builtInParseables->getCommonString(), version, profile, spvVersion, EShLangVertex, infoSink, *commonTable[EPcGeneral]); if (profile == EEsProfile) InitializeSymbolTable(builtInParseables->getCommonString(), version, profile, spvVersion, EShLangFragment, infoSink, *commonTable[EPcFragment]); // do the per-stage tables // always have vertex and fragment InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangVertex, infoSink, commonTable, symbolTables); InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangFragment, infoSink, commonTable, symbolTables); // check for tessellation if ((profile != EEsProfile && version >= 150) || (profile == EEsProfile && version >= 310)) { InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTessControl, infoSink, commonTable, symbolTables); InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTessEvaluation, infoSink, commonTable, symbolTables); } // check for geometry if ((profile != EEsProfile && version >= 150) || (profile == EEsProfile && version >= 310)) InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangGeometry, infoSink, commonTable, symbolTables); // check for compute if ((profile != EEsProfile && version >= 420) || (profile == EEsProfile && version >= 310)) InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, infoSink, commonTable, symbolTables); return true; } bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& infoSink, TSymbolTable& symbolTable, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, EShSource source) { std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source)); builtInParseables->initialize(*resources, version, profile, spvVersion, language); InitializeSymbolTable(builtInParseables->getCommonString(), version, profile, spvVersion, language, infoSink, symbolTable); builtInParseables->identifyBuiltIns(version, profile, spvVersion, language, symbolTable, *resources); return true; } // // To do this on the fly, we want to leave the current state of our thread's // pool allocator intact, so: // - Switch to a new pool for parsing the built-ins // - Do the parsing, which builds the symbol table, using the new pool // - Switch to the process-global pool to save a copy the resulting symbol table // - Free up the new pool used to parse the built-ins // - Switch back to the original thread's pool // // This only gets done the first time any thread needs a particular symbol table // (lazy evaluation). // void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& spvVersion, EShSource source) { TInfoSink infoSink; // Make sure only one thread tries to do this at a time glslang::GetGlobalLock(); // See if it's already been done for this version/profile combination int versionIndex = MapVersionToIndex(version); int spvVersionIndex = MapSpvVersionToIndex(spvVersion); int profileIndex = MapProfileToIndex(profile); int sourceIndex = MapSourceToIndex(source); if (CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][EPcGeneral]) { glslang::ReleaseGlobalLock(); return; } // Switch to a new pool TPoolAllocator& previousAllocator = GetThreadPoolAllocator(); TPoolAllocator* builtInPoolAllocator = new TPoolAllocator(); SetThreadPoolAllocator(*builtInPoolAllocator); // Dynamically allocate the local symbol tables so we can control when they are deallocated WRT when the pool is popped. TSymbolTable* commonTable[EPcCount]; TSymbolTable* stageTables[EShLangCount]; for (int precClass = 0; precClass < EPcCount; ++precClass) commonTable[precClass] = new TSymbolTable; for (int stage = 0; stage < EShLangCount; ++stage) stageTables[stage] = new TSymbolTable; // Generate the local symbol tables using the new pool InitializeSymbolTables(infoSink, commonTable, stageTables, version, profile, spvVersion, source); // Switch to the process-global pool SetThreadPoolAllocator(*PerProcessGPA); // Copy the local symbol tables from the new pool to the global tables using the process-global pool for (int precClass = 0; precClass < EPcCount; ++precClass) { if (! commonTable[precClass]->isEmpty()) { CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][precClass] = new TSymbolTable; CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][precClass]->copyTable(*commonTable[precClass]); CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][precClass]->readOnly(); } } for (int stage = 0; stage < EShLangCount; ++stage) { if (! stageTables[stage]->isEmpty()) { SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage] = new TSymbolTable; SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->adoptLevels(*CommonSymbolTable [versionIndex][spvVersionIndex][profileIndex][sourceIndex][CommonIndex(profile, (EShLanguage)stage)]); SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->copyTable(*stageTables[stage]); SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->readOnly(); } } // Clean up the local tables before deleting the pool they used. for (int precClass = 0; precClass < EPcCount; ++precClass) delete commonTable[precClass]; for (int stage = 0; stage < EShLangCount; ++stage) delete stageTables[stage]; delete builtInPoolAllocator; SetThreadPoolAllocator(previousAllocator); glslang::ReleaseGlobalLock(); } // Return true if the shader was correctly specified for version/profile/stage. bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNotFirst, int defaultVersion, EShSource source, int& version, EProfile& profile, const SpvVersion& spvVersion) { const int FirstProfileVersion = 150; bool correct = true; if (source == EShSourceHlsl) { version = 450; // TODO: GLSL parser is still used for builtins. profile = ECoreProfile; // allow doubles in prototype parsing return correct; } // Get a good version... if (version == 0) { version = defaultVersion; // infoSink.info.message(EPrefixWarning, "#version: statement missing; use #version on first line of shader"); } // Get a good profile... if (profile == ENoProfile) { if (version == 300 || version == 310) { correct = false; infoSink.info.message(EPrefixError, "#version: versions 300 and 310 require specifying the 'es' profile"); profile = EEsProfile; } else if (version == 100) profile = EEsProfile; else if (version >= FirstProfileVersion) profile = ECoreProfile; else profile = ENoProfile; } else { // a profile was provided... if (version < 150) { correct = false; infoSink.info.message(EPrefixError, "#version: versions before 150 do not allow a profile token"); if (version == 100) profile = EEsProfile; else profile = ENoProfile; } else if (version == 300 || version == 310) { if (profile != EEsProfile) { correct = false; infoSink.info.message(EPrefixError, "#version: versions 300 and 310 support only the es profile"); } profile = EEsProfile; } else { if (profile == EEsProfile) { correct = false; infoSink.info.message(EPrefixError, "#version: only version 300 and 310 support the es profile"); if (version >= FirstProfileVersion) profile = ECoreProfile; else profile = ENoProfile; } // else: typical desktop case... e.g., "#version 410 core" } } // Correct for stage type... switch (stage) { case EShLangGeometry: if ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 150)) { correct = false; infoSink.info.message(EPrefixError, "#version: geometry shaders require es profile with version 310 or non-es profile with version 150 or above"); version = (profile == EEsProfile) ? 310 : 150; if (profile == EEsProfile || profile == ENoProfile) profile = ECoreProfile; } break; case EShLangTessControl: case EShLangTessEvaluation: if ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 150)) { correct = false; infoSink.info.message(EPrefixError, "#version: tessellation shaders require es profile with version 310 or non-es profile with version 150 or above"); version = (profile == EEsProfile) ? 310 : 400; // 150 supports the extension, correction is to 400 which does not if (profile == EEsProfile || profile == ENoProfile) profile = ECoreProfile; } break; case EShLangCompute: if ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 420)) { correct = false; infoSink.info.message(EPrefixError, "#version: compute shaders require es profile with version 310 or above, or non-es profile with version 420 or above"); version = profile == EEsProfile ? 310 : 420; } break; default: break; } if (profile == EEsProfile && version >= 300 && versionNotFirst) { correct = false; infoSink.info.message(EPrefixError, "#version: statement must appear first in es-profile shader; before comments or newlines"); } // Check for SPIR-V compatibility if (spvVersion.spv != 0) { switch (profile) { case EEsProfile: if (spvVersion.vulkan >= 100 && version < 310) { correct = false; infoSink.info.message(EPrefixError, "#version: ES shaders for Vulkan SPIR-V require version 310 or higher"); version = 310; } if (spvVersion.openGl >= 100) { correct = false; infoSink.info.message(EPrefixError, "#version: ES shaders for OpenGL SPIR-V are not supported"); version = 310; } break; case ECompatibilityProfile: infoSink.info.message(EPrefixError, "#version: compilation for SPIR-V does not support the compatibility profile"); break; default: if (spvVersion.vulkan >= 100 && version < 140) { correct = false; infoSink.info.message(EPrefixError, "#version: Desktop shaders for Vulkan SPIR-V require version 140 or higher"); version = 140; } if (spvVersion.openGl >= 100 && version < 330) { correct = false; infoSink.info.message(EPrefixError, "#version: Desktop shaders for OpenGL SPIR-V require version 330 or higher"); version = 330; } break; } } // A meta check on the condition of the compiler itself... switch (version) { // ES versions case 100: case 300: // versions are complete break; // Desktop versions case 110: case 120: case 130: case 140: case 150: case 330: // versions are complete break; case 310: case 400: case 410: case 420: case 430: case 440: case 450: infoSink.info << "Warning, version " << version << " is not yet complete; most version-specific features are present, but some are missing.\n"; break; default: infoSink.info << "Warning, version " << version << " is unknown.\n"; break; } return correct; } // This is the common setup and cleanup code for PreprocessDeferred and // CompileDeferred. // It takes any callable with a signature of // bool (TParseContextBase& parseContext, TPpContext& ppContext, // TInputScanner& input, bool versionWillBeError, // TSymbolTable& , TIntermediate& , // EShOptimizationLevel , EShMessages ); // Which returns false if a failure was detected and true otherwise. // template<typename ProcessingContext> bool ProcessDeferred( TCompiler* compiler, const char* const shaderStrings[], const int numStrings, const int* inputLengths, const char* const stringNames[], const char* customPreamble, const EShOptimizationLevel optLevel, const TBuiltInResource* resources, int defaultVersion, // use 100 for ES environment, 110 for desktop; this is the GLSL version, not SPIR-V or Vulkan EProfile defaultProfile, // set version/profile to defaultVersion/defaultProfile regardless of the #version // directive in the source code bool forceDefaultVersionAndProfile, bool forwardCompatible, // give errors for use of deprecated features EShMessages messages, // warnings/errors/AST; things to print out TIntermediate& intermediate, // returned tree, etc. ProcessingContext& processingContext, bool requireNonempty, TShader::Includer& includer ) { if (! InitThread()) return false; // This must be undone (.pop()) by the caller, after it finishes consuming the created tree. GetThreadPoolAllocator().push(); if (numStrings == 0) return true; // Move to length-based strings, rather than null-terminated strings. // Also, add strings to include the preamble and to ensure the shader is not null, // which lets the grammar accept what was a null (post preprocessing) shader. // // Shader will look like // string 0: system preamble // string 1: custom preamble // string 2...numStrings+1: user's shader // string numStrings+2: "int;" const int numPre = 2; const int numPost = requireNonempty? 1 : 0; const int numTotal = numPre + numStrings + numPost; size_t* lengths = new size_t[numTotal]; const char** strings = new const char*[numTotal]; const char** names = new const char*[numTotal]; for (int s = 0; s < numStrings; ++s) { strings[s + numPre] = shaderStrings[s]; if (inputLengths == 0 || inputLengths[s] < 0) lengths[s + numPre] = strlen(shaderStrings[s]); else lengths[s + numPre] = inputLengths[s]; } if (stringNames != nullptr) { for (int s = 0; s < numStrings; ++s) names[s + numPre] = stringNames[s]; } else { for (int s = 0; s < numStrings; ++s) names[s + numPre] = nullptr; } // First, without using the preprocessor or parser, find the #version, so we know what // symbol tables, processing rules, etc. to set up. This does not need the extra strings // outlined above, just the user shader. int version; EProfile profile; glslang::TInputScanner userInput(numStrings, &strings[numPre], &lengths[numPre]); // no preamble bool versionNotFirstToken; bool versionNotFirst = userInput.scanVersion(version, profile, versionNotFirstToken); bool versionNotFound = version == 0; if (forceDefaultVersionAndProfile) { if (! (messages & EShMsgSuppressWarnings) && ! versionNotFound && (version != defaultVersion || profile != defaultProfile)) { compiler->infoSink.info << "Warning, (version, profile) forced to be (" << defaultVersion << ", " << ProfileName(defaultProfile) << "), while in source code it is (" << version << ", " << ProfileName(profile) << ")\n"; } if (versionNotFound) { versionNotFirstToken = false; versionNotFirst = false; versionNotFound = false; } version = defaultVersion; profile = defaultProfile; } SpvVersion spvVersion; if (messages & EShMsgSpvRules) spvVersion.spv = 0x00010000; // TODO: eventually have this come from the outside EShSource source = (messages & EShMsgReadHlsl) ? EShSourceHlsl : EShSourceGlsl; if (messages & EShMsgVulkanRules) spvVersion.vulkan = 100; // TODO: eventually have this come from the outside else if (spvVersion.spv != 0) spvVersion.openGl = 100; // TODO: eventually have this come from the outside bool goodVersion = DeduceVersionProfile(compiler->infoSink, compiler->getLanguage(), versionNotFirst, defaultVersion, source, version, profile, spvVersion); bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst)); bool warnVersionNotFirst = false; if (! versionWillBeError && versionNotFirstToken) { if (messages & EShMsgRelaxedErrors) warnVersionNotFirst = true; else versionWillBeError = true; } intermediate.setSource(source); intermediate.setVersion(version); intermediate.setProfile(profile); intermediate.setSpv(spvVersion); if (spvVersion.vulkan >= 100) intermediate.setOriginUpperLeft(); SetupBuiltinSymbolTable(version, profile, spvVersion, source); TSymbolTable* cachedTable = SharedSymbolTables[MapVersionToIndex(version)] [MapSpvVersionToIndex(spvVersion)] [MapProfileToIndex(profile)] [MapSourceToIndex(source)] [compiler->getLanguage()]; // Dynamically allocate the symbol table so we can control when it is deallocated WRT the pool. TSymbolTable* symbolTableMemory = new TSymbolTable; TSymbolTable& symbolTable = *symbolTableMemory; if (cachedTable) symbolTable.adoptLevels(*cachedTable); // Add built-in symbols that are potentially context dependent; // they get popped again further down. AddContextSpecificSymbols(resources, compiler->infoSink, symbolTable, version, profile, spvVersion, compiler->getLanguage(), source); // // Now we can process the full shader under proper symbols and rules. // TParseContextBase* parseContext; if (source == EShSourceHlsl) { parseContext = new HlslParseContext(symbolTable, intermediate, false, version, profile, spvVersion, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages); } else { intermediate.setEntryPointName("main"); parseContext = new TParseContext(symbolTable, intermediate, false, version, profile, spvVersion, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages); } TPpContext ppContext(*parseContext, names[numPre]? names[numPre]: "", includer); // only GLSL (bison triggered, really) needs an externally set scan context glslang::TScanContext scanContext(*parseContext); if ((messages & EShMsgReadHlsl) == 0) parseContext->setScanContext(&scanContext); parseContext->setPpContext(&ppContext); parseContext->setLimits(*resources); if (! goodVersion) parseContext->addError(); if (warnVersionNotFirst) { TSourceLoc loc; loc.init(); parseContext->warn(loc, "Illegal to have non-comment, non-whitespace tokens before #version", "#version", ""); } parseContext->initializeExtensionBehavior(); // Fill in the strings as outlined above. std::string preamble; parseContext->getPreamble(preamble); strings[0] = preamble.c_str(); lengths[0] = strlen(strings[0]); names[0] = nullptr; strings[1] = customPreamble; lengths[1] = strlen(strings[1]); names[1] = nullptr; assert(2 == numPre); if (requireNonempty) { const int postIndex = numStrings + numPre; strings[postIndex] = "\n int;"; lengths[postIndex] = strlen(strings[numStrings + numPre]); names[postIndex] = nullptr; } TInputScanner fullInput(numStrings + numPre + numPost, strings, lengths, names, numPre, numPost); // Push a new symbol allocation scope that will get used for the shader's globals. symbolTable.push(); bool success = processingContext(*parseContext, ppContext, fullInput, versionWillBeError, symbolTable, intermediate, optLevel, messages); // Clean up the symbol table. The AST is self-sufficient now. delete symbolTableMemory; delete parseContext; delete [] lengths; delete [] strings; delete [] names; return success; } // Responsible for keeping track of the most recent source string and line in // the preprocessor and outputting newlines appropriately if the source string // or line changes. class SourceLineSynchronizer { public: SourceLineSynchronizer(const std::function<int()>& lastSourceIndex, std::stringstream* output) : getLastSourceIndex(lastSourceIndex), output(output), lastSource(-1), lastLine(0) {} // SourceLineSynchronizer(const SourceLineSynchronizer&) = delete; // SourceLineSynchronizer& operator=(const SourceLineSynchronizer&) = delete; // Sets the internally tracked source string index to that of the most // recently read token. If we switched to a new source string, returns // true and inserts a newline. Otherwise, returns false and outputs nothing. bool syncToMostRecentString() { if (getLastSourceIndex() != lastSource) { // After switching to a new source string, we need to reset lastLine // because line number resets every time a new source string is // used. We also need to output a newline to separate the output // from the previous source string (if there is one). if (lastSource != -1 || lastLine != 0) *output << std::endl; lastSource = getLastSourceIndex(); lastLine = -1; return true; } return false; } // Calls syncToMostRecentString() and then sets the internally tracked line // number to tokenLine. If we switched to a new line, returns true and inserts // newlines appropriately. Otherwise, returns false and outputs nothing. bool syncToLine(int tokenLine) { syncToMostRecentString(); const bool newLineStarted = lastLine < tokenLine; for (; lastLine < tokenLine; ++lastLine) { if (lastLine > 0) *output << std::endl; } return newLineStarted; } // Sets the internally tracked line number to newLineNum. void setLineNum(int newLineNum) { lastLine = newLineNum; } private: SourceLineSynchronizer& operator=(const SourceLineSynchronizer&); // A function for getting the index of the last valid source string we've // read tokens from. const std::function<int()> getLastSourceIndex; // output stream for newlines. std::stringstream* output; // lastSource is the source string index (starting from 0) of the last token // processed. It is tracked in order for newlines to be inserted when a new // source string starts. -1 means we haven't started processing any source // string. int lastSource; // lastLine is the line number (starting from 1) of the last token processed. // It is tracked in order for newlines to be inserted when a token appears // on a new line. 0 means we haven't started processing any line in the // current source string. int lastLine; }; // DoPreprocessing is a valid ProcessingContext template argument, // which only performs the preprocessing step of compilation. // It places the result in the "string" argument to its constructor. struct DoPreprocessing { explicit DoPreprocessing(std::string* string): outputString(string) {} bool operator()(TParseContextBase& parseContext, TPpContext& ppContext, TInputScanner& input, bool versionWillBeError, TSymbolTable&, TIntermediate&, EShOptimizationLevel, EShMessages) { // This is a list of tokens that do not require a space before or after. static const std::string unNeededSpaceTokens = ";()[]"; static const std::string noSpaceBeforeTokens = ","; glslang::TPpToken token; parseContext.setScanner(&input); ppContext.setInput(input, versionWillBeError); std::stringstream outputStream; SourceLineSynchronizer lineSync( std::bind(&TInputScanner::getLastValidSourceIndex, &input), &outputStream); parseContext.setExtensionCallback([&lineSync, &outputStream]( int line, const char* extension, const char* behavior) { lineSync.syncToLine(line); outputStream << "#extension " << extension << " : " << behavior; }); parseContext.setLineCallback([&lineSync, &outputStream, &parseContext]( int curLineNum, int newLineNum, bool hasSource, int sourceNum, const char* sourceName) { // SourceNum is the number of the source-string that is being parsed. lineSync.syncToLine(curLineNum); outputStream << "#line " << newLineNum; if (hasSource) { outputStream << " "; if (sourceName != nullptr) { outputStream << "\"" << sourceName << "\""; } else { outputStream << sourceNum; } } if (parseContext.lineDirectiveShouldSetNextLine()) { // newLineNum is the new line number for the line following the #line // directive. So the new line number for the current line is newLineNum -= 1; } outputStream << std::endl; // And we are at the next line of the #line directive now. lineSync.setLineNum(newLineNum + 1); }); parseContext.setVersionCallback( [&lineSync, &outputStream](int line, int version, const char* str) { lineSync.syncToLine(line); outputStream << "#version " << version; if (str) { outputStream << " " << str; } }); parseContext.setPragmaCallback([&lineSync, &outputStream]( int line, const glslang::TVector<glslang::TString>& ops) { lineSync.syncToLine(line); outputStream << "#pragma "; for(size_t i = 0; i < ops.size(); ++i) { outputStream << ops[i]; } }); parseContext.setErrorCallback([&lineSync, &outputStream]( int line, const char* errorMessage) { lineSync.syncToLine(line); outputStream << "#error " << errorMessage; }); int lastToken = EndOfInput; // lastToken records the last token processed. while (const char* tok = ppContext.tokenize(&token)) { bool isNewString = lineSync.syncToMostRecentString(); bool isNewLine = lineSync.syncToLine(token.loc.line); if (isNewLine) { // Don't emit whitespace onto empty lines. // Copy any whitespace characters at the start of a line // from the input to the output. outputStream << std::string(token.loc.column - 1, ' '); } // Output a space in between tokens, but not at the start of a line, // and also not around special tokens. This helps with readability // and consistency. if (!isNewString && !isNewLine && lastToken != EndOfInput && (unNeededSpaceTokens.find((char)token.token) == std::string::npos) && (unNeededSpaceTokens.find((char)lastToken) == std::string::npos) && (noSpaceBeforeTokens.find((char)token.token) == std::string::npos)) { outputStream << " "; } lastToken = token.token; outputStream << tok; } outputStream << std::endl; *outputString = outputStream.str(); bool success = true; if (parseContext.getNumErrors() > 0) { success = false; parseContext.infoSink.info.prefix(EPrefixError); parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n"; } return success; } std::string* outputString; }; // DoFullParse is a valid ProcessingConext template argument for fully // parsing the shader. It populates the "intermediate" with the AST. struct DoFullParse{ bool operator()(TParseContextBase& parseContext, TPpContext& ppContext, TInputScanner& fullInput, bool versionWillBeError, TSymbolTable& symbolTable, TIntermediate& intermediate, EShOptimizationLevel optLevel, EShMessages messages) { bool success = true; // Parse the full shader. if (! parseContext.parseShaderStrings(ppContext, fullInput, versionWillBeError)) success = false; intermediate.addSymbolLinkageNodes(parseContext.getLinkage(), parseContext.getLanguage(), symbolTable); if (success && intermediate.getTreeRoot()) { if (optLevel == EShOptNoGeneration) parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested."); else success = intermediate.postProcess(intermediate.getTreeRoot(), parseContext.getLanguage()); } else if (! success) { parseContext.infoSink.info.prefix(EPrefixError); parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n"; } if (messages & EShMsgAST) intermediate.output(parseContext.infoSink, true); return success; } }; // Take a single compilation unit, and run the preprocessor on it. // Return: True if there were no issues found in preprocessing, // False if during preprocessing any unknown version, pragmas or // extensions were found. bool PreprocessDeferred( TCompiler* compiler, const char* const shaderStrings[], const int numStrings, const int* inputLengths, const char* const stringNames[], const char* preamble, const EShOptimizationLevel optLevel, const TBuiltInResource* resources, int defaultVersion, // use 100 for ES environment, 110 for desktop EProfile defaultProfile, bool forceDefaultVersionAndProfile, bool forwardCompatible, // give errors for use of deprecated features EShMessages messages, // warnings/errors/AST; things to print out TShader::Includer& includer, TIntermediate& intermediate, // returned tree, etc. std::string* outputString) { DoPreprocessing parser(outputString); return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames, preamble, optLevel, resources, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, intermediate, parser, false, includer); } // // do a partial compile on the given strings for a single compilation unit // for a potential deferred link into a single stage (and deferred full compile of that // stage through machine-dependent compilation). // // all preprocessing, parsing, semantic checks, etc. for a single compilation unit // are done here. // // return: the tree and other information is filled into the intermediate argument, // and true is returned by the function for success. // bool CompileDeferred( TCompiler* compiler, const char* const shaderStrings[], const int numStrings, const int* inputLengths, const char* const stringNames[], const char* preamble, const EShOptimizationLevel optLevel, const TBuiltInResource* resources, int defaultVersion, // use 100 for ES environment, 110 for desktop EProfile defaultProfile, bool forceDefaultVersionAndProfile, bool forwardCompatible, // give errors for use of deprecated features EShMessages messages, // warnings/errors/AST; things to print out TIntermediate& intermediate,// returned tree, etc. TShader::Includer& includer) { DoFullParse parser; return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames, preamble, optLevel, resources, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, intermediate, parser, true, includer); } } // end anonymous namespace for local functions // // ShInitialize() should be called exactly once per process, not per thread. // int ShInitialize() { glslang::InitGlobalLock(); if (! InitProcess()) return 0; if (! PerProcessGPA) PerProcessGPA = new TPoolAllocator(); glslang::TScanContext::fillInKeywordMap(); return 1; } // // Driver calls these to create and destroy compiler/linker // objects. // ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions) { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions)); return reinterpret_cast<void*>(base); } ShHandle ShConstructLinker(const EShExecutable executable, int debugOptions) { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructLinker(executable, debugOptions)); return reinterpret_cast<void*>(base); } ShHandle ShConstructUniformMap() { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructUniformMap()); return reinterpret_cast<void*>(base); } void ShDestruct(ShHandle handle) { if (handle == 0) return; TShHandleBase* base = static_cast<TShHandleBase*>(handle); if (base->getAsCompiler()) DeleteCompiler(base->getAsCompiler()); else if (base->getAsLinker()) DeleteLinker(base->getAsLinker()); else if (base->getAsUniformMap()) DeleteUniformMap(base->getAsUniformMap()); } // // Cleanup symbol tables // int __fastcall ShFinalize() { for (int version = 0; version < VersionCount; ++version) { for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) { for (int p = 0; p < ProfileCount; ++p) { for (int source = 0; source < SourceCount; ++source) { for (int stage = 0; stage < EShLangCount; ++stage) { delete SharedSymbolTables[version][spvVersion][p][source][stage]; SharedSymbolTables[version][spvVersion][p][source][stage] = 0; } } } } } for (int version = 0; version < VersionCount; ++version) { for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) { for (int p = 0; p < ProfileCount; ++p) { for (int source = 0; source < SourceCount; ++source) { for (int pc = 0; pc < EPcCount; ++pc) { delete CommonSymbolTable[version][spvVersion][p][source][pc]; CommonSymbolTable[version][spvVersion][p][source][pc] = 0; } } } } } if (PerProcessGPA) { PerProcessGPA->popAll(); delete PerProcessGPA; PerProcessGPA = 0; } glslang::TScanContext::deleteKeywordMap(); return 1; } // // Do a full compile on the given strings for a single compilation unit // forming a complete stage. The result of the machine dependent compilation // is left in the provided compile object. // // Return: The return value is really boolean, indicating // success (1) or failure (0). // int ShCompile( const ShHandle handle, const char* const shaderStrings[], const int numStrings, const int* inputLengths, const EShOptimizationLevel optLevel, const TBuiltInResource* resources, int /*debugOptions*/, int defaultVersion, // use 100 for ES environment, 110 for desktop bool forwardCompatible, // give errors for use of deprecated features EShMessages messages // warnings/errors/AST; things to print out ) { // Map the generic handle to the C++ object if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; compiler->infoSink.info.erase(); compiler->infoSink.debug.erase(); TIntermediate intermediate(compiler->getLanguage()); TShader::ForbidInclude includer; bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr, "", optLevel, resources, defaultVersion, ENoProfile, false, forwardCompatible, messages, intermediate, includer); // // Call the machine dependent compiler // if (success && intermediate.getTreeRoot() && optLevel != EShOptNoGeneration) success = compiler->compile(intermediate.getTreeRoot(), intermediate.getVersion(), intermediate.getProfile()); intermediate.removeTree(); // Throw away all the temporary memory used by the compilation process. // The push was done in the CompileDeferred() call above. GetThreadPoolAllocator().pop(); return success ? 1 : 0; } // // Link the given compile objects. // // Return: The return value of is really boolean, indicating // success or failure. // int ShLinkExt( const ShHandle linkHandle, const ShHandle compHandles[], const int numHandles) { if (linkHandle == 0 || numHandles == 0) return 0; THandleList cObjects; for (int i = 0; i < numHandles; ++i) { if (compHandles[i] == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]); if (base->getAsLinker()) { cObjects.push_back(base->getAsLinker()); } if (base->getAsCompiler()) cObjects.push_back(base->getAsCompiler()); if (cObjects[i] == 0) return 0; } TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; linker->infoSink.info.erase(); for (int i = 0; i < numHandles; ++i) { if (cObjects[i]->getAsCompiler()) { if (! cObjects[i]->getAsCompiler()->linkable()) { linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code."); return 0; } } } bool ret = linker->link(cObjects); return ret ? 1 : 0; } // // ShSetEncrpytionMethod is a place-holder for specifying // how source code is encrypted. // void ShSetEncryptionMethod(ShHandle handle) { if (handle == 0) return; } // // Return any compiler/linker/uniformmap log of messages for the application. // const char* ShGetInfoLog(const ShHandle handle) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(handle); TInfoSink* infoSink; if (base->getAsCompiler()) infoSink = &(base->getAsCompiler()->getInfoSink()); else if (base->getAsLinker()) infoSink = &(base->getAsLinker()->getInfoSink()); else return 0; infoSink->info << infoSink->debug.c_str(); return infoSink->info.c_str(); } // // Return the resulting binary code from the link process. Structure // is machine dependent. // const void* ShGetExecutable(const ShHandle handle) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; return linker->getObjectCode(); } // // Let the linker know where the application said it's attributes are bound. // The linker does not use these values, they are remapped by the ICD or // hardware. It just needs them to know what's aliased. // // Return: The return value of is really boolean, indicating // success or failure. // int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* table) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; linker->setAppAttributeBindings(table); return 1; } // // Let the linker know where the predefined attributes have to live. // int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; linker->setFixedAttributeBindings(table); return 1; } // // Some attribute locations are off-limits to the linker... // int ShExcludeAttributes(const ShHandle handle, int *attributes, int count) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; linker->setExcludedAttributes(attributes, count); return 1; } // // Return the index for OpenGL to use for knowing where a uniform lives. // // Return: The return value of is really boolean, indicating // success or failure. // int ShGetUniformLocation(const ShHandle handle, const char* name) { if (!InitThread()) return 0; if (handle == 0) return -1; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TUniformMap* uniformMap= base->getAsUniformMap(); if (uniformMap == 0) return -1; return uniformMap->getLocation(name); } //////////////////////////////////////////////////////////////////////////////////////////// // // Deferred-Lowering C++ Interface // ----------------------------------- // // Below is a new alternate C++ interface that might potentially replace the above // opaque handle-based interface. // // See more detailed comment in ShaderLang.h // namespace glslang { #include "../Include/revision.h" const char* GetEsslVersionString() { return "OpenGL ES GLSL 3.00 glslang LunarG Khronos." GLSLANG_REVISION " " GLSLANG_DATE; } const char* GetGlslVersionString() { return "4.20 glslang LunarG Khronos." GLSLANG_REVISION " " GLSLANG_DATE; } int GetKhronosToolId() { return 8; } bool InitializeProcess() { return ShInitialize() != 0; } void FinalizeProcess() { ShFinalize(); } class TDeferredCompiler : public TCompiler { public: TDeferredCompiler(EShLanguage s, TInfoSink& i) : TCompiler(s, i) { } virtual bool compile(TIntermNode*, int = 0, EProfile = ENoProfile) { return true; } }; TShader::TShader(EShLanguage s) : pool(0), stage(s), lengths(nullptr), stringNames(nullptr), preamble("") { infoSink = new TInfoSink; compiler = new TDeferredCompiler(stage, *infoSink); intermediate = new TIntermediate(s); } TShader::~TShader() { delete infoSink; delete compiler; delete intermediate; delete pool; } void TShader::setStrings(const char* const* s, int n) { strings = s; numStrings = n; lengths = nullptr; } void TShader::setStringsWithLengths(const char* const* s, const int* l, int n) { strings = s; numStrings = n; lengths = l; } void TShader::setStringsWithLengthsAndNames( const char* const* s, const int* l, const char* const* names, int n) { strings = s; numStrings = n; lengths = l; stringNames = names; } void TShader::setEntryPoint(const char* entryPoint) { intermediate->setEntryPointName(entryPoint); } void TShader::setShiftSamplerBinding(unsigned int base) { intermediate->setShiftSamplerBinding(base); } void TShader::setShiftTextureBinding(unsigned int base) { intermediate->setShiftTextureBinding(base); } void TShader::setShiftUboBinding(unsigned int base) { intermediate->setShiftUboBinding(base); } void TShader::setAutoMapBindings(bool map) { intermediate->setAutoMapBindings(map); } void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlattenUniformArrays(flatten); } // // Turn the shader strings into a parse tree in the TIntermediate. // // Returns true for success. // bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, bool forwardCompatible, EShMessages messages, Includer& includer) { if (! InitThread()) return false; pool = new TPoolAllocator(); SetThreadPoolAllocator(*pool); if (! preamble) preamble = ""; return CompileDeferred(compiler, strings, numStrings, lengths, stringNames, preamble, EShOptNone, builtInResources, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, *intermediate, includer); } bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages) { return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages); } // Fill in a string with the result of preprocessing ShaderStrings // Returns true if all extensions, pragmas and version strings were valid. bool TShader::preprocess(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, bool forwardCompatible, EShMessages message, std::string* output_string, Includer& includer) { if (! InitThread()) return false; pool = new TPoolAllocator(); SetThreadPoolAllocator(*pool); if (! preamble) preamble = ""; return PreprocessDeferred(compiler, strings, numStrings, lengths, stringNames, preamble, EShOptNone, builtInResources, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, message, includer, *intermediate, output_string); } const char* TShader::getInfoLog() { return infoSink->info.c_str(); } const char* TShader::getInfoDebugLog() { return infoSink->debug.c_str(); } TProgram::TProgram() : pool(0), reflection(0), ioMapper(nullptr), linked(false) { infoSink = new TInfoSink; for (int s = 0; s < EShLangCount; ++s) { intermediate[s] = 0; newedIntermediate[s] = false; } } TProgram::~TProgram() { delete infoSink; delete reflection; for (int s = 0; s < EShLangCount; ++s) if (newedIntermediate[s]) delete intermediate[s]; delete pool; } // // Merge the compilation units within each stage into a single TIntermediate. // All starting compilation units need to be the result of calling TShader::parse(). // // Return true for success. // bool TProgram::link(EShMessages messages) { if (linked) return false; linked = true; bool error = false; pool = new TPoolAllocator(); SetThreadPoolAllocator(*pool); for (int s = 0; s < EShLangCount; ++s) { if (! linkStage((EShLanguage)s, messages)) error = true; } // TODO: Link: cross-stage error checking return ! error; } // // Merge the compilation units within the given stage into a single TIntermediate. // // Return true for success. // bool TProgram::linkStage(EShLanguage stage, EShMessages messages) { if (stages[stage].size() == 0) return true; int numEsShaders = 0, numNonEsShaders = 0; for (auto it = stages[stage].begin(); it != stages[stage].end(); ++it) { if ((*it)->intermediate->getProfile() == EEsProfile) { numEsShaders++; } else { numNonEsShaders++; } } if (numEsShaders > 0 && numNonEsShaders > 0) { infoSink->info.message(EPrefixError, "Cannot mix ES profile with non-ES profile shaders"); return false; } else if (numEsShaders > 1) { infoSink->info.message(EPrefixError, "Cannot attach multiple ES shaders of the same type to a single program"); return false; } // // Be efficient for the common single compilation unit per stage case, // reusing it's TIntermediate instead of merging into a new one. // TIntermediate *firstIntermediate = stages[stage].front()->intermediate; if (stages[stage].size() == 1) intermediate[stage] = firstIntermediate; else { intermediate[stage] = new TIntermediate(stage, firstIntermediate->getVersion(), firstIntermediate->getProfile()); newedIntermediate[stage] = true; } infoSink->info << "\nLinked " << StageName(stage) << " stage:\n\n"; if (stages[stage].size() > 1) { std::list<TShader*>::const_iterator it; for (it = stages[stage].begin(); it != stages[stage].end(); ++it) intermediate[stage]->merge(*infoSink, *(*it)->intermediate); } intermediate[stage]->finalCheck(*infoSink); if (messages & EShMsgAST) intermediate[stage]->output(*infoSink, true); return intermediate[stage]->getNumErrors() == 0; } const char* TProgram::getInfoLog() { return infoSink->info.c_str(); } const char* TProgram::getInfoDebugLog() { return infoSink->debug.c_str(); } // // Reflection implementation. // bool TProgram::buildReflection() { if (! linked || reflection) return false; reflection = new TReflection; for (int s = 0; s < EShLangCount; ++s) { if (intermediate[s]) { if (! reflection->addStage((EShLanguage)s, *intermediate[s])) return false; } } return true; } int TProgram::getNumLiveUniformVariables() { return reflection->getNumUniforms(); } int TProgram::getNumLiveUniformBlocks() { return reflection->getNumUniformBlocks(); } const char* TProgram::getUniformName(int index) { return reflection->getUniform(index).name.c_str(); } const char* TProgram::getUniformBlockName(int index) { return reflection->getUniformBlock(index).name.c_str(); } int TProgram::getUniformBlockSize(int index) { return reflection->getUniformBlock(index).size; } int TProgram::getUniformIndex(const char* name) { return reflection->getIndex(name); } int TProgram::getUniformBlockIndex(int index) { return reflection->getUniform(index).index; } int TProgram::getUniformType(int index) { return reflection->getUniform(index).glDefineType; } int TProgram::getUniformBufferOffset(int index) { return reflection->getUniform(index).offset; } int TProgram::getUniformArraySize(int index) { return reflection->getUniform(index).size; } int TProgram::getNumLiveAttributes() { return reflection->getNumAttributes(); } const char* TProgram::getAttributeName(int index) { return reflection->getAttribute(index).name.c_str(); } int TProgram::getAttributeType(int index) { return reflection->getAttribute(index).glDefineType; } void TProgram::dumpReflection() { reflection->dump(); } // // I/O mapping implementation. // bool TProgram::mapIO() { if (! linked || ioMapper) return false; ioMapper = new TIoMapper; for (int s = 0; s < EShLangCount; ++s) { if (intermediate[s]) { if (! ioMapper->addStage((EShLanguage)s, *intermediate[s])) return false; } } return true; } } // end namespace glslang
; A184004: a(n) = n + floor(sqrt(4n/3)); complement of A184005. ; 2,3,5,6,7,8,10,11,12,13,14,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,102,103,104,105,106,107,108,109,110,111 mov $5,$0 mul $0,2 add $0,1 mul $0,2 mov $2,3 mov $3,1 lpb $0 add $0,1 add $3,3 sub $0,$3 sub $0,1 add $2,4 add $3,1 trn $0,$3 mov $4,$3 sub $3,1 lpe mov $1,$2 sub $1,$4 lpb $5 add $1,1 sub $5,1 lpe mov $0,$1
;****************************************************************************** .define dir_reg, 0x00 .define port_reg, 0x01 .define pin_reg, 0x02 .define prescaler_l, 0x03 .define prescaler_h, 0x04 .define count_ctrl, 0x05 .define gpu_addr, 0x2000 .define gpu_ctrl_reg, 0x80 .define top_isr_vec_reg_l, 0x0f .define top_isr_vec_reg_h, 0x10 ;****************************************************************************** .code ldi r14, 0xff ; set stack pointer ldi r0, isr[l] ; setup the top isr vector out r0, top_isr_vec_reg_l ldi r0, isr[h] out r0, top_isr_vec_reg_h ldi r0, 0b00011000 out r0, gpu_ctrl_reg ldi r2, gpu_addr[l] ldi r3, gpu_addr[h] ldi r0, 0xff out r0, dir_reg ; set all pins to output ldi r0, 36 out r0, prescaler_l ; set LSBs of prescaler ldi r0, 244 out r0, prescaler_h ; set MSPs of prescaler ldi r0, 0b00010010 out r0, count_ctrl ; set pwm mode, set top interrupt ldi r5, 0 ssr 8 ; enable interrupts loop: br loop ; loop and wait for interrupt ;****************************************************************************** numToStr: mov r13, r12 srl r13 srl r13 srl r13 srl r13 cpi r13, 0x09 bc alpha1 adi r13, 48 br print1 alpha1: adi r13, 55 print1: sri r13, p2 ani r12, 0x0f cpi r12, 0x09 bc alpha2 adi r12, 48 br print2 alpha2: adi r12, 55 print2: sri r12, p2 ret ;****************************************************************************** isr: out r5, port_reg mov r12, r5 call numToStr ldi r2, gpu_addr[l] ldi r3, gpu_addr[h] adi r5, 1 exit: ssr 8 ; enable interrupts ret ;******************************************************************************
#cal_set={add,sub,or,and,sll,sllv,srl,srlv} #Timer 0x7f00-0x7f0b #UART 0x7f10-0x7f2b #Switch 0x7f2c-0x7f33 #LED 0x7f34-0x7f37 #Tube 0x7f38-0x7f3f #Key 0x7f40-0x7f43 .text initial: li $t0,0xfc01 #allow all IRQ mtc0 $t0,$12 li $t0,0xffffffff #set timer continuously count mode sw $t0,0x7f00($0) li $t0,10000000 #set count-down time for timer sw $t0,0x7f04($0) wait_key: j wait_key nop .ktext 0x4180 lw $k1,0x7f2c($0) #use $k1 as new val to count down lw $t2,0x7f38($0) #use $t2 as tube's current val li $s1,2 slt $s2,$k1,$s1 beq $k1,0,reset nop beq $s2,1,one_second #if new_val<2 count down for 1s nop beq $s2,0,two_second #if new_val>=2 count down for 2s nop j return nop one_second: li $k0,10000000 #set count-down time for timer sw $k0,0x7f04($0) j continue nop two_second: li $k0,20000000 #set count-down time for timer sw $k0,0x7f04($0) j continue nop continue: beq $t2,9,reset nop addi $t2,$t2,1 sw $t2,0x7f38($0) j return nop reset: sw $0,0x7f38($0) return: eret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %rax push %rcx push %rdi push %rsi lea addresses_A_ht+0x9341, %rdi nop nop nop sub %rax, %rax movb (%rdi), %r10b nop nop nop nop nop dec %rdi lea addresses_A_ht+0x7d3, %rsi lea addresses_A_ht+0x83, %rdi nop nop nop xor $65313, %r11 mov $105, %rcx rep movsw nop nop add %rcx, %rcx lea addresses_normal_ht+0x1d383, %r11 nop nop nop and %rdi, %rdi mov (%r11), %esi nop dec %rdi lea addresses_A_ht+0xd283, %rsi lea addresses_A_ht+0x11253, %rdi nop nop nop nop nop dec %r10 mov $121, %rcx rep movsl nop nop nop nop nop xor %r11, %r11 pop %rsi pop %rdi pop %rcx pop %rax pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r8 push %rax push %rsi // Faulty Load mov $0x351a460000000c03, %rsi nop nop nop nop sub %r8, %r8 mov (%rsi), %r11d lea oracles, %r8 and $0xff, %r11 shlq $12, %r11 mov (%r8,%r11,1), %r11 pop %rsi pop %rax pop %r8 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_NC', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_NC', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}} {'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}} {'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 */
; A008789: a(n) = n^(n+3). ; 0,1,32,729,16384,390625,10077696,282475249,8589934592,282429536481,10000000000000,379749833583241,15407021574586368,665416609183179841,30491346729331195904,1477891880035400390625,75557863725914323419136,4064231406647572522401601,229468251895129407139872768,13569980418174090907801371961,838860800000000000000000000000,54108198377272584130510593262881,3635524038174209847159494312722432,254052654154149545721997685422868689,18437563379178327736384102280592359424 mov $1,$0 add $1,3 pow $0,$1
; English texts for Help Menu  1988 Tony Tebby QJUMP section language include 'dev8_mac_text' mktits hlpt,{Help on} mktext nhlp,{Help file is not available} ;64 mkxstr agen,'A',{Again} ; 6 mkxstr page,'P',{Page} ; 6 mkxstr line,'L',{Line} ; 6 end
/* * Copyright (C) 2020 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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 APPLE INC. ``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 APPLE INC. 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 "config.h" #include "DFGCodeOriginPool.h" #if ENABLE(DFG_JIT) namespace JSC { namespace DFG { CallSiteIndex CodeOriginPool::addCodeOrigin(CodeOrigin codeOrigin) { if (m_codeOrigins.isEmpty() || m_codeOrigins.last() != codeOrigin) m_codeOrigins.append(codeOrigin); unsigned index = m_codeOrigins.size() - 1; ASSERT(m_codeOrigins[index] == codeOrigin); return CallSiteIndex(index); } CallSiteIndex CodeOriginPool::addUniqueCallSiteIndex(CodeOrigin codeOrigin) { m_codeOrigins.append(codeOrigin); unsigned index = m_codeOrigins.size() - 1; ASSERT(m_codeOrigins[index] == codeOrigin); return CallSiteIndex(index); } CallSiteIndex CodeOriginPool::lastCallSite() const { RELEASE_ASSERT(m_codeOrigins.size()); return CallSiteIndex(m_codeOrigins.size() - 1); } DisposableCallSiteIndex CodeOriginPool::addDisposableCallSiteIndex(CodeOrigin codeOrigin) { if (!m_callSiteIndexFreeList.isEmpty()) { unsigned index = m_callSiteIndexFreeList.takeLast(); m_codeOrigins[index] = codeOrigin; return DisposableCallSiteIndex(index); } m_codeOrigins.append(codeOrigin); unsigned index = m_codeOrigins.size() - 1; ASSERT(m_codeOrigins[index] == codeOrigin); return DisposableCallSiteIndex(index); } void CodeOriginPool::removeDisposableCallSiteIndex(DisposableCallSiteIndex callSite) { RELEASE_ASSERT(callSite.bits() < m_codeOrigins.size()); m_callSiteIndexFreeList.append(callSite.bits()); m_codeOrigins[callSite.bits()] = CodeOrigin(); } void CodeOriginPool::shrinkToFit() { m_codeOrigins.shrinkToFit(); m_callSiteIndexFreeList.shrinkToFit(); } } } // namespace JSC::DFG #endif // ENABLE(DFG_JIT)
; A259042: Period 8 sequence [0, 1, 1, 1, 2, 1, 1, 1, ...]. ; 0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1,1,1,2,1,1,1,0,1 gcd $0,1073741824 mov $1,2 mov $2,$0 trn $2,3 bin $1,$2
; GOLD Card RTC operations section sms xdef sms_artc xdef sms_rrtc xdef sms_srtc xdef rtc_init xdef rtc.ptype xdef rtc.card rtc.ptype equ $00 rtc.card equ 'GC ' include 'dev8_smsq_gold_keys' include 'dev8_keys_err' include 'dev8_keys_sys' include 'dev8_mac_assert' include 'dev8_smsq_smsq_base_keys' rtc_init rts ;+++ ; Read date taking the Year Month Day Hour Minute and Second from the RTC ; ; d1 r date ; status return 0 or err.nc ;--- sms_rrtc move.l sms.rte,-(sp) gl_rdate tst.b sys_prtc(a6) ; protected date? beq.s grd_do ; ... no grd_ql move.l ql_clock,d0 ; date move.l ql_clock,d1 ; and again sub.l d1,d0 ; ... the same? bne.s grd_ql rts ;-------- grd_60 mulu #60,d3 grd_10 moveq #5,d5 grd_10l subq.w #1,d5 blt.s grd_10p move.w #$f0,d0 move.w d0,d4 and.w (a1),d4 ; get 10s and.w (a1),d0 cmp.w d0,d4 ; stable data? bne.s grd_10l ; ... no lsr.b #4,d0 cmp.b #9,d0 bge.s grd_10l grd_10p subq.l #glk.rtca,a1 add.w d0,d0 move.w d0,d2 lsl.w #2,d2 add.w d0,d2 ; *10 grd_unit moveq #0,d0 ; ... patch grd_ul subq.w #1,d5 blt.s grd_up move.w #$f0,d0 move.w d0,d4 and.w (a1),d4 ; get units and.w (a1),d0 cmp.w d0,d4 ; stable data? bne.s grd_ul ; ... no lsr.b #4,d0 cmp.b #9,d0 bge.s grd_ul grd_up subq.l #glk.rtca,a1 add.w d2,d0 ; add 10s rts grd_mtab dc.w 0 dc.w 31 dc.w 31+28 dc.w 31+28+31 dc.w 31+28+31+30 dc.w 31+28+31+30+31 dc.w 31+28+31+30+31+30 dc.w 31+28+31+30+31+30+31 dc.w 31+28+31+30+31+30+31+31 dc.w 31+28+31+30+31+30+31+31+30 dc.w 31+28+31+30+31+30+31+31+30+31 dc.w 31+28+31+30+31+30+31+31+30+31+30 grd_mtbe ; Read RTC grd_do grd.reg reg d2/d3/d4/d5/d6/d7/a1 movem.l grd.reg,-(sp) moveq #10,d6 ; try lots of times grd_loop lea glc_base,a1 move.w glo_rtcs(a1),d7 swap d7 ; am / pm lea glo_s10(a1),a1 bsr.s grd_10 move.w d0,d7 ; keep seconds lea glo_y10-glo_s10+glk.rtca*2(a1),a1 bsr.s grd_10 ; get year move.w d0,d1 mulu #365,d1 ; year to days divu #4,d0 add.w d0,d1 ; + leap years swap d0 move.w d0,d3 ; keep remainder bsr.l grd_10 ; month (1-12??) subq.w #3,d3 ; is it a leap year? bne.s grd_smonth ; ... no cmp.w #2,d0 ; beyond February? ble.s grd_smonth ; ... no addq.w #1,d1 ; yes, add a day grd_smonth add.w d0,d0 add.w grd_mtab-2(pc,d0.w),d1 ; add first day of month table bsr.l grd_10 subq.w #1,d0 ; day is 1 to 31 add.w d0,d1 ; ... this is now the complete day mulu #12*60*60,d1 ; 2 seconds add.l d1,d1 ; seconds bsr.l grd_10 ; hours btst #glk..24h+16,d7 ; 24 hour? bne.s grd_min ; ... yes divu #12,d0 ; time is mod 12 swap d0 btst #glk..pm+16,d7 ; but is is PM? beq.s grd_min ; ... no add.w #12,d0 ; ... yes grd_min move.w d0,d3 bsr.l grd_60 ; hours+minutes add.w d0,d3 bsr.l grd_60 ; +seconds add.l d0,d3 add.l d3,d1 ; complete date sub.w d7,d0 ; time changed? dbeq d6,grd_loop moveq #0,d0 ; ... too many times grd_exit movem.l (sp)+,grd.reg rts ;+++ ; Adjust the RTC date by D1 seconds ; ; d1 cr adjustment / date ; status return 0 ;--- sms_artc gl_adate move.l d1,-(sp) ; save adjustment bsr.l gl_rdate add.l (sp)+,d1 ; adjusted date ;+++ ; Set date taking putting Year Month Day Hour Minute and Second into the RTC ; ; d1 cp date ; status return 0 or err.nc ;--- sms_srtc move.l sms.rte,-(sp) gl_sdate gsd.reg reg d1/d2/d3/d4/d5/d6/d7/a0/a1/a2 stk_d1 equ $00 movem.l gsd.reg,-(sp) lea ql_clock,a1 clr.b (a1)+ ; clear the clock moveq #$ffffffdf,d3 ; set one byte at a time moveq #3,d2 ; four altogether gsd_sqlb asr.w #1,d3 ; next byte moveq #0,d0 rol.l #8,d1 move.b d1,d0 ; msbyte bra.s gsd_sqel gsd_sqlp move.b d3,(a1) ; clock register gsd_sqel dbra d0,gsd_sqlp dbra d2,gsd_sqlb moveq #0,d0 tst.b sys_prtc(a6) ; protect the clock? bne.l gsd_exit moveq #10,d6 ; try several times gsd_rtry lea glc_base,a2 move.b #glk.rtcs,glo_rtcc(a2) ; stop the clock lea glo_s01(a2),a1 move.l stk_d1(sp),d1 ; restore time moveq #0,d0 ; seconds lsr.l #1,d1 ; prevent overflow on divide roxr.w #1,d0 ; seconds bit in msb d0.w divu #24*60*30,d1 ; split into days / 2 seconds moveq #0,d3 move.w d1,d3 move.w d0,d1 rol.l #1,d1 ; seconds in upper d1 (ovf in lsb) moveq #6,d2 bsr.l gsd_divp ; divide upper d1 by 10 and d2 and put bsr.l gsd_divp ; twice clr.w d1 swap d1 ; hours are the remainder divu #12,d1 move.w d1,d7 ; 0/1 in d7 is am/pm clr.w d1 swap d1 ; if remainder is 0 bne.s gsd_hours moveq #12,d1 ; it's 12 o'clock gsd_hours bsr.s gsd_putd divu #365*4+1,d3 ; four year cycle move.l d3,d1 ; swap d1 ; four year day lsl.w #2,d3 ; years cmp.w #365*3+31+28,d1 ; is it Feb 29? blt.s gsd_day bgt.s gsd_day1 addq.w #3,d3 ; leap year moveq #2,d2 ; leap month moveq #29,d1 ; leap day bra.s gsd_pday gsd_day1 subq.w #1,d1 ; after Feb 29 adjust by one day gsd_day ext.l d1 divu #365,d1 ; days add.w d1,d3 ; real years clr.w d1 swap d1 ; day of year moveq #13,d2 ; month lea grd_mtbe,a0 gsd_mloop subq.w #1,d2 cmp.w -(a0),d1 blt.s gsd_mloop sub.w (a0),d1 ; day of month addq.w #1,d1 ; 1..31 gsd_pday bsr.s gsd_putd move.w d2,d1 ; month bsr.s gsd_putd move.w d3,d1 ; year bsr.s gsd_putd moveq #0,d1 lea glo_rtcs(a2),a1 bsr.s gsd_put addq.b #1,d3 ; leap year counter (1961 base) assert glk..pm+1,glk.lpsf add.b d3,d3 add.b d7,d3 lsl.b #glk..pm,d3 move.b d3,d1 lea glo_rtcs(a2),a1 bsr.s gsd_pnib move.b #glk.rtcg,glo_rtcc(a2) ; clock go jsr grd_do ; date correct? move.l d1,d0 move.l stk_d1(sp),d1 sub.l d1,d0 dbeq d6,gsd_rtry gsd_exit moveq #0,d0 movem.l (sp)+,gsd.reg rts ; put two decimal digits (d1) gsd_putd divu #10,d1 bsr.s gsd_putm bra.s gsd_putm ; divide d1 by d2 and put two decimal digits gsd_divp swap d1 divu #10,d1 bsr.s gsd_putm ; next nibble is 0-9 swap d1 divu d2,d1 ; get 10s gsd_putm swap d1 gsd_put lsl.b #4,d1 gsd_pnib moveq #8,d5 gsd_putl move.b d1,(a1) ;;; these were word operations not.b d1 move.b d1,glo_ten(a2) not.b d1 swap d4 moveq #$fffffff0,d4 and.w (a1),d4 cmp.b d4,d1 beq.s gsd_putx dbra d5,gsd_putl move.b #1,sys_prtc(a6) ; set protected (no RTC) gsd_putx addq.l #glk.rtca,a1 clr.w d1 ; we've used this bit rts end
; A049390: Expansion of (1-25*x)^(4/5). ; Submitted by Jon Maiga ; 1,-20,-50,-500,-6875,-110000,-1925000,-35750000,-692656250,-13853125000,-283989062500,-5937953125000,-126181503906250,-2717755468750000,-59208244140625000,-1302581371093750000 mul $0,2 mov $1,1 mov $2,4 mov $3,$0 mov $4,5 lpb $3 mul $1,$2 mul $1,$4 sub $3,2 mov $4,$2 sub $5,1 div $1,$5 sub $2,5 sub $4,$2 lpe mov $0,$1
// // Created by alexweiss on 7/3/19. // #include "testBase.hpp" #include <cmath> #include "../lib/utility/Units.hpp" #include <stdio.h> #include "../lib/geometry/Translation2d.hpp" namespace test { void assertEquals(double val, double compare, double eps) { if(std::fabs(val - compare) > eps) { // BAD printf("FAILURE\n"); } else { printf("PASS\n"); } } void assertTrue(bool val) { if(!val) { // BAD printf("FAILURE\n"); } else { printf("PASS\n"); } } void assertFalse(bool val) { if(val) { // BAD printf("FAILURE\n"); } else { printf("PASS\n"); } } }
/* * Utilities for I2C Master Module * * org: 6/22/2014 * auth: Nels "Chip" Pearson * * Usage: * .include utilities.asm * */ /* * Generate CKSUM * * CKSUM = (CKSUM ^ Data) ROL 1 * * input: X(r27:26) reg -> Data buffer * R18: Number of bytes * * output: R17: CKSUM * * Registers: All saved and restored * */ util_gen_cksum: push R16 push R17 push R18 push XL push XH ; clr R17 ugc_loop00: ld R16, X+ eor R17, R16 lsl R17 brcc ugc_skip00 ori R17, 0x01 ; bring in CY bit ; ugc_skip00: dec R18 brne ugc_loop00 ; done? ; yes pop XH pop XL pop R18 pop R17 pop R16 ; ret
extern printf extern scanf section .data format db "%d",0 napis db "Podaj liczbe: ",0 liczba dd 0 wynik dd 0 parz db "Podana liczba jest parzysta.",10,0 nparz db "Podana liczba jest nieparzysta.",10,0 section .text global main main: xor rax, rax mov rdi, napis call printf xor rax, rax mov rdi, format mov rsi, liczba call scanf mov edx, 0 mov eax, dword [liczba] mov ecx, 2 div ecx cmp edx, 1 je _nparz cmp edx, 0 je _parz _parz: xor rax, rax mov rdi, parz call printf jmp _koniec _nparz: xor rax, rax mov rdi, nparz call printf _koniec: mov rax, 1 mov rbx, 0 int 80h
; A004334: Binomial coefficient C(4n,n-4). ; 1,20,276,3276,35960,376992,3838380,38320568,377348994,3679075400,35607051480,342700125300,3284214703056,31368725759168,298824321028320,2840671544105280,26958221130508525,255485622301674660,2418561960739869780,22874501983241808900,216182590635135019896,2041841411062132125600,19275363554408880147320,181886780350687116846960,1715732991205642874801700,16179865592117872482804624,152545362254235362167040880,1437939683881863050948448004,13552381436214961593354574880,127713597307826514169251580800 mov $1,4 mul $1,$0 add $1,16 bin $1,$0 mov $0,$1
.MACRO LKS_LOAD_CG SNES_CGADD \1 SNES_DMA0 $00 SNES_DMA0_BADD $22 lda #:\2 ldx #\2 ldy #\3 stx DMA_ADDL sta DMA_BANK sty DMA_SIZEL SNES_MDMAEN $01 .ENDM .MACRO LKS_LOAD_VRAM SNES_DMA0 $01 SNES_DMA0_BADD $18 SNES_VMADD \1 lda #:\3 ldx #\3+\2 ldy #\4 stx DMA_ADDL sta DMA_BANK sty DMA_SIZEL SNES_MDMAEN $01 .ENDM .MACRO LKS_LOAD_WRAM SNES_DMA0 $00 SNES_DMA0_BADD $80 SNES_WMADD \1,0 lda #:\2 ldx #\2 ldy #\3 stx DMA_ADDL sta DMA_BANK sty DMA_SIZEL SNES_MDMAEN $01 .ENDM
UnknownText_0x1c0000:: text "Oh, no picture?" line "Come again, OK?" done UnknownText_0x1c0021:: text "An EGG? My talent" line "is worth more…" done UnknownText_0x1c0043:: text "Hello, hello! I'm" line "the NAME RATER." para "I rate the names" line "of #MON." para "Would you like me" line "to rate names?" done UnknownText_0x1c00a0:: text "Which #MON's" line "nickname should I" cont "rate for you?" prompt UnknownText_0x1c00cd:: text "Hm… @" text_ram wStringBuffer1 text "…" line "That's a fairly" cont "decent name." para "But, how about a" line "slightly better" cont "nickname?" para "Want me to give it" line "a better name?" done UnknownText_0x1c0142:: text "All right. What" line "name should we" cont "give it, then?" prompt UnknownText_0x1c0171:: text "That's a better" line "name than before!" para "Well done!" done UnknownText_0x1c019e:: text "OK, then. Come" line "again sometime." done UnknownText_0x1c01be:: text "Hm… @" text_ram wStringBuffer1 text "?" line "What a great name!" cont "It's perfect." para "Treat @" text_ram wStringBuffer1 text_start line "with loving care." done UnknownText_0x1c0208:: text "Whoa… That's just" line "an EGG." done UnknownText_0x1c0222:: text "It might look the" line "same as before," para "but this new name" line "is much better!" para "Well done!" done UnknownText_0x1c0272:: text "All right. This" line "#MON is now" cont "named @" text_ram wStringBuffer1 text "." prompt Text_Gained:: text_ram wStringBuffer1 text " gained@" text_end Text_ABoostedStringBuffer2ExpPoints:: text_start line "a boosted" cont "@" text_decimal wStringBuffer2, 2, 4 text " EXP. Points!" prompt Text_StringBuffer2ExpPoints:: text_start line "@" text_decimal wStringBuffer2, 2, 4 text " EXP. Points!" prompt Text_GoMon:: text "Go! @" text_end Text_DoItMon:: text "Do it! @" text_end Text_GoForItMon:: text "Go for it," line "@" text_end Text_YourFoesWeakGetmMon:: text "Your foe's weak!" line "Get'm, @" text_end Text_BattleMonNick01:: text_ram wBattleMonNick text "!" done Text_BattleMonNickComma:: text_ram wBattleMonNick text ",@" text_end Text_ThatsEnoughComeBack:: text " that's" line "enough! Come back!@" text_end Text_OKComeBack:: text " OK!" line "Come back!@" text_end Text_GoodComeBack:: text " good!" line "Come back!@" text_end Text_ComeBack:: text " come" line "back!" done UnknownText_0x1c0373:: text "Booted up a TM." prompt UnknownText_0x1c0384:: text "Booted up an HM." prompt UnknownText_0x1c0396:: text "It contained" line "@" text_ram wStringBuffer2 text "." para "Teach @" text_ram wStringBuffer2 text_start line "to a #MON?" done UnknownText_0x1c03c2:: text_ram wStringBuffer2 text " is" line "not compatible" cont "with @" text_ram wStringBuffer1 text "." para "It can't learn" line "@" text_ram wStringBuffer2 text "." prompt UnknownText_0x1c03fa:: text "You have no room" line "for any more" cont "@" text_ram wStringBuffer1 text "S." prompt UnknownText_0x1c0421:: text "You received" line "@" text_ram wStringBuffer1 text "!" prompt UnknownText_0x1c0436:: text "The link has been" line "cancelled." prompt UnknownText_0x1c0454:: text "Communication" line "error." prompt UnknownText_0x1c046a:: text "Must retrieve GIFT" line "at #MON CENTER." prompt UnknownText_0x1c048e:: text "Your friend isn't" line "ready." prompt UnknownText_0x1c04a7:: text "Sorry--only five" line "GIFTS a day." prompt UnknownText_0x1c04c6:: text "Sorry. One GIFT" line "a day per person." prompt UnknownText_0x1c04e9:: text_ram wMysteryGiftPartnerName text " sent" line "@" text_ram wStringBuffer1 text "." prompt UnknownText_0x1c04fa:: text_ram wMysteryGiftPartnerName text " sent" line "@" text_ram wStringBuffer1 text_start cont "to @" text_ram wMysteryGiftPlayerName text "'s home." prompt UnknownText_0x1c051a:: text "Received" line "@" text_ram wc850 text "'s CARD." prompt UnknownText_0x1c0531:: text_ram wc850 text "'s CARD was" line "listed as no.@" text_decimal wDeciramBuffer, 1, 2 text "." prompt UnknownText_0x1c0555:: text "The CARD was not" line "registered." prompt UnknownText_0x1c0573:: text "The link has been" line "cancelled." prompt UnknownText_0x1c0591:: text "Communication" line "error." prompt _BadgeRequiredText:: text "Sorry! A new BADGE" line "is required." prompt UnknownText_0x1c05c8:: text "Can't use that" line "here." prompt UnknownText_0x1c05dd:: text_ram wStringBuffer2 text " used" line "CUT!" prompt UnknownText_0x1c05ec:: text "There's nothing to" line "CUT here." prompt UnknownText_0x1c0609:: text "A blinding FLASH" line "lights the area!@" text_waitbutton text_end text_end ; unused _UsedSurfText:: text_ram wStringBuffer2 text " used" line "SURF!" done _CantSurfText:: text "You can't SURF" line "here." prompt _AlreadySurfingText:: text "You're already" line "SURFING." prompt _AskSurfText:: text "The water is calm." line "Want to SURF?" done UnknownText_0x1c068e:: text_ram wStringBuffer2 text " used" line "WATERFALL!" done UnknownText_0x1c06a3:: text "Wow, it's a huge" line "waterfall." done UnknownText_0x1c06bf:: text "Do you want to use" line "WATERFALL?" done UnknownText_0x1c06de:: text_ram wStringBuffer2 text " used" line "DIG!" done UnknownText_0x1c06ed:: text "<PLAYER> used an" line "ESCAPE ROPE." done UnknownText_0x1c0705:: text "Can't use that" line "here." done UnknownText_0x1c071a:: text "Return to the last" line "#MON CENTER." done UnknownText_0x1c073b:: text "Can't use that" line "here." para "" done UnknownText_0x1c0751:: text "A #MON is using" line "STRENGTH already." prompt UnknownText_0x1c0774:: text_ram wStringBuffer2 text " used" line "STRENGTH!" done UnknownText_0x1c0788:: text_ram wStringBuffer1 text " can" line "move boulders." prompt UnknownText_0x1c07a0:: text "A #MON may be" line "able to move this." para "Want to use" line "STRENGTH?" done UnknownText_0x1c07d8:: text "Boulders may now" line "be moved!" done UnknownText_0x1c07f4:: text "A #MON may be" line "able to move this." done UnknownText_0x1c0816:: text_ram wStringBuffer2 text " used" line "WHIRLPOOL!" prompt UnknownText_0x1c082b:: text "It's a vicious" line "whirlpool!" para "A #MON may be" line "able to pass it." done UnknownText_0x1c0864:: text "A whirlpool is in" line "the way." para "Want to use" line "WHIRLPOOL?" done UnknownText_0x1c0897:: text_ram wStringBuffer2 text " did a" line "HEADBUTT!" prompt UnknownText_0x1c08ac:: text "Nope. Nothing…" done UnknownText_0x1c08bc:: text "A #MON could be" line "in this tree." para "Want to HEADBUTT" line "it?" done UnknownText_0x1c08f0:: text_ram wStringBuffer2 text " used" line "ROCK SMASH!" prompt UnknownText_0x1c0906:: text "Maybe a #MON" line "can break this." done UnknownText_0x1c0924:: text "This rock looks" line "breakable." para "Want to use ROCK" line "SMASH?" done UnknownText_0x1c0958:: text "Oh!" line "A bite!" prompt UnknownText_0x1c0965:: text "Not even a nibble!" prompt UnknownText_0x1c0979:: text "Looks like there's" line "nothing here." prompt UnknownText_0x1c099a:: text "You can't get off" line "here!" done UnknownText_0x1c09b2:: text "<PLAYER> got on the" line "@" text_ram wStringBuffer2 text "." done UnknownText_0x1c09c7:: text "<PLAYER> got off" line "the @" text_ram wStringBuffer2 text "." done UnknownText_0x1c09dd:: text "This tree can be" line "CUT!" para "Want to use CUT?" done UnknownText_0x1c0a05:: text "This tree can be" line "CUT!" done UnknownText_0x1c0a1c:: text "<PLAYER> found" line "@" text_ram wStringBuffer3 text "!" done UnknownText_0x1c0a2c:: text "But <PLAYER> can't" line "carry any more" cont "items." done UnknownText_0x1c0a4e:: text "<PLAYER> is out of" line "useable #MON!" para "<PLAYER> whited" line "out!" done UnknownText_0x1c0a77:: text "Yes! ITEMFINDER" line "indicates there's" cont "an item nearby." prompt UnknownText_0x1c0aa9:: text "Nope! ITEMFINDER" line "isn't responding." prompt UnknownText_0x1c0acc:: text_ram wStringBuffer3 text_start line "fainted!" prompt UnknownText_0x1c0ada:: text "<PLAYER> is out of" line "useable #MON!" para "<PLAYER> whited" line "out!" prompt UnknownText_0x1c0b03:: text_ram wStringBuffer3 text " used" line "SWEET SCENT!" done UnknownText_0x1c0b1a:: text "Looks like there's" line "nothing here…" done UnknownText_0x1c0b3b:: text "<PLAYER> sprinkled" line "water." para "But nothing" line "happened…" done UnknownText_0x1c0b65:: text "<PLAYER>'s #MON" line "were all healed!" done Text_AnEGGCantHoldAnItem:: text "An EGG can't hold" line "an item." prompt UnknownText_0x1c0b9a:: text "No items." done UnknownText_0x1c0ba5:: text "Throw away how" line "many?" done UnknownText_0x1c0bbb:: text "Throw away @" text_decimal wItemQuantityChangeBuffer, 1, 2 text_start line "@" text_ram wStringBuffer2 text "(S)?" done UnknownText_0x1c0bd8:: text "Threw away" line "@" text_ram wStringBuffer2 text "(S)." prompt UnknownText_0x1c0bee:: text "OAK: <PLAYER>!" line "This isn't the" cont "time to use that!" prompt Text_YouDontHaveAMon:: text "You don't have a" line "#MON!" prompt UnknownText_0x1c0c2e:: text "Registered the" line "@" text_ram wStringBuffer2 text "." prompt UnknownText_0x1c0c45:: text "You can't register" line "that item." prompt UnknownText_0x1c0c63:: text "Where should this" line "be moved to?" done UnknownText_0x1c0c83:: text_start done Text_YouCantUseItInABattle:: text "You can't use it" line "in a battle." prompt Text_AreYouABoyOrAreYouAGirl:: text "Are you a boy?" line "Or are you a girl?" done UnknownText_0x1c0cc6:: text "<USER>'s" line "@" text_ram wStringBuffer2 text_end text_end ; unused UnknownText_0x1c0cd0:: text_pause text "<SCROLL>went way up!" prompt UnknownText_0x1c0ce0:: text " went up!" prompt UnknownText_0x1c0ceb:: text "<TARGET>'s" line "@" text_ram wStringBuffer2 text_end text_end ; unused UnknownText_0x1c0cf5:: text_pause text "<SCROLL>sharply fell!" prompt UnknownText_0x1c0d06:: text " fell!" prompt UnknownText_0x1c0d0e:: text "<USER>@" text_end UnknownText_0x1c0d12:: text_start line "made a whirlwind!" prompt UnknownText_0x1c0d26:: text_start line "took in sunlight!" prompt UnknownText_0x1c0d3a:: text_start line "lowered its head!" prompt UnknownText_0x1c0d4e:: text_start line "is glowing!" prompt UnknownText_0x1c0d5c:: text_start line "flew up high!" prompt UnknownText_0x1c0d6c:: text_start line "dug a hole!" prompt _ActorNameText:: text "<USER>@" text_end _UsedMoveText:: text_start line "used @" text_end _UsedInsteadText:: text "instead," cont "@" text_end _MoveNameText:: text_ram wStringBuffer2 text "!" done UnknownText_0x1c0db0:: text "Huh?" para "@" text_end UnknownText_0x1c0db8:: text_start done UnknownText_0x1c0dba:: text_ram wStringBuffer1 text " came" line "out of its EGG!@" sound_caught_mon text_waitbutton text_end text_end ; unused UnknownText_0x1c0dd8:: text "Give a nickname to" line "@" text_ram wStringBuffer1 text "?" done UnknownText_0x1c0df3:: text "It's @" text_ram wBreedMon2Nick text_start line "that was left with" cont "the DAY-CARE LADY." done UnknownText_0x1c0e24:: text "It's @" text_ram wBreedMon1Nick text_start line "that was left with" cont "the DAY-CARE MAN." done UnknownText_0x1c0e54:: text "It's brimming with" line "energy." prompt UnknownText_0x1c0e6f:: text "It has no interest" line "in @" text_ram wStringBuffer1 text "." prompt UnknownText_0x1c0e8d:: text "It appears to care" line "for @" text_ram wStringBuffer1 text "." prompt UnknownText_0x1c0eac:: text "It's friendly with" line "@" text_ram wStringBuffer1 text "." prompt UnknownText_0x1c0ec6:: text "It shows interest" line "in @" text_ram wStringBuffer1 text "." prompt _EmptyMailboxText:: text "There's no MAIL" line "here." prompt ClearedMailPutAwayText:: text "The cleared MAIL" line "was put away." prompt MailPackFullText:: text "The PACK is full." prompt MailMessageLostText:: text "The MAIL's message" line "will be lost. OK?" done MailAlreadyHoldingItemText:: text "It's already hold-" line "ing an item." prompt MailEggText:: text "An EGG can't hold" line "any MAIL." prompt MailMovedFromBoxText:: text "The MAIL was moved" line "from the MAILBOX." prompt UnknownText_0x1c0fb3:: text "Yes" prompt UnknownText_0x1c0fb8:: text "No" prompt UnknownText_0x1c0fbc:: text_decimal wcf64, 1, 3 text " @" text_ram wStringBuffer1 text_start line "Animation type @" text_ram wStringBuffer2 text_end text_end ; unused UnknownText_0x1c0fdd:: text "#MON number?" done Text_WasSentToBillsPC:: text_ram wStringBuffer1 text " was" line "sent to BILL's PC." prompt UnknownText_0x1c1006:: text "You gotta have" line "#MON to call!" prompt UnknownText_0x1c1024:: text "What?" done UnknownText_0x1c102b:: text "There is a #MON" line "holding MAIL." para "Please remove the" line "MAIL." prompt UnknownText_0x1c1062:: text "You don't have a" line "single #MON!" prompt UnknownText_0x1c1080:: text "You can't deposit" line "your last #MON!" prompt UnknownText_0x1c10a2:: text "You can't take any" line "more #MON." prompt UnknownText_0x1c10c0:: text "Caught @" text_ram wStringBuffer1 text "!" prompt UnknownText_0x1c10cf:: text "Switch #MON?" done UnknownText_0x1c10dd:: text "You already caught" line "a @" text_ram wStringBuffer1 text "." prompt ContestJudging_FirstPlaceText:: text "This Bug-Catching" line "Contest winner is@" text_pause text "…" para "@" text_ram wBugContestWinnerName text "," line "who caught a" cont "@" text_ram wStringBuffer1 text "!@" text_end ContestJudging_FirstPlaceScoreText:: text_start para "The winning score" line "was @" text_decimal wBugContestFirstPlaceScore, 2, 3 text " points!" prompt ContestJudging_SecondPlaceText:: text "Placing second was" line "@" text_ram wBugContestWinnerName text "," para "who caught a" line "@" text_ram wStringBuffer1 text "!@" text_end ContestJudging_SecondPlaceScoreText:: text_start para "The score was" line "@" text_decimal wBugContestSecondPlaceScore, 2, 3 text " points!" prompt ContestJudging_ThirdPlaceText:: text "Placing third was" line "@" text_ram wBugContestWinnerName text "," para "who caught a" line "@" text_ram wStringBuffer1 text "!@" text_end ContestJudging_ThirdPlaceScoreText:: text_start para "The score was" line "@" text_decimal wBugContestThirdPlaceScore, 2, 3 text " points!" prompt UnknownText_0x1c1203:: text "Let me measure" line "that MAGIKARP." para "…Hm, it measures" line "@" text_ram wStringBuffer1 text "." prompt UnknownText_0x1c123a:: text "CURRENT RECORD" para "@" text_ram wStringBuffer1 text " caught by" line "@" text_ram wMagikarpRecordHoldersName text_waitbutton text_end text_end ; unused UnknownText_0x1c1261:: text "Congratulations!" para "We have a match" line "with the ID number" para "of @" text_ram wStringBuffer1 text " in" line "your party." prompt UnknownText_0x1c12ae:: text "Congratulations!" para "We have a match" line "with the ID number" para "of @" text_ram wStringBuffer1 text " in" line "your PC BOX." prompt UnknownText_0x1c12fc:: text "Give a nickname to" line "the @" text_ram wStringBuffer1 text " you" cont "received?" done UnknownText_0x1c1328:: text "Bzzzzt! You must" line "have a #MON to" cont "use this!" prompt UnknownText_0x1c1353:: text "<PLAYER> turned on" line "the PC." prompt UnknownText_0x1c1368:: text "What do you want" line "to do?" done _PlayersPCHowManyWithdrawText:: text "How many do you" line "want to withdraw?" done _PlayersPCWithdrewItemsText:: text "Withdrew @" text_decimal wItemQuantityChangeBuffer, 1, 2 text_start line "@" text_ram wStringBuffer2 text "(S)." prompt _PlayersPCNoRoomWithdrawText:: text "There's no room" line "for more items." prompt UnknownText_0x1c13df:: text "No items here!" prompt _PlayersPCHowManyDepositText:: text "How many do you" line "want to deposit?" done _PlayersPCDepositItemsText:: text "Deposited @" text_decimal wItemQuantityChangeBuffer, 1, 2 text_start line "@" text_ram wStringBuffer2 text "(S)." prompt _PlayersPCNoRoomDepositText:: text "There's no room to" line "store items." prompt UnknownText_0x1c144d:: text "<PLAYER> turned on" line "the PC." prompt UnknownText_0x1c1462:: text "Access whose PC?" done UnknownText_0x1c1474:: text "BILL's PC" line "accessed." para "#MON Storage" line "System opened." prompt UnknownText_0x1c14a4:: text "Accessed own PC." para "Item Storage" line "System opened." prompt UnknownText_0x1c14d2:: text "PROF.OAK's PC" line "accessed." para "#DEX Rating" line "System opened." prompt UnknownText_0x1c1505:: text "…" line "Link closed…" done _OakPCText1:: text "Want to get your" line "#DEX rated?" done _OakPCText2:: text "Current #DEX" line "completion level:" prompt _OakPCText3:: text_ram wStringBuffer3 text " #MON seen" line "@" text_ram wStringBuffer4 text " #MON owned" para "PROF.OAK's" line "Rating:" done _OakRating01:: text "Look for #MON" line "in grassy areas!" done _OakRating02:: text "Good. I see you" line "understand how to" cont "use # BALLS." done _OakRating03:: text "You're getting" line "good at this." para "But you have a" line "long way to go." done _OakRating04:: text "You need to fill" line "up the #DEX." para "Catch different" line "kinds of #MON!" done _OakRating05:: text "You're trying--I" line "can see that." para "Your #DEX is" line "coming together." done _OakRating06:: text "To evolve, some" line "#MON grow," para "others use the" line "effects of STONES." done _OakRating07:: text "Have you gotten a" line "fishing ROD? You" para "can catch #MON" line "by fishing." done _OakRating08:: text "Excellent! You" line "seem to like col-" cont "lecting things!" done _OakRating09:: text "Some #MON only" line "appear during" para "certain times of" line "the day." done _OakRating10:: text "Your #DEX is" line "filling up. Keep" cont "up the good work!" done _OakRating11:: text "I'm impressed." line "You're evolving" para "#MON, not just" line "catching them." done _OakRating12:: text "Have you met KURT?" line "His custom BALLS" cont "should help." done _OakRating13:: text "Wow. You've found" line "more #MON than" para "the last #DEX" line "research project." done _OakRating14:: text "Are you trading" line "your #MON?" para "It's tough to do" line "this alone!" done _OakRating15:: text "Wow! You've hit" line "200! Your #DEX" cont "is looking great!" done _OakRating16:: text "You've found so" line "many #MON!" para "You've really" line "helped my studies!" done _OakRating17:: text "Magnificent! You" line "could become a" para "#MON professor" line "right now!" done _OakRating18:: text "Your #DEX is" line "amazing! You're" para "ready to turn" line "professional!" done _OakRating19:: text "Whoa! A perfect" line "#DEX! I've" para "dreamt about this!" line "Congratulations!" done _OakPCText4:: text "The link to PROF." line "OAK's PC closed." done UnknownText_0x1c19cd:: text "Triple-theme" line "trainer ranking!" para "The SAVE file you" line "just sent might" cont "make the rankings!" para "" done UnknownText_0x1c1a22:: text "There is no" line "ranking data." para "Link to obtain" line "ranking data." para "" done UnknownText_0x1c1a5b:: text " , yeah!" done UnknownText_0x1c1a65:: text "Darn…" done UnknownText_0x1c1a6c:: text "Would you like to" line "end the Contest?" done UnknownText_0x1c1a90:: text "Toss out how many" line "@" text_ram wStringBuffer2 text "(S)?" done UnknownText_0x1c1aad:: text "Throw away @" text_decimal wItemQuantityChangeBuffer, 1, 2 text_start line "@" text_ram wStringBuffer2 text "(S)?" done UnknownText_0x1c1aca:: text "Discarded" line "@" text_ram wStringBuffer1 text "(S)." prompt UnknownText_0x1c1adf:: text "That's too impor-" line "tant to toss out!" prompt UnknownText_0x1c1b03:: text "OAK: <PLAYER>!" line "This isn't the" cont "time to use that!" done UnknownText_0x1c1b2c:: text "Took @" text_ram wMonOrItemNameBuffer text "'s" line "@" text_ram wStringBuffer1 text " and" para "made it hold" line "@" text_ram wStringBuffer2 text "." prompt UnknownText_0x1c1b57:: text "Made @" text_ram wMonOrItemNameBuffer text_start line "hold @" text_ram wStringBuffer2 text "." prompt UnknownText_0x1c1b6f:: text "Please remove the" line "MAIL first." prompt UnknownText_0x1c1b8e:: text_ram wMonOrItemNameBuffer text " isn't" line "holding anything." prompt UnknownText_0x1c1baa:: text "Item storage space" line "full." prompt UnknownText_0x1c1bc4:: text "Took @" text_ram wStringBuffer1 text_start line "from @" text_ram wMonOrItemNameBuffer text "." prompt UnknownText_0x1c1bdc:: text_ram wMonOrItemNameBuffer text " is" line "already holding" para "@" text_ram wStringBuffer1 text "." line "Switch items?" done UnknownText_0x1c1c09:: text "This item can't be" line "held." prompt UnknownText_0x1c1c22:: text "The MAIL will lose" line "its message. OK?" done UnknownText_0x1c1c47:: text "MAIL detached from" line "@" text_ram wStringBuffer1 text "." prompt UnknownText_0x1c1c62:: text "There's no space" line "for removing MAIL." prompt UnknownText_0x1c1c86:: text "Send the removed" line "MAIL to your PC?" done UnknownText_0x1c1ca9:: text "Your PC's MAILBOX" line "is full." prompt UnknownText_0x1c1cc4:: text "The MAIL was sent" line "to your PC." prompt UnknownText_0x1c1ce3:: text "Not enough HP!" prompt UnknownText_0x1c1cf3:: text "An item in your" line "PACK may be" para "registered for use" line "on SELECT Button." done _OakText1:: text "Hello! Sorry to" line "keep you waiting!" para "Welcome to the" line "world of #MON!" para "My name is OAK." para "People call me the" line "#MON PROF." prompt _OakText2:: text "This world is in-" line "habited by crea-" cont "tures that we call" cont "#MON.@" text_end _OakText3:: text_waitbutton text_end text_end ; unused _OakText4:: text "People and #MON" line "live together by" para "supporting each" line "other." para "Some people play" line "with #MON, some" cont "battle with them." prompt _OakText5:: text "But we don't know" line "everything about" cont "#MON yet." para "There are still" line "many mysteries to" cont "solve." para "That's why I study" line "#MON every day." prompt
; "Hello World!" in 32 bit Linux NASM ; adapted from http://asm.sourceforge.net/intro/hello.html by Mark Loiseau ; referenced in http://blog.markloiseau.com/2012/04/hello-world-NASM-Linux global _start ; global entry point export for ld section .text _start: ; sys_write(stdout, message, length) mov eax, 4 ; sys_write syscall mov ebx, 1 ; stdout mov ecx, message ; message address mov edx, length ; message string length int 80h ; sys_exit(return_code) mov eax, 1 ; sys_exit syscall mov ebx, 0 ; return 0 (success) int 80h section .data message: db 'Hola, mundo!',0x0A ; message and newline length: equ $-message ; NASM definition pseudo-instruction
; =============================================================== ; Aug 2003 ; =============================================================== ; ; void in_mouse_amx(uint8_t *buttons, uint16_t *x, uint16_t *y) ; ; Returns mouse coordinate and button state. ; ; =============================================================== SECTION code_input PUBLIC asm_in_mouse_amx EXTERN __input_amx_mouse_x, __input_amx_mouse_y asm_in_mouse_amx: ; exit : a = button state = 0000 0MRL active high ; de = x coordinate ; bc = y coordinate ; ; uses : af, bc, de ; amx button state can randomly fluctuate ; take several reads and mix results ld bc,$051f button_loop: in a,($df) or c ld c,a djnz button_loop rlca rlca rlca and $07 add a,button_table % 256 ld c,a ld a,0 adc a,button_table / 256 ld b,a ld a,(bc) ; a = button state = 0000 0MRL active high ; x coordinate ld de,(__input_amx_mouse_x + 1) ld d,0 ; y coordinate ld bc,(__input_amx_mouse_y + 1) ld b,d ret button_table: defb $07, $03, $05, $01, $06, $02, $04, $00
/* Automatically generated file. Do not edit directly. */ /* This file is part of The New Aspell * Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL * license version 2.0 or 2.1. You should have received a copy of the * LGPL license along with this library if you did not you can find it * at http://www.gnu.org/. */ #include "document_checker.hpp" #include "error.hpp" namespace acommon { class CanHaveError; class DocumentChecker; struct Error; class Filter; class Speller; extern "C" void delete_aspell_document_checker(DocumentChecker * ths) { delete ths; } extern "C" unsigned int aspell_document_checker_error_number(const DocumentChecker * ths) { return ths->err_ == 0 ? 0 : 1; } extern "C" const char * aspell_document_checker_error_message(const DocumentChecker * ths) { return ths->err_ ? ths->err_->mesg : ""; } extern "C" const Error * aspell_document_checker_error(const DocumentChecker * ths) { return ths->err_; } extern "C" CanHaveError * new_aspell_document_checker(Speller * speller) { PosibErr<DocumentChecker *> ret = new_document_checker(speller); if (ret.has_err()) { return new CanHaveError(ret.release_err()); } else { return ret; } } extern "C" DocumentChecker * to_aspell_document_checker(CanHaveError * obj) { return static_cast<DocumentChecker *>(obj); } extern "C" void aspell_document_checker_reset(DocumentChecker * ths) { ths->reset(); } extern "C" void aspell_document_checker_process(DocumentChecker * ths, const char * str, int size) { ths->process(str, size); } extern "C" Token aspell_document_checker_next_misspelling(DocumentChecker * ths) { return ths->next_misspelling(); } extern "C" Filter * aspell_document_checker_filter(DocumentChecker * ths) { return ths->filter(); } }
.data _newLine: .asciiz "\n" _divByZeroMessage: .asciiz "\nException: division by zero\nProgram will be terminated\n" _floatOverflowMessage: .asciiz "\nException: floating point operation result too great to fit in floating point word\nProgram will be terminated\n" _floatUnderflowMessage: .asciiz "\nException: floating point operation result too small to fit in floating point word\nPrgoram will be terminated\n" _intStack: .align 2 .space 64 _floatStack: .align 3 .space 128 _boolStack: .align 2 .space 64 _INT_MAX: .align 2 .word 1073741823 _INT_MIN: .align 2 .word -1073741824 _FLOAT_MAX: .align 3 .double 98079714615416886934934209737619787751599303819750539264 _FLOAT_MAX_NEG: .align 3 .double -98079714615416886934934209737619787751599303819750539264 _FLOAT_MIN: .align 3 .double 1.593091911132452E-58 _FLOAT_MIN_NEG: .align 3 .double -1.593091911132452E-58 _float0: .align 3 .double 1.0 _float1: .align 3 .double 1.0 _float2: .align 3 .double 1.0 _float3: .align 3 .double 1.0 _float4: .align 3 .double 3.2 _float5: .align 3 .double 3.0 .text la $s0, _intStack la $s2, _floatStack la $s4, _boolStack j main _floatOverflow: la $a0, _floatOverflowMessage j _exceptionAndExit _floatUnderflow: la $a0, _floatUnderflowMessage j _exceptionAndExit _divByZero: la $a0, _divByZeroMessage j _exceptionAndExit _exceptionAndExit: li $v0, 4 syscall li $v0, 10 syscall _floatOverflowCheck: mtc1.d $a0, $f4 l.d $f6, _FLOAT_MAX c.le.d $f4, $f6 bc1f _floatOverflow l.d $f6, _FLOAT_MAX_NEG c.lt.d $f4, $f6 bc1t _floatOverflow mtc1 $zero, $f6 cvt.d.w $f6, $f6 c.eq.d $f4, $f6 bc1t _floatOverflowCheck_return c.lt.d $f4, $f6 bc1t _floatOverflowCheck_lessThanZero l.d $f6, _FLOAT_MIN c.lt.d $f4, $f6 bc1t _floatUnderflow j _floatOverflowCheck_return _floatOverflowCheck_lessThanZero: l.d $f6, _FLOAT_MIN_NEG c.le.d $f4, $f6 bc1f _floatUnderflow _floatOverflowCheck_return: jr $ra _intOverflowCheck: move $t0, $a0 lw $t2, _INT_MAX lw $t3, _INT_MIN bgt $t0, $t2, _intOverflow_max blt $t0, $t3, _intOverflow_min j _intOverflowCheck_return _intOverflow_max: sub $t0, $t0, $t2 subi $t0, $t0, 1 add $t0, $t0, $t3 j _intOverflowCheck_return _intOverflow_min: sub $t0, $t0, $t3 addi $t0, $t0, 1 add $t0, $t0, $t2 _intOverflowCheck_return: move $v0, $t0 jr $ra main: li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 addi $s0, $s0, -4 lw $t1, ($s0) addi $s0, $s0, -4 lw $t0, ($s0) beq $t0, $t1, _else0 li $t3, 1 sw $t3, ($s4) addi $s4, $s4, 4 j _afterIf0 _else0: sw $zero, ($s4) addi $s4, $s4, 4 _afterIf0: addi $s4, $s4, -4 lw $t0, ($s4) beq $t0, 0, _afterIf1 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $v0 1 addi $s0, $s0, -4 lw $a0, ($s0) syscall li $v0, 4 la $a0, _newLine syscall _afterIf1: li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 l.d $f4, _float0 s.d $f4, ($s2) addi $s2, $s2, 8 addi $s0, $s0, -4 lw $t0, ($s0) mtc1 $t0, $f4 cvt.d.w $f4, $f4 addi $s2, $s2, -8 l.d $f6, ($s2) c.eq.d $f4, $f6 bc1t _else2 li $t3, 1 sw $t3, ($s4) addi $s4, $s4, 4 j _afterIf2 _else2: sw $zero, ($s4) addi $s4, $s4, 4 _afterIf2: addi $s4, $s4, -4 lw $t0, ($s4) beq $t0, 0, _afterIf3 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $v0 1 addi $s0, $s0, -4 lw $a0, ($s0) syscall li $v0, 4 la $a0, _newLine syscall _afterIf3: l.d $f4, _float1 s.d $f4, ($s2) addi $s2, $s2, 8 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 addi $s2, $s2, -8 l.d $f4, ($s2) addi $s0, $s0, -4 lw $t0, ($s0) mtc1 $t0, $f6 cvt.d.w $f6, $f6 c.eq.d $f4, $f6 bc1t _else4 li $t3, 1 sw $t3, ($s4) addi $s4, $s4, 4 j _afterIf4 _else4: sw $zero, ($s4) addi $s4, $s4, 4 _afterIf4: addi $s4, $s4, -4 lw $t0, ($s4) beq $t0, 0, _afterIf5 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $v0 1 addi $s0, $s0, -4 lw $a0, ($s0) syscall li $v0, 4 la $a0, _newLine syscall _afterIf5: l.d $f4, _float2 s.d $f4, ($s2) addi $s2, $s2, 8 l.d $f4, _float3 s.d $f4, ($s2) addi $s2, $s2, 8 addi $s2, $s2, -8 l.d $f6, ($s2) addi $s2, $s2, -8 l.d $f4, ($s2) c.eq.d $f4, $f6 bc1t _else6 li $t3, 1 sw $t3, ($s4) addi $s4, $s4, 4 j _afterIf6 _else6: sw $zero, ($s4) addi $s4, $s4, 4 _afterIf6: addi $s4, $s4, -4 lw $t0, ($s4) beq $t0, 0, _afterIf7 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $v0 1 addi $s0, $s0, -4 lw $a0, ($s0) syscall li $v0, 4 la $a0, _newLine syscall _afterIf7: l.d $f4, _float4 s.d $f4, ($s2) addi $s2, $s2, 8 li $t0, 0 sw $t0, ($s0) addi $s0, $s0, 4 addi $s2, $s2, -8 l.d $f4, ($s2) addi $s0, $s0, -4 lw $t0, ($s0) mtc1 $t0, $f6 cvt.d.w $f6, $f6 c.le.d $f4, $f6 bc1f _else8 li $t3, 1 sw $t3, ($s4) addi $s4, $s4, 4 j _afterIf8 _else8: sw $zero, ($s4) addi $s4, $s4, 4 _afterIf8: addi $s4, $s4, -4 lw $t0, ($s4) beq $t0, 0, _afterIf9 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $v0 1 addi $s0, $s0, -4 lw $a0, ($s0) syscall li $v0, 4 la $a0, _newLine syscall _afterIf9: li $t0, 9 sw $t0, ($s0) addi $s0, $s0, 4 li $t0, 10 sw $t0, ($s0) addi $s0, $s0, 4 addi $s0, $s0, -4 lw $t1, ($s0) addi $s0, $s0, -4 lw $t0, ($s0) ble $t0, $t1, _else10 li $t3, 1 sw $t3, ($s4) addi $s4, $s4, 4 j _afterIf10 _else10: sw $zero, ($s4) addi $s4, $s4, 4 _afterIf10: addi $s4, $s4, -4 lw $t0, ($s4) beq $t0, 0, _afterIf11 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $v0 1 addi $s0, $s0, -4 lw $a0, ($s0) syscall li $v0, 4 la $a0, _newLine syscall _afterIf11: li $t0, 10 sw $t0, ($s0) addi $s0, $s0, 4 l.d $f4, _float5 s.d $f4, ($s2) addi $s2, $s2, 8 addi $s0, $s0, -4 lw $t0, ($s0) mtc1 $t0, $f4 cvt.d.w $f4, $f4 addi $s2, $s2, -8 l.d $f6, ($s2) mtc1 $zero, $f8 cvt.d.w $f8, $f8 c.eq.d $f6, $f8 bc1t _divByZero div.d $f4, $f4, $f6 mov.d $f20, $f4 mfc1.d $a0, $f20 jal _floatOverflowCheck s.d $f20, ($s2) addi $s2, $s2, 8 li $t0, 4 sw $t0, ($s0) addi $s0, $s0, 4 addi $s2, $s2, -8 l.d $f4, ($s2) addi $s0, $s0, -4 lw $t0, ($s0) mtc1 $t0, $f6 cvt.d.w $f6, $f6 c.lt.d $f4, $f6 bc1t _else12 li $t3, 1 sw $t3, ($s4) addi $s4, $s4, 4 j _afterIf12 _else12: sw $zero, ($s4) addi $s4, $s4, 4 _afterIf12: addi $s4, $s4, -4 lw $t0, ($s4) beq $t0, 0, _afterIf13 li $t0, 1 sw $t0, ($s0) addi $s0, $s0, 4 li $v0 1 addi $s0, $s0, -4 lw $a0, ($s0) syscall li $v0, 4 la $a0, _newLine syscall _afterIf13: li $v0, 10 syscall
; A346965: a(n) is the number of ascending subsequences in reducing n to 1 using the Collatz reduction, or -1 if n refutes the Collatz conjecture. ; Submitted by Jon Maiga ; 0,0,1,0,1,1,3,0,4,1,3,1,2,3,2,0,3,4,4,1,1,3,2,1,5,2,17,3,4,2,16,0,6,3,2,4,4,4,6,1,17,1,6,3,4,2,16,1,5,5,5,2,2,17,17,3,7,4,6,2,3,16,15,0,6,6,5,3,3,2,16,4,18,4,2,4,5,6,6,1,4,17,17,1,1,6,5,3,6,4,14,2,3,16,15,1,19,5,4,5 mov $2,$0 seq $0,160541 ; Number of odd-then-even runs to reach 1 under the modified `3x+1' map: n -> n/2 if n is even, n -> (3n+1)/2 if n is odd. gcd $2,2 add $0,$2 sub $0,2