projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Test disk code slightly more thoroughly.
[pintos-anon]
/
src
/
threads
/
init.c
diff --git
a/src/threads/init.c
b/src/threads/init.c
index f7702cd365e423ed44ff0ed2221c26c59bd687cc..81188e950c6e8825052c18003d3eeea761ae1435 100644
(file)
--- a/
src/threads/init.c
+++ b/
src/threads/init.c
@@
-18,6
+18,7
@@
#include "vga.h"
#ifdef FILESYS
#include "filesys.h"
#include "vga.h"
#ifdef FILESYS
#include "filesys.h"
+#include "disk.h"
#endif
/* Size of kernel static code and data, in 4 kB pages. */
#endif
/* Size of kernel static code and data, in 4 kB pages. */
@@
-32,6
+33,17
@@
void power_off (void);
static void
main_thread (void *aux UNUSED)
{
static void
main_thread (void *aux UNUSED)
{
+ struct disk *hda;
+ disk_init ();
+ hda = disk_get (1);
+ if (hda != NULL)
+ {
+ char buf[DISK_SECTOR_SIZE];
+ disk_read (hda, 0, buf);
+ //hex_dump (buf, sizeof buf);
+ }
+ else
+ printk ("no hda\n");
thread_execute ("a.out");
}
thread_execute ("a.out");
}
@@
-44,21
+56,21
@@
main (void)
/* Clear out the BSS segment. */
memset (&__bss_start, 0, &_end - &__bss_start);
/* Clear out the BSS segment. */
memset (&__bss_start, 0, &_end - &__bss_start);
+ /* Initialize components needed by printk() very early. */
vga_init ();
serial_init ();
vga_init ();
serial_init ();
+ printk ("Booting cnachos86...\n");
/* Calculate how much RAM the kernel uses, and find out from
the bootloader how much RAM this machine has. */
kernel_pages = (&_end - &_text + 4095) / 4096;
/* Calculate how much RAM the kernel uses, and find out from
the bootloader how much RAM this machine has. */
kernel_pages = (&_end - &_text + 4095) / 4096;
- ram_pages = *(uint32_t *) (0x7e00 - 8);
-
- printk ("Initializing nachos-x86, %d kB RAM detected.\n",
- ram_pages * 4);
+ ram_pages = *(uint32_t *) (0x7e00 - 6);
+ printk ("ram: detected %'d kB main memory.\n", ram_pages * 4);
/* Memory from the end of the kernel through the end of memory
is free. Give it to the page allocator. */
/* Memory from the end of the kernel through the end of memory
is free. Give it to the page allocator. */
- palloc_init ((void *) (KERN_BASE + kernel_pages *
NBPG
),
- (void *) (PHYS_BASE + ram_pages *
NBPG
));
+ palloc_init ((void *) (KERN_BASE + kernel_pages *
PGSIZE
),
+ (void *) (PHYS_BASE + ram_pages *
PGSIZE
));
paging_init ();
gdt_init ();
paging_init ();
gdt_init ();
@@
-71,7
+83,6
@@
main (void)
#ifdef FILESYS
filesys_init (false);
#ifdef FILESYS
filesys_init (false);
- filesys_self_test ();
#endif
thread_init ();
#endif
thread_init ();
@@
-94,13
+105,13
@@
make_seg_desc (uint32_t base,
uint32_t e0 = ((limit & 0xffff) /* Limit 15:0. */
| (base << 16)); /* Base 15:0. */
uint32_t e1 = (((base >> 16) & 0xff) /* Base 23:16. */
uint32_t e0 = ((limit & 0xffff) /* Limit 15:0. */
| (base << 16)); /* Base 15:0. */
uint32_t e1 = (((base >> 16) & 0xff) /* Base 23:16. */
- | (
system << 12)
/* 0=system, 1=code/data. */
- | (
type << 8)
/* Segment type. */
+ | (
system << 12)
/* 0=system, 1=code/data. */
+ | (
type << 8)
/* Segment type. */
| (dpl << 13) /* Descriptor privilege. */
| (1 << 15) /* Present. */
| (limit & 0xf0000) /* Limit 16:19. */
| (1 << 22) /* 32-bit segment. */
| (dpl << 13) /* Descriptor privilege. */
| (1 << 15) /* Present. */
| (limit & 0xf0000) /* Limit 16:19. */
| (1 << 22) /* 32-bit segment. */
- | (
granularity << 23)
/* Byte/page granularity. */
+ | (
granularity << 23)
/* Byte/page granularity. */
| (base & 0xff000000)); /* Base 31:24. */
return e0 | ((uint64_t) e1 << 32);
}
| (base & 0xff000000)); /* Base 31:24. */
return e0 | ((uint64_t) e1 << 32);
}
@@
-120,9
+131,10
@@
make_data_desc (int dpl)
}
static uint64_t
}
static uint64_t
-make_tss_desc (
uint32_t base
)
+make_tss_desc (
void *vaddr
)
{
{
- return make_seg_desc (base, 0x67, SYS_SYSTEM, TYPE_TSS_32_A, 0, GRAN_BYTE);
+ return make_seg_desc ((uint32_t) vaddr,
+ 0x67, SYS_SYSTEM, TYPE_TSS_32_A, 0, GRAN_BYTE);
}
uint64_t gdt[SEL_CNT];
}
uint64_t gdt[SEL_CNT];
@@
-150,7
+162,7
@@
gdt_init (void)
gdt[SEL_KDSEG / sizeof *gdt] = make_data_desc (0);
gdt[SEL_UCSEG / sizeof *gdt] = make_code_desc (3);
gdt[SEL_UDSEG / sizeof *gdt] = make_data_desc (3);
gdt[SEL_KDSEG / sizeof *gdt] = make_data_desc (0);
gdt[SEL_UCSEG / sizeof *gdt] = make_code_desc (3);
gdt[SEL_UDSEG / sizeof *gdt] = make_data_desc (3);
- gdt[SEL_TSS / sizeof *gdt] = make_tss_desc (
vtop (tss)
);
+ gdt[SEL_TSS / sizeof *gdt] = make_tss_desc (
tss
);
/* Load GDTR, TR. */
gdtr_operand = make_dtr_operand (sizeof gdt - 1, gdt);
/* Load GDTR, TR. */
gdtr_operand = make_dtr_operand (sizeof gdt - 1, gdt);