Changeset 76cec1e in mainline
- Timestamp:
- 2005-07-15T21:57:30Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b4a4c5e3
- Parents:
- e41c47e
- Files:
-
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia32/boot/boot.S
re41c47e r76cec1e 51 51 xorw %ax,%ax # reset, %al will be used below 52 52 movw %ax,%dx # fd0, %dh and %dl will be used below 53 53 movw %dx,%ds 54 54 55 55 movw %dx,%ss # initialize stack … … 59 59 jc stop_trying 60 60 61 61 movw %dx,%ds 62 62 movw %dx,%ss 63 63 movw $0x7c00,%sp … … 93 93 movw logical_sector,%ax 94 94 divb sectors 95 95 96 96 movb %ah,%cl 97 98 97 incb %cl # sector 98 99 99 movb %al,%ch 100 100 shrb $1,%ch # track 101 101 102 102 movb %al,%dh 103 103 andb $1,%dh # head … … 127 127 movw %sp,%bp 128 128 pusha 129 129 130 130 movb $0xe,%ah 131 131 movb $7,%bl 132 132 int $0x10 133 133 134 134 popa 135 135 pop %bp -
arch/ia32/boot/boot.ld
re41c47e r76cec1e 1 1 OUTPUT_FORMAT(binary) 2 2 SECTIONS { 3 3 .text 0x7c00 : AT (0x0) { *(.text) } 4 4 } -
arch/ia32/include/cpu.h
re41c47e r76cec1e 43 43 44 44 struct cpu_arch { 45 46 47 48 45 int vendor; 46 int family; 47 int model; 48 int stepping; 49 49 struct tss *tss; 50 50 }; -
arch/ia32/src/acpi/acpi.c
re41c47e r76cec1e 85 85 void acpi_init(void) 86 86 { 87 88 87 __u8 *addr[2] = { NULL, (__u8 *) 0xe0000 }; 88 int i, j, length[2] = { 1024, 128*1024 }; 89 89 __u64 *sig = (__u64 *) RSDP_SIGNATURE; 90 90 91 91 /* 92 92 * Find Root System Description Pointer 93 94 95 93 * 1. search first 1K of EBDA 94 * 2. search 128K starting at 0xe0000 95 */ 96 96 97 97 addr[0] = (__u8 *) ebda; 98 98 for (i = (ebda ? 0 : 1); i < 2; i++) { 99 100 101 102 103 104 105 99 for (j = 0; j < length[i]; j += 16) { 100 if (*((__u64 *) &addr[i][j]) == *sig && rsdp_check(&addr[i][j])) { 101 acpi_rsdp = (struct acpi_rsdp *) &addr[i][j]; 102 goto rsdp_found; 103 } 104 } 105 } 106 106 107 107 return; 108 108 109 109 rsdp_found: 110 111 110 printf("%L: ACPI Root System Description Pointer\n", acpi_rsdp); 111 112 112 acpi_rsdt = (struct acpi_rsdt *) acpi_rsdp->rsdt_address; 113 113 if (acpi_rsdp->revision) acpi_xsdt = (struct acpi_xsdt *) ((__address) acpi_rsdp->xsdt_address); … … 138 138 struct acpi_sdt_header *h = (struct acpi_sdt_header *) acpi_rsdt->entry[i]; 139 139 140 140 map_sdt(h); 141 141 if (*((__u32 *) &h->signature[0])==*((__u32 *) &signature_map[j].signature[0])) { 142 142 if (!acpi_sdt_check((__u8 *) h)) -
arch/ia32/src/asm.s
re41c47e r76cec1e 96 96 push %ds 97 97 push %es 98 98 99 99 # we must fill the data segment registers 100 100 movw $16,%ax 101 101 movw %ax,%ds 102 102 movw %ax,%es 103 103 104 104 movl $(\i),%edi 105 105 pushl %ebp … … 114 114 popa 115 115 pop %ebp 116 117 118 116 117 iret 118 119 119 .if (\n-\i)-1 120 120 handler "(\i+1)",\n … … 180 180 movl %esp,%ebp 181 181 pusha 182 182 183 183 movl 8(%ebp),%edx 184 184 movl 12(%ebp),%eax 185 185 outb %al,%dx 186 186 187 187 popa 188 188 pop %ebp … … 198 198 movl %esp,%ebp 199 199 pusha 200 200 201 201 movl 8(%ebp),%edx 202 202 movl 12(%ebp),%eax 203 203 outw %ax,%dx 204 204 205 205 popa 206 206 pop %ebp … … 216 216 movl %esp,%ebp 217 217 pusha 218 218 219 219 movl 8(%ebp),%edx 220 220 movl 12(%ebp),%eax 221 221 outl %eax,%dx 222 222 223 223 popa 224 224 pop %ebp … … 240 240 movl %esp,%ebp 241 241 pusha 242 242 243 243 cld 244 244 movl CNT(%ebp),%ecx 245 245 movl DST(%ebp),%edi 246 movl SRC(%ebp),%esi 247 246 movl SRC(%ebp),%esi 247 248 248 rep movsb %ds:(%esi),%es:(%edi) 249 249 250 250 popa 251 251 pop %ebp … … 266 266 movl %esp,%ebp 267 267 pusha 268 268 269 269 cld 270 270 movl CNT(%ebp),%ecx 271 271 movl DST(%ebp),%edi 272 272 movl X(%ebp),%eax 273 273 274 274 rep stosb %al,%es:(%edi) 275 276 275 276 popa 277 277 pop %ebp 278 278 ret … … 292 292 movl %esp,%ebp 293 293 pusha 294 294 295 295 cld 296 296 movl CNT(%ebp),%ecx 297 297 movl DST(%ebp),%edi 298 298 movl X(%ebp),%eax 299 299 300 300 rep stosw %ax,%es:(%edi) 301 302 301 302 popa 303 303 pop %ebp 304 304 ret … … 321 321 322 322 pusha 323 323 324 324 cld 325 325 movl CNT(%ebp),%ecx 326 326 movl DST(%ebp),%edi 327 movl SRC(%ebp),%esi 328 327 movl SRC(%ebp),%esi 328 329 329 repe cmpsb %es:(%edi),%ds:(%esi) 330 330 movl %ecx,(%ebp) -
arch/ia32/src/boot/boot.S
re41c47e r76cec1e 57 57 movw %ax,%fs 58 58 movw %ax,%ds # kernel data + stack 59 59 movw %ax,%ss 60 60 movl $0x7c00,%esp 61 61 -
arch/ia32/src/context.s
re41c47e r76cec1e 43 43 movl 4(%esp),%eax # the caller's return %eip 44 44 movl 8(%esp),%ebx # address of the kernel_context variable to save context to 45 45 movl %eax,4(%ebx) # %eip -> ctx->pc 46 46 movl %esp,(%ebx) # %esp -> ctx->sp 47 47 … … 54 54 movl %esi,20(%eax) 55 55 movl %edi,24(%eax) 56 movl %ebp,28(%eax) 57 56 movl %ebp,28(%eax) 57 58 58 xorl %eax,%eax # context_save returns 1 59 59 incl %eax … … 65 65 # Restore CPU context from the kernel_context variable 66 66 # pointed by the 1st argument. Returns 0 in EAX. 67 # 67 # 68 68 context_restore: 69 69 movl 4(%esp),%eax # address of the kernel_context variable to restore context from … … 80 80 movl 4(%eax),%eax 81 81 movl %eax,(%esp) # ctx->pc -> saver's return %eip 82 82 xorl %eax,%eax # context_restore returns 0 83 83 ret -
arch/ia32/src/cpu/cpu.c
re41c47e r76cec1e 109 109 * Check for AMD processor. 110 110 */ 111 if (info.cpuid_ebx==AMD_CPUID_EBX && 112 info.cpuid_ecx==AMD_CPUID_ECX && 113 info.cpuid_edx==AMD_CPUID_EDX) { 114 111 if (info.cpuid_ebx==AMD_CPUID_EBX && info.cpuid_ecx==AMD_CPUID_ECX && info.cpuid_edx==AMD_CPUID_EDX) { 115 112 CPU->arch.vendor = VendorAMD; 116 113 } … … 119 116 * Check for Intel processor. 120 117 */ 121 if (info.cpuid_ebx==INTEL_CPUID_EBX && 122 info.cpuid_ecx==INTEL_CPUID_ECX && 123 info.cpuid_edx==INTEL_CPUID_EDX) { 124 118 if (info.cpuid_ebx==INTEL_CPUID_EBX && info.cpuid_ecx==INTEL_CPUID_ECX && info.cpuid_edx==INTEL_CPUID_EDX) { 125 119 CPU->arch.vendor = VendorIntel; 126 127 120 } 128 121 -
arch/ia32/src/cpuid.s
re41c47e r76cec1e 84 84 movl %ecx,8(%esi) 85 85 movl %edx,12(%esi) 86 86 87 87 popa 88 88 popl %ebp -
arch/ia32/src/drivers/ega.c
re41c47e r76cec1e 70 70 { 71 71 if (ega_cursor < SCREEN) 72 72 return; 73 73 74 74 memcopy(PA2KA(VIDEORAM) + ROW*2, PA2KA(VIDEORAM), (SCREEN - ROW)*2); … … 86 86 switch (ch) { 87 87 case '\n': 88 89 88 ega_cursor = (ega_cursor + ROW) - ega_cursor % ROW; 89 break; 90 90 case '\t': 91 92 91 ega_cursor = (ega_cursor + 8) - ega_cursor % 8; 92 break; 93 93 default: 94 95 96 94 ega_display_char(ch); 95 ega_cursor++; 96 break; 97 97 } 98 98 ega_check_cursor(); 99 99 ega_move_cursor(); 100 100 101 101 spinlock_unlock(&egalock); 102 102 cpu_priority_restore(pri); -
arch/ia32/src/drivers/i8254.c
re41c47e r76cec1e 84 84 85 85 do { 86 86 /* will read both status and count */ 87 87 outb(CLK_PORT4, 0xc2); 88 88 not_ok = (inb(CLK_PORT1)>>6)&1; … … 110 110 o2 |= inb(CLK_PORT1) << 8; 111 111 112 113 CPU->delay_loop_const = ((MAGIC_NUMBER*LOOPS)/1000) / ((t1-t2)-(o1-o2)) + 114 (((MAGIC_NUMBER*LOOPS)/1000) % ((t1-t2)-(o1-o2)) ? 1 : 0); 115 112 CPU->delay_loop_const = ((MAGIC_NUMBER*LOOPS)/1000) / ((t1-t2)-(o1-o2)) + (((MAGIC_NUMBER*LOOPS)/1000) % ((t1-t2)-(o1-o2)) ? 1 : 0); 116 113 117 114 clk1 = rdtsc(); -
arch/ia32/src/drivers/i8259.c
re41c47e r76cec1e 45 45 /* ICW2: IRQ 0 maps to INT IRQBASE */ 46 46 outb(PIC_PIC0PORT2, IVT_IRQBASE); 47 47 48 48 /* ICW3: pic1 using IRQ IRQ_PIC1 */ 49 49 outb(PIC_PIC0PORT2, 1 << IRQ_PIC1); 50 51 /* ICW4: i8086 mode */ 50 51 /* ICW4: i8086 mode */ 52 52 outb(PIC_PIC0PORT2, 1); 53 53 … … 55 55 outb(PIC_PIC1PORT1, PIC_ICW1 | PIC_NEEDICW4); 56 56 57 /* ICW2: IRQ 8 maps to INT (IVT_IRQBASE + 8) */ 57 /* ICW2: IRQ 8 maps to INT (IVT_IRQBASE + 8) */ 58 58 outb(PIC_PIC1PORT2, IVT_IRQBASE + 8); 59 59 … … 61 61 outb(PIC_PIC1PORT2, PIC_PIC1ID); 62 62 63 /* ICW4: i8086 mode */ 63 /* ICW4: i8086 mode */ 64 64 outb(PIC_PIC1PORT2, 1); 65 65 … … 76 76 disable_irqs_function = pic_disable_irqs; 77 77 eoi_function = pic_eoi; 78 78 79 79 pic_disable_irqs(0xffff); /* disable all irq's */ 80 80 pic_enable_irqs(1<<IRQ_PIC1); /* but enable pic1 */ … … 84 84 { 85 85 __u8 x; 86 86 87 87 if (irqmask & 0xff) { 88 88 x = inb(PIC_PIC0PORT2); 89 89 outb(PIC_PIC0PORT2, x & (~(irqmask & 0xff))); 90 90 } 91 91 if (irqmask >> 8) { 92 92 x = inb(PIC_PIC1PORT2); 93 93 outb(PIC_PIC1PORT2, x & (~(irqmask >> 8))); 94 94 } … … 98 98 { 99 99 __u8 x; 100 100 101 101 if (irqmask & 0xff) { 102 102 x = inb(PIC_PIC0PORT2); 103 103 outb(PIC_PIC0PORT2, x | (irqmask & 0xff)); 104 104 } 105 105 if (irqmask >> 8) { 106 106 x = inb(PIC_PIC1PORT2); 107 107 outb(PIC_PIC1PORT2, x | (irqmask >> 8)); 108 108 } … … 112 112 { 113 113 outb(0x20,0x20); 114 114 outb(0xa0,0x20); 115 115 } 116 116 -
arch/ia32/src/fpu_context.c
re41c47e r76cec1e 79 79 { 80 80 asm( 81 81 "fninit;" 82 82 ); 83 83 } -
arch/ia32/src/ia32.c
re41c47e r76cec1e 56 56 bios_init(); 57 57 i8042_init(); /* a20 bit */ 58 58 i8259_init(); /* PIC */ 59 59 i8254_init(); /* hard clock */ 60 60 -
arch/ia32/src/interrupt.c
re41c47e r76cec1e 98 98 { 99 99 reset_TS_flag(); 100 if ((CPU->fpu_owner)!=NULL) 101 { 102 fpu_lazy_context_save(&((CPU->fpu_owner)->saved_fpu_context)); 100 if ((CPU->fpu_owner)!=NULL) { 101 fpu_lazy_context_save(&((CPU->fpu_owner)->saved_fpu_context)); 103 102 (CPU->fpu_owner)->fpu_context_engaged=0; /* don't prevent migration */ 104 103 } 105 104 if(THREAD->fpu_context_exists) fpu_lazy_context_restore(&(THREAD->saved_fpu_context)); 106 105 else {fpu_init();THREAD->fpu_context_exists=1;} 107 106 CPU->fpu_owner=THREAD; 108 107 } -
arch/ia32/src/mm/frame.c
re41c47e r76cec1e 40 40 frame_not_free(0x0); 41 41 42 43 42 frame_region_not_free(0xa0000,0xff000); 43 frame_region_not_free(0xfec00000,0xffffffff); 44 44 } 45 45 } -
arch/ia32/src/mm/page.c
re41c47e r76cec1e 57 57 dba = frame_alloc(FRAME_KA | FRAME_PANIC); 58 58 memsetb(dba, PAGE_SIZE, 0); 59 59 60 60 bootstrap_dba = dba; 61 61 -
arch/ia32/src/pm.c
re41c47e r76cec1e 46 46 */ 47 47 struct descriptor gdt[GDT_ITEMS] = { 48 49 50 51 52 53 54 55 56 57 58 59 48 /* NULL descriptor */ 49 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 50 /* KTEXT descriptor */ 51 { 0xffff, 0, 0, AR_PRESENT | AR_CODE | DPL_KERNEL, 0xf, 0, 0, 1, 1, 0 }, 52 /* KDATA descriptor */ 53 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 0xf, 0, 0, 1, 1, 0 }, 54 /* UTEXT descriptor */ 55 { 0xffff, 0, 0, AR_PRESENT | AR_CODE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 56 /* UDATA descriptor */ 57 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 58 /* TSS descriptor - set up will be completed later */ 59 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } 60 60 }; 61 61 … … 72 72 void gdt_setbase(struct descriptor *d, __address base) 73 73 { 74 d->base_0_15 = base & 0xffff; 75 d->base_16_23 = ((base) >> 16) & 0xff; 76 d->base_24_31 = ((base) >> 24) & 0xff; 77 74 d->base_0_15 = base & 0xffff; 75 d->base_16_23 = ((base) >> 16) & 0xff; 76 d->base_24_31 = ((base) >> 24) & 0xff; 78 77 } 79 78 80 79 void gdt_setlimit(struct descriptor *d, __u32 limit) 81 80 { 82 83 81 d->limit_0_15 = limit & 0xffff; 82 d->limit_16_19 = (limit >> 16) & 0xf; 84 83 } 85 84 … … 105 104 struct idescriptor *d; 106 105 int i; 107 106 108 107 for (i = 0; i < IDT_ITEMS; i++) { 109 108 d = &idt[i]; -
arch/ia32/src/proc/scheduler.c
re41c47e r76cec1e 35 35 { 36 36 CPU->arch.tss->esp0 = (__address) &THREAD->kstack[THREAD_STACK_SIZE-8]; 37 37 CPU->arch.tss->ss0 = selector(KDATA_DES); 38 38 } -
arch/ia32/src/smp/apic.c
re41c47e r76cec1e 85 85 86 86 if ((pin = mps_irq_to_pin(i)) != -1) 87 87 io_apic_change_ioredtbl(pin,0xf,IVT_IRQBASE+i,LOPRI); 88 88 } 89 89 … … 137 137 if ((esr>>7) & 1) 138 138 printf("Illegal Register Address\n"); 139 139 140 140 return !esr; 141 141 } -
arch/ia32/src/smp/mps.c
re41c47e r76cec1e 244 244 l_intr_entry_cnt++; 245 245 ct_l_intr_entry((struct __l_intr_entry *) cur); 246 246 cur += 8; 247 247 break; 248 248 249 249 default: 250 250 /* -
arch/ia32/src/userspace.c
re41c47e r76cec1e 47 47 48 48 __asm__ volatile ("" 49 50 51 52 53 54 55 49 "pushl %0\n" 50 "pushl %1\n" 51 "pushl %2\n" 52 "pushl %3\n" 53 "pushl %4\n" 54 "iret" 55 : : "i" (selector(UDATA_DES) | PL_USER), "i" (USTACK_ADDRESS+(THREAD_STACK_SIZE-1)), "r" (pri), "i" (selector(UTEXT_DES) | PL_USER), "i" (UTEXT_ADDRESS)); 56 56 57 57 /* Unreachable */ -
arch/ia64/_link.ld
re41c47e r76cec1e 89 89 _hardcoded_kdata_size = kdata_end - kdata_start; 90 90 _hardcoded_load_address = 0x0000000000001000; 91 91 92 92 } -
arch/ia64/boot/_link.ld
re41c47e r76cec1e 3 3 4 4 SECTIONS { 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 5 .image 0x0000000000000000: AT (0x0000000000000000) { 6 *(.text .stub .text.* .gnu.linkonce.t.*) 7 *(.interp) 8 *(.hash) 9 *(.dynsym) 10 *(.dynstr) 11 *(.rel.init) 12 *(.rela.init) 13 *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) 14 *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) 15 *(.rel.fini) 16 *(.rela.fini) 17 *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) 18 *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) 19 *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) 20 *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) 21 *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) 22 *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) 23 *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) 24 *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) 25 *(.rel.got) 26 *(.rela.got) 27 *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) 28 *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) 29 *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) 30 *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) 31 *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) 32 *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) 33 *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) 34 *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) 35 *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) 36 *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) 37 *(.rel.plt) 38 *(.rela.plt) 39 *(.rela.IA_64.pltoff) 40 *(.init) 41 *(.plt) 42 *(.fini) 43 *(.rodata .rodata.* .gnu.linkonce.r.*) 44 *(.rodata1) 45 *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) 46 *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) 47 *(.opd) 48 *(.IA_64.unwind_info* .gnu.linkonce.ia64unwi.*) 49 *(.IA_64.unwind* .gnu.linkonce.ia64unw.*) 50 *(.eh_frame_hdr) 51 *(.preinit_array) 52 *(.init_array) 53 *(.fini_array) 54 *(.data .data.* .gnu.linkonce.d.*) 55 *(.data1) 56 *(.tdata .tdata.* .gnu.linkonce.td.*) 57 *(.tcommon) 58 *(.eh_frame) 59 *(.gcc_except_table) 60 *(.dynamic) 61 *(.jcr) 62 *(.got) 63 *(.IA_64.pltoff) 64 *(.sdata .sdata.* .gnu.linkonce.s.*) 65 *(.dynsbss) 66 *(.sbss .sbss.* .gnu.linkonce.sb.*) 67 *(.scommon) 68 *(.dynbss) 69 *(.bss .bss.* .gnu.linkonce.b.*) 70 *(COMMON) 71 } 72 72 } -
arch/ia64/include/mm/page.h
re41c47e r76cec1e 49 49 #define PTL3_INDEX_ARCH(vaddr) 0 50 50 51 #define GET_PTL0_ADDRESS_ARCH() 52 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) 53 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) 54 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) 55 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) 51 #define GET_PTL0_ADDRESS_ARCH() ((pte_t *) 0) 52 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *) 0) 53 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) ((pte_t *) 0) 54 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) ((pte_t *) 0) 55 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((pte_t *) 0) 56 56 57 57 #define SET_PTL0_ADDRESS_ARCH(ptl0) … … 61 61 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) 62 62 63 #define GET_PTL1_FLAGS_ARCH(ptl0, i) 64 #define GET_PTL2_FLAGS_ARCH(ptl1, i) 65 #define GET_PTL3_FLAGS_ARCH(ptl2, i) 66 #define GET_FRAME_FLAGS_ARCH(ptl3, i) 63 #define GET_PTL1_FLAGS_ARCH(ptl0, i) 0 64 #define GET_PTL2_FLAGS_ARCH(ptl1, i) 0 65 #define GET_PTL3_FLAGS_ARCH(ptl2, i) 0 66 #define GET_FRAME_FLAGS_ARCH(ptl3, i) 0 67 67 68 68 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) -
arch/mips/_link.ld
re41c47e r76cec1e 32 32 . = ABSOLUTE(hardcoded_ktext_size); 33 33 .patch_1 : { 34 34 LONG(ktext_end - ktext_start); 35 35 } 36 36 37 37 . = ABSOLUTE(hardcoded_kdata_size); 38 38 .patch_2 : { 39 39 LONG(kdata_end - kdata_start); 40 40 } 41 41 42 42 . = ABSOLUTE(hardcoded_load_address); 43 43 .patch_3 : { 44 44 LONG(0x80000000); 45 45 } 46 46 -
arch/mips/boot/boot.s
re41c47e r76cec1e 36 36 # move 0x80000000 to reg $8 37 37 lui $8, 0x8000 38 38 39 39 # prepare stack 40 40 lui $29, 0x8100 41 41 42 42 j $8 43 43 nop -
arch/mips/include/context.h
re41c47e r76cec1e 36 36 37 37 struct context { 38 39 40 41 __u32 r3; 42 43 44 45 __u32 r7; 46 47 48 49 __u32 r11; 50 51 52 53 __u32 r15; 54 55 56 57 __u32 r19; 58 59 60 61 __u32 r23; 62 63 64 65 __u32 r27; 66 67 68 69 70 38 __u32 r0; 39 __u32 r1; 40 __u32 r2; 41 __u32 r3; 42 __u32 r4; 43 __u32 r5; 44 __u32 r6; 45 __u32 r7; 46 __u32 r8; 47 __u32 r9; 48 __u32 r10; 49 __u32 r11; 50 __u32 r12; 51 __u32 r13; 52 __u32 r14; 53 __u32 r15; 54 __u32 r16; 55 __u32 r17; 56 __u32 r18; 57 __u32 r19; 58 __u32 r20; 59 __u32 r21; 60 __u32 r22; 61 __u32 r23; 62 __u32 r24; 63 __u32 r25; 64 __u32 r26; 65 __u32 r27; 66 __u32 r28; 67 __u32 sp; 68 __u32 r30; 69 __u32 pc; 70 __u32 pri; 71 71 }; 72 72 -
arch/mips/include/cpu.h
re41c47e r76cec1e 35 35 36 36 struct cpu_arch { 37 38 37 int imp_num; 38 int rev_num; 39 39 }; 40 40 -
arch/mips/include/mm/page.h
re41c47e r76cec1e 60 60 #define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>14)&0xfff) 61 61 62 #define GET_PTL0_ADDRESS_ARCH() 62 #define GET_PTL0_ADDRESS_ARCH() (PTL0) 63 63 #define SET_PTL0_ADDRESS_ARCH(ptl0) (PTL0 = (pte_t *)(ptl0)) 64 64 65 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) 66 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) 67 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) 68 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) 65 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *)(ptl0))[(i)].pfn<<14) 66 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 67 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 68 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *)(ptl3))[(i)].pfn<<14) 69 69 70 70 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].pfn = (a)>>14) … … 73 73 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *)(ptl3))[(i)].pfn = (a)>>14) 74 74 75 #define GET_PTL1_FLAGS_ARCH(ptl0, i) 76 #define GET_PTL2_FLAGS_ARCH(ptl1, i) 77 #define GET_PTL3_FLAGS_ARCH(ptl2, i) 78 #define GET_FRAME_FLAGS_ARCH(ptl3, i) 75 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *)(ptl0), (index_t)(i)) 76 #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT 77 #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT 78 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *)(ptl3), (index_t)(i)) 79 79 80 80 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x)) -
arch/mips/src/cpu/cpu.c
re41c47e r76cec1e 40 40 char *model; 41 41 } imp_data[] = { 42 43 { "MIPS", "R2000" },/* 0x01 */44 { "MIPS", "R3000" },/* 0x02 */45 { "MIPS", "R6000" },/* 0x03 */46 { "MIPS", " R4000/R4400" },/* 0x04 */47 48 { "MIPS", "R6000A" },/* 0x06 */49 { "IDT", "3051/3052" },/* 0x07 */50 51 52 { "MIPS", "R4200" },/* 0x0a */53 54 55 56 57 58 { "MIPS", "R8000" },/* 0x10 */59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 { "Sony", "R3000" },/* 0x21 */76 { "Toshiba", "R3000" },/* 0x22 */77 42 { "Invalid", "Invalid" }, /* 0x00 */ 43 { "MIPS", "R2000" }, /* 0x01 */ 44 { "MIPS", "R3000" }, /* 0x02 */ 45 { "MIPS", "R6000" }, /* 0x03 */ 46 { "MIPS", " R4000/R4400" }, /* 0x04 */ 47 { "LSI Logic", "R3000" }, /* 0x05 */ 48 { "MIPS", "R6000A" }, /* 0x06 */ 49 { "IDT", "3051/3052" }, /* 0x07 */ 50 { "Invalid", "Invalid" }, /* 0x08 */ 51 { "MIPS", "R10000/T5" }, /* 0x09 */ 52 { "MIPS", "R4200" }, /* 0x0a */ 53 { "Unknown", "Unknown" }, /* 0x0b */ 54 { "Unknown", "Unknown" }, /* 0x0c */ 55 { "Invalid", "Invalid" }, /* 0x0d */ 56 { "Invalid", "Invalid" }, /* 0x0e */ 57 { "Invalid", "Invalid" }, /* 0x0f */ 58 { "MIPS", "R8000" }, /* 0x10 */ 59 { "Invalid", "Invalid" }, /* 0x11 */ 60 { "Invalid", "Invalid" }, /* 0x12 */ 61 { "Invalid", "Invalid" }, /* 0x13 */ 62 { "Invalid", "Invalid" }, /* 0x14 */ 63 { "Invalid", "Invalid" }, /* 0x15 */ 64 { "Invalid", "Invalid" }, /* 0x16 */ 65 { "Invalid", "Invalid" }, /* 0x17 */ 66 { "Invalid", "Invalid" }, /* 0x18 */ 67 { "Invalid", "Invalid" }, /* 0x19 */ 68 { "Invalid", "Invalid" }, /* 0x1a */ 69 { "Invalid", "Invalid" }, /* 0x1b */ 70 { "Invalid", "Invalid" }, /* 0x1c */ 71 { "Invalid", "Invalid" }, /* 0x1d */ 72 { "Invalid", "Invalid" }, /* 0x1e */ 73 { "Invalid", "Invalid" }, /* 0x1f */ 74 { "QED", "R4600" }, /* 0x20 */ 75 { "Sony", "R3000" }, /* 0x21 */ 76 { "Toshiba", "R3000" }, /* 0x22 */ 77 { "NKK", "R3000" } /* 0x23 */ 78 78 }; 79 79 -
arch/mips/src/interrupt.c
re41c47e r76cec1e 36 36 pri_t cpu_priority_high(void) 37 37 { 38 39 40 38 pri_t pri = (pri_t) cp0_status_read(); 39 cp0_status_write(pri & ~cp0_status_ie_enabled_bit); 40 return pri; 41 41 } 42 42 43 43 pri_t cpu_priority_low(void) 44 44 { 45 46 47 45 pri_t pri = (pri_t) cp0_status_read(); 46 cp0_status_write(pri | cp0_status_ie_enabled_bit); 47 return pri; 48 48 } 49 49 50 50 void cpu_priority_restore(pri_t pri) 51 51 { 52 52 cp0_status_write(cp0_status_read() | (pri & cp0_status_ie_enabled_bit)); 53 53 } 54 54 55 55 pri_t cpu_priority_read(void) 56 56 { 57 57 return cp0_status_read(); 58 58 } 59 59 … … 85 85 case 7: /* Timer Interrupt */ 86 86 cp0_compare_write(cp0_compare_value); /* clear timer interrupt */ 87 88 cp0_count_write(0); 87 /* start counting over again */ 88 cp0_count_write(0); 89 89 clock(); 90 90 break; -
arch/mips/src/mips.c
re41c47e r76cec1e 38 38 */ 39 39 cp0_status_write(cp0_status_read() & ~(cp0_status_bev_bootstrap_bit|cp0_status_erl_error_bit)); 40 40 41 41 /* 42 42 * Unmask hardware clock interrupt. 43 43 */ 44 44 cp0_status_write(cp0_status_read() | (1<<cp0_status_im7_shift)); 45 45 46 46 /* 47 47 * Start hardware clock. -
arch/mips/src/start.S
re41c47e r76cec1e 52 52 j cache_error_handler 53 53 nop 54 54 55 55 .org 0x180 56 56 exception_entry: … … 58 58 sub $29, STACK_SPACE 59 59 REGISTERS_STORE $29 60 60 61 61 jal exception 62 62 nop 63 63 64 64 REGISTERS_LOAD $29 65 65 add $29, STACK_SPACE … … 70 70 sub $29, STACK_SPACE 71 71 REGISTERS_STORE $29 72 72 73 73 jal tlb_refill 74 74 nop 75 75 76 76 REGISTERS_LOAD $29 77 77 add $29, STACK_SPACE 78 78 79 79 eret 80 80 … … 85 85 jal cache_error 86 86 nop 87 87 88 88 REGISTERS_LOAD $29 89 89 add $29, STACK_SPACE -
arch/powerpc/_link.ld
re41c47e r76cec1e 11 11 12 12 SECTIONS { 13 14 ktext_start = .;15 *(.text);16 ktext_end = .;13 .image 0x80000000: AT (0x80000000) { 14 ktext_start = .; 15 *(.text); 16 ktext_end = .; 17 17 18 kdata_start = .; 19 kdata_end = .; 18 kdata_start = .; 19 kdata_end = .; 20 } = 0x00000000 20 21 21 } = 0x00000000 22 . = ABSOLUTE(hardcoded_ktext_size); 23 .patch_1 : { 24 LONG(ktext_end - ktext_start); 25 } 22 26 23 . = ABSOLUTE(hardcoded_ktext_size);24 .patch_1: {25 LONG(ktext_end - ktext_start);26 27 . = ABSOLUTE(hardcoded_kdata_size); 28 .patch_2 : { 29 LONG(kdata_end - kdata_start); 30 } 27 31 28 . = ABSOLUTE(hardcoded_kdata_size); 29 .patch_2 : { 30 LONG(kdata_end - kdata_start); 31 } 32 33 . = ABSOLUTE(hardcoded_load_address); 34 .patch_3 : { 35 LONG(0x80000000); 36 } 32 . = ABSOLUTE(hardcoded_load_address); 33 .patch_3 : { 34 LONG(0x80000000); 35 } 37 36 38 37 } -
include/mm/page.h
re41c47e r76cec1e 43 43 #define PAGE_EXEC_SHIFT 5 44 44 45 #define PAGE_NOT_CACHEABLE 46 #define PAGE_CACHEABLE 45 #define PAGE_NOT_CACHEABLE (0<<PAGE_CACHEABLE_SHIFT) 46 #define PAGE_CACHEABLE (1<<PAGE_CACHEABLE_SHIFT) 47 47 48 #define PAGE_PRESENT 49 #define PAGE_NOT_PRESENT 48 #define PAGE_PRESENT (0<<PAGE_PRESENT_SHIFT) 49 #define PAGE_NOT_PRESENT (1<<PAGE_PRESENT_SHIFT) 50 50 51 #define PAGE_USER 52 #define PAGE_KERNEL 51 #define PAGE_USER (1<<PAGE_USER_SHIFT) 52 #define PAGE_KERNEL (0<<PAGE_USER_SHIFT) 53 53 54 54 #define PAGE_READ (1<<PAGE_READ_SHIFT) -
include/proc/thread.h
re41c47e r76cec1e 74 74 context_t saved_context; 75 75 context_t sleep_timeout_context; 76 fpu_context_t saved_fpu_context; 77 int fpu_context_exists; 78 int fpu_context_engaged; /* Defined only if thread doesn't run. It means that fpu context is in CPU 79 that last time executes this thread. This disables migration */ 80 81 76 fpu_context_t saved_fpu_context; 77 int fpu_context_exists; 78 79 /* 80 * Defined only if thread doesn't run. 81 * It means that fpu context is in CPU that last time executes this thread. 82 * This disables migration 83 */ 84 int fpu_context_engaged; 85 82 86 waitq_t *sleep_queue; 83 87 timeout_t sleep_timeout; -
include/stackarg.h
re41c47e r76cec1e 51 51 52 52 #define va_end(ap) 53 53 54 54 55 55 #endif -
include/synch/semaphore.h
re41c47e r76cec1e 37 37 struct semaphore 38 38 { 39 39 waitq_t wq; 40 40 }; 41 41 -
include/synch/waitq.h
re41c47e r76cec1e 40 40 41 41 struct waitq { 42 43 44 42 spinlock_t lock; 43 int missed_wakeups; 44 link_t head; 45 45 }; 46 46 -
include/time/timeout.h
re41c47e r76cec1e 35 35 #include <list.h> 36 36 37 #define us2ticks(us) 37 #define us2ticks(us) ((__u64)(((__u32) (us)/(1000000/HZ)))) 38 38 39 39 typedef void (* timeout_handler)(void *arg); -
src/cpu/cpu.c
re41c47e r76cec1e 67 67 memsetb((__address) cpu_private_data, sizeof(cpu_private_data_t) * config.cpu_count, 0); 68 68 memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0); 69 69 70 70 for (i=0; i < config.cpu_count; i++) { 71 71 cpus[i].stack = (__u8 *) malloc(CPU_STACK_SIZE); -
src/main/kinit.c
re41c47e r76cec1e 95 95 #ifdef __SMP__ 96 96 if (config.cpu_count > 1) { 97 97 /* 98 98 * For each CPU, create its load balancing thread. 99 99 */ -
src/mm/frame.c
re41c47e r76cec1e 55 55 void frame_init(void) 56 56 { 57 57 if (config.cpu_active == 1) { 58 58 59 60 61 59 /* 60 * The bootstrap processor will allocate all necessary memory for frame allocation. 61 */ 62 62 63 64 65 66 67 63 frames = config.memory_size / FRAME_SIZE; 64 frame_bitmap_octets = frames / 8 + (frames % 8 > 0); 65 frame_bitmap = (__u8 *) malloc(frame_bitmap_octets); 66 if (!frame_bitmap) 67 panic("malloc/frame_bitmap\n"); 68 68 69 70 71 72 73 69 /* 70 * Mark all frames free. 71 */ 72 memsetb((__address) frame_bitmap, frame_bitmap_octets, 0); 73 frames_free = frames; 74 74 } 75 75 … … 81 81 82 82 if (config.cpu_active == 1) { 83 84 85 86 83 /* 84 * Create the memory address space map. Marked frames and frame 85 * regions cannot be used for allocation. 86 */ 87 87 frame_region_not_free(config.base, config.base + config.kernel_size); 88 88 } -
src/mm/page.c
re41c47e r76cec1e 54 54 55 55 /* TODO: implement portable way of computing page address from address */ 56 57 56 length = size + (s - (s & 0xfffff000)); 57 cnt = length/PAGE_SIZE + (length%PAGE_SIZE>0); 58 58 59 60 59 for (i = 0; i < cnt; i++) 60 map_page_to_frame(s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE, 0); 61 61 62 62 } … … 74 74 void map_page_to_frame(__address page, __address frame, int flags, __address root) 75 75 { 76 77 76 pte_t *ptl0, *ptl1, *ptl2, *ptl3; 77 __address newpt; 78 78 79 79 ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS()); 80 80 81 82 83 84 85 86 81 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { 82 newpt = frame_alloc(FRAME_KA); 83 memsetb(newpt, PAGE_SIZE, 0); 84 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); 85 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER); 86 } 87 87 88 88 ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 89 89 90 91 92 93 94 95 90 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { 91 newpt = frame_alloc(FRAME_KA); 92 memsetb(newpt, PAGE_SIZE, 0); 93 SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); 94 SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER); 95 } 96 96 97 97 ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 98 98 99 100 101 102 103 104 99 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { 100 newpt = frame_alloc(FRAME_KA); 101 memsetb(newpt, PAGE_SIZE, 0); 102 SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); 103 SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER); 104 } 105 105 106 106 ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 107 107 108 109 108 SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame); 109 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags); 110 110 } -
src/proc/scheduler.c
re41c47e r76cec1e 103 103 */ 104 104 if (test_and_set(&CPU->kcpulbstarted) == 0) { 105 105 waitq_wakeup(&CPU->kcpulb_wq, 0); 106 106 goto loop; 107 107 } … … 239 239 */ 240 240 before_thread_runs(); 241 241 spinlock_unlock(&THREAD->lock); 242 242 cpu_priority_restore(THREAD->saved_context.pri); 243 243 return; … … 279 279 switch (THREAD->state) { 280 280 case Running: 281 282 283 284 281 THREAD->state = Ready; 282 spinlock_unlock(&THREAD->lock); 283 thread_ready(THREAD); 284 break; 285 285 286 286 case Exiting: 287 frame_free((__address) THREAD->kstack); 288 if (THREAD->ustack) { 289 frame_free((__address) THREAD->ustack); 290 } 291 292 /* 293 * Detach from the containing task. 294 */ 295 spinlock_lock(&TASK->lock); 296 list_remove(&THREAD->th_link); 297 spinlock_unlock(&TASK->lock); 298 299 spinlock_unlock(&THREAD->lock); 300 301 spinlock_lock(&threads_lock); 302 list_remove(&THREAD->threads_link); 303 spinlock_unlock(&threads_lock); 304 305 spinlock_lock(&CPU->lock); 306 if(CPU->fpu_owner==THREAD) CPU->fpu_owner=NULL; 307 spinlock_unlock(&CPU->lock); 308 309 310 free(THREAD); 311 312 break; 313 287 frame_free((__address) THREAD->kstack); 288 if (THREAD->ustack) { 289 frame_free((__address) THREAD->ustack); 290 } 291 292 /* 293 * Detach from the containing task. 294 */ 295 spinlock_lock(&TASK->lock); 296 list_remove(&THREAD->th_link); 297 spinlock_unlock(&TASK->lock); 298 299 spinlock_unlock(&THREAD->lock); 300 301 spinlock_lock(&threads_lock); 302 list_remove(&THREAD->threads_link); 303 spinlock_unlock(&threads_lock); 304 305 spinlock_lock(&CPU->lock); 306 if(CPU->fpu_owner==THREAD) CPU->fpu_owner=NULL; 307 spinlock_unlock(&CPU->lock); 308 309 free(THREAD); 310 311 break; 312 314 313 case Sleeping: 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 314 /* 315 * Prefer the thread after it's woken up. 316 */ 317 THREAD->pri = -1; 318 319 /* 320 * We need to release wq->lock which we locked in waitq_sleep(). 321 * Address of wq->lock is kept in THREAD->sleep_queue. 322 */ 323 spinlock_unlock(&THREAD->sleep_queue->lock); 324 325 /* 326 * Check for possible requests for out-of-context invocation. 327 */ 328 if (THREAD->call_me) { 329 THREAD->call_me(THREAD->call_me_with); 330 THREAD->call_me = NULL; 331 THREAD->call_me_with = NULL; 332 } 333 334 spinlock_unlock(&THREAD->lock); 335 336 break; 338 337 339 338 default: 340 341 342 343 344 339 /* 340 * Entering state is unexpected. 341 */ 342 panic("tid%d: unexpected state %s\n", THREAD->tid, thread_states[THREAD->state]); 343 break; 345 344 } 346 345 THREAD = NULL; 347 346 } 348 347 349 348 THREAD = find_best_thread(); 350 349 … … 470 469 t = list_get_instance(l, thread_t, rq_link); 471 470 /* 472 471 * We don't want to steal CPU-wired threads neither threads already stolen. 473 472 * The latter prevents threads from migrating between CPU's without ever being run. 474 473 * We don't want to steal threads whose FPU context is still in CPU. 475 474 */ 476 475 spinlock_lock(&t->lock); … … 498 497 atomic_dec(&nrdy); 499 498 500 499 r->n--; 501 500 list_remove(&t->rq_link); 502 501 … … 528 527 529 528 /* 530 529 * We are not satisfied yet, focus on another CPU next time. 531 530 */ 532 531 k++; … … 553 552 554 553 goto not_satisfied; 555 554 556 555 satisfied: 557 556 /* -
src/proc/thread.c
re41c47e r76cec1e 147 147 } 148 148 spinlock_unlock(&cpu->lock); 149 149 150 150 cpu_priority_restore(pri); 151 151 } … … 278 278 void thread_sleep(__u32 sec) 279 279 { 280 280 thread_usleep(sec*1000000); 281 281 } 282 282 -
src/time/clock.c
re41c47e r76cec1e 90 90 91 91 spinlock_lock(&THREAD->lock); 92 92 if (!THREAD->ticks--) { 93 93 spinlock_unlock(&THREAD->lock); 94 94 scheduler(); -
src/time/timeout.c
re41c47e r76cec1e 106 106 spinlock_lock(&CPU->timeoutlock); 107 107 spinlock_lock(&t->lock); 108 108 109 109 if (t->cpu) 110 110 panic("t->cpu != 0"); … … 115 115 t->handler = f; 116 116 t->arg = arg; 117 117 118 118 /* 119 119 * Insert t into the active timeouts list according to t->ticks. -
test/fpu/fpu1/test.c
re41c47e r76cec1e 76 76 { 77 77 int i; 78 79 78 double lpi, pi; 79 double n, ab, ad; 80 80 81 81 waitq_sleep(&can_start); … … 86 86 pi = 0; 87 87 88 89 88 for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) { 89 double sc, cd; 90 90 91 92 93 94 95 96 91 sc = sqrt(1 - (ab*ab/4)); 92 cd = 1 - sc; 93 ad = sqrt(ab*ab/4 + cd*cd); 94 lpi = pi; 95 pi = 2 * n * ad; 96 } 97 97 98 98 if((int)(100000000*pi)!=PI_10e8)
Note:
See TracChangeset
for help on using the changeset viewer.