Skip to content
Permalink
Browse files

Add forgotten unpack.c file.

  • Loading branch information
valerius2k committed Jun 18, 2020
1 parent bc8d222 commit 842b1177761bd3d5364e90b1e7ca09f9e47c15ab
Showing with 706 additions and 48 deletions.
  1. BIN filesys/os2/ansi.exe
  2. BIN filesys/os2/argenv.exe
  3. BIN filesys/os2/awk.exe
  4. BIN filesys/os2/cat.exe
  5. BIN filesys/os2/cls.exe
  6. BIN filesys/os2/cmd.exe
  7. BIN filesys/os2/comp.exe
  8. BIN filesys/os2/cut.exe
  9. BIN filesys/os2/doscalls.dll
  10. BIN filesys/os2/edtname.exe
  11. BIN filesys/os2/emx.dll
  12. BIN filesys/os2/emxlibcs.dll
  13. BIN filesys/os2/fc.exe
  14. BIN filesys/os2/find.exe
  15. BIN filesys/os2/fp.exe
  16. BIN filesys/os2/get.exe
  17. BIN filesys/os2/get2.exe
  18. BIN filesys/os2/get3.exe
  19. BIN filesys/os2/gnuintl.dll
  20. BIN filesys/os2/gnutu.dll
  21. BIN filesys/os2/infoblocks.exe
  22. BIN filesys/os2/kbdcalls.dll
  23. BIN filesys/os2/libuni.dll
  24. BIN filesys/os2/makeini.exe
  25. BIN filesys/os2/mem.exe
  26. BIN filesys/os2/mem2.exe
  27. BIN filesys/os2/mem3.exe
  28. BIN filesys/os2/mini33.exe
  29. BIN filesys/os2/minicmd-mini.exe
  30. BIN filesys/os2/minicmd.exe
  31. BIN filesys/os2/minicmd3.exe
  32. BIN filesys/os2/moncalls.dll
  33. BIN filesys/os2/more.exe
  34. BIN filesys/os2/moucalls.dll
  35. BIN filesys/os2/msg.dll
  36. BIN filesys/os2/nls.dll
  37. BIN filesys/os2/pmmerge.dll
  38. BIN filesys/os2/pmshapi.dll
  39. BIN filesys/os2/pmwin.dll
  40. BIN filesys/os2/putmsg.exe
  41. BIN filesys/os2/quecalls.dll
  42. BIN filesys/os2/scanenv.exe
  43. BIN filesys/os2/sed.exe
  44. BIN filesys/os2/sesmgr.dll
  45. BIN filesys/os2/sort.exe
  46. BIN filesys/os2/sub32.dll
  47. BIN filesys/os2/thread.exe
  48. BIN filesys/os2/uconv.dll
  49. BIN filesys/os2/unzip.exe
  50. BIN filesys/os2/utlapi.dll
  51. BIN filesys/os2/ver.exe
  52. BIN filesys/os2/viocalls.dll
  53. BIN filesys/os2/wmake.exe
  54. BIN filesys/os2/zip-emx.exe
  55. +2 −1 platform/l4env/patches/Makefile
  56. +13 −0 platform/l4env/patches/force-ds-es.patch
  57. +18 −0 platform/l4env/patches/ldtsize.patch
  58. +5 −5 platform/l4env/tools/menu.lst
  59. +1 −1 platform/l4re/build.cfg
  60. +21 −8 shared/app/os2app/kal/kal.c
  61. +22 −4 shared/app/os2app/kal/start.c
  62. +1 −1 shared/lib/ixf/lx/allocmem.c
  63. +42 −20 shared/lib/ixf/lx/loadobj.c
  64. +7 −4 shared/lib/ixf/lx/lx.c
  65. +567 −0 shared/lib/ixf/lx/unpack.c
  66. +7 −4 shared/server/os2exec/modmgr.c
