Advertisement
Guest User

xv6.patch

a guest
Apr 9th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.91 KB | None | 0 0
  1. diff --git a/Makefile b/Makefile
  2. index 20cb884..e2d9196 100644
  3. --- a/Makefile
  4. +++ b/Makefile
  5. @@ -121,8 +121,8 @@ kernel: $(OBJS) entry.o entryother initcode kernel.ld
  6.  # great for testing the kernel on real hardware without
  7.  # needing a scratch disk.
  8.  MEMFSOBJS = $(filter-out ide.o,$(OBJS)) memide.o
  9. -kernelmemfs: $(MEMFSOBJS) entry.o entryother initcode fs.img
  10. -   $(LD) $(LDFLAGS) -Ttext 0x100000 -e main -o kernelmemfs entry.o  $(MEMFSOBJS) -b binary initcode entryother fs.img
  11. +kernelmemfs: $(MEMFSOBJS) entry.o entryother initcode kernel.ld fs.img
  12. +   $(LD) $(LDFLAGS) -T kernel.ld -o kernelmemfs entry.o  $(MEMFSOBJS) -b binary initcode entryother fs.img
  13.     $(OBJDUMP) -S kernelmemfs > kernelmemfs.asm
  14.     $(OBJDUMP) -t kernelmemfs | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernelmemfs.sym
  15.  
  16. diff --git a/kernel.ld b/kernel.ld
  17. index e24c860..a02d5b4 100644
  18. --- a/kernel.ld
  19. +++ b/kernel.ld
  20. @@ -3,7 +3,7 @@
  21.  
  22.  OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
  23.  OUTPUT_ARCH(i386)
  24. -ENTRY(_start)
  25. +ENTRY(entry)
  26.  
  27.  SECTIONS
  28.  {
  29. diff --git a/vm.c b/vm.c
  30. index 4cffb58..2f4ba3e 100644
  31. --- a/vm.c
  32. +++ b/vm.c
  33. @@ -32,6 +32,10 @@ seginit(void)
  34.    c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);
  35.  
  36.    lgdt(c->gdt, sizeof(c->gdt));
  37. +
  38. +  loadcs(SEG_KCODE << 3);
  39. +  loadds(SEG_KDATA << 3);
  40. +  loades(SEG_KDATA << 3);
  41.    loadgs(SEG_KCPU << 3);
  42.    
  43.    // Initialize cpu-local storage.
  44. diff --git a/x86.h b/x86.h
  45. index 3949900..7d4bcce 100644
  46. --- a/x86.h
  47. +++ b/x86.h
  48. @@ -99,6 +99,22 @@ readeflags(void)
  49.    return eflags;
  50.  }
  51.  
  52. +#define loadcs(v)                               \
  53. +  asm volatile("ljmp %0, $set_cs\n"             \
  54. +               "set_cs:" : : "n" (v));
  55. +
  56. +static inline void
  57. +loadds(ushort v)
  58. +{
  59. +  asm volatile("movw %0, %%ds" : : "r" (v));
  60. +}
  61. +
  62. +static inline void
  63. +loades(ushort v)
  64. +{
  65. +  asm volatile("movw %0, %%es" : : "r" (v));
  66. +}
  67. +
  68.  static inline void
  69.  loadgs(ushort v)
  70.  {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement