X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fuserprog%2Ftss.c;h=569e8d183336657aa82e04f882cd9ebd80c65b0d;hb=9a602e952252dbfb1332f5137dd7c33a21b6fc6d;hp=4b32d8507976f6995d8c242bdc8664b9ce034fbb;hpb=c7172468133f9f739b66d22f351b1934d1b6190e;p=pintos-anon diff --git a/src/userprog/tss.c b/src/userprog/tss.c index 4b32d85..569e8d1 100644 --- a/src/userprog/tss.c +++ b/src/userprog/tss.c @@ -1,9 +1,9 @@ -#include "tss.h" +#include "userprog/tss.h" +#include #include -#include "debug.h" -#include "gdt.h" -#include "mmu.h" -#include "palloc.h" +#include "userprog/gdt.h" +#include "threads/palloc.h" +#include "threads/vaddr.h" /* The Task-State Segment (TSS). @@ -43,9 +43,10 @@ stack pointer to point to the new thread's kernel stack. (The call is in schedule_tail() in thread.c.) - See [IA32-v3] 6.2.1 for a description of the TSS and 5.12.1 - for a description of when and how stack switching occurs - during an interrupt. */ + See [IA32-v3a] 6.2.1 "Task-State Segment (TSS)" for a + description of the TSS. See [IA32-v3a] 5.12.1 "Exception- or + Interrupt-Handler Procedures" for a description of when and + how stack switching occurs during an interrupt. */ struct tss { uint16_t back_link, :16; @@ -80,10 +81,10 @@ tss_init (void) /* Our TSS is never used in a call gate or task gate, so only a few fields of it are ever referenced, and those are the only ones we initialize. */ - tss = palloc_get (PAL_ASSERT | PAL_ZERO); - tss->esp0 = ptov(0x20000); + tss = palloc_get_page (PAL_ASSERT | PAL_ZERO); tss->ss0 = SEL_KDSEG; tss->bitmap = 0xdfff; + tss_update (); } /* Returns the kernel TSS. */ @@ -94,10 +95,11 @@ tss_get (void) return tss; } -/* Sets the ring 0 stack pointer in the TSS to ESP0. */ +/* Sets the ring 0 stack pointer in the TSS to point to the end + of the thread stack. */ void -tss_set_esp0 (uint8_t *esp0) +tss_update (void) { ASSERT (tss != NULL); - tss->esp0 = esp0; + tss->esp0 = (uint8_t *) thread_current () + PGSIZE; }