BIN -5.72 KB (67%) filesys/os2/ansi.exe
Binary file not shown.
BIN -3.28 KB (72%) filesys/os2/argenv.exe
Binary file not shown.
BIN -39.5 KB (65%) filesys/os2/awk.exe
Binary file not shown.
BIN -2.33 KB (57%) filesys/os2/cat.exe
Binary file not shown.
BIN -5.65 KB (67%) filesys/os2/cls.exe
Binary file not shown.
BIN -63.3 KB (70%) filesys/os2/cmd.exe
Binary file not shown.
BIN -8.59 KB (58%) filesys/os2/comp.exe
Binary file not shown.
BIN -3.17 KB (58%) filesys/os2/cut.exe
Binary file not shown.
BIN -42.9 KB (58%) filesys/os2/doscalls.dll
Binary file not shown.
BIN -3.16 KB (73%) filesys/os2/edtname.exe
Binary file not shown.
BIN -33.6 KB (62%) filesys/os2/emx.dll
Binary file not shown.
BIN -66.1 KB (63%) filesys/os2/emxlibcs.dll
Binary file not shown.
BIN -118 KB (70%) filesys/os2/fc.exe
Binary file not shown.
BIN -3.15 KB (90%) filesys/os2/find.exe
Binary file not shown.
BIN -58.4 KB (53%) filesys/os2/fp.exe
Binary file not shown.
BIN -3.09 KB (73%) filesys/os2/get.exe
Binary file not shown.
BIN -4.4 KB (72%) filesys/os2/get2.exe
Binary file not shown.
BIN -4.36 KB (73%) filesys/os2/get3.exe
Binary file not shown.
BIN -3.67 KB (62%) filesys/os2/gnuintl.dll
Binary file not shown.
BIN -4.8 KB (60%) filesys/os2/gnutu.dll
Binary file not shown.
BIN -3.14 KB (72%) filesys/os2/infoblocks.exe
Binary file not shown.
BIN -356 Bytes (73%) filesys/os2/kbdcalls.dll
Binary file not shown.
BIN -18.6 KB (76%) filesys/os2/libuni.dll
Binary file not shown.
BIN -21 KB (72%) filesys/os2/makeini.exe
Binary file not shown.
BIN -3.4 KB (71%) filesys/os2/mem.exe
Binary file not shown.
BIN -3.74 KB (69%) filesys/os2/mem2.exe
Binary file not shown.
BIN -3.79 KB (69%) filesys/os2/mem3.exe
Binary file not shown.
BIN -2 Bytes (100%) filesys/os2/mini33.exe
Binary file not shown.
BIN -4.73 KB (48%) filesys/os2/minicmd-mini.exe
Binary file not shown.
BIN -13 KB (51%) filesys/os2/minicmd.exe 100755 → 100644
Binary file not shown.
BIN -10.7 KB (49%) filesys/os2/minicmd3.exe
Binary file not shown.
BIN -176 Bytes (75%) filesys/os2/moncalls.dll
Binary file not shown.
BIN -5.58 KB (85%) filesys/os2/more.exe
Binary file not shown.
BIN -457 Bytes (72%) filesys/os2/moucalls.dll
Binary file not shown.
BIN -130 Bytes (74%) filesys/os2/msg.dll
Binary file not shown.
BIN -128 Bytes (74%) filesys/os2/nls.dll
Binary file not shown.
BIN -57.6 KB (62%) filesys/os2/pmmerge.dll
Binary file not shown.
BIN -128 Bytes (97%) filesys/os2/pmshapi.dll
Binary file not shown.
BIN -416 Bytes (96%) filesys/os2/pmwin.dll
Binary file not shown.
BIN -449 Bytes (79%) filesys/os2/putmsg.exe
Binary file not shown.
BIN -131 Bytes (78%) filesys/os2/quecalls.dll
Binary file not shown.
BIN -3.16 KB (73%) filesys/os2/scanenv.exe
Binary file not shown.
BIN -11.3 KB (68%) filesys/os2/sed.exe
Binary file not shown.
BIN -129 Bytes (91%) filesys/os2/sesmgr.dll
Binary file not shown.
BIN -6.03 KB (71%) filesys/os2/sort.exe
Binary file not shown.
BIN -3 KB (76%) filesys/os2/sub32.dll
Binary file not shown.
BIN -3.41 KB (71%) filesys/os2/thread.exe
Binary file not shown.
BIN -4.49 KB (80%) filesys/os2/uconv.dll
Binary file not shown.
BIN -48.1 KB (65%) filesys/os2/unzip.exe
Binary file not shown.
BIN -894 Bytes (73%) filesys/os2/utlapi.dll
Binary file not shown.
BIN -5.68 KB (67%) filesys/os2/ver.exe
Binary file not shown.
BIN -1.31 KB (63%) filesys/os2/viocalls.dll
Binary file not shown.
BIN -48.7 KB (71%) filesys/os2/wmake.exe
Binary file not shown.
BIN -44.7 KB (64%) filesys/os2/zip-emx.exe
Binary file not shown.
@@ -7,7 +7,8 @@ include $(REP_DIR)/mk/osfree.mk
# contain a Makefile. If you need to change this, uncomment the following
# line and adapt it.

