Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ames!apple!rutgers!mcnc!ecsvax.uncecs.edu!jrw From: jrw@uncecs.edu (James R. White) Newsgroups: comp.os.minix Subject: TurboC+1.5.5 protected mode bug Message-ID: <1990Mar25.054215.18952@uncecs.edu> Date: 25 Mar 90 05:42:15 GMT Organization: UNC Educational Computing Service Lines: 52 When using Turbo C to compile 1.5.5, there is a bug when trying to use protected mode. There are several places where a pointer is converted to a long with a cast, such as: (phys_bytes) some_pointer (where phys_bytes is typedefed to long) Now Turbo C has a large model mentality even when compiling for the tiny model, so it assigns the large model form of the pointer to the long. So while minix assumes the high order part will be zero, TC sets it to the value in the segment register. The fix I used was to cast the pointer to an int, and then to a long. With this fix (and the previously posted mpx fix) I am now able to boot my TC compiled minix 1.5.5 in both real and protected mode. Here are the diffs for protect1.c and protect.c ------------------------------ protect1.c -------------------------- 77c77 < data_base + (phys_bytes) rp->p_ldt, --- > data_base + (phys_bytes)(int) rp->p_ldt, ------------------------------ protect.c --------------------------- 156,159c156,159 < data_base + (phys_bytes) gdt; < ((struct desctableptr_s *) &gdt[BIOS_IDT_INDEX])->limit = sizeof idt - 1; < ((struct desctableptr_s *) &gdt[BIOS_IDT_INDEX])->base = < data_base + (phys_bytes) idt; --- > data_base + (phys_bytes)(int) gdt; > ((struct desctableptr_s *) &gdt[BIOS_IDT_INDEX])->limit = sizeof idt - 1; > ((struct desctableptr_s *) &gdt[BIOS_IDT_INDEX])->base = > data_base + (phys_bytes)(int) idt; 172c172 < init_dataseg(&gdt[GDT_INDEX], data_base + (phys_bytes) gdt, --- > init_dataseg(&gdt[GDT_INDEX], data_base + (phys_bytes)(int) gdt, 195c195 < init_dataseg(&gdt[TSS_INDEX], data_base + (phys_bytes) &tss, --- > init_dataseg(&gdt[TSS_INDEX], data_base + (phys_bytes)(int) &tss, 202,205c202,205 < int_gate(gtp->vec_nr, (phys_bytes) gtp->gate, < PRESENT | INT_GATE_TYPE | (gtp->privilege << DPL_SHIFT)); < } < int_gate(SYS_VECTOR, (phys_bytes) p_s_call, --- > int_gate(gtp->vec_nr, (phys_bytes)(int) gtp->gate, > PRESENT | INT_GATE_TYPE | (gtp->privilege << DPL_SHIFT)); > } > int_gate(SYS_VECTOR, (phys_bytes)(int) p_s_call, 224c224 < int_gate(SYS386_VECTOR, (phys_bytes) s_call, --- > int_gate(SYS386_VECTOR, (phys_bytes)(int) s_call, -----------------------------------------------------------------