PATCHES = l4rm l4vfs modes modules-max
PATCHES = l4rm l4vfs modes modules-max \
force-ds-es ldtsize

apply:
@cd $(ROOT) && for file in $(PATCHES); do \
@@ -0,0 +1,13 @@
--- kernel/fiasco/src/kern/shared/entry-ia32-ux-o.S 2020-05-16 03:12:41.540635820 +0300
+++ kernel/fiasco/src/kern/shared/entry-ia32-ux.S 2020-05-16 02:55:23.784611157 +0300
@@ -179,7 +179,9 @@
CHECK_SANITY 60(%esp) /* scratches ecx */
RESET_USER_SEGMENTS 60(%esp),in_cli /* scratches ecx */

- addl $4*2,%esp /* Pop ds, es segment registers */
+ /* addl $4*2,%esp */ /* Pop ds, es segment registers */
+ popl %es /* vs */
+ popl %ds /* vs */
popl REG_GS
popl %fs /* Restore segment registers */
popa
@@ -0,0 +1,18 @@
--- kernel/fiasco/src/kern/shared/thread-ia32-amd64-o.cpp 2020-05-16 03:16:31.056641275 +0300
+++ kernel/fiasco/src/kern/shared/thread-ia32-amd64.cpp 2020-05-16 03:18:36.200644249 +0300
@@ -730,11 +730,12 @@
// Allocate the memory if needed
// LDT maximum size is one page, anything else causes too much headache
if (!s->ldt_addr())
- s->ldt_addr(Mapped_allocator::allocator()->alloc(Config::PAGE_SHIFT));
+ s->ldt_addr(Mapped_allocator::allocator()->alloc(Config::PAGE_SHIFT + 4));

- if (entry_number * Cpu::Ldt_entry_size + size > Config::PAGE_SIZE)
+ // size is hardcoded
+ if (entry_number * Cpu::Ldt_entry_size + size > Config::PAGE_SIZE * 16)
{
- WARN("set_ldt: LDT size exceeds one page, not supported.");
+ WARN("set_ldt: LDT size exceeds 65536 bytes, not supported.");
return 0;
}

@@ -1,4 +1,4 @@
default 4
default 5

set ROOT = (nd)
set T = $(ROOT)/tftpboot
@@ -92,10 +92,10 @@ module $(B)/simple_file_server -v 14
# module $(B)/os2/libuni.dll
module $(B)/os2/utlapi.dll
# module $(B)/os2/pmwin.dll
# module $(B)/os2/pmmerge.dll
# module $(B)/os2/pmshapi.dll
module $(B)/os2/pmmerge.dll
module $(B)/os2/pmshapi.dll
module $(B)/os2/cat.exe
module $(B)/os2/cut.exe
# module $(B)/os2/cut.exe
# module $(B)/os2/putmsg.exe
# module $(B)/os2/ansi.exe
# module $(B)/os2/sed.exe
@@ -114,7 +114,7 @@ module $(B)/simple_file_server -v 14
# module $(B)/os2/unzip.exe
module $(B)/os2/minicmd.exe
module $(B)/os2/mini33.exe
module $(B)/os2/argenv.exe
# module $(B)/os2/argenv.exe
# module $(B)/os2/scanenv.exe
# module $(B)/os2/edtname.exe
module $(B)/os2/sort.exe
@@ -19,7 +19,7 @@ l4api = l4f
MEM = 64
# VNC display to connect to qemu VM
# DISP = -display vnc=172.30.0.101:2
DISP = -display sdl
DISP = -display gtk

# virtualization acceleration
ACCEL=-no-kvm
@@ -621,10 +621,10 @@ long attach_module (ULONG hmod, unsigned long long area)
//l4_threadid_t pager;
unsigned short type;
unsigned long index;
unsigned char acc;
unsigned char acc, acc2;
unsigned long base, size;
struct desc desc;
int i;
int i = 0, j = 0, l;
ULONG rc;

io_log("attach_module: area=%llx, hmod=%lx\n", area, hmod);
@@ -664,37 +664,50 @@ long attach_module (ULONG hmod, unsigned long long area)
rc = attach_ds_area (ds, area, flags, addr);

// object requires 16:16 alias or is a data segment
if ( (sect.flags & OBJALIAS16) || (type & SECTYPE_WRITE) )
//if ( (sect.flags & OBJALIAS16) || (sect.flags & OBJBIGDEF) )
{
// descriptor access bits
if (type & SECTYPE_EXECUTE)
acc = 0xfa;
else
acc = 0xf3;
acc = 0xf2;

if (sect.flags & OBJBIGDEF)
acc2 = 0x04;
else
acc2 = 0;

io_log("type=%x, sect.flags=%lx\n", type, sect.flags);
io_log("acc=%x\n", acc);

j = i;
i = (unsigned long)addr >> 16;

base = i << 16;
io_log("ds %x @ %x, size %u\n", ds.ds.id, addr, size);
io_log("base=%x\n", base);

desc.limit_lo = (size - 1) & 0xffff; desc.limit_hi = (size - 1) >> 16;
desc.acc_lo = acc; desc.acc_hi = 0;
desc.acc_lo = acc; desc.acc_hi = acc2;
desc.base_lo1 = base & 0xffff;
desc.base_lo2 = (base >> 16) & 0xff;
desc.base_hi = base >> 24;

segment_ldt_set(&desc, sizeof(struct desc), i, me);
io_log("size - 1=%x\n", size - 1);
io_log("desc.limit_lo=%x\n", desc.limit_lo);
io_log("i=%x, j=%x\n", i, j);

if (i > j) // if we have a new 16-bit seg
{
segment_ldt_set(&desc, sizeof(struct desc), i, me);
}

// touch page ro
if (sect.flags & OBJALIAS16)
//if ( (sect.flags & OBJALIAS16) || (sect.flags & OBJBIGDEF) )
{
volatile char *p = base;

for (i = 0, p = (char *)base; i < size; i++, p++)
for (l = 0, p = (char *)base; l < size; l++, p++)
*p;
}
}
@@ -61,7 +61,7 @@ trampoline(struct param *param)

/* Prepare TIB GDT descriptor */
desc.limit_lo = 0x30; desc.limit_hi = 0;
desc.acc_lo = 0xF3; desc.acc_hi = 0;
desc.acc_lo = 0xf2; desc.acc_hi = 0x04; // 32-bit
desc.base_lo1 = base & 0xffff;
desc.base_lo2 = (base >> 16) & 0xff;
desc.base_hi = base >> 24;
@@ -83,7 +83,7 @@ trampoline(struct param *param)
io_log("stack top: %x\n", param->esp);

/* We have changed the stack so it now points to our LX image. */
//enter_kdebug("debug");
enter_kdebug("debug");
old_sel = tramp(argv, envp, hmod, tib_sel, param->eip);

STKOUT
@@ -126,6 +126,18 @@ unsigned long ulActual;
char *p = buf;
int i;

#pragma pack(1)

typedef struct
{
unsigned short limit;
unsigned long base;
} ldtr;

ldtr ldt = {0};

#pragma pack()

APIRET CDECL KalStartApp(struct options *opts, char *pszLoadError, ULONG cbLoadError)
{
// create LDT for tiled area
@@ -135,8 +147,8 @@ APIRET CDECL KalStartApp(struct options *opts, char *pszLoadError, ULONG cbLoadE

base = i * size;

desc.limit_lo = size & 0xffff; desc.limit_hi = size >> 16;
desc.acc_lo = 0xF3; desc.acc_hi = 0;
desc.limit_lo = (size - 1) & 0xffff; desc.limit_hi = (size - 1) >> 16;
desc.acc_lo = 0xf2; desc.acc_hi = 0;
desc.base_lo1 = base & 0xffff;
desc.base_lo2 = (base >> 16) & 0xff;
desc.base_hi = base >> 24;
@@ -163,6 +175,12 @@ APIRET CDECL KalStartApp(struct options *opts, char *pszLoadError, ULONG cbLoadE
io_log("eip: %x\n", s.ip);
io_log("esp: %x\n", s.sp);

//asm volatile("sldt %[ldt]\n\t"
// ::[ldt] "m" (ldt));

//io_log("ldt.base=%lx\n", ldt.base);
//io_log("ldt.limit=%x\n", ldt.limit);

param.eip = s.ip;
param.esp = s.sp;

@@ -1,5 +1,5 @@
//
// Memory allocation work in following logic:
// Memory allocation works in the following logic:
// 1. Get region of memory using l4dm_mem_open
// 2. After memory opened we need to map pages
// Map can be done page by page. Whole region can't be mapped if it large of L4_PAGESIZE
@@ -159,7 +159,7 @@ void *vm_alloc_obj_lx(IXFModule *ixfModule, struct o32_obj *lx_obj)
#ifndef __OS2__
#include <os3/allocmem.h>

if (lx_obj->o32_flags & OBJALIAS16)
//if (lx_obj->o32_flags & OBJALIAS16)
{
align = 16; // align 16-bit segments to 64k boundary
}
@@ -336,6 +336,8 @@ void apply_internal_fixup(struct LX_module *lx_exe_mod, struct r32_rlc *min_rlc,
unsigned long vm_start_target_obj;
unsigned long vm_source;
unsigned long vm_target;
int trg_off_size = 0;
int object_size = 0;
int i, cnt;

if (min_rlc->nr_flags & 0x04) // additive present
@@ -347,24 +349,21 @@ void apply_internal_fixup(struct LX_module *lx_exe_mod, struct r32_rlc *min_rlc,
if (additive_size)
addit = get_additive_rlc(min_rlc);

if (min_rlc->nr_stype & NRCHAIN)
{
int trg_off_size = 0;
int object_size = 0;

if (min_rlc->nr_flags & 0x10) // 32-bit target offset flag
trg_off_size = 4;
else
trg_off_size = 2;
if (min_rlc->nr_flags & 0x10) // 32-bit target offset flag
trg_off_size = 4;
else
trg_off_size = 2;

if ( (min_rlc->nr_stype & NRSRCMASK) == 0x02) // 16-bit selector fixup
trg_off_size = 0;
if ( (min_rlc->nr_stype & NRSRCMASK) == 0x02) // 16-bit selector fixup
trg_off_size = 0;

if (min_rlc->nr_flags & 0x40) // 16-bit object number/module ordinal flag
object_size = 2;
else
object_size = 1;
if (min_rlc->nr_flags & 0x40) // 16-bit object number/module ordinal flag
object_size = 2;
else
object_size = 1;

if (min_rlc->nr_stype & NRCHAIN)
{
short *srcoff = (short *)
((char *)min_rlc + 3 * 1 + object_size + trg_off_size + additive_size);

@@ -376,7 +375,14 @@ void apply_internal_fixup(struct LX_module *lx_exe_mod, struct r32_rlc *min_rlc,
vm_start_target_obj = target_object->o32_base;

/* Get address of target offset and put in source offset. */
vm_target = vm_start_target_obj + get_imp_ord1_rlc(min_rlc) + addit;
vm_target = vm_start_target_obj + addit;

if (trg_off_size)
{
// 16-bit selector fixup has target offset missing
vm_target += get_imp_ord1_rlc(min_rlc);
}

cnt = get_srcoff_cnt1_rlc(min_rlc);

//io_log("!src=%02x, trg=%02x, cnt=%02x, obj#=%02x, trgoff=%04x, addit=%d\nsrcoffs = ",
@@ -404,9 +410,17 @@ void apply_internal_fixup(struct LX_module *lx_exe_mod, struct r32_rlc *min_rlc,
vm_start_target_obj = target_object->o32_base;

/* Get address of target offset and put in source offset. */
vm_target = vm_start_target_obj + get_imp_ord1_rlc(min_rlc) + addit;
vm_target = vm_start_target_obj + addit;

if (trg_off_size)
{
// 16-bit selector fixup has target offset missing
vm_target += get_imp_ord1_rlc(min_rlc);
}

vm_source = vm_start_of_page + srcoff_cnt1;

//io_log("vm_target=%x, vm_start_target_obj=%x, get_imp_ord1_rlc(min_rlc)=%x, addit=%x\n", vm_target, vm_start_target_obj, get_imp_ord1_rlc(min_rlc), addit);
//io_log("!src=%02x, trg=%02x, srcoff=%04x, obj#=%02x, trgoff=%04x, addit=%d\n",
// min_rlc->nr_stype, min_rlc->nr_flags, srcoff_cnt1,
// min_rlc->r32_objmod, get_imp_ord1_rlc(min_rlc), addit);
@@ -606,8 +620,14 @@ void apply_internal_entry_table_fixup(struct LX_module *lx_exe_mod, struct r32_r
}
}


void apply_fixup(int type, unsigned long vm_source, unsigned long vm_target)
{
unsigned short flat_cs;

asm volatile("movw %%cs, %%ax\n\t"
"movw %%ax, %[flat_cs]\n\t"::[flat_cs] "m" (flat_cs));

switch (type)
{
case 0x00: // 8-bit fixup
@@ -624,6 +644,8 @@ void apply_fixup(int type, unsigned long vm_source, unsigned long vm_target)
unsigned short *ptr_source;
unsigned long ptr = flat2sel(vm_target);

//io_log("^^^ vm_target=%x\n", vm_target);

ptr_source = (unsigned short *)vm_source;
*ptr_source = (unsigned short)(ptr >> 16);
}
@@ -652,11 +674,11 @@ void apply_fixup(int type, unsigned long vm_source, unsigned long vm_target)
case 0x06: // 16:32 pointer fixup
{
unsigned short *ptr_source;
unsigned long ptr = flat2sel(vm_target);

ptr_source = (unsigned short *)vm_source;
*ptr_source++ = (unsigned short)(ptr >> 16);
*(unsigned long *)ptr_source = vm_target;
ptr_source += 2;
*ptr_source = flat_cs;
}
break;

@@ -644,7 +644,7 @@ int convert_imp_fixup_obj_lx(IXFModule *ixfModule,
//int object1;
int addit = 0;
int additive_size = 0;
int srcoff_cnt1;
short srcoff_cnt1;
//int fixup_source_flag;
int fixup_source;
int fixup_offset;
@@ -701,6 +701,9 @@ int convert_imp_fixup_obj_lx(IXFModule *ixfModule,
*/
while (fixup_offset < pg_end_offs_fix)
{
addit = 0;
additive_size = 0;

//io_log("fixup_offset=%lx\n", fixup_offset);
min_rlc = get_fixup_rec_tbl_obj(lx_exe_mod, fixup_offset);
//io_log("min_rlc=%lx\n", min_rlc);
@@ -755,7 +758,7 @@ int convert_imp_fixup_obj_lx(IXFModule *ixfModule,

if (min_rlc->nr_stype & NRCHAIN)
{
unsigned short *srcoff = (unsigned short *)
short *srcoff = (short *)
((char *)min_rlc + 3 * 1 + mod_ord_size +
import_ord_size + additive_size);

@@ -764,7 +767,7 @@ int convert_imp_fixup_obj_lx(IXFModule *ixfModule,
srcoff_cnt1 = srcoff[i];
io_log("mod_ord_size=%u, import_ord_size=%u, additive_size=%u\n",
mod_ord_size, import_ord_size, additive_size);
io_log("srcoff[%i]=%x, \n", i, srcoff[i]);
io_log("srcoff[%i]=%x\n", i, srcoff[i]);

ixfModule->Fixups[*fixup_counter].flags = min_rlc->nr_stype & 0xf;
ixfModule->Fixups[*fixup_counter].SrcVmAddress = (void *)(vm_start_of_page + srcoff_cnt1);
@@ -832,7 +835,7 @@ int convert_imp_fixup_obj_lx(IXFModule *ixfModule,

if (min_rlc->nr_stype & NRCHAIN)
{
unsigned short *srcoff = (unsigned short *)
short *srcoff = (short *)
((char *)min_rlc + 3 * 1 + mod_ord_size +
proc_name_off_size + additive_size);

0 comments on commit 842b117

Please sign in to comment.