freedos-32-commit Mailing List for FreeDOS-32
Status: Pre-Alpha
Brought to you by:
salvois
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(6) |
Dec
(32) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(41) |
Feb
(98) |
Mar
(101) |
Apr
(99) |
May
(112) |
Jun
(68) |
Jul
(49) |
Aug
(39) |
Sep
(94) |
Oct
(78) |
Nov
(107) |
Dec
(64) |
2006 |
Jan
(57) |
Feb
(25) |
Mar
(16) |
Apr
(31) |
May
(1) |
Jun
(7) |
Jul
(13) |
Aug
(15) |
Sep
(4) |
Oct
(9) |
Nov
|
Dec
(4) |
2007 |
Jan
|
Feb
|
Mar
(13) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Joseph <te...@gi...> - 2008-02-23 10:09:39
|
I use LS120 to boot freedos-32.<br />It cannot find a: or c:.<br />And it crash at [psmouse].<br /> |
From: <ha...@us...> - 2007-05-17 14:00:09
|
Revision: 869 http://svn.sourceforge.net/freedos-32/?rev=869&view=rev Author: hanzac Date: 2007-05-17 07:00:01 -0700 (Thu, 17 May 2007) Log Message: ----------- Add i8042_wait_read and i8042_wait_write, make it more specific Modified Paths: -------------- trunk/fd32/modules/psmouse/init.c Modified: trunk/fd32/modules/psmouse/init.c =================================================================== --- trunk/fd32/modules/psmouse/init.c 2007-03-31 07:56:12 UTC (rev 868) +++ trunk/fd32/modules/psmouse/init.c 2007-05-17 14:00:01 UTC (rev 869) @@ -23,6 +23,7 @@ #include <errno.h> #include <devices.h> #include <mouse.h> +#include <timer.h> #include "psmouse.h" @@ -70,8 +71,7 @@ static fd32_request_t request; static psmouse_info_t info; -static fd32_mousecallback_t *callback; /* The user-defined callback */ -static volatile int tmp; +static fd32_mousecallback_t *callback; /* The user-defined callback */ static int request(DWORD function, void *params) @@ -119,21 +119,42 @@ } -/* The temporary wait only for initialization */ -static void tmp_wait(void) +/* + * The i8042_wait_read() and i8042_wait_write functions wait for the i8042 to + * be ready for reading values from it / writing values to it. + * Called always with i8042_lock held. + */ +#define I8042_CTL_TIMEOUT 10000 + +static int i8042_wait_read(void) { - psctrl_status_t status; + int i = 0; + psctrl_status_t status; - for(status.data = fd32_inb(0x64); status.data&0x03; status.data = fd32_inb(0x64)) - { - if(status.s.outbuf_full) { - tmp = fd32_inb(0x60); - fd32_log_printf("[PSMOUSE] Retrieve mouse outbuf data ... %x\n", tmp); - } - } + status.data = fd32_inb(0x64); + while (!status.s.outbuf_full && (i < I8042_CTL_TIMEOUT)) { + timer_delay(50); + status.data = fd32_inb(0x64); + i++; + } + return -(i == I8042_CTL_TIMEOUT); } +static int i8042_wait_write(void) +{ + int i = 0; + psctrl_status_t status; + status.data = fd32_inb(0x64); + while (status.s.inbuf_full && (i < I8042_CTL_TIMEOUT)) { + timer_delay(50); + status.data = fd32_inb(0x64); + i++; + } + return -(i == I8042_CTL_TIMEOUT); +} + + /* The temporary handler only for initialization */ static volatile DWORD stage = 0; static void tmp_handler(int n) @@ -157,9 +178,9 @@ case 0xFA: if (psmouse_init_seq[stage].cmd != 0) { - tmp_wait(); + i8042_wait_write(); fd32_outb(0x64, psmouse_init_seq[stage].cmd); - tmp_wait(); + i8042_wait_write(); fd32_outb(0x60, psmouse_init_seq[stage].data); } else if (psmouse_init_seq[stage].data == 0) { /* Set the real interrupt handler in the end */ @@ -191,42 +212,41 @@ /* TODO: Check if the PS/2 port exists */ fd32_message("Start PS/2 mouse initialization ...\n"); - /* TODO: Save the old handler for recovery */ - fd32_irq_bind(PS2MOUSE_IRQ, tmp_handler); /* Enable mouse interface */ - tmp_wait(); + i8042_wait_write(); fd32_outb(0x64, CMD_ENABLE_MOUSE); - /* Turn on mouse interrupt */ - tmp_wait(); + i8042_wait_write(); fd32_outb(0x64, CMD_WRITE_MODE); - tmp_wait(); + i8042_wait_write(); fd32_outb(0x60, MOUSE_INTERRUPTS_ON); #ifdef __PSMOUSE_DEBUG__ - tmp_wait(); + i8042_wait_write(); fd32_outb(0x64, CMD_READ_MODE); - tmp_wait(); + i8042_wait_read(); + volatile int tmp = fd32_inb(0x60); fd32_log_printf("[PSMOUSE] PS/2 CTRL mode is: %x\n", tmp); #endif - /* Detect PS/2 mouse */ + /* TODO: Save the old handler for recovery */ + fd32_irq_bind(PS2MOUSE_IRQ, tmp_handler); + + /* TODO: Detect PS/2 mouse and check PS/2 mouse attached or not */ + /* fd32_message("[PSMOUSE] Could not find a PS/2 mouse!\n"); */ + + i8042_wait_write(); fd32_outb(0x64, CMD_WRITE_MOUSE); - tmp_wait(); - /* Check PS/2 mouse attached or not */ - if (tmp != 0xFE) { - /* Reset defaults and disable mouse data reporting */ - fd32_outb(0x60, (BYTE)PSMOUSE_CMD_RESET_DIS); + /* Reset defaults and disable mouse data reporting */ + i8042_wait_write(); + fd32_outb(0x60, (BYTE)PSMOUSE_CMD_RESET_DIS); - /* Triger the start phase through a temporary handler then wait for ready */ - WFC (stage != 0xFFFFFFFF); + /* Triger the start phase through a temporary handler then wait for ready */ + WFC (stage != 0xFFFFFFFF); - if (fd32_dev_register(request, 0, "mouse") < 0) - fd32_message("[PSMOUSE] Could not register the mouse device\n"); + if (fd32_dev_register(request, 0, "mouse") < 0) + fd32_message("[PSMOUSE] Could not register the mouse device\n"); - fd32_message("PS/2 mouse initialized!\n"); - } else { - fd32_message("[PSMOUSE] Could not find a PS/2 mouse!\n"); - } + fd32_message("PS/2 mouse initialized!\n"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-31 07:56:34
|
Revision: 868 http://svn.sourceforge.net/freedos-32/?rev=868&view=rev Author: hanzac Date: 2007-03-31 00:56:12 -0700 (Sat, 31 Mar 2007) Log Message: ----------- FS bug fix, set the drives info correctly Modified Paths: -------------- trunk/fd32/filesys/drives.c Modified: trunk/fd32/filesys/drives.c =================================================================== --- trunk/fd32/filesys/drives.c 2007-03-31 01:27:49 UTC (rev 867) +++ trunk/fd32/filesys/drives.c 2007-03-31 07:56:12 UTC (rev 868) @@ -95,8 +95,6 @@ if (drives[res].handle == handle) break; if (res != DRIVE_MAX_NUM) continue; - /* Set the block device info */ - drives[res].dev_info = bdi.flags; /* If the block device type is not what we are searching we skip it */ if ((bdi.flags & BLOCK_DEVICE_INFO_TYPEMASK) != type) continue; /* If no file system driver can handle such a partition we skip it */ @@ -117,6 +115,9 @@ drives[d].req = NULL; drives[d].handle = NULL; drives[d].dos_dpb = NULL; + /* Set the block device info */ + drives[d].dev_info = bdi.flags; + message("FS Layer: '%c' drive assigned to device '%s'\n", d + 'A', name); /* Set the default drive to this drive if boot device is known, * otherwise set the default drive to the first drive detected. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-31 01:27:48
|
Revision: 867 http://svn.sourceforge.net/freedos-32/?rev=867&view=rev Author: hanzac Date: 2007-03-30 18:27:49 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Modified Paths: -------------- trunk/fd32/modules/dpmi/src/int21.c Modified: trunk/fd32/modules/dpmi/src/int21.c =================================================================== --- trunk/fd32/modules/dpmi/src/int21.c 2007-03-31 01:27:04 UTC (rev 866) +++ trunk/fd32/modules/dpmi/src/int21.c 2007-03-31 01:27:49 UTC (rev 867) @@ -1199,15 +1199,8 @@ r->x.ax = 0x0; /* No error! */ break; case 0x0E: - res = fd32_get_block_dev_info(r->h.bl); - if (res >= 0) { - if (res&BLOCK_DEVICE_INFO_TACTIVE || - res&BLOCK_DEVICE_INFO_TLOGICAL || - res&BLOCK_DEVICE_INFO_TPRIMARY) - r->x.ax = r->h.bl; - else - res = -ENOTBLK; - } + res = 0; + r->h.al = 0; /* No support for drive mapping */ break; case 0x11: res = -0x4401; /* IOCTL capability not available */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-31 01:27:05
|
Revision: 866 http://svn.sourceforge.net/freedos-32/?rev=866&view=rev Author: hanzac Date: 2007-03-30 18:27:04 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Mouse interrupt subroutine bug fix Modified Paths: -------------- trunk/fd32/modules/dpmi/src/int33.c Modified: trunk/fd32/modules/dpmi/src/int33.c =================================================================== --- trunk/fd32/modules/dpmi/src/int33.c 2007-03-15 13:31:04 UTC (rev 865) +++ trunk/fd32/modules/dpmi/src/int33.c 2007-03-31 01:27:04 UTC (rev 866) @@ -47,6 +47,7 @@ static volatile WORD buttons; /* text mode cursor and mask */ static WORD save = 0, scrmask = 0x77ff, curmask = 0x7700; +static int cursor_visible = 0; /* interrupt subroutine */ static fd32_mouse_subroutine_t subroutine; #define CALLMASK_MOUSE_MOVE 0x01 @@ -80,12 +81,15 @@ /* Save the previous character */ save = (*screen)[text_y][text_x]; /* Display the cursor */ - (*screen)[text_y][text_x] &= scrmask; - (*screen)[text_y][text_x] ^= curmask; + if (cursor_visible) { + (*screen)[text_y][text_x] &= scrmask; + (*screen)[text_y][text_x] ^= curmask; + } } static void cb(const fd32_mousedata_t *data) { + static WORD pre_buttons = 0; buttons = data->buttons; x += data->axes[MOUSE_X]; y -= data->axes[MOUSE_Y]; @@ -102,20 +106,21 @@ if (subroutine.call_mask) { int call_mask = 0; - if (data->axes[MOUSE_X] && data->axes[MOUSE_Y]) + if (data->axes[MOUSE_X] || data->axes[MOUSE_Y]) call_mask |= CALLMASK_MOUSE_MOVE; - if (data->buttons&MOUSE_LBUT) + if (buttons&MOUSE_LBUT) call_mask |= CALLMASK_LBUTTON_PRESSED; - else + else if (pre_buttons&MOUSE_LBUT) call_mask |= CALLMASK_LBUTTON_RELEASED; - if (data->buttons&MOUSE_RBUT) + if (buttons&MOUSE_RBUT) call_mask |= CALLMASK_RBUTTON_PRESSED; - else + else if (pre_buttons&MOUSE_RBUT) call_mask |= CALLMASK_RBUTTON_RELEASED; - if (data->buttons&MOUSE_MBUT) + if (buttons&MOUSE_MBUT) call_mask |= CALLMASK_MBUTTON_PRESSED; - else + else if (pre_buttons&MOUSE_MBUT) call_mask |= CALLMASK_MBUTTON_RELEASED; + pre_buttons = buttons; if (subroutine.call_mask&call_mask) { @@ -125,8 +130,8 @@ s.ds = 0; s.es = 0; s.ss = 0; - in.x.ax = subroutine.call_mask; - in.x.bx = buttons; + in.x.ax = call_mask; + in.x.bx = buttons&(MOUSE_LBUT|MOUSE_RBUT|MOUSE_MBUT); in.x.cx = text_x*8; in.x.dx = text_y*8; in.x.si = 0; @@ -178,6 +183,7 @@ #ifdef __INT33_DEBUG__ LOG_PRINTF("Show Mouse cursor\n"); #endif + cursor_visible = 1; save = (*screen)[text_y][text_x]; (*screen)[text_y][text_x] &= scrmask; (*screen)[text_y][text_x] ^= curmask; @@ -187,6 +193,7 @@ #ifdef __INT33_DEBUG__ LOG_PRINTF("Hide mouse cursor\n"); #endif + cursor_visible = 0; (*screen)[text_y][text_x] = save; break; /* MS MOUSE v1.0+ - RETURN POSITION AND BUTTON STATUS */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-15 13:31:22
|
Revision: 865 http://svn.sourceforge.net/freedos-32/?rev=865&view=rev Author: hanzac Date: 2007-03-15 06:31:04 -0700 (Thu, 15 Mar 2007) Log Message: ----------- Modified Paths: -------------- trunk/fd32/modules/dpmi/src/int33.c Modified: trunk/fd32/modules/dpmi/src/int33.c =================================================================== --- trunk/fd32/modules/dpmi/src/int33.c 2007-03-15 13:26:58 UTC (rev 864) +++ trunk/fd32/modules/dpmi/src/int33.c 2007-03-15 13:31:04 UTC (rev 865) @@ -194,11 +194,9 @@ r->x.bx = buttons&0x07; r->x.cx = text_x*8; r->x.dx = text_y*8; - if(r->x.bx != 0) - fd32_log_printf("[MOUSE BIOS] Button clicked, cx: %x\tdx: %x\tbx: %x\n", r->x.cx, r->x.dx, r->x.bx); #ifdef __INT33_DEBUG__ if(r->x.bx != 0) - fd32_log_printf("[MOUSE BIOS] Button clicked, cx: %x\tdx: %x\tbx: %x\n", r->x.cx, r->x.dx, r->x.bx); + LOG_PRINTF("[MOUSE BIOS] Button clicked, cx: %x\tdx: %x\tbx: %x\n", r->x.cx, r->x.dx, r->x.bx); #endif break; /* MS MOUSE v1.0+ - POSITION MOUSE CURSOR */ @@ -243,7 +241,7 @@ break; /* MS MOUSE v1.0+ - DEFINE INTERRUPT SUBROUTINE PARAMETERS */ case 0x000C: - fd32_log_printf("DEFINE INTERRUPT SUBROUTINE PARAMETERS: %x\n", r->x.cx); + LOG_PRINTF("DEFINE INTERRUPT SUBROUTINE PARAMETERS: %x\n", r->x.cx); subroutine.cs = r->x.es; subroutine.ip = r->x.dx; subroutine.call_mask = r->x.cx; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-15 13:28:41
|
Revision: 864 http://svn.sourceforge.net/freedos-32/?rev=864&view=rev Author: hanzac Date: 2007-03-15 06:26:58 -0700 (Thu, 15 Mar 2007) Log Message: ----------- Change back to local_bss (name of uninitialized data) & remove the so called `global symbol address fix', dunno ... maybe I was drunk/out of mind at that time (I was not stable these days :$) or the mingw compiler made joke to me. Modified Paths: -------------- trunk/fd32/dynalink/coff.c trunk/fd32/dynalink/common.c trunk/fd32/dynalink/elf.c trunk/fd32/include/format.h trunk/fd32/kernel/exec.c Modified: trunk/fd32/dynalink/coff.c =================================================================== --- trunk/fd32/dynalink/coff.c 2007-03-11 07:08:09 UTC (rev 863) +++ trunk/fd32/dynalink/coff.c 2007-03-15 13:26:58 UTC (rev 864) @@ -290,8 +290,8 @@ } else { /* common symbol */ syms[i].section = COMMON_SYMBOL; - /* calculate the global_data_size */ - tables->global_data_size += syms[i].offset; + /* calculate the local_bss_size */ + tables->local_bss_size += syms[i].offset; } break; case 0xFFFF: Modified: trunk/fd32/dynalink/common.c =================================================================== --- trunk/fd32/dynalink/common.c 2007-03-11 07:08:09 UTC (rev 863) +++ trunk/fd32/dynalink/common.c 2007-03-15 13:26:58 UTC (rev 864) @@ -21,7 +21,7 @@ { unsigned int i, j, idx; DWORD address, destination; - DWORD global_data = tables->global_data; + DWORD local_bss = tables->local_bss; struct reloc_info *rel = s[sect].reloc; /* Setup the common space-uninitialized symbols at the first section relocation @@ -31,11 +31,8 @@ for (i = 0; i < tables->num_symbols; i++) { if (syms[i].section == COMMON_SYMBOL) { j = syms[i].offset; - if (!(tables->flags&ELF_OBJECT)) /* NOTE: COFF & ELF objects only */ - syms[i].offset = global_data - j; - else - syms[i].offset = global_data; - global_data += j; + syms[i].offset = local_bss; + local_bss += j; } else if (syms[i].section == EXTERN_SYMBOL) { #ifdef __COFF_DEBUG__ kf->log("Searching for symbol %s\n", syms[i].name); @@ -253,13 +250,13 @@ for (i = 0; i < n; i++) { needed_mem += s[i].size; } - needed_mem += tables->global_data_size; + needed_mem += tables->local_bss_size; mem_space = (BYTE *)kf->mem_alloc(needed_mem); /* Allocate for the local bss at the mean time */ - if (tables->global_data_size != 0) { - tables->global_data = (DWORD)mem_space+needed_mem-tables->global_data_size; + if (tables->local_bss_size != 0) { + tables->local_bss = (DWORD)mem_space+needed_mem-tables->local_bss_size; } else { - tables->global_data = 0; + tables->local_bss = 0; } #ifdef __ELF_DEBUG__ Modified: trunk/fd32/dynalink/elf.c =================================================================== --- trunk/fd32/dynalink/elf.c 2007-03-11 07:08:09 UTC (rev 863) +++ trunk/fd32/dynalink/elf.c 2007-03-15 13:26:58 UTC (rev 864) @@ -347,8 +347,8 @@ /* extern symbol */ syms[i].section = COMMON_SYMBOL; syms[i].offset = symbol.st_size; - /* calculate the global_data_size */ - tables->global_data_size += syms[i].offset; + /* calculate the local_bss_size */ + tables->local_bss_size += syms[i].offset; } } Modified: trunk/fd32/include/format.h =================================================================== --- trunk/fd32/include/format.h 2007-03-11 07:08:09 UTC (rev 863) +++ trunk/fd32/include/format.h 2007-03-15 13:26:58 UTC (rev 864) @@ -67,8 +67,8 @@ DWORD image_base; - DWORD global_data; - DWORD global_data_size; + DWORD local_bss; + DWORD local_bss_size; /* In PEI, it's a pei extra info */ DWORD private_info; }; Modified: trunk/fd32/kernel/exec.c =================================================================== --- trunk/fd32/kernel/exec.c 2007-03-11 07:08:09 UTC (rev 863) +++ trunk/fd32/kernel/exec.c 2007-03-15 13:26:58 UTC (rev 864) @@ -35,7 +35,7 @@ /* Initialize the table info */ tables.section_names_size = 0; - tables.global_data_size = 0; + tables.local_bss_size = 0; tables.private_info = 0; entry = rf->read_headers(kf, file, &tables); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-11 07:08:12
|
Revision: 863 http://svn.sourceforge.net/freedos-32/?rev=863&view=rev Author: hanzac Date: 2007-03-10 23:08:09 -0800 (Sat, 10 Mar 2007) Log Message: ----------- Modified Paths: -------------- trunk/fd32/modules/dpmi/include/dosexec.h trunk/fd32/modules/dpmi/src/dosexec.c trunk/fd32/modules/dpmi/src/int21.c trunk/fd32/modules/dpmi/src/int2f.c Modified: trunk/fd32/modules/dpmi/include/dosexec.h =================================================================== --- trunk/fd32/modules/dpmi/include/dosexec.h 2007-03-07 11:40:59 UTC (rev 862) +++ trunk/fd32/modules/dpmi/include/dosexec.h 2007-03-11 07:08:09 UTC (rev 863) @@ -55,8 +55,9 @@ void *ps_prevpsp; /* 38 previous psp pointer */ BYTE ps_fill2[20]; /* 3c */ BYTE ps_unix[3]; /* 50 unix style call - 0xcd 0x21 0xcb */ - BYTE ps_fill3[3]; /* 53 */ + BYTE ps_fill3[2]; /* 53 */ /* FD/32 items */ + BYTE indos_flag; void *dta; /* 56 FD32 use allocated from ps_fill3, under DOS this pointer is stored in the SDA */ WORD stubinfo_sel; BYTE def_fcb_1[16]; Modified: trunk/fd32/modules/dpmi/src/dosexec.c =================================================================== --- trunk/fd32/modules/dpmi/src/dosexec.c 2007-03-07 11:40:59 UTC (rev 862) +++ trunk/fd32/modules/dpmi/src/dosexec.c 2007-03-11 07:08:09 UTC (rev 863) @@ -62,6 +62,7 @@ ppsp->ps_environ = env_sel; ppsp->stubinfo_sel = stubinfo_sel; + ppsp->indos_flag = 0; /* Allow reentrance */ ppsp->dta = &ppsp->command_line_len; /* And now... Set the arg list!!! */ _set_psp_commandline(ppsp, args); Modified: trunk/fd32/modules/dpmi/src/int21.c =================================================================== --- trunk/fd32/modules/dpmi/src/int21.c 2007-03-07 11:40:59 UTC (rev 862) +++ trunk/fd32/modules/dpmi/src/int21.c 2007-03-11 07:08:09 UTC (rev 863) @@ -1016,6 +1016,13 @@ break; } break; + /* DOS 2+ - Get address of indos flag */ + case 0x34: + r->x.es = ((DWORD)&curpsp->indos_flag)>>4; + r->x.bx = ((DWORD)&curpsp->indos_flag)&0x0F; + res = 0; + break; + /* DOS 2+ - Get interrupt vector */ case 0x35: res = fd32_get_real_mode_int(r->h.al, &(r->x.es), &(r->x.bx)); LOG_PRINTF(("[DPMI] Get Int %x: %x %x\n", r->h.al, r->x.es, r->x.bx)); Modified: trunk/fd32/modules/dpmi/src/int2f.c =================================================================== --- trunk/fd32/modules/dpmi/src/int2f.c 2007-03-07 11:40:59 UTC (rev 862) +++ trunk/fd32/modules/dpmi/src/int2f.c 2007-03-11 07:08:09 UTC (rev 863) @@ -44,7 +44,7 @@ /* None */ break; default: - fd32_log_printf("[DPMI] Unsupported INT 0x2F EAX: 0x%lx\n", r->d.eax); + fd32_log_printf("[DPMI] Unsupported INT 2FH EAX: 0x%lx\n", r->d.eax); break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-07 11:41:04
|
Revision: 862 http://svn.sourceforge.net/freedos-32/?rev=862&view=rev Author: hanzac Date: 2007-03-07 03:40:59 -0800 (Wed, 07 Mar 2007) Log Message: ----------- * Better process management (maybe thread support) <initial> * Support Win32 programs with HX win32 DLLs <initial> * Changes to int21 and FS Drives, for support of verifying disk drives, mpxplay needs this function Modified Paths: -------------- trunk/fd32/filesys/drives.c trunk/fd32/include/exec.h trunk/fd32/include/filesys.h trunk/fd32/include/format.h trunk/fd32/kernel/exec.c trunk/fd32/kernel/process.c trunk/fd32/kernel/run.s trunk/fd32/kernel/syscalls.c trunk/fd32/modules/dpmi/src/dosexec.c trunk/fd32/modules/dpmi/src/int21.c trunk/fd32/modules/wrapper/src/private_funcs.c Modified: trunk/fd32/filesys/drives.c =================================================================== --- trunk/fd32/filesys/drives.c 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/filesys/drives.c 2007-03-07 11:40:59 UTC (rev 862) @@ -51,6 +51,7 @@ fd32_request_t *req; void *handle; void *dos_dpb; /* at Dos-memory */ + int dev_info; } Drive; @@ -93,6 +94,9 @@ for (res = 0; res < DRIVE_MAX_NUM; res++) if (drives[res].handle == handle) break; if (res != DRIVE_MAX_NUM) continue; + + /* Set the block device info */ + drives[res].dev_info = bdi.flags; /* If the block device type is not what we are searching we skip it */ if ((bdi.flags & BLOCK_DEVICE_INFO_TYPEMASK) != type) continue; /* If no file system driver can handle such a partition we skip it */ @@ -285,6 +289,15 @@ } +int fd32_get_block_dev_info(int DriveNum) +{ + if (DriveNum < DRIVE_MAX_NUM) + return drives[DriveNum].dev_info; + else + return -EINVAL; +} + + int fd32_drive_read(char Drive, void *buffer, QWORD start, DWORD count) { BlockOperations *bops; Modified: trunk/fd32/include/exec.h =================================================================== --- trunk/fd32/include/exec.h 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/include/exec.h 2007-03-07 11:40:59 UTC (rev 862) @@ -25,6 +25,7 @@ void *mem_info; void *jft; DWORD jft_size; + void *dll_entry_list; void *_context; /* Task context for switching to the previous process */ void (*_exit)(int res) __attribute__ ((noreturn)); /* Turn back the previous running state, after running a program */ @@ -51,7 +52,14 @@ } vm86; } process_params_t; +typedef struct executable_info { + DWORD exec_space; + DWORD image_base; + DWORD size; + void *dll_entry_list; +} executable_info_t; + process_info_t *fd32_get_current_pi(void); void fd32_set_current_pi(process_info_t *ppi); void fd32_set_previous_pi(process_info_t *ppi); @@ -59,6 +67,6 @@ int fd32_start_process(process_info_t *ppi, process_params_t *pparams); void fd32_stop_process(process_info_t *ppi); int fd32_exec_process(struct kern_funcs *kf, int file, struct read_funcs *rf, char *filename, char *args); -DWORD fd32_load_process(struct kern_funcs *kf, int file, struct read_funcs *rf, DWORD *exec_space, DWORD *image_base, DWORD *size); +DWORD fd32_load_executable(struct kern_funcs *kf, int file, struct read_funcs *rf, executable_info_t *execinfo); #endif Modified: trunk/fd32/include/filesys.h =================================================================== --- trunk/fd32/include/filesys.h 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/include/filesys.h 2007-03-07 11:40:59 UTC (rev 862) @@ -247,6 +247,7 @@ char fd32_drive_get_next(char Drive); void fd32_drive_set_parameter_block(char Drive, void *p); void *fd32_drive_get_parameter_block(char Drive); +int fd32_get_block_dev_info(int DriveNum); /* FS.C - File system functions */ int fd32_get_dev_info(int fd); Modified: trunk/fd32/include/format.h =================================================================== --- trunk/fd32/include/format.h 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/include/format.h 2007-03-07 11:40:59 UTC (rev 862) @@ -23,17 +23,16 @@ #define NO_ENTRY 16 #define DLL_WITH_STDCALL 32 -/* module formats */ -/* -#define MOD_ASCII 1 -#define MOD_COFF 2 -#define MOD_ELF 3 -#define MOD_MZ 4 -#define MOD_UNKNOWN 5 -#define MOD_PECOFF 6 +/* module formats +enum module_format { + MOD_ASCII, + MOD_COFF, + MOD_ELF, + MOD_PEI, + MOD_MZ, + MOD_UNKNOWN +}; */ -*/ - struct symbol_info { char *name; DWORD offset; @@ -155,6 +154,7 @@ int isELF(struct kern_funcs *kf, int f, struct read_funcs *rf); typedef int (*check_func_t)(struct kern_funcs *kf, int f, struct read_funcs *rf); +/* TODO: Load an object file not exec it! */ typedef int (*exec_func_t)(struct kern_funcs *kf, int f, struct read_funcs *rf, char *cmdline, char *args); /** \struct bin_format */ Modified: trunk/fd32/kernel/exec.c =================================================================== --- trunk/fd32/kernel/exec.c 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/kernel/exec.c 2007-03-07 11:40:59 UTC (rev 862) @@ -23,7 +23,7 @@ /* #define __EXEC_DEBUG__ */ -DWORD fd32_load_process(struct kern_funcs *kf, int file, struct read_funcs *rf, DWORD *ex_exec_space, DWORD *image_base, DWORD *ex_size) +DWORD fd32_load_executable(struct kern_funcs *kf, int file, struct read_funcs *rf, executable_info_t *execinfo) { DWORD size; DWORD exec_space; @@ -114,7 +114,7 @@ } /* The size of the execution space */ - *ex_size = size; + execinfo->size = size; if (tables.flags & NO_ENTRY) { int init_sect; @@ -138,8 +138,8 @@ sections[init_sect].base, exec_space); #endif entry += sections[init_sect].base + exec_space; - *image_base = exec_space; - *ex_exec_space = 0; + execinfo->image_base = exec_space; + execinfo->exec_space = 0; rf->free_tables(kf, &tables, symbols, sections); return entry; } else { @@ -148,8 +148,8 @@ } } else if (tables.flags & DLL_WITH_STDCALL) { entry += exec_space; - *image_base = exec_space; - *ex_exec_space = -1; /* Note: Just to notify the exec_process it"s DLL with STDCALL entry */ + execinfo->image_base = exec_space; + execinfo->exec_space = -1; /* Note: Just to notify the exec_process it"s DLL with STDCALL entry */ rf->free_tables(kf, &tables, symbols, sections); return entry; @@ -160,8 +160,8 @@ #ifdef __EXEC_DEBUG__ fd32_log_printf("[EXEC] 1) Before calling 0x%lx ...\n", entry); #endif - *ex_exec_space = exec_space; - *image_base = tables.image_base; + execinfo->exec_space = exec_space; + execinfo->image_base = tables.image_base; rf->free_tables(kf, &tables, symbols, sections); return entry; @@ -173,11 +173,15 @@ { process_info_t *ppi; process_params_t params; - int retval; + executable_info_t info; DWORD exec_space; DWORD offset; + int retval; - params.normal.entry = fd32_load_process(kf, file, rf, &exec_space, ¶ms.normal.base, ¶ms.normal.size); + params.normal.entry = fd32_load_executable(kf, file, rf, &info); + params.normal.base = info.image_base; + params.normal.size = info.size; + exec_space = info.exec_space; if (params.normal.entry == -1) return -1; Modified: trunk/fd32/kernel/process.c =================================================================== --- trunk/fd32/kernel/process.c 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/kernel/process.c 2007-03-07 11:40:59 UTC (rev 862) @@ -135,6 +135,7 @@ #endif switch (ppi->type&0x00FF) { case NORMAL_PROCESS: + /* TODO: DLLs attach ...! Add a DLL list entry in the process_info_t */ res = run(pparams->normal.entry, pparams->normal.fs_sel, (DWORD)/*args*/ppi); break; case DLL_PROCESS: Modified: trunk/fd32/kernel/run.s =================================================================== --- trunk/fd32/kernel/run.s 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/kernel/run.s 2007-03-07 11:40:59 UTC (rev 862) @@ -44,20 +44,15 @@ movl 8(%esp), %eax movw %ax, stubinfo_sel movl 4(%esp), %eax -/* - movl $0, %eax - movw stubinfo_sel, %ax - ret -*/ pusha - pushl %fs + pushl %fs movl param, %ebx pushl %ebx movl %esp, SYMBOL_NAME(current_SP) movw stubinfo_sel, %fs call *%eax popl %ebx - popl %fs + popl %fs popa movl retval, %eax ret Modified: trunk/fd32/kernel/syscalls.c =================================================================== --- trunk/fd32/kernel/syscalls.c 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/kernel/syscalls.c 2007-03-07 11:40:59 UTC (rev 862) @@ -274,6 +274,7 @@ { "fd32_drive_get_next", fd32_drive_get_next }, { "fd32_drive_set_parameter_block", fd32_drive_set_parameter_block }, { "fd32_drive_get_parameter_block", fd32_drive_get_parameter_block }, + { "fd32_get_block_dev_info", fd32_get_block_dev_info }, /* in unicode module: Symbols for Unicode support (from unicode.h) */ /* in nls module: Symbols for NLS support (from nls.h) */ /* TODO: Remove the following from the kernel */ @@ -287,8 +288,8 @@ /* Symbols for Exec and Process */ { "fd32_get_binfmt", fd32_get_binfmt }, { "fd32_set_binfmt", fd32_set_binfmt }, + { "fd32_load_executable",fd32_load_executable }, { "fd32_exec_process", fd32_exec_process }, - { "fd32_load_process", fd32_load_process }, { "fd32_start_process", fd32_start_process }, { "fd32_stop_process", fd32_stop_process }, { "fd32_new_process", fd32_new_process }, @@ -520,7 +521,7 @@ /* Get the binary format object table, ending with NULL name */ binfmt = fd32_get_binfmt(); - /* Load different modules in various binary format */ + /* Load the shared/dynamic-linking module */ for (i = 0; binfmt[i].name != NULL; i++) { if (binfmt[i].check(&kf, (int)(&f), &rf)) { @@ -528,7 +529,6 @@ break; } } - /* TODO: load the DLL, add the DLL table */ /* Search for the DLL again */ for (p = &dll_int_list; p != NULL; q = p, p = p->next) { Modified: trunk/fd32/modules/dpmi/src/dosexec.c =================================================================== --- trunk/fd32/modules/dpmi/src/dosexec.c 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/modules/dpmi/src/dosexec.c 2007-03-07 11:40:59 UTC (rev 862) @@ -72,6 +72,27 @@ strcpy(env_data + i + 4, filename); } +struct threadinfo { + DWORD pvExcept; + DWORD pvStackUserTop; /* start stackpointer */ + DWORD pvStackUserBase; + DWORD SubSystemTib; + DWORD FiberData; + DWORD pvArbitrary; + DWORD ptibSelf; /* Linear address of TIB structure */ + + DWORD unknown2; + DWORD processID; + DWORD threadID; + DWORD unknown3; + + DWORD pvTLSArray; + DWORD pProcess; + DWORD staticload; + + BYTE res[8]; /* adjust to make it 40h bytes in size */ +}; + /* NOTE: Move the structure here, Correct? */ struct stubinfo { char magic[16]; @@ -321,7 +342,8 @@ process_info_t *ppi; int retval; DWORD exec_mem; - DWORD size, exec_space, entry, base, user_stack; + DWORD entry, user_stack; + executable_info_t info; char current_drive[2]; char current_path[FD32_LFNPMAX]; @@ -329,7 +351,7 @@ kf->mem_alloc = wrapper_alloc; kf->mem_alloc_region = wrapper_alloc_region; - entry = fd32_load_process(kf, f, rf, &exec_space, &base, &size); + entry = fd32_load_executable(kf, f, rf, &info); if (entry == -1) { return -1; } @@ -339,10 +361,10 @@ ppi->_exit = wrap_restore_sp; /* Total memory allocated for wrapper execution */ - exec_mem = exec_space-base; - size += base; + exec_mem = info.exec_space-info.image_base; + info.size += info.image_base; /* HACK: Make use of the space before image base */ - user_stack = base; + user_stack = info.image_base; /* Inherit the current path from the previous process */ current_drive[0] = fd32_get_default_drive(); @@ -350,12 +372,12 @@ fd32_getcwd(current_drive, current_path); fd32_set_current_pi(ppi); fd32_chdir(current_path); - retval = wrapper_create_process(ppi, entry, exec_mem, size, user_stack, filename, args); + retval = wrapper_create_process(ppi, entry, exec_mem, info.size, user_stack, filename, args); /* Back to the previous process NOTE: TSR native programs? */ fd32_stop_process(ppi); message("Returned: %d!!!\n", retval); - mem_free(exec_mem, size); + mem_free(exec_mem, info.size); return retval; } @@ -367,12 +389,14 @@ process_info_t *ppi; process_params_t params; int retval; - DWORD exec_space; DWORD offset; + executable_info_t info; - params.normal.entry = fd32_load_process(kf, f, rf, &exec_space, ¶ms.normal.base, ¶ms.normal.size); + params.normal.entry = fd32_load_executable(kf, f, rf, &info); + params.normal.base = info.image_base; + params.normal.size = info.size; - if (params.normal.entry != -1 && exec_space != 0 && exec_space != -1) { + if (params.normal.entry != -1 && info.exec_space != 0 && info.exec_space != -1) { ppi = fd32_new_process(filename, args, MAX_OPEN_FILES); ppi->type = NORMAL_PROCESS; #ifdef __DOS_EXEC_DEBUG__ @@ -380,9 +404,9 @@ #endif if ((retval = _go32_init(ppi, params.normal.size, filename, args, get_cs(), get_ds())) == -1) return -1; - offset = exec_space - params.normal.base; + offset = info.exec_space - params.normal.base; params.normal.entry += offset; - params.normal.base = exec_space; + params.normal.base = info.exec_space; params.normal.fs_sel = retval; retval = fd32_start_process(ppi, ¶ms); /* Back to the previous process NOTE: TSR native programs? */ @@ -392,7 +416,7 @@ #endif if (!(ppi->type&RESIDENT)) { _restore_psp(); - mem_free(exec_space, params.normal.size); + mem_free(info.exec_space, params.normal.size); } return retval; } else { @@ -482,6 +506,46 @@ return out.x.ax; /* Return value */ } +static int pei_exec_process(struct kern_funcs *kf, int f, struct read_funcs *rf, + char *filename, char *args) +{ + process_info_t *ppi; + process_params_t params; + executable_info_t info; + int retval = -1; + DWORD offset; + + params.normal.entry = fd32_load_executable(kf, f, rf, &info); + params.normal.base = info.image_base; + params.normal.size = info.size; + + if (params.normal.entry != -1) { + ppi = fd32_new_process(filename, args, MAX_OPEN_FILES); + if (info.exec_space == 0) { /* Normal PEI */ + struct threadinfo *tib = (struct threadinfo *)mem_get(sizeof(struct threadinfo)); + ppi->type = NORMAL_PROCESS; + offset = info.exec_space - params.normal.base; + params.normal.entry += offset; + params.normal.base = info.exec_space; + params.normal.fs_sel = fd32_allocate_descriptors(1); + fd32_set_segment_base_address(params.normal.fs_sel, (DWORD)tib); + fd32_set_segment_limit(params.normal.fs_sel, sizeof(struct stubinfo)); + tib->ptibSelf = (DWORD)tib; + } else { /* DLL PEI */ + ppi->type = DLL_PROCESS|RESIDENT; + info.exec_space = params.normal.base; + } +fd32_log_printf("%x\n", fd32_start_process); + retval = fd32_start_process(ppi, ¶ms); + if (!(ppi->type&RESIDENT)) + mem_free(info.exec_space, params.normal.size); + /* Back to the previous process */ + fd32_stop_process(ppi); + } + + return retval; +} + /* MZ format handling for VM86 */ static int isMZ(struct kern_funcs *kf, int f, struct read_funcs *rf) { @@ -519,6 +583,8 @@ *((WORD *)(env_data+8)) = 1; /* Count of the env-strings */ } + fd32_set_binfmt("pei", NULL, pei_exec_process); + switch(option) { case DOS_VM86_EXEC: @@ -597,8 +663,6 @@ g_env_segment = env_segment; g_fcb1 = fcb1; g_fcb2 = fcb2; - /* NOTE: args[0] is the space */ - if (args != NULL) args++; *return_val = binfmt[i].exec(&kf, (int)(&f), &rf, filename, args); break; } Modified: trunk/fd32/modules/dpmi/src/int21.c =================================================================== --- trunk/fd32/modules/dpmi/src/int21.c 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/modules/dpmi/src/int21.c 2007-03-07 11:40:59 UTC (rev 862) @@ -38,6 +38,9 @@ #include "dosmem.h" #include "dosexec.h" +#include <dr-env/stdint.h> +#include <block/block.h> + #define DOS_API_INPUT_IS_UTF8 1 #if !DOS_API_INPUT_IS_UTF8 #include <unicode/unicode.h> @@ -319,6 +322,8 @@ RMREGS_SET_CARRY; if (res < sizeof(errno2dos)) r->x.ax = errno2dos[res]; + else if (res == 0x4401) + r->x.ax = 0x4401; /* IOCTL capability not available */ else if (res == 0x7100) r->x.ax = 0x7100; /* Yet another convention: LONG FILENAME */ else @@ -759,18 +764,26 @@ } /* Truename (CL=subfunction) */ case 0x60: - /* FIXME: Only subservice 01h "Get short (8.3) filename for file" is implemented */ - if (r->h.cl != 0x01) - { - res = -ENOTSUP; - break; - } /* CH=SUBST expansion flag (ignored), 80h to not resolve SUBST * DS:SI->ASCIZ long file name or path * ES:DI->64-bytes buffer for short path name */ - res = fix_path(fn, (const char *) FAR2ADDR(r->x.ds, r->x.si), sizeof(fn)); - if (res >= 0) res = fd32_sfn_truename((char *) FAR2ADDR(r->x.es, r->x.di), fn); + if (r->h.cl < 0x03) + res = fix_path(fn, (const char *) FAR2ADDR(r->x.ds, r->x.si), sizeof(fn)); + else + res = -ENOTDIR; + + if (res >= 0) { + if (r->h.cl == 0x00) + res = fd32_truename((char *) FAR2ADDR(r->x.es, r->x.di), fn, r->h.ch == 0x80 ? FD32_TNSUBST : 0); + else if (r->h.cl == 0x01) /* "Get short (8.3) filename for file" */ + res = fd32_sfn_truename((char *) FAR2ADDR(r->x.es, r->x.di), fn); + else if (r->h.cl == 0x02) + res = fd32_truename((char *) FAR2ADDR(r->x.es, r->x.di), fn, r->h.ch == 0x80 ? FD32_TNSUBST : 0); + else + res = -ENOTSUP; + } + break; /* Create or open file (BX=access mode and sharing flags, CX=attributes * for creation, DX=action, DS:SI->ASCIZ file name, DI=numeric tail hint). @@ -831,6 +844,7 @@ { int res; long long int res64; + char *buf; /* The current PSP is needed for the pointer to the DTA */ struct psp *curpsp = fd32_get_current_pi()->psp; char fn[FD32_LFNPMAX]; @@ -916,6 +930,10 @@ LOG_PRINTF(("[DPMI] Set Int %x: %x %x\n", r->h.al, r->x.ds, r->x.dx)); res = fd32_set_real_mode_int (r->h.al, r->x.ds, r->x.dx); break; + case 0x29: + fd32_log_printf("[DPMI] INT 29h: Parse filename %s\n", (char *)FAR2ADDR(r->x.ds, r->x.dx)); + res = -ENOTSUP; /* Invalid subfunction */ + break; /* DOS 1+ - GET SYSTEM DATE */ case 0x2A: { @@ -1142,13 +1160,21 @@ r->x.ax = 0x0; /* No error! */ } break; + case 0x08: + res = fd32_get_block_dev_info(r->h.bl); + if (res >= 0) { + if (res&BLOCK_DEVICE_INFO_REMOVABLE) + r->x.ax = 0x0; /* removable */ + else + r->x.ax = 0x1; /* fixed */ + } + break; case 0x09: r->x.dx = 0; res = 0; break; case 0x0D: - { - char *buf = (char *)mem_get(0x200); + buf = (char *)mem_get(0x200); fd32_drive_read('A'+r->h.bl-1, buf, 0, 1); if (r->x.cx == 0x0860) { /* disk drive */ @@ -1164,9 +1190,21 @@ mem_free((DWORD)buf, 0x200); res = 0; r->x.ax = 0x0; /* No error! */ - fd32_log_printf("[DPMI] INT 21H AX=0x%x not completed!\n", r->x.ax); break; - } + case 0x0E: + res = fd32_get_block_dev_info(r->h.bl); + if (res >= 0) { + if (res&BLOCK_DEVICE_INFO_TACTIVE || + res&BLOCK_DEVICE_INFO_TLOGICAL || + res&BLOCK_DEVICE_INFO_TPRIMARY) + r->x.ax = r->h.bl; + else + res = -ENOTBLK; + } + break; + case 0x11: + res = -0x4401; /* IOCTL capability not available */ + break; default: fd32_log_printf("[DPMI] INT 21H AX=0x%x BX=0x%x CX=0x%x DX=0x%x\n", r->x.ax, r->x.bx, r->x.cx, r->x.dx); res = -ENOSYS; /* Invalid subfunction */ @@ -1232,7 +1270,6 @@ break; /* DOS 2+ - "EXEC" - Load and/or Execute program */ case 0x4B: - fd32_log_printf("GetModuleHandle %x\n", r->d.edx); /* Only AL = 0x00 - Load and Execute - is currently supported */ if (r->h.al == 0) { ExecParams *pb = (ExecParams *) FAR2ADDR(r->x.es, r->x.bx); @@ -1249,6 +1286,7 @@ res = fix_path(fn, (const char *) FAR2ADDR(r->x.ds, r->x.dx), sizeof(fn)); LOG_PRINTF(("\t\"%s\"\n", fn)); + if (args[0] == ' ') args ++; /* NOTE: Skip the space char */ if (res >= 0) res = dos_exec(fn, pb->Env, args, pb->Fcb1, pb->Fcb2, &dos_return_code); } else if (r->h.al == 0x01) { } else if (r->h.al == 0x03) { Modified: trunk/fd32/modules/wrapper/src/private_funcs.c =================================================================== --- trunk/fd32/modules/wrapper/src/private_funcs.c 2007-03-07 11:37:19 UTC (rev 861) +++ trunk/fd32/modules/wrapper/src/private_funcs.c 2007-03-07 11:40:59 UTC (rev 862) @@ -58,21 +58,18 @@ int my_exec_process(struct kern_funcs *p, int file, struct read_funcs *parser, char *filename, char *args) { int retval; - DWORD size; - DWORD exec_space; - DWORD dyn_entry; - DWORD base; - int res; + DWORD entry; + executable_info_t info; - dyn_entry = fd32_load_process(p, file, parser, &exec_space, &base, &size); + entry = fd32_load_executable(p, file, parser, &info); fd32_kernel_close(file); fd32_log_printf("[Wrapper] Process Loaded\n"); - if (dyn_entry == -1) { + if (entry == -1) { /* We failed... */ return -1; } - if (exec_space == 0) { + if (info.exec_space == 0) { /* No entry point... We assume that we need dynamic linking */ /* This is not supported by the wrapper!!! */ message("Wrapper: Trying to load a dynamic executable???\n"); @@ -82,28 +79,22 @@ #ifdef __WRAP_DEBUG__ fd32_log_printf("[Wrapper] DynEntry = 0x%lx ExecSpace = 0x%lx Base = 0x%lx\n", - dyn_entry, exec_space, base); + entry, info.exec_space, info.image_base); #endif - res = mem_get_region(exec_space + size, STACKSIZE); - if (res < 0) { - message("Cannot allocate 0x%lx, %d\n", exec_space + size, STACKSIZE); + retval = mem_get_region(info.exec_space + info.size, STACKSIZE); + if (retval < 0) { + message("Cannot allocate 0x%lx, %d\n", info.exec_space + info.size, STACKSIZE); return -1; } /* Note: use the real entry */ - retval = my_create_process(dyn_entry, exec_space, size + STACKSIZE, - base + size + STACKSIZE, filename, args); + retval = my_create_process(entry, info.exec_space, info.size + STACKSIZE, + info.image_base + info.size + STACKSIZE, filename, args); #ifdef __WRAP_DEBUG__ message("Returned: %d!!!\n", retval); #endif - mem_free(exec_space, size); - mem_free(exec_space + size, STACKSIZE); - /* Well... And this??? - mem_free((DWORD)sections, sizeof(struct section_info)); - if (symbols != NULL) { - mem_free((DWORD)symbols, symsize); - } - */ + mem_free(info.exec_space, info.size); + mem_free(info.exec_space + info.size, STACKSIZE); return retval; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-07 11:37:20
|
Revision: 861 http://svn.sourceforge.net/freedos-32/?rev=861&view=rev Author: hanzac Date: 2007-03-07 03:37:19 -0800 (Wed, 07 Mar 2007) Log Message: ----------- Clear-up ... Modified Paths: -------------- trunk/fd32/modules/dpmi/src/int2f.c Modified: trunk/fd32/modules/dpmi/src/int2f.c =================================================================== --- trunk/fd32/modules/dpmi/src/int2f.c 2007-03-01 16:02:29 UTC (rev 860) +++ trunk/fd32/modules/dpmi/src/int2f.c 2007-03-07 11:37:19 UTC (rev 861) @@ -27,18 +27,6 @@ r->x.bx = 0; /* number of CD-ROM drive letters used */ /* r->x.cx = 0; starting drive letter (0=A:) */ break; - /* CD-ROM v2.00+ - Drive check */ - case 0x150B: - /* None */ - break; - /* MS Windows - Windows enhanced mode installation check */ - case 0x1600: - /* None */ - break; - /* MS Windows 3.1 - Identify windows version and type */ - case 0x160A: - /* None */ - break; /* MS Windows, DPMI, various - Release current virtual machine time-slice */ case 0x1680: dosidle_int(r); /* TODO: support multitasking here? */ @@ -51,20 +39,12 @@ fd32_log_printf("[DPMI] Windows get title ...\n"); r->x.ax = 0x0000; /* failed now */ break; - /* MS Windows WINOLDAP - Identify WinOldAp version */ - case 0x1700: - /* None */ - break; - /* OS/2 v2.0+ - Installation check / Get version */ - case 0x4010: - /* None */ - break; /* Extended memory specification (XMS) v2+ - Installation check */ case 0x4300: /* None */ break; default: - message("[DPMI] Unsupported INT 0x2F EAX: 0x%lx\n", r->d.eax); + fd32_log_printf("[DPMI] Unsupported INT 0x2F EAX: 0x%lx\n", r->d.eax); break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-01 16:02:29
|
Revision: 860 http://svn.sourceforge.net/freedos-32/?rev=860&view=rev Author: hanzac Date: 2007-03-01 08:02:29 -0800 (Thu, 01 Mar 2007) Log Message: ----------- FIX: free the allocated stack Modified Paths: -------------- trunk/fd32/modules/dpmi/src/handlers.s Modified: trunk/fd32/modules/dpmi/src/handlers.s =================================================================== --- trunk/fd32/modules/dpmi/src/handlers.s 2007-03-01 15:42:49 UTC (rev 859) +++ trunk/fd32/modules/dpmi/src/handlers.s 2007-03-01 16:02:29 UTC (rev 860) @@ -11,6 +11,7 @@ .text .extern SYMBOL_NAME(memcpy) .extern SYMBOL_NAME(mem_get) +.extern SYMBOL_NAME(mem_free) .extern SYMBOL_NAME(dpmi_chandler) .globl SYMBOL_NAME(chandler) @@ -23,6 +24,7 @@ /* Move eax to the stack top */ addl $(DPMI_STACK_SIZE), %eax + /* { stack frame */ push %ebp movl %esp, %ebp addl $0x08, %ebp @@ -49,12 +51,26 @@ movl %eax, 0x4(%esp) movl %ebp, (%esp) call SYMBOL_NAME(memcpy) + addl $0x0c, %esp + + /* Get the stack in eax */ + movl %esp, %eax + addl $(INT_HANDLER_PARAMS_SIZE), %eax + subl $(DPMI_STACK_SIZE), %eax subl $0x08, %ebp leave + /* } */ + + /* Free the stack */ + subl $0x08, %esp + movl $(DPMI_STACK_SIZE), 4(%esp) + movl %eax, (%esp) + call SYMBOL_NAME(mem_free) + addl $0x08, %esp ret -.text + .globl SYMBOL_NAME(farcall) SYMBOL_NAME_LABEL(farcall) push %ebp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-01 15:42:50
|
Revision: 859 http://svn.sourceforge.net/freedos-32/?rev=859&view=rev Author: hanzac Date: 2007-03-01 07:42:49 -0800 (Thu, 01 Mar 2007) Log Message: ----------- DLL loading on PE execution ... TODO: HX PE loader compatible Modified Paths: -------------- trunk/fd32/kernel/exec.c trunk/fd32/kernel/syscalls.c trunk/fd32/modules/dpmi/src/int21.c Modified: trunk/fd32/kernel/exec.c =================================================================== --- trunk/fd32/kernel/exec.c 2007-03-01 15:37:54 UTC (rev 858) +++ trunk/fd32/kernel/exec.c 2007-03-01 15:42:49 UTC (rev 859) @@ -25,13 +25,10 @@ DWORD fd32_load_process(struct kern_funcs *kf, int file, struct read_funcs *rf, DWORD *ex_exec_space, DWORD *image_base, DWORD *ex_size) { - #ifdef __EXEC_DEBUG__ - DWORD offset; - #endif DWORD size; DWORD exec_space; int bss_sect, i; - DWORD dyn_entry; + DWORD entry; struct section_info *sections; struct symbol_info *symbols = NULL; struct table_info tables; @@ -41,7 +38,7 @@ tables.global_data_size = 0; tables.private_info = 0; - dyn_entry = rf->read_headers(kf, file, &tables); + entry = rf->read_headers(kf, file, &tables); sections = (struct section_info *)mem_get(sizeof(struct section_info) * tables.num_sections); if (sections == 0) { @@ -132,43 +129,42 @@ mem_free(exec_space, size); return -1; } - dyn_entry = (DWORD)rf->import_symbol(kf, tables.num_symbols, symbols, "_init", &init_sect); + entry = (DWORD)rf->import_symbol(kf, tables.num_symbols, symbols, "_init", &init_sect); if (init_sect != -1) { #ifdef __EXEC_DEBUG__ fd32_log_printf("Found: (%d = 0x%x) 0x%lx\n", init_sect, - init_sect, dyn_entry); + init_sect, entry); fd32_log_printf(" Section Base: 0x%lx Exec Space: 0x%lx\n", sections[init_sect].base, exec_space); #endif - dyn_entry += sections[init_sect].base + exec_space; + entry += sections[init_sect].base + exec_space; *image_base = exec_space; *ex_exec_space = 0; rf->free_tables(kf, &tables, symbols, sections); - return dyn_entry; + return entry; } else { message("WARNING: Initialization function not found!\n"); return -1; } } else if (tables.flags & DLL_WITH_STDCALL) { - dyn_entry += exec_space; + entry += exec_space; *image_base = exec_space; *ex_exec_space = -1; /* Note: Just to notify the exec_process it"s DLL with STDCALL entry */ rf->free_tables(kf, &tables, symbols, sections); - return dyn_entry; + return entry; } else { /* Reloc the entry if it's a relocated (PE) executable image */ if (tables.flags & NEED_IMAGE_RELOCATION) - dyn_entry += ((struct pe_reloc_info *)sections[0].reloc)->offset; + entry += ((struct pe_reloc_info *)sections[0].reloc)->offset; #ifdef __EXEC_DEBUG__ - fd32_log_printf("[EXEC] 1) Before calling 0x%lx = 0x%lx + 0x%lx...\n", - dyn_entry + offset, dyn_entry, offset); + fd32_log_printf("[EXEC] 1) Before calling 0x%lx ...\n", entry); #endif *ex_exec_space = exec_space; *image_base = tables.image_base; rf->free_tables(kf, &tables, symbols, sections); - return dyn_entry; + return entry; } } @@ -196,7 +192,7 @@ exec_space = params.normal.base; /* TODO: ... */ } else { #ifdef __EXEC_DEBUG__ - fd32_log_printf("[EXEC] 2) Before calling 0x%lx...\n", dyn_entry); + fd32_log_printf("[EXEC] 2) Before calling 0x%lx...\n", params.normal.entry); #endif ppi->type = NORMAL_PROCESS; offset = exec_space - params.normal.base; Modified: trunk/fd32/kernel/syscalls.c =================================================================== --- trunk/fd32/kernel/syscalls.c 2007-03-01 15:37:54 UTC (rev 858) +++ trunk/fd32/kernel/syscalls.c 2007-03-01 15:42:49 UTC (rev 859) @@ -476,6 +476,13 @@ struct dll_table *get_dll_table(char *dll_name) { struct dll_int_table *p, *q; + char *filepath; + struct bin_format *binfmt; + struct kern_funcs kf; + struct read_funcs rf; + struct kernel_file f; + DWORD i; + strlwr(dll_name); /* Search for the DLL */ @@ -487,7 +494,40 @@ /* Find and Load the DLL */ message("Find and Load %s ...\n", dll_name); - /* dos_exec(dll_name, 0, 0, 0, 0, &retval); */ + + if (strcmp(dll_name, "kernel32.dll") == 0) + filepath = "\\hx\\dkrnl32.dll"; + else + filepath = dll_name; + + if (fd32_kernel_open(filepath, O_RDONLY, 0, 0, &f) < 0) + return NULL; + + kf.file_read = fd32_kernel_read; + kf.file_seek = fd32_kernel_seek; + kf.mem_alloc = mem_get; + kf.mem_alloc_region = mem_get_region; + kf.mem_free = mem_free; + kf.message = message; + kf.log = fd32_log_printf; + kf.error = message; + kf.get_dll_table = get_dll_table; + kf.add_dll_table = add_dll_table; + kf.seek_set = FD32_SEEKSET; + kf.seek_cur = FD32_SEEKCUR; + kf.file_offset = 0; + + /* Get the binary format object table, ending with NULL name */ + binfmt = fd32_get_binfmt(); + + /* Load different modules in various binary format */ + for (i = 0; binfmt[i].name != NULL; i++) + { + if (binfmt[i].check(&kf, (int)(&f), &rf)) { + binfmt[i].exec(&kf, (int)(&f), &rf, dll_name, NULL); + break; + } + } /* TODO: load the DLL, add the DLL table */ /* Search for the DLL again */ Modified: trunk/fd32/modules/dpmi/src/int21.c =================================================================== --- trunk/fd32/modules/dpmi/src/int21.c 2007-03-01 15:37:54 UTC (rev 858) +++ trunk/fd32/modules/dpmi/src/int21.c 2007-03-01 15:42:49 UTC (rev 859) @@ -1232,34 +1232,48 @@ break; /* DOS 2+ - "EXEC" - Load and/or Execute program */ case 0x4B: - { - ExecParams *pb; - char *args, *p, c[128]; - int cnt, i; - LOG_PRINTF(("[DPMI] INT 21h: Load and Execute, al=%02xh\n", r->h.al)); - pb = (ExecParams *) FAR2ADDR(r->x.es, r->x.bx); + fd32_log_printf("GetModuleHandle %x\n", r->d.edx); /* Only AL = 0x00 - Load and Execute - is currently supported */ - if (r->h.al != 0) - { + if (r->h.al == 0) { + ExecParams *pb = (ExecParams *) FAR2ADDR(r->x.es, r->x.bx); + char *args, *p; + unsigned int cnt, i; + + LOG_PRINTF(("[DPMI] INT 21h: Load and Execute, al=%02xh\n", r->h.al)); + args = p = (char *) FAR2ADDR(pb->arg_seg, pb->arg_offs); + cnt = *p; + for (i = 0; i < cnt; i++, p++) + *p = *(p+1); + *p = '\0'; + + res = fix_path(fn, (const char *) FAR2ADDR(r->x.ds, r->x.dx), sizeof(fn)); + LOG_PRINTF(("\t\"%s\"\n", fn)); + + if (res >= 0) res = dos_exec(fn, pb->Env, args, pb->Fcb1, pb->Fcb2, &dos_return_code); + } else if (r->h.al == 0x01) { + } else if (r->h.al == 0x03) { + } else if (r->h.al == 0x04) { + + /* Compatible with HX PE Loader */ + } else if (r->h.al == 0x80) { + + } else if (r->h.al == 0x81) { + } else if (r->h.al == 0x82) { /* (GetModuleHandle): Get the handle of a PE module. */ + fd32_log_printf("GetModuleHandle %x\n", r->d.edx); + } else if (r->h.al == 0x83) { /* Get next PE module handle. */ + } else if (r->h.al == 0x84) { /* (CallProc32W): Call 32-bit flat procedure from a 16-bit dll. */ + } else if (r->h.al == 0x85) { /* (GetProcAddress16): Get the address of a procedure in a 16-bit module. */ + } else if (r->h.al == 0x86) { /* (GetModuleFileName): Get a pointer to a module's full path and file name. */ + } else if (r->h.al == 0x87) { + } else if (r->h.al == 0x88) { + } else if (r->h.al == 0x91) { + } else if (r->h.al == 0x92) { + } else if (r->h.al == 0x93) { + } else if (r->h.al == 0x94) { + } else { res = -ENOTSUP; /* Invalid subfunction */ - break; } - p = (char *) FAR2ADDR(pb->arg_seg, pb->arg_offs); - cnt = *p++; - if (cnt == 0) { - args = NULL; - } else { - for (i = 0; i < cnt; i++) { - c[i] = *p++; - } - c[i] = 0; - args = c; - } - res = fix_path(fn, (const char *) FAR2ADDR(r->x.ds, r->x.dx), sizeof(fn)); - LOG_PRINTF((" dos_exec: \"%s\"\n", fn)); - if (res >= 0) res = dos_exec(fn, pb->Env, args, pb->Fcb1, pb->Fcb2, &dos_return_code); break; - } /* DOS 2+ - Get return code */ case 0x4D: LOG_PRINTF(("[DPMI] INT 21h: Get return code: %02xh\n", dos_return_code)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-01 15:37:54
|
Revision: 858 http://svn.sourceforge.net/freedos-32/?rev=858&view=rev Author: hanzac Date: 2007-03-01 07:37:54 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Modified Paths: -------------- trunk/fd32/modules/dpmi/Makefile Modified: trunk/fd32/modules/dpmi/Makefile =================================================================== --- trunk/fd32/modules/dpmi/Makefile 2007-03-01 15:37:24 UTC (rev 857) +++ trunk/fd32/modules/dpmi/Makefile 2007-03-01 15:37:54 UTC (rev 858) @@ -11,13 +11,14 @@ include $(OSLIB)/config.mk INCL = $(OSLIB) -LIB_PATH = $(OSLIB)/lib/ +LIB_PATH = $(OSLIB)/lib/ LIB_DIR = $(OSLIB)\lib #DEBUG = -D__DEBUG__ -D__DPMI_DEBUG__ -D__DPMIMEM_DEBUG__ -D__RM_INT_DEBUG__ CONFIG = -DENABLE_BIOSVGA C_OPT += -I../../include -I./include -I../include -I$(MODULES) -I$(PORTAB) $(CONFIG) $(DEBUG) +ASM_OPT += -I./include LINK_OPT = -Bstatic OBJS = init.o chandler.o dpmimem.o dpmiexc.o rmint.o ldtmanag.o handlers.o \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-01 15:37:24
|
Revision: 857 http://svn.sourceforge.net/freedos-32/?rev=857&view=rev Author: hanzac Date: 2007-03-01 07:37:24 -0800 (Thu, 01 Mar 2007) Log Message: ----------- DPMI kernel stack allocation moved into handlers.s Modified Paths: -------------- trunk/fd32/modules/dpmi/include/dpmi.h Added Paths: ----------- trunk/fd32/modules/dpmi/include/const.h Added: trunk/fd32/modules/dpmi/include/const.h =================================================================== --- trunk/fd32/modules/dpmi/include/const.h (rev 0) +++ trunk/fd32/modules/dpmi/include/const.h 2007-03-01 15:37:24 UTC (rev 857) @@ -0,0 +1,10 @@ +#ifndef __DPMI_CONST_H +#define __DPMI_CONST_H + +/* DPMI kernel-mode stack size */ +#define DPMI_STACK_SIZE 0x2000 + +/* Interrupt switch context size */ +#define INT_HANDLER_PARAMS_SIZE 0x64 + +#endif Modified: trunk/fd32/modules/dpmi/include/dpmi.h =================================================================== --- trunk/fd32/modules/dpmi/include/dpmi.h 2007-03-01 15:36:24 UTC (rev 856) +++ trunk/fd32/modules/dpmi/include/dpmi.h 2007-03-01 15:37:24 UTC (rev 857) @@ -1,8 +1,6 @@ #ifndef __FD32_DPMI_H #define __FD32_DPMI_H -#define DPMI_STACK_SIZE 0x2000 - /* VM86 extended */ #define VM86_EXT 1 @@ -86,8 +84,6 @@ } h; }; -extern DWORD dpmi_stack; -extern DWORD dpmi_stack_top; extern struct ll_cpu_info cpu; static inline void dpmi_return(int res, union regs *r) @@ -112,4 +108,3 @@ void int_redirect_to_rmint(DWORD intnum, volatile union regs *r); #endif /* __FD32_DPMI_H */ - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2007-03-01 15:36:27
|
Revision: 856 http://svn.sourceforge.net/freedos-32/?rev=856&view=rev Author: hanzac Date: 2007-03-01 07:36:24 -0800 (Thu, 01 Mar 2007) Log Message: ----------- DPMI kernel stack allocation moved into handlers.s Modified Paths: -------------- trunk/fd32/modules/dpmi/src/chandler.c trunk/fd32/modules/dpmi/src/dosexec.c trunk/fd32/modules/dpmi/src/handlers.s trunk/fd32/modules/dpmi/src/init.c trunk/fd32/modules/dpmi/src/rmint.c Modified: trunk/fd32/modules/dpmi/src/chandler.c =================================================================== --- trunk/fd32/modules/dpmi/src/chandler.c 2006-12-28 21:54:35 UTC (rev 855) +++ trunk/fd32/modules/dpmi/src/chandler.c 2007-03-01 15:36:24 UTC (rev 856) @@ -109,7 +109,6 @@ void int_redirect_to_bios(DWORD intnum, volatile union regs *r) { DWORD f; - DWORD stack_mem, pre_stack_mem; X_REGS16 regs_r; X_SREGS16 selectors_r; @@ -126,15 +125,7 @@ selectors_r.ds = r->d.vm86_ds; } - /* Use the new dpmi stack */ - pre_stack_mem = dpmi_stack; - stack_mem = dpmi_stack = mem_get(DPMI_STACK_SIZE); - dpmi_stack_top = dpmi_stack+DPMI_STACK_SIZE; vm86_callBIOS(intnum, ®s_r, ®s_r, &selectors_r); - /* Restore the previous stack */ - dpmi_stack = pre_stack_mem; - dpmi_stack_top = dpmi_stack+DPMI_STACK_SIZE; - mem_free(stack_mem, DPMI_STACK_SIZE); r->x.ax = regs_r.x.ax; r->x.bx = regs_r.x.bx; Modified: trunk/fd32/modules/dpmi/src/dosexec.c =================================================================== --- trunk/fd32/modules/dpmi/src/dosexec.c 2006-12-28 21:54:35 UTC (rev 855) +++ trunk/fd32/modules/dpmi/src/dosexec.c 2007-03-01 15:36:24 UTC (rev 856) @@ -321,7 +321,6 @@ process_info_t *ppi; int retval; DWORD exec_mem; - DWORD stack_mem; DWORD size, exec_space, entry, base, user_stack; char current_drive[2]; char current_path[FD32_LFNPMAX]; @@ -339,10 +338,6 @@ ppi = fd32_new_process(filename, args, MAX_OPEN_FILES); ppi->_exit = wrap_restore_sp; - dpmi_stack = 0; /* Disable the stack switch in chandler */ - dpmi_stack_top = 0xFFFFFFFF; - - stack_mem = mem_get(DPMI_STACK_SIZE); /* Total memory allocated for wrapper execution */ exec_mem = exec_space-base; size += base; @@ -360,7 +355,6 @@ fd32_stop_process(ppi); message("Returned: %d!!!\n", retval); - mem_free(stack_mem, DPMI_STACK_SIZE); mem_free(exec_mem, size); return retval; @@ -390,9 +384,6 @@ params.normal.entry += offset; params.normal.base = exec_space; params.normal.fs_sel = retval; - /* Disable the stack switch in chandler */ - dpmi_stack = 0; - dpmi_stack_top = 0xFFFFFFFF; retval = fd32_start_process(ppi, ¶ms); /* Back to the previous process NOTE: TSR native programs? */ fd32_stop_process(ppi); @@ -419,7 +410,6 @@ struct psp *ppsp; X_REGS16 in, out; X_SREGS16 s; - DWORD stack_mem, pre_stack_mem; BYTE *exec_text; DWORD exec_size; WORD load_seg, exec_seg; @@ -480,18 +470,10 @@ params.vm86.out_regs = &out; params.vm86.seg_regs = &s; params.vm86.prev_cpu_context = ppi->_context; - /* Use the new dpmi stack */ - pre_stack_mem = dpmi_stack; - stack_mem = dpmi_stack = mem_get(DPMI_STACK_SIZE); - dpmi_stack_top = dpmi_stack+DPMI_STACK_SIZE; /* Call in VM86 mode */ out.x.ax = fd32_start_process(ppi, ¶ms); /* Back to the previous process */ fd32_stop_process(ppi); - /* Restore the previous stack */ - dpmi_stack = pre_stack_mem; - dpmi_stack_top = dpmi_stack+DPMI_STACK_SIZE; - mem_free(stack_mem, DPMI_STACK_SIZE); mem_free((DWORD)ppi->_context, sizeof(struct tss)); if (!(ppi->type & RESIDENT)) Modified: trunk/fd32/modules/dpmi/src/handlers.s =================================================================== --- trunk/fd32/modules/dpmi/src/handlers.s 2006-12-28 21:54:35 UTC (rev 855) +++ trunk/fd32/modules/dpmi/src/handlers.s 2007-03-01 15:36:24 UTC (rev 856) @@ -6,58 +6,54 @@ #include <ll/i386/sel.h> #include <ll/i386/linkage.h> +#include "const.h" -#define INT_HANDLER_PARAMS_SIZE 0x64 - .text .extern SYMBOL_NAME(memcpy) +.extern SYMBOL_NAME(mem_get) .extern SYMBOL_NAME(dpmi_chandler) -.extern SYMBOL_NAME(dpmi_stack) -.extern SYMBOL_NAME(dpmi_stack_top) .globl SYMBOL_NAME(chandler) SYMBOL_NAME_LABEL(chandler) - movl %esp, %eax - cmpl SYMBOL_NAME(dpmi_stack), %eax - jbe STACK_SWITCH - cmpl SYMBOL_NAME(dpmi_stack_top), %eax - ja STACK_SWITCH - jmp SYMBOL_NAME(dpmi_chandler) + /* Allocate new stack */ + subl $0x04, %esp + movl $(DPMI_STACK_SIZE), (%esp) + call SYMBOL_NAME(mem_get) + addl $0x04, %esp + /* Move eax to the stack top */ + addl $(DPMI_STACK_SIZE), %eax -STACK_SWITCH: - push %ebp - movl %esp, %ebp - addl $0x08, %ebp + push %ebp + movl %esp, %ebp + addl $0x08, %ebp - /* Switch to the new stack */ - movl SYMBOL_NAME(dpmi_stack_top), %eax - subl $(INT_HANDLER_PARAMS_SIZE), %eax - /* SS is always X_FLATDATA_SEL */ - movl %eax, %esp - - subl $0x10, %esp - /* Copy the parameters to the new stack */ - movl $(INT_HANDLER_PARAMS_SIZE), 0x8(%esp) - movl %ebp, 0x4(%esp) - movl %eax, (%esp) - call SYMBOL_NAME(memcpy) - addl $0x10, %esp - - call SYMBOL_NAME(dpmi_chandler) - - subl $0x10, %esp - /* Copy back the parameters */ - movl $(INT_HANDLER_PARAMS_SIZE), 0x8(%esp) - movl %ebp, (%esp) - movl SYMBOL_NAME(dpmi_stack_top), %eax - subl $(INT_HANDLER_PARAMS_SIZE), %eax - movl %eax, 0x4(%esp) - call SYMBOL_NAME(memcpy) - - subl $0x08, %ebp - leave - ret + /* Switch to the new stack, SS is always X_FLATDATA_SEL */ + movl %eax, %esp + subl $(INT_HANDLER_PARAMS_SIZE), %esp + movl %esp, %eax + /* Copy the parameters to the new stack */ + subl $0x0c, %esp + movl $(INT_HANDLER_PARAMS_SIZE), 0x8(%esp) + movl %ebp, 0x4(%esp) + movl %eax, (%esp) + call SYMBOL_NAME(memcpy) + addl $0x0c, %esp + + call SYMBOL_NAME(dpmi_chandler) + + movl %esp, %eax + /* Copy back the parameters */ + subl $0x0c, %esp + movl $(INT_HANDLER_PARAMS_SIZE), 0x8(%esp) + movl %eax, 0x4(%esp) + movl %ebp, (%esp) + call SYMBOL_NAME(memcpy) + + subl $0x08, %ebp + leave + ret + .text .globl SYMBOL_NAME(farcall) SYMBOL_NAME_LABEL(farcall) Modified: trunk/fd32/modules/dpmi/src/init.c =================================================================== --- trunk/fd32/modules/dpmi/src/init.c 2006-12-28 21:54:35 UTC (rev 855) +++ trunk/fd32/modules/dpmi/src/init.c 2007-03-01 15:36:24 UTC (rev 856) @@ -25,8 +25,6 @@ #endif extern char use_biosmouse; -DWORD dpmi_stack; -DWORD dpmi_stack_top; struct ll_cpu_info cpu; static struct option dpmi_options[] = Modified: trunk/fd32/modules/dpmi/src/rmint.c =================================================================== --- trunk/fd32/modules/dpmi/src/rmint.c 2006-12-28 21:54:35 UTC (rev 855) +++ trunk/fd32/modules/dpmi/src/rmint.c 2007-03-01 15:36:24 UTC (rev 856) @@ -27,7 +27,6 @@ static int dpmi_rmint_to_bios(DWORD intnum, volatile union rmregs *r) { DWORD f; - DWORD stack_mem, pre_stack_mem; X_REGS16 regs_r; X_SREGS16 selectors_r; @@ -42,15 +41,7 @@ selectors_r.es = r->x.es; selectors_r.ds = r->x.ds; - /* Use the new dpmi stack */ - pre_stack_mem = dpmi_stack; - stack_mem = dpmi_stack = mem_get(DPMI_STACK_SIZE); - dpmi_stack_top = dpmi_stack+DPMI_STACK_SIZE; vm86_callBIOS(intnum, ®s_r, ®s_r, &selectors_r); - /* Restore the previous stack */ - dpmi_stack = pre_stack_mem; - dpmi_stack_top = dpmi_stack+DPMI_STACK_SIZE; - mem_free(stack_mem, DPMI_STACK_SIZE); r->x.ax = regs_r.x.ax; r->x.bx = regs_r.x.bx; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-12-28 21:54:36
|
Revision: 855 http://svn.sourceforge.net/freedos-32/?rev=855&view=rev Author: salvois Date: 2006-12-28 13:54:35 -0800 (Thu, 28 Dec 2006) Log Message: ----------- FAT32 FSInfo sector written to disk on sync only if it has been modified. Modified Paths: -------------- trunk/fd32/modules/fat/alloc.c trunk/fd32/modules/fat/fat.h trunk/fd32/modules/fat/volume.c Modified: trunk/fd32/modules/fat/alloc.c =================================================================== --- trunk/fd32/modules/fat/alloc.c 2006-12-22 05:01:19 UTC (rev 854) +++ trunk/fd32/modules/fat/alloc.c 2006-12-28 21:54:35 UTC (rev 855) @@ -1,5 +1,5 @@ /* The FreeDOS-32 FAT Driver version 2.0 - * Copyright (C) 2001-2005 Salvatore ISAJA + * Copyright (C) 2001-2006 Salvatore ISAJA * * This file "alloc.c" is part of the FreeDOS-32 FAT Driver (the Program). * @@ -320,6 +320,7 @@ if (!res) { v->next_free = (Cluster) k; + v->fsinfo_changed = true; return (int32_t) k; } } @@ -345,6 +346,7 @@ res = find_free_cluster_in_range(v, 2, hint); if (res != -ENOSPC) return res; v->next_free = FAT_FSI_NA; + v->fsinfo_changed = true; return -ENOSPC; } @@ -380,6 +382,7 @@ if (res < 0) return res; } v->free_clusters--; + v->fsinfo_changed = true; res = write_fat_entry(v, cluster, FAT_EOC); if (res < 0) return res; return cluster; @@ -432,6 +435,7 @@ res = write_fat_entry(v, from, 0); if (res < 0) return res; v->free_clusters++; + v->fsinfo_changed = true; from = (Cluster) next; } while (next != FAT_EOC); Modified: trunk/fd32/modules/fat/fat.h =================================================================== --- trunk/fd32/modules/fat/fat.h 2006-12-22 05:01:19 UTC (rev 854) +++ trunk/fd32/modules/fat/fat.h 2006-12-28 21:54:35 UTC (rev 855) @@ -1,5 +1,5 @@ /* The FreeDOS-32 FAT Driver version 2.0 - * Copyright (C) 2001-2005 Salvatore ISAJA + * Copyright (C) 2001-2006 Salvatore ISAJA * * This file "fat.h" is part of the FreeDOS-32 FAT Driver (the Program). * @@ -215,6 +215,7 @@ Cluster data_clusters; Cluster free_clusters; Cluster next_free; + bool fsinfo_changed; /* Functions to access the file allocation table */ int32_t (*fat_read) (Volume *v, Cluster n, unsigned fat_num); Modified: trunk/fd32/modules/fat/volume.c =================================================================== --- trunk/fd32/modules/fat/volume.c 2006-12-22 05:01:19 UTC (rev 854) +++ trunk/fd32/modules/fat/volume.c 2006-12-28 21:54:35 UTC (rev 855) @@ -1,5 +1,5 @@ /* The FreeDOS-32 FAT Driver version 2.0 - * Copyright (C) 2001-2005 Salvatore ISAJA + * Copyright (C) 2001-2006 Salvatore ISAJA * * This file "volume.c" is part of the FreeDOS-32 FAT Driver (the Program). * @@ -76,7 +76,7 @@ unsigned k; int res; Buffer *b = NULL; - if (v->fat_type == FAT32) + if ((v->fat_type == FAT32) && v->fsinfo_changed) { struct fat_fsinfo *fsi; res = fat_readbuf(v, 1, &b, false); @@ -85,6 +85,7 @@ fsi->free_clusters = v->free_clusters; fsi->next_free = v->next_free; res = fat_dirtybuf(b, false); + v->fsinfo_changed = false; } for (k = 0; k < v->num_buffers; k++) { @@ -411,6 +412,7 @@ memcpy(v->volume_label, bpb->volume_label, sizeof(v->volume_label)); v->free_clusters = FAT_FSI_NA; v->next_free = FAT_FSI_NA; + v->fsinfo_changed = false; if (v->fat_type == FAT32) { struct fat32_bpb *bpb32 = (struct fat32_bpb *) secbuf; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-12-22 05:01:20
|
Revision: 854 http://svn.sourceforge.net/freedos-32/?rev=854&view=rev Author: hanzac Date: 2006-12-21 21:01:19 -0800 (Thu, 21 Dec 2006) Log Message: ----------- Support Watcom C++ 1.6 Modified Paths: -------------- trunk/apps/command/command.c trunk/apps/command/command.h Modified: trunk/apps/command/command.c =================================================================== --- trunk/apps/command/command.c 2006-12-21 10:15:52 UTC (rev 853) +++ trunk/apps/command/command.c 2006-12-22 05:01:19 UTC (rev 854) @@ -40,7 +40,6 @@ * modified for FreeDOS-32 by Salvo Isaja and Hanzac Chen */ -#include <dir.h> #include <dos.h> #include <time.h> #include <utime.h> @@ -654,11 +653,7 @@ printf("Creating directory - %s\\\n", dir_path); else *c = '\0'; -#ifdef __MINGW32__ if (mkdir(dir_path) != 0 && c == NULL) -#else - if (mkdir(dir_path, S_IWUSR) != 0 && c == NULL) -#endif { cprintf("Unable to create directory - %s\\\r\n", dir_path); return -1; @@ -676,12 +671,6 @@ FILE *dest_stream; char transfer_buffer[32768]; size_t byte_count; -#ifdef __MINGW32__ - struct stat source_st; - struct _utimbuf dest_ut; -#else - struct ftime file_time; -#endif if (stricmp(source_file, dest_file) == 0) { @@ -717,21 +706,9 @@ while (byte_count > 0); /* Copy date and time */ -#ifdef __MINGW32__ - if (fstat(fileno(source_stream), &source_st) != 0) - goto copy_error_close; fflush(dest_stream); - dest_ut.actime = source_st.st_atime; - dest_ut.modtime = source_st.st_mtime; - if (futime(fileno(dest_stream), &dest_ut) != 0) + if (file_copytime (fileno(dest_stream), fileno(source_stream)) != 0) goto copy_error_close; -#else - if (getftime(fileno(source_stream), &file_time) != 0) - goto copy_error_close; - fflush(dest_stream); - if (setftime(fileno(dest_stream), &file_time) != 0) - goto copy_error_close; -#endif /* Close source and dest files */ fclose(source_stream); @@ -2229,11 +2206,7 @@ advance_cmd_arg(); if (*arg) { -#ifdef __MINGW32__ if (mkdir(arg) != 0) -#else - if (mkdir(arg, S_IWUSR) != 0) -#endif { cprintf("Could not create directory - %s\r\n", arg); reset_batfile_call_stack(); @@ -2991,11 +2964,6 @@ " \xB3 These may be freely downloaded from www.delorie.com \xB3\r\n" // CWSDPMI.EXE without sources. " \xC0\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xD9\r\n"); #else -#ifdef __GNUC__ -#define __CMD_COMPILER__ "GCC " -#else -#define __CMD_COMPILER__ "UNKNOWN " -#endif cprintf(" \xDA\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4Ŀ\r\n" " \xB3 The program COMMAND.EXE was created with the compiler \xB3\r\n" " \xB3 %51s \xB3\r\n" @@ -3021,5 +2989,7 @@ } exec_cmd(); } + + return 0; } Modified: trunk/apps/command/command.h =================================================================== --- trunk/apps/command/command.h 2006-12-21 10:15:52 UTC (rev 853) +++ trunk/apps/command/command.h 2006-12-22 05:01:19 UTC (rev 854) @@ -1,10 +1,14 @@ /* Command shell definitions and portability between - * different environments ... + * different environments, etc. by Hanzac Chen */ #ifndef __COMMAND_H__ #define __COMMAND_H__ +#ifdef __GNUC__ +#define __CMD_COMPILER__ "GCC " +#endif + /* * Command.com shell modes */ @@ -38,7 +42,6 @@ /* * Temporarily and Slightly FIX the keyboard problem - * by Hanzac Chen */ #define GET_ENHANCED_KEYSTROKE 0x10 #define GET_EXTENDED_SHIFT_STATES 0x12 @@ -59,18 +62,12 @@ #define KEY_DELETE KEY_EXTM(0x53E0) /* - * Portability between different environments - * by Hanzac Chen + * Common definitions */ -#ifdef __MINGW32__ -#include <errno.h> +#if defined(__MINGW32__) || defined(__WATCOMC__) #include <direct.h> -#include <unistd.h> -#include <windows.h> -#define pipe(filedes) _pipe(filedes, 0x4000, O_TEXT) -#define futime(a,b) _futime(a,b) -#define _fixpath(a,b) _fullpath(b,a,MAX_PATH) +#define _fixpath(a,b) _fullpath(b,a,_MAX_PATH) #define fnsplit(p,drive,dir,n,e) _splitpath(p,drive,dir,n,e) #define fnmerge(p,drive,dir,n,e) _makepath(p,drive,dir,n,e) @@ -78,6 +75,77 @@ #define _NOCURSOR 0 #define _SOLIDCURSOR 1 #define _NORMALCURSOR 2 + +/* Additional access() checks */ +#define D_OK 0x10 + +#define FA_RDONLY 1 +#define FA_HIDDEN 2 +#define FA_SYSTEM 4 +#define FA_LABEL 8 +#define FA_DIREC 16 +#define FA_ARCH 32 +#define MAXINT (0x7fffffff) +#define MAXPATH _MAX_PATH +#define MAXDRIVE 3 +#define MAXDIR 256 +#define MAXFILE 256 +#define MAXEXT 255 + +/* File find */ +typedef struct _finddata_t finddata_t; +static inline int findfirst_f(const char *pathname, finddata_t *ff, int attrib, long *handle) +{ + if (attrib == FA_LABEL) { + return -1; + } else { + long h = _findfirst(pathname, ff); + if (h != -1) { + if (handle != NULL) + *handle = h; + return 0; + } else { + return -1; + } + } +} +static inline int findnext_f(finddata_t *ff, long handle) +{ + return _findnext(handle, ff); +} +static inline int findclose_f(long handle) +{ + return _findclose(handle); +} +#define FINDDATA_T_FILENAME(f) f.name +#define FINDDATA_T_ATTRIB(f) f.attrib +#define FINDDATA_T_SIZE(f) f.size +#define FINDDATA_T_WDATE_YEAR(f) localtime(&f.time_write)->tm_year+1900 +#define FINDDATA_T_WDATE_MON(f) localtime(&f.time_write)->tm_mon+1 +#define FINDDATA_T_WDATE_DAY(f) localtime(&f.time_write)->tm_mday +#define FINDDATA_T_WTIME_HOUR(f) localtime(&f.time_write)->tm_hour +#define FINDDATA_T_WTIME_MIN(f) localtime(&f.time_write)->tm_min + +typedef struct _diskfree_t diskfree_t; +#define DISKFREE_T_AVAIL(d) d.avail_clusters +#define DISKFREE_T_TOTAL(d) d.total_clusters +#define DISKFREE_T_BSEC(d) d.bytes_per_sector +#define DISKFREE_T_SCLUS(d) d.sectors_per_cluster + +#define getdfree(d,p) _getdiskfree(d,p) + +#endif + +/* + * Different compilers + */ +#ifdef __MINGW32__ +#include <errno.h> +#include <unistd.h> +#include <windows.h> + +#define pipe(filedes) _pipe(filedes, 0x4000, O_TEXT) + /* Conio utilites */ #define cprintf(...) _cprintf(__VA_ARGS__) #define cputs(s) _cputs(s) @@ -143,54 +211,7 @@ SetConsoleCursorInfo (GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); } #define delay(t) Sleep(t/1000) -/* Additional access() checks */ -#define D_OK 0x10 -#define FA_RDONLY 1 -#define FA_HIDDEN 2 -#define FA_SYSTEM 4 -#define FA_LABEL 8 -#define FA_DIREC 16 -#define FA_ARCH 32 -#define MAXINT (0x7fffffff) -#define MAXPATH MAX_PATH -#define MAXDRIVE 3 -#define MAXDIR 256 -#define MAXFILE 256 -#define MAXEXT 255 -/* File find */ -typedef struct _finddata_t finddata_t; -static inline int findfirst_f(const char *pathname, finddata_t *ff, int attrib, long *handle) -{ - if (attrib == FA_LABEL) { - return -1; - } else { - long h = _findfirst(pathname, ff); - if (h != -1) { - if (handle != NULL) - *handle = h; - return 0; - } else { - return -1; - } - } -} -static inline int findnext_f(finddata_t *ff, long handle) -{ - return _findnext(handle, ff); -} -static inline int findclose_f(long handle) -{ - return _findclose(handle); -} -#define FINDDATA_T_FILENAME(f) f.name -#define FINDDATA_T_ATTRIB(f) f.attrib -#define FINDDATA_T_SIZE(f) f.size -#define FINDDATA_T_WDATE_YEAR(f) localtime(&f.time_write)->tm_year+1900 -#define FINDDATA_T_WDATE_MON(f) localtime(&f.time_write)->tm_mon+1 -#define FINDDATA_T_WDATE_DAY(f) localtime(&f.time_write)->tm_mday -#define FINDDATA_T_WTIME_HOUR(f) localtime(&f.time_write)->tm_hour -#define FINDDATA_T_WTIME_MIN(f) localtime(&f.time_write)->tm_min /* File attributes */ static inline unsigned int setfileattr(const char *filename, unsigned int attr) { @@ -245,6 +266,18 @@ } return access(filename, flags); } +static inline int file_copytime(int desc_handle, int src_handle) +{ + int ret; + struct stat source_st; + struct _utimbuf dest_ut; + if ((ret = fstat(src_handle, &source_st)) == 0) { + dest_ut.actime = source_st.st_atime; + dest_ut.modtime = source_st.st_mtime; + ret = _futime(desc_handle, &dest_ut); + } + return ret; +} /* Disk free */ static inline void setdrive(unsigned int drive, unsigned int *p_drives) { @@ -255,19 +288,80 @@ if (p_drive != NULL) *p_drive = _getdrive(); } -#define getdfree(d,p) _getdiskfree(d,p) -typedef struct _diskfree_t diskfree_t; -#define DISKFREE_T_AVAIL(d) d.avail_clusters -#define DISKFREE_T_TOTAL(d) d.total_clusters -#define DISKFREE_T_BSEC(d) d.bytes_per_sector -#define DISKFREE_T_SCLUS(d) d.sectors_per_cluster +#elif __WATCOMC__ +#ifndef __VERSION__ +#define __VERSION__ "1.6" +#endif + +#ifndef __CMD_COMPILER__ +#define __CMD_COMPILER__ "WATCOMC " +#endif + +int pipe( int *__phandles) +{ + return 0; +} + +static inline void clrscr(void) +{ +} +static inline void clreol(void) +{ +} +static inline void _setcursortype(int type) +{ +} + +struct ftime { + unsigned ft_tsec:5; /* 0-29, double to get real seconds */ + unsigned ft_min:6; /* 0-59 */ + unsigned ft_hour:5; /* 0-23 */ + unsigned ft_day:5; /* 1-31 */ + unsigned ft_month:4; /* 1-12 */ + unsigned ft_year:7; /* since 1980 */ +}; + +static inline void setdrive(unsigned int drive, unsigned int *p_drives) +{ + _dos_setdrive(drive, p_drives); +} +static inline void getdrive(unsigned int *p_drive) +{ + _dos_getdrive(p_drive); +} + +/* File attributes */ +static inline unsigned int setfileattr(const char *filename, unsigned int attr) +{ + return _dos_setfileattr(filename, attr); +} +static inline unsigned int getfileattr(const char *filename, unsigned int *p_attr) +{ + return _dos_getfileattr(filename, p_attr); +} +static inline int file_access(const char *filename, int flags) +{ + return access(filename, flags); +} +static inline int file_copytime(int desc_handle, int src_handle) +{ + int ret; + unsigned short _date, _time; + if ((ret = _dos_getftime(src_handle, &_date, &_time)) == 0) + ret = _dos_setftime(desc_handle, _date, _time); + return ret; +} + #elif __DJGPP__ #include <dir.h> #include <bios.h> #include <values.h> #include <unistd.h> #include <sys/exceptn.h> + +#define mkdir(dir_path) mkdir(dir_path, S_IWUSR) + /* File find */ typedef struct ffblk finddata_t; static inline int findfirst_f(const char *pathname, finddata_t *ff, int attrib, long *handle) @@ -303,6 +397,14 @@ { return access(filename, flags); } +static inline int file_copytime(int desc_handle, int src_handle) +{ + int ret; + struct ftime file_time; + if ((ret = getftime(src_handle, &file_time)) == 0) + ret = setftime(desc_handle, &file_time); + return ret; +} /* Disk free */ static inline void setdrive(unsigned int drive, unsigned int *p_drives) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-12-21 10:15:52
|
Revision: 853 http://svn.sourceforge.net/freedos-32/?rev=853&view=rev Author: hanzac Date: 2006-12-21 02:15:52 -0800 (Thu, 21 Dec 2006) Log Message: ----------- ELF object need not the global symbol address fix so identify it Modified Paths: -------------- trunk/fd32/dynalink/common.c trunk/fd32/dynalink/elf.c trunk/fd32/include/format.h Modified: trunk/fd32/dynalink/common.c =================================================================== --- trunk/fd32/dynalink/common.c 2006-12-21 07:15:00 UTC (rev 852) +++ trunk/fd32/dynalink/common.c 2006-12-21 10:15:52 UTC (rev 853) @@ -31,7 +31,10 @@ for (i = 0; i < tables->num_symbols; i++) { if (syms[i].section == COMMON_SYMBOL) { j = syms[i].offset; - syms[i].offset = global_data-j; + if (!(tables->flags&ELF_OBJECT)) /* NOTE: COFF & ELF objects only */ + syms[i].offset = global_data - j; + else + syms[i].offset = global_data; global_data += j; } else if (syms[i].section == EXTERN_SYMBOL) { #ifdef __COFF_DEBUG__ Modified: trunk/fd32/dynalink/elf.c =================================================================== --- trunk/fd32/dynalink/elf.c 2006-12-21 07:15:00 UTC (rev 852) +++ trunk/fd32/dynalink/elf.c 2006-12-21 10:15:52 UTC (rev 853) @@ -33,7 +33,7 @@ return 0; } - tables->flags = 0; + tables->flags = ELF_OBJECT; if (header.e_ident[4] != ELFCLASS32) { kf->error("Wrong ELF class\n"); kf->message("Class: 0x%x!!!\n", header.e_ident[4]); Modified: trunk/fd32/include/format.h =================================================================== --- trunk/fd32/include/format.h 2006-12-21 07:15:00 UTC (rev 852) +++ trunk/fd32/include/format.h 2006-12-21 10:15:52 UTC (rev 853) @@ -19,7 +19,8 @@ #define NEED_IMAGE_RELOCATION 1 #define NEED_SECTION_RELOCATION 2 #define NEED_LOAD_RELOCATABLE 4 -#define NO_ENTRY 16 +#define ELF_OBJECT 8 +#define NO_ENTRY 16 #define DLL_WITH_STDCALL 32 /* module formats */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-12-21 07:15:05
|
Revision: 852 http://svn.sourceforge.net/freedos-32/?rev=852&view=rev Author: hanzac Date: 2006-12-20 23:15:00 -0800 (Wed, 20 Dec 2006) Log Message: ----------- Fix bug of extern symbol relocation, rename local_bss, global_data is a proper name Modified Paths: -------------- trunk/fd32/dynalink/coff.c trunk/fd32/dynalink/common.c trunk/fd32/dynalink/elf.c trunk/fd32/include/format.h trunk/fd32/kernel/exec.c Modified: trunk/fd32/dynalink/coff.c =================================================================== --- trunk/fd32/dynalink/coff.c 2006-10-27 06:33:55 UTC (rev 851) +++ trunk/fd32/dynalink/coff.c 2006-12-21 07:15:00 UTC (rev 852) @@ -139,7 +139,7 @@ memcpy(name, h.s_name, 8); name[8] = 0; - if (strcmp(name, ".bss") == 0) { + if (h.s_flags & SECT_UNINIT_DATA) { bss = i; } @@ -290,8 +290,8 @@ } else { /* common symbol */ syms[i].section = COMMON_SYMBOL; - /* calculate the local_bss_size */ - tables->local_bss_size += syms[i].offset; + /* calculate the global_data_size */ + tables->global_data_size += syms[i].offset; } break; case 0xFFFF: Modified: trunk/fd32/dynalink/common.c =================================================================== --- trunk/fd32/dynalink/common.c 2006-10-27 06:33:55 UTC (rev 851) +++ trunk/fd32/dynalink/common.c 2006-12-21 07:15:00 UTC (rev 852) @@ -21,7 +21,7 @@ { unsigned int i, j, idx; DWORD address, destination; - DWORD local_bss = tables->local_bss; + DWORD global_data = tables->global_data; struct reloc_info *rel = s[sect].reloc; /* Setup the common space-uninitialized symbols at the first section relocation @@ -31,8 +31,8 @@ for (i = 0; i < tables->num_symbols; i++) { if (syms[i].section == COMMON_SYMBOL) { j = syms[i].offset; - syms[i].offset = local_bss; - local_bss += j; + syms[i].offset = global_data-j; + global_data += j; } else if (syms[i].section == EXTERN_SYMBOL) { #ifdef __COFF_DEBUG__ kf->log("Searching for symbol %s\n", syms[i].name); @@ -250,13 +250,13 @@ for (i = 0; i < n; i++) { needed_mem += s[i].size; } - needed_mem += tables->local_bss_size; + needed_mem += tables->global_data_size; mem_space = (BYTE *)kf->mem_alloc(needed_mem); /* Allocate for the local bss at the mean time */ - if (tables->local_bss_size != 0) { - tables->local_bss = (DWORD)mem_space+needed_mem-tables->local_bss_size; + if (tables->global_data_size != 0) { + tables->global_data = (DWORD)mem_space+needed_mem-tables->global_data_size; } else { - tables->local_bss = 0; + tables->global_data = 0; } #ifdef __ELF_DEBUG__ Modified: trunk/fd32/dynalink/elf.c =================================================================== --- trunk/fd32/dynalink/elf.c 2006-10-27 06:33:55 UTC (rev 851) +++ trunk/fd32/dynalink/elf.c 2006-12-21 07:15:00 UTC (rev 852) @@ -347,8 +347,8 @@ /* extern symbol */ syms[i].section = COMMON_SYMBOL; syms[i].offset = symbol.st_size; - /* calculate the local_bss_size */ - tables->local_bss_size += syms[i].offset; + /* calculate the global_data_size */ + tables->global_data_size += syms[i].offset; } } Modified: trunk/fd32/include/format.h =================================================================== --- trunk/fd32/include/format.h 2006-10-27 06:33:55 UTC (rev 851) +++ trunk/fd32/include/format.h 2006-12-21 07:15:00 UTC (rev 852) @@ -67,8 +67,8 @@ DWORD image_base; - DWORD local_bss; - DWORD local_bss_size; + DWORD global_data; + DWORD global_data_size; /* In PEI, it's a pei extra info */ DWORD private_info; }; Modified: trunk/fd32/kernel/exec.c =================================================================== --- trunk/fd32/kernel/exec.c 2006-10-27 06:33:55 UTC (rev 851) +++ trunk/fd32/kernel/exec.c 2006-12-21 07:15:00 UTC (rev 852) @@ -38,7 +38,7 @@ /* Initialize the table info */ tables.section_names_size = 0; - tables.local_bss_size = 0; + tables.global_data_size = 0; tables.private_info = 0; dyn_entry = rf->read_headers(kf, file, &tables); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-10-27 06:34:07
|
Revision: 851 http://svn.sourceforge.net/freedos-32/?rev=851&view=rev Author: hanzac Date: 2006-10-26 23:33:55 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Pass arguments to built-in commands Modified Paths: -------------- trunk/apps/command/command.c Modified: trunk/apps/command/command.c =================================================================== --- trunk/apps/command/command.c 2006-10-25 08:34:58 UTC (rev 850) +++ trunk/apps/command/command.c 2006-10-27 06:33:55 UTC (rev 851) @@ -123,7 +123,7 @@ */ static void parse_cmd_line(void); static void perform_external_cmd(int call, char *ext_cmd); -static void perform_set(void *data); +static void perform_set(const char *arg); static void perform_unimplemented_cmd(void); /*** @@ -1216,7 +1216,7 @@ /////////////////////////////////////////////////////////////////////////////////// -static void perform_attrib(void *data) +static void perform_attrib(const char *arg) { long ffhandle = 0; int ffrc; @@ -1239,18 +1239,18 @@ unsigned req_attrib = 0, attrib_mask = 0; unsigned search_attrib; - while (*cmd_arg != '\0') + while (*arg != '\0') { if (*cmd_switch == '\0') // if not a command switch ... { - if (strlen(cmd_arg) == 2 && (cmd_arg[0] == '+' || cmd_arg[0] == '-')) + if (strlen(arg) == 2 && (arg[0] == '+' || arg[0] == '-')) { for (a = 0; a < 4; a++) { - if (toupper(cmd_arg[1]) == toupper(attrib_letters[a])) + if (toupper(arg[1]) == toupper(attrib_letters[a])) { attrib_mask |= attrib_values[a]; - if (cmd_arg[0] == '+') + if (arg[0] == '+') req_attrib |= attrib_values[a]; else req_attrib &= (~(attrib_values[a])); @@ -1259,7 +1259,7 @@ } else if (*path == '\0') { - strncpy(path, cmd_arg, MAXPATH); + strncpy(path, arg, MAXPATH); path[MAXPATH-1] = '\0'; conv_unix_path_to_ms_dos(path); } @@ -1387,24 +1387,24 @@ printf("File(s) not found - %s%s\n", path, filespec); } -static void perform_call(void *data) +static void perform_call(const char *arg) { while (*cmd_switch) // skip switches advance_cmd_arg(); - strcpy(cmd, cmd_arg); + strcpy(cmd, arg); advance_cmd_arg(); perform_external_cmd(true, cmd); } -static void perform_cd(void *data) +static void perform_cd(const char *arg) { while (*cmd_switch) // skip switches advance_cmd_arg(); - if (*cmd_arg) + if (*arg) { - if (chdir(cmd_arg) != 0) + if (chdir(arg) != 0) { - cprintf("Directory does not exist - %s\r\n",cmd_arg); + cprintf("Directory does not exist - %s\r\n",arg); reset_batfile_call_stack(); return; } @@ -1431,14 +1431,14 @@ } } -static void perform_choice(void *data) +static void perform_choice(const char *arg) { char *choices = "YN"; // Y,N are the default choices char *text = ""; int supress_prompt = false; int choice; - while (*cmd_arg != '\0') + while (*arg != '\0') { if (*cmd_switch == '\0') // if not a command switch ... { @@ -1485,17 +1485,17 @@ return; } -static void perform_copy(void *data) +static void perform_copy(const char *arg) { general_file_transfer(FILE_XFER_COPY); } -static void perform_xcopy(void *data) +static void perform_xcopy(const char *arg) { general_file_transfer(FILE_XFER_XCOPY); } -static void perform_date(void *data) +static void perform_date(const char *arg) { time_t t = time(NULL); struct tm *loctime = localtime (&t); @@ -1504,20 +1504,20 @@ loctime->tm_mon+1, loctime->tm_mday, loctime->tm_year+1900); } -static void perform_delete(void *data) +static void perform_delete(const char *arg) { finddata_t ff; char filespec[MAXPATH] = ""; char full_filespec[MAXPATH] = ""; char drive[MAXDRIVE], dir[MAXDIR]; - while (*cmd_arg != '\0') + while (*arg != '\0') { if (*cmd_switch == '\0') // if not a command switch ... { if (*filespec == '\0') { - strncpy(filespec, cmd_arg, MAXPATH); + strncpy(filespec, arg, MAXPATH); filespec[MAXPATH-1] = '\0'; } else @@ -1561,7 +1561,7 @@ } } -static void perform_deltree(void *data) +static void perform_deltree(const char *arg) { long ffhandle = 0; int ffrc; @@ -1583,13 +1583,13 @@ int choice; unsigned search_attrib; - while (*cmd_arg != '\0') + while (*arg != '\0') { if (*cmd_switch == '\0') // if not a command switch ... { if (*path == '\0') { - strncpy(path, cmd_arg, MAXPATH); + strncpy(path, arg, MAXPATH); path[MAXPATH-1] = '\0'; conv_unix_path_to_ms_dos(path); } @@ -1753,7 +1753,7 @@ printf("%9d (sub)directories removed\n", dir_count); } -static void perform_dir(void *data) +static void perform_dir(const char *arg) { long ffhandle; int ffrc; @@ -1768,13 +1768,13 @@ char full_filespec[MAXPATH]; char filespec[MAXPATH] = ""; - while (*cmd_arg != '\0') + while (*arg != '\0') { if (*cmd_switch == '\0') // if not a command switch ... { if (*filespec == '\0') { - strncpy(filespec, cmd_arg, MAXPATH); + strncpy(filespec, arg, MAXPATH); filespec[MAXPATH-1] = '\0'; conv_unix_path_to_ms_dos(filespec); } @@ -1885,13 +1885,13 @@ printf("%15lli GB free\n", avail / 1024 / 1024 / 1024); } -static void perform_echo(void *data) +static void perform_echo(const char *arg) { - if (stricmp(cmd_arg, "off") == 0) + if (stricmp(arg, "off") == 0) echo_on[stack_level] = false; - else if (stricmp(cmd_arg, "on") == 0) + else if (stricmp(arg, "on") == 0) echo_on[stack_level] = true; - else if (cmd_arg[0] == '\0') + else if (arg[0] == '\0') { if (echo_on[stack_level]) puts("ECHO is on"); @@ -1902,7 +1902,7 @@ puts(cmd_args); } -static void perform_exit(void *data) +static void perform_exit(const char *arg) { int ba; bat_file_path[stack_level][0] = '\0'; @@ -2081,11 +2081,11 @@ return; } -static void perform_goto(void *data) +static void perform_goto(const char *arg) { if (bat_file_path[stack_level][0] != '\0') { - strcpy(goto_label, cmd_arg); + strcpy(goto_label, arg); bat_file_line_number[stack_level] = MAXINT; } else @@ -2223,19 +2223,19 @@ return; } -static void perform_md(void *data) +static void perform_md(const char *arg) { while (*cmd_switch) // skip switches advance_cmd_arg(); - if (*cmd_arg) + if (*arg) { #ifdef __MINGW32__ - if (mkdir(cmd_arg) != 0) + if (mkdir(arg) != 0) #else - if (mkdir(cmd_arg, S_IWUSR) != 0) + if (mkdir(arg, S_IWUSR) != 0) #endif { - cprintf("Could not create directory - %s\r\n", cmd_arg); + cprintf("Could not create directory - %s\r\n", arg); reset_batfile_call_stack(); } } @@ -2246,14 +2246,14 @@ } } -static void perform_more(void *data) +static void perform_more(const char *arg) { int c; while ((c = getchar()) != EOF) putchar(c); } -static void perform_move(void *data) +static void perform_move(const char *arg) { general_file_transfer(FILE_XFER_MOVE); } @@ -2262,7 +2262,7 @@ { } -static void perform_path(void *data) +static void perform_path(const char *arg) { if (*cmd_args == '\0') { @@ -2281,28 +2281,28 @@ } } -static void perform_pause(void *data) +static void perform_pause(const char *arg) { cputs("Press any key to continue . . .\r\n"); getch(); } -static void perform_prompt(void *data) +static void perform_prompt(const char *arg) { memmove(cmd_args+7, cmd_args, strlen(cmd_args)+1); strncpy(cmd_args, "PROMPT=", 7); - perform_set(data); + perform_set(arg); } -static void perform_rd(void *data) +static void perform_rd(const char *arg) { while (*cmd_switch) // skip switches advance_cmd_arg(); if (*cmd_arg) { - if (rmdir(cmd_arg) != 0) + if (rmdir(arg) != 0) { - cprintf("Could not remove directory - %s\r\n", cmd_arg); + cprintf("Could not remove directory - %s\r\n", arg); reset_batfile_call_stack(); } } @@ -2313,7 +2313,7 @@ } } -static void perform_rename(void *data) +static void perform_rename(const char *arg) { long ffhandle; int ffrc; @@ -2328,19 +2328,19 @@ char full_from_filespec[MAXPATH], full_to_filespec[MAXPATH]; char *w; - while (*cmd_arg != '\0') + while (*arg != '\0') { if (*cmd_switch == '\0') // if not a command switch ... { if (*from_path == '\0') { - strncpy(from_path, cmd_arg, MAXPATH); + strncpy(from_path, arg, MAXPATH); from_path[MAXPATH-1] = '\0'; conv_unix_path_to_ms_dos(from_path); } else if (*to_path == '\0') { - strncpy(to_path, cmd_arg, MAXPATH); + strncpy(to_path, arg, MAXPATH); to_path[MAXPATH-1] = '\0'; conv_unix_path_to_ms_dos(to_path); } @@ -2441,10 +2441,10 @@ } } -static void perform_set(void *data) +static void perform_set(const char *arg) { - char *var_name; - if (*cmd_args == '\0') + const char *var_name; + if (*arg == '\0') { int i = 0; while (environ[i]) @@ -2452,14 +2452,14 @@ } else { - var_name = cmd_args; + var_name = arg; if (strlen(var_name) == 0) { cputs("Syntax error\r\n"); reset_batfile_call_stack(); return; } - strupr(var_name); + /* strupr(var_name); */ if (putenv(var_name) != 0) { cprintf("Error setting environment variable - %s\r\n", var_name); @@ -2469,7 +2469,7 @@ } } -static void perform_time(void *data) +static void perform_time(const char *arg) { time_t t = time(NULL); struct tm *loctime = localtime (&t); @@ -2491,19 +2491,19 @@ } -static void perform_type(void *data) +static void perform_type(const char *arg) { FILE *textfile; char filespec[MAXPATH] = ""; int c; - while (*cmd_arg != '\0') + while (*arg != '\0') { if (*cmd_switch == '\0') // if not a command switch ... { if (*filespec == '\0') { - strncpy(filespec, cmd_arg, MAXPATH); + strncpy(filespec, arg, MAXPATH); filespec[MAXPATH-1] = '\0'; conv_unix_path_to_ms_dos(filespec); } @@ -2534,7 +2534,7 @@ } } -static void perform_cls(void *data) +static void perform_cls(const char *arg) { clrscr(); } @@ -2550,42 +2550,41 @@ struct built_in_cmd { char *cmd_name; - void *cmd_data; - void (*cmd_fn)(void *data); + void (*cmd_fn)(const char *); }; static struct built_in_cmd cmd_table[] = { - {"attrib", NULL, perform_attrib}, - {"call", NULL, perform_call}, - {"cd", NULL, perform_cd}, - {"chdir", NULL, perform_cd}, - {"choice", NULL, perform_choice}, - {"cls", NULL, perform_cls}, - {"copy", NULL, perform_copy}, - {"date", NULL, perform_date}, - {"del", NULL, perform_delete}, - {"deltree", NULL, perform_deltree}, - {"erase", NULL, perform_delete}, - {"dir", NULL, perform_dir}, - {"echo", NULL, perform_echo}, - {"exit", NULL, perform_exit}, - {"goto", NULL, perform_goto}, - {"md", NULL, perform_md}, - {"mkdir", NULL, perform_md}, - {"move", NULL, perform_move}, - {"more", NULL, perform_more}, - {"path", NULL, perform_path}, - {"pause", NULL, perform_pause}, - {"prompt", NULL, perform_prompt}, - {"rd", NULL, perform_rd}, - {"rmdir", NULL, perform_rd}, - {"rename", NULL, perform_rename}, - {"ren", NULL, perform_rename}, - {"set", NULL, perform_set}, - {"time", NULL, perform_time}, - {"type", NULL, perform_type}, - {"xcopy", NULL, perform_xcopy} + {"attrib", perform_attrib}, + {"call", perform_call}, + {"cd", perform_cd}, + {"chdir", perform_cd}, + {"choice", perform_choice}, + {"cls", perform_cls}, + {"copy", perform_copy}, + {"date", perform_date}, + {"del", perform_delete}, + {"deltree", perform_deltree}, + {"erase", perform_delete}, + {"dir", perform_dir}, + {"echo", perform_echo}, + {"exit", perform_exit}, + {"goto", perform_goto}, + {"md", perform_md}, + {"mkdir", perform_md}, + {"move", perform_move}, + {"more", perform_more}, + {"path", perform_path}, + {"pause", perform_pause}, + {"prompt", perform_prompt}, + {"rd", perform_rd}, + {"rmdir", perform_rd}, + {"rename", perform_rename}, + {"ren", perform_rename}, + {"set", perform_set}, + {"time", perform_time}, + {"type", perform_type}, + {"xcopy", perform_xcopy} }; static void parse_cmd_line(void) @@ -2876,7 +2875,7 @@ { if (stricmp(cmd, cmd_table[c].cmd_name) == 0) { - cmd_table[c].cmd_fn(cmd_table[c].cmd_data); + cmd_table[c].cmd_fn(cmd_arg); break; } } @@ -2899,7 +2898,7 @@ { if (stricmp(pipe_to_cmd, cmd_table[c].cmd_name) == 0) { - cmd_table[c].cmd_fn(cmd_table[c].cmd_data); + cmd_table[c].cmd_fn(cmd_arg); break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-10-25 08:35:27
|
Revision: 850 http://svn.sourceforge.net/freedos-32/?rev=850&view=rev Author: hanzac Date: 2006-10-25 01:34:58 -0700 (Wed, 25 Oct 2006) Log Message: ----------- Adjust/Move the fd32_vm86_to_mode switch ... Modified Paths: -------------- trunk/fd32/modules/dpmi/include/dosexec.h trunk/fd32/modules/dpmi/src/dosexec.c trunk/fd32/modules/dpmi/src/handlers.s trunk/fd32/modules/dpmi/src/int2f.c Modified: trunk/fd32/modules/dpmi/include/dosexec.h =================================================================== --- trunk/fd32/modules/dpmi/include/dosexec.h 2006-10-24 08:20:43 UTC (rev 849) +++ trunk/fd32/modules/dpmi/include/dosexec.h 2006-10-25 08:34:58 UTC (rev 850) @@ -75,6 +75,6 @@ #define DOS_DIRECT_EXEC 1 /* Support COFF-GO32 only */ #define DOS_WRAPPER_EXEC 2 int dos_exec_switch(int option); /* Return TRUE(1) or FALSE(0) */ -extern void (*fd32_vm86_to_pmode)(void); /* 16bit DPMI mode-switch */ +extern void *fd32_vm86_to_pmode; /* 16bit DPMI mode-switch */ #endif Modified: trunk/fd32/modules/dpmi/src/dosexec.c =================================================================== --- trunk/fd32/modules/dpmi/src/dosexec.c 2006-10-24 08:20:43 UTC (rev 849) +++ trunk/fd32/modules/dpmi/src/dosexec.c 2006-10-25 08:34:58 UTC (rev 850) @@ -520,7 +520,7 @@ static int (*p_isMZ)(struct kern_funcs *kf, int f, struct read_funcs *rf) = NULL; extern void _fd32_vm86_to_pmode(); extern void _fd32_vm86_to_pmode_end(); -void (*fd32_vm86_to_pmode)(void) = NULL; +void *fd32_vm86_to_pmode = NULL; int dos_exec_switch(int option) { @@ -543,12 +543,12 @@ /* Install the fd32_vm86_to_pmode */ if (fd32_vm86_to_pmode == NULL) { const DWORD psize = (DWORD)_fd32_vm86_to_pmode_end - (DWORD)_fd32_vm86_to_pmode; - BYTE *p = (BYTE *)dosmem_get((psize+0x10)&0xFFFFFFF0); + BYTE *p = (BYTE *)dosmem_get(psize); /* ".code16" "mov $0xfd32, %ax;" "int $0x2f;" "lret;" */ memcpy(p, _fd32_vm86_to_pmode, psize); /* p[0] = 0xB8, p[1] = 0x32, p[2] = 0xFD; p[3] = 0xCD, p[4] = 0x2F, p[5] = 0xCB; */ - fd32_vm86_to_pmode = (void (*)(void))p; + fd32_vm86_to_pmode = p; } /* Store the previous check */ if (p_isMZ == NULL) { Modified: trunk/fd32/modules/dpmi/src/handlers.s =================================================================== --- trunk/fd32/modules/dpmi/src/handlers.s 2006-10-24 08:20:43 UTC (rev 849) +++ trunk/fd32/modules/dpmi/src/handlers.s 2006-10-25 08:34:58 UTC (rev 850) @@ -188,8 +188,6 @@ .globl SYMBOL_NAME(_fd32_rm_callback_end) SYMBOL_NAME_LABEL(_fd32_vm86_to_pmode) - /* NOTE: Only AX=0x01 (32-bit program) is supported */ - mov $0xFD32, %ax int $0x2f pop %eax pop %ss Modified: trunk/fd32/modules/dpmi/src/int2f.c =================================================================== --- trunk/fd32/modules/dpmi/src/int2f.c 2006-10-24 08:20:43 UTC (rev 849) +++ trunk/fd32/modules/dpmi/src/int2f.c 2006-10-25 08:34:58 UTC (rev 850) @@ -104,6 +104,45 @@ *_p_cs = rmcb_regs->x.cs; *_p_ip = rmcb_regs->x.ip; + } else if ((DWORD)fd32_vm86_to_pmode == (r->x.cs<<4)+r->x.ip-2) { + /* FD32 specific vm86->pmode switch + NOTE: Only AX=0x01 (32-bit program) is supported */ + DWORD p_vm86_app_stack; + struct tss *p_vm86_tss = vm86_get_tss(X_VM86_TSS); + struct psp *ppsp = (struct psp *)(p_vm86_tss->es<<4); + WORD retf_cs; + +#ifdef __DPMI_DEBUG__ + fd32_log_printf("[DPMI] TASK Switch from VM86 (CS:%x IP:%x)!\n", r->x.cs, r->x.ip); +#endif + /* Create new selectors */ + r->d.ecs = fd32_segment_to_descriptor(r->d.ecs); + fd32_set_descriptor_access_rights(r->d.ecs, 0x009A); + /* NOTE: The DS access rights is different with CS */ + r->d.eds = fd32_segment_to_descriptor(r->d.vm86_ds); + /* NOTE: The CS in the VM86 stack is replaced with the new CS selector */ + /* p_vm86_stack = r->d.esp+sizeof(DWORD)*3; */ /* use the ring0/system(vm86_tss:ss0) stack and skip eip, ecs, flags */ + p_vm86_app_stack = (r->d.vm86_ss<<4)+r->d.vm86_esp; + retf_cs = fd32_allocate_descriptors(1); + fd32_set_segment_base_address(retf_cs, ((WORD *)p_vm86_app_stack)[1]<<4); + fd32_set_segment_limit(retf_cs, 0xFFFF); + fd32_set_descriptor_access_rights(retf_cs, 0x009A); + /* r->d.vm86_esp = (((WORD *)p_vm86_app_stack)[0]) | (retf_cs<<16); */ + ((WORD *)p_vm86_app_stack)[1] = retf_cs; + r->d.vm86_ss = fd32_segment_to_descriptor(r->d.vm86_ss); + /* Using vm86 system stack, not the original vm86 app stack */ + /* NOTE: The ES = selector to program's PSP (100h byte limit) */ + r->d.ees = fd32_segment_to_descriptor(p_vm86_tss->es); + /* NOTE: The ENV selector is also created */ + ppsp->ps_environ = fd32_segment_to_descriptor(ppsp->ps_environ); +#ifdef __DPMI_DEBUG__ + fd32_log_printf("[DPMI] TASK Switch to PMODE (CS:%lx EIP:%lx)\n", r->d.ecs, r->d.eip); +#endif + /* Clear the VM flag, NOTE: clear the NT flag (for DOS/32A 9.1.2+ compatible) */ + r->d.flags &= ~(CPU_FLAG_VM|CPU_FLAG_NT); + /* NOTE: Technique, iret to the targeted CS:IP still in protected mode + but the space of vm registers saved in the ring0 stack is mostly lost + */ } else { switch (r->x.ax) { @@ -124,47 +163,6 @@ #endif break; } - /* FD32 specific vm86->pmode switch */ - case 0xFD32: - { - DWORD p_vm86_app_stack; - struct tss *p_vm86_tss = vm86_get_tss(X_VM86_TSS); - struct psp *ppsp = (struct psp *)(p_vm86_tss->es<<4); - WORD retf_cs; - -#ifdef __DPMI_DEBUG__ - fd32_log_printf("[DPMI] TASK Switch from VM86 (ECS:%x EIP:%x)!\n", (int)r->d.ecs, (int)r->d.eip); -#endif - /* Create new selectors */ - r->d.ecs = fd32_segment_to_descriptor(r->d.ecs); - fd32_set_descriptor_access_rights(r->d.ecs, 0x009A); - /* NOTE: The DS access rights is different with CS */ - r->d.eds = fd32_segment_to_descriptor(r->d.vm86_ds); - /* NOTE: The CS in the VM86 stack is replaced with the new CS selector */ - /* p_vm86_stack = r->d.esp+sizeof(DWORD)*3; */ /* use the ring0/system(vm86_tss:ss0) stack and skip eip, ecs, flags */ - p_vm86_app_stack = (r->d.vm86_ss<<4)+r->d.vm86_esp; - retf_cs = fd32_allocate_descriptors(1); - fd32_set_segment_base_address(retf_cs, ((WORD *)p_vm86_app_stack)[1]<<4); - fd32_set_segment_limit(retf_cs, 0xFFFF); - fd32_set_descriptor_access_rights(retf_cs, 0x009A); - /* r->d.vm86_esp = (((WORD *)p_vm86_app_stack)[0]) | (retf_cs<<16); */ - ((WORD *)p_vm86_app_stack)[1] = retf_cs; - r->d.vm86_ss = fd32_segment_to_descriptor(r->d.vm86_ss); - /* Using vm86 system stack, not the original vm86 app stack */ - /* NOTE: The ES = selector to program's PSP (100h byte limit) */ - r->d.ees = fd32_segment_to_descriptor(p_vm86_tss->es); - /* NOTE: The ENV selector is also created */ - ppsp->ps_environ = fd32_segment_to_descriptor(ppsp->ps_environ); -#ifdef __DPMI_DEBUG__ - fd32_log_printf("[DPMI] TASK Switch to PMODE (CS:%lx EIP:%lx)\n", r->d.ecs, r->d.eip); -#endif - /* Clear the VM flag, NOTE: clear the NT flag (for DOS/32A 9.1.2+ compatible) */ - r->d.flags &= ~(CPU_FLAG_VM|CPU_FLAG_NT); - /* NOTE: Technique, iret to the targeted CS:IP still in protected mode - but the space of vm registers saved in the ring0 stack is mostly lost - */ - break; - } default: int_redirect_to_rmint (0x2f, r); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-10-24 08:20:58
|
Revision: 849 http://svn.sourceforge.net/freedos-32/?rev=849&view=rev Author: hanzac Date: 2006-10-24 01:20:43 -0700 (Tue, 24 Oct 2006) Log Message: ----------- Bug of spelling ... Modified Paths: -------------- trunk/fd32/modules/dpmi/src/chandler.c trunk/fd32/modules/dpmi/src/int31_03.c Modified: trunk/fd32/modules/dpmi/src/chandler.c =================================================================== --- trunk/fd32/modules/dpmi/src/chandler.c 2006-10-24 08:07:00 UTC (rev 848) +++ trunk/fd32/modules/dpmi/src/chandler.c 2006-10-24 08:20:43 UTC (rev 849) @@ -270,7 +270,7 @@ break; case 0x0304: - int31_0303(r); + int31_0304(r); break; case 0x0400: Modified: trunk/fd32/modules/dpmi/src/int31_03.c =================================================================== --- trunk/fd32/modules/dpmi/src/int31_03.c 2006-10-24 08:07:00 UTC (rev 848) +++ trunk/fd32/modules/dpmi/src/int31_03.c 2006-10-24 08:20:43 UTC (rev 849) @@ -68,7 +68,7 @@ DWORD addr; int res; tRMCBTrack *t = (tRMCBTrack *)mem_get(sizeof(tRMCBTrack)); - /* TODO: This must be completely implemented */ + /* TODO: Check if completely implemented */ const DWORD size = (DWORD)_fd32_rm_callback_end - (DWORD)_fd32_rm_callback; BYTE *p = (BYTE *)dosmem_get(size); memcpy(p, _fd32_rm_callback, size); @@ -109,7 +109,7 @@ { tRMCBTrack *p; tRMCBTrack *q; - /* TODO: Debug a DOS/32A program, why it doesn't call this service when terminating */ + #ifdef __DEBUG__ fd32_log_printf("[DPMI]: Free Real Mode CallBack Address\n"); fd32_log_printf(" Real Mode CallBack Address: 0x%x:0x%lx\n", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-10-24 08:07:14
|
Revision: 848 http://svn.sourceforge.net/freedos-32/?rev=848&view=rev Author: hanzac Date: 2006-10-24 01:07:00 -0700 (Tue, 24 Oct 2006) Log Message: ----------- Minor changes ... Modified Paths: -------------- trunk/fd32/modules/dpmi/src/dosmem.c trunk/fd32/modules/dpmi/src/int31_03.c trunk/fd32/modules/dpmi/src/int31_09.c Modified: trunk/fd32/modules/dpmi/src/dosmem.c =================================================================== --- trunk/fd32/modules/dpmi/src/dosmem.c 2006-10-24 08:05:31 UTC (rev 847) +++ trunk/fd32/modules/dpmi/src/dosmem.c 2006-10-24 08:07:00 UTC (rev 848) @@ -13,21 +13,22 @@ #include "dosmem.h" /* The dos memory tracker is for recording the dos memory usage */ -typedef struct dos_mem_track +typedef struct dosmem_track { - struct dos_mem_track *next; DWORD base; DWORD size; WORD alignment_fix; WORD dos_seg; -} dos_mem_track_t; -static dos_mem_track_t dmtrack_top = {NULL, 0, 0}; + struct dosmem_track *next; +} dosmem_track_t; +static dosmem_track_t dmtrack_top = {NULL, 0, 0}; + /* Allocate dos memory in paragraphs */ WORD dos_alloc(WORD size) { - dos_mem_track_t *p = (dos_mem_track_t *)mem_get(sizeof(dos_mem_track_t)); + dosmem_track_t *p = (dosmem_track_t *)mem_get(sizeof(dosmem_track_t)); p->size = size<<4; p->base = dosmem_get(p->size); @@ -56,7 +57,7 @@ dmtrack_top.next = p; return p->dos_seg; } else { - mem_free((DWORD)p, sizeof(dos_mem_track_t)); + mem_free((DWORD)p, sizeof(dosmem_track_t)); return 0; } } @@ -65,14 +66,14 @@ int dos_free(WORD seg) { int res; - dos_mem_track_t *p, *q; + dosmem_track_t *p, *q; for (q = &dmtrack_top, p = dmtrack_top.next; p != NULL; q = p, p = p->next) if (seg == p->dos_seg) { res = dosmem_free(p->base, p->size); if (res == 0) { q->next = p->next; - return mem_free((DWORD)p, sizeof(dos_mem_track_t)); + return mem_free((DWORD)p, sizeof(dosmem_track_t)); } else { return res; } @@ -85,7 +86,7 @@ /* Resize the dos memory */ int dos_resize(WORD seg, WORD newsize) { - dos_mem_track_t *p; + dosmem_track_t *p; for (p = dmtrack_top.next; p != NULL; p = p->next) if (seg == p->dos_seg) { Modified: trunk/fd32/modules/dpmi/src/int31_03.c =================================================================== --- trunk/fd32/modules/dpmi/src/int31_03.c 2006-10-24 08:05:31 UTC (rev 847) +++ trunk/fd32/modules/dpmi/src/int31_03.c 2006-10-24 08:07:00 UTC (rev 848) @@ -109,7 +109,7 @@ { tRMCBTrack *p; tRMCBTrack *q; - + /* TODO: Debug a DOS/32A program, why it doesn't call this service when terminating */ #ifdef __DEBUG__ fd32_log_printf("[DPMI]: Free Real Mode CallBack Address\n"); fd32_log_printf(" Real Mode CallBack Address: 0x%x:0x%lx\n", Modified: trunk/fd32/modules/dpmi/src/int31_09.c =================================================================== --- trunk/fd32/modules/dpmi/src/int31_09.c 2006-10-24 08:05:31 UTC (rev 847) +++ trunk/fd32/modules/dpmi/src/int31_09.c 2006-10-24 08:07:00 UTC (rev 848) @@ -22,7 +22,7 @@ #endif /* Do something... */ - r->h.al = (r->d.flags&CPU_FLAG_IF != 0); + r->h.al = ((r->d.flags&CPU_FLAG_IF) != 0); r->d.flags &= ~CPU_FLAG_IF; CLEAR_CARRY; @@ -36,7 +36,7 @@ #endif /* Do something... */ - r->h.al = (r->d.flags&CPU_FLAG_IF != 0); + r->h.al = ((r->d.flags&CPU_FLAG_IF) != 0); r->d.flags |= CPU_FLAG_IF; CLEAR_CARRY; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-10-24 08:06:07
|
Revision: 847 http://svn.sourceforge.net/freedos-32/?rev=847&view=rev Author: hanzac Date: 2006-10-24 01:05:31 -0700 (Tue, 24 Oct 2006) Log Message: ----------- Using a linked list of used-memory to free all the memory allocated for a DPMI program when it's terminating, especially for the program using DOS32/A extender, 'cause its clear-up memory job is done in the DOS32/A kernel's wrapper of int21 0x4C Modified Paths: -------------- trunk/fd32/include/exec.h trunk/fd32/kernel/process.c trunk/fd32/modules/dpmi/include/dpmimem.h trunk/fd32/modules/dpmi/src/chandler.c trunk/fd32/modules/dpmi/src/dosexec.c trunk/fd32/modules/dpmi/src/dpmiexc.c trunk/fd32/modules/dpmi/src/dpmimem.c trunk/fd32/modules/winb/winb.h Modified: trunk/fd32/include/exec.h =================================================================== --- trunk/fd32/include/exec.h 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/include/exec.h 2006-10-24 08:05:31 UTC (rev 847) @@ -22,7 +22,7 @@ void *cds_list; /* Under DOS this is a global array */ char *args; char *filename; - DWORD memlimit; + void *mem_info; void *jft; DWORD jft_size; Modified: trunk/fd32/kernel/process.c =================================================================== --- trunk/fd32/kernel/process.c 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/kernel/process.c 2006-10-24 08:05:31 UTC (rev 847) @@ -94,7 +94,7 @@ ppi->cds_list = NULL; /* Pointer set by FS */ ppi->args = args; ppi->filename = filename; - ppi->memlimit = 0; + ppi->mem_info = NULL; /* Sets the JFT for the current process. */ ppi->jft = fd32_init_jft(file_size); @@ -131,19 +131,16 @@ #ifdef __PROCESS_DEBUG__ fd32_log_printf("[PROCESS] Going to run 0x%lx, size 0x%lx\n", entry, size); - message("Mem Limit: 0x%lx = 0x%lx 0x%lx\n", ppi->memlimit, base, size); + message("Mem info 0x%lx, base 0x%lx, size 0x%lx\n", ppi->mem_info, base, size); #endif switch (ppi->type&0x00FF) { case NORMAL_PROCESS: - ppi->memlimit = pparams->normal.base + pparams->normal.size; res = run(pparams->normal.entry, pparams->normal.fs_sel, (DWORD)/*args*/ppi); break; case DLL_PROCESS: - ppi->memlimit = pparams->normal.base + pparams->normal.size; res = dll_run(pparams->normal.entry); break; case VM86_PROCESS: - ppi->memlimit = 0; res = vm86_call(pparams->vm86.ip, pparams->vm86.sp, pparams->vm86.in_regs, pparams->vm86.out_regs, pparams->vm86.seg_regs, pparams->vm86.prev_cpu_context, NULL); break; default: Modified: trunk/fd32/modules/dpmi/include/dpmimem.h =================================================================== --- trunk/fd32/modules/dpmi/include/dpmimem.h 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/modules/dpmi/include/dpmimem.h 2006-10-24 08:05:31 UTC (rev 847) @@ -1,9 +1,22 @@ #ifndef __DPMIMEM_H__ #define __DPMIMEM_H__ +#include <ll/i386/hw-data.h> + +#define MEMSIG 0xFD32 + +struct dpmimem_info { + DWORD signature; + DWORD size; + + struct dpmimem_info *next; +}; + void dpmi_set_limit(DWORD l); DWORD dpmi_get_mem(DWORD addr, DWORD size); DWORD dpmi_alloc(DWORD size, DWORD *base); int dpmi_free(DWORD handle); +void dpmi_clear_mem(struct dpmimem_info *top); + #endif /* DPMIMEM_H */ Modified: trunk/fd32/modules/dpmi/src/chandler.c =================================================================== --- trunk/fd32/modules/dpmi/src/chandler.c 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/modules/dpmi/src/chandler.c 2006-10-24 08:05:31 UTC (rev 847) @@ -16,6 +16,7 @@ #include <kernel.h> #include "dpmi.h" +#include "dpmimem.h" #include "rmint.h" #include "int31_00.h" #include "int31_01.h" @@ -61,6 +62,8 @@ fd32_get_current_pi()->type |= RESIDENT; if (bl != NULL) { + /* Free all the memory of the program (e.g. dos/32a) */ + dpmi_clear_mem(fd32_get_current_pi()->mem_info); /* No need to free the static memory system-stack * and Task switch back to the kernel task */ @@ -156,7 +159,7 @@ /* Terminate and stay resident */ return_to_dos(r, 1); } else if (r->x.ax == 0x4B82) { - fd32_log_printf("INT21 0x4B82 %x\n", r->d.edx); + fd32_log_printf("INT21 0x4B82 %lx\n", r->d.edx); } else { /* Redirect to call RM interrupts' handler */ int_redirect_to_rmint(0x21, r); Modified: trunk/fd32/modules/dpmi/src/dosexec.c =================================================================== --- trunk/fd32/modules/dpmi/src/dosexec.c 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/modules/dpmi/src/dosexec.c 2006-10-24 08:05:31 UTC (rev 847) @@ -18,6 +18,7 @@ #include <kernel.h> #include <logger.h> #include "dpmi.h" +#include "dpmimem.h" #include "dosmem.h" #include "dosexec.h" #include "ldtmanag.h" @@ -336,7 +337,6 @@ /* Create and set process information */ ppi = fd32_new_process(filename, args, MAX_OPEN_FILES); - ppi->memlimit = base + size; ppi->_exit = wrap_restore_sp; dpmi_stack = 0; /* Disable the stack switch in chandler */ @@ -414,6 +414,7 @@ { process_info_t *ppi; process_params_t params; + struct dpmimem_info dminfo; struct dos_header hdr; struct psp *ppsp; X_REGS16 in, out; @@ -467,6 +468,11 @@ ppi = fd32_new_process(filename, args, MAX_OPEN_FILES); _set_psp(ppi, ppsp, exec_seg+exec_size, 0, g_env_segment, 0, g_fcb1, g_fcb2, filename, args); ppi->type = VM86_PROCESS; + /* Init dpmimem info */ + dminfo.signature = MEMSIG; + dminfo.size = 0; + dminfo.next = NULL; + ppi->mem_info = &dminfo; ppi->_context = (void *)mem_get(sizeof(struct tss)); params.vm86.ip = hdr.e_ip; params.vm86.sp = hdr.e_sp; Modified: trunk/fd32/modules/dpmi/src/dpmiexc.c =================================================================== --- trunk/fd32/modules/dpmi/src/dpmiexc.c 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/modules/dpmi/src/dpmiexc.c 2006-10-24 08:05:31 UTC (rev 847) @@ -12,11 +12,11 @@ #include <logger.h> #include <kmem.h> -#include <timer.h> #include "handler.h" #include "dpmi.h" #include "dpmiexc.h" #include "ldtmanag.h" +#include "rmint.h" extern struct handler exc_table[32]; extern struct gate IDT[256]; @@ -191,9 +191,11 @@ return ERROR_INVALID_VALUE; } - /* TODO: Right place to resolve hardware intnum? and PIC2_BASE ... */ + /* TODO: Right place to resolve hardware intnum? */ if (intnum >= 8 && intnum < 16) intnum = intnum-8+PIC1_BASE; + if (intnum >= 0x70 && intnum < 0x78) + intnum = intnum-0x70+PIC2_BASE; /* CX:EDX = <selector>:<offset> of the interrupt handler */ /* Set it */ @@ -213,9 +215,11 @@ #ifdef __DPMIEXC_DEBUG__ fd32_log_printf("[DPMI] Set protect mode interrupt handler 0x%x!\n", intnum); #endif - /* TODO: Right place to resolve hardware intnum? and PIC2_BASE ... */ - if (intnum >= 8 && intnum < 16) - intnum = intnum-8+PIC1_BASE; + /* TODO: Right place to resolve hardware intnum? */ + if (intnum >= 0x08 && intnum < 0x10) + intnum = intnum-0x08+PIC1_BASE; + if (intnum >= 0x70 && intnum < 0x78) + intnum = intnum-0x70+PIC2_BASE; /* CX:EDX = <selector>:<offset> of the interrupt handler */ /* Set it */ Modified: trunk/fd32/modules/dpmi/src/dpmimem.c =================================================================== --- trunk/fd32/modules/dpmi/src/dpmimem.c 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/modules/dpmi/src/dpmimem.c 2006-10-24 08:05:31 UTC (rev 847) @@ -5,46 +5,49 @@ */ #include <ll/i386/hw-data.h> +#include <ll/string.h> -#include "kmem.h" -#include "kernel.h" +#include <kmem.h> +#include <kernel.h> +#include <exec.h> #include "dpmimem.h" -#define MEMSIG 0xFD32 /* #define __DPMIMEM_DEBUG__ */ -struct dpmimem_info { - DWORD signature; - DWORD size; -}; - DWORD dpmi_get_mem(DWORD addr, DWORD size) { + struct dpmimem_info *top = (struct dpmimem_info *)fd32_get_current_pi()->mem_info; struct dpmimem_info *p; DWORD area; int res; - - res = mem_get_region(addr - sizeof(struct dpmimem_info), - size + sizeof(struct dpmimem_info)); + + area = addr - sizeof(struct dpmimem_info); + res = mem_get_region(area, size + sizeof(struct dpmimem_info)); if (res == -1) { return 0; } - area = addr - sizeof(struct dpmimem_info); /* Fill the memory info header... */ p = (struct dpmimem_info *)area; p->signature = MEMSIG; p->size = size; + /* Link */ + if (top != NULL) { + p->next = top->next; + top->next = p; + } + return area; } DWORD dpmi_alloc(DWORD size, DWORD *base) { + struct dpmimem_info *top = (struct dpmimem_info *)fd32_get_current_pi()->mem_info; struct dpmimem_info *p; DWORD area; @@ -59,9 +62,8 @@ fd32_get_current_pi()->memlimit = area + (size + sizeof(struct dpmimem_info)); */ - /* NOTE: Use a normal mem_get 'cause Djlibc can support memory anywhere + /* NOTE: Use a normal mem_get 'cause DJGPP libc can support memory anywhere * althought it maybe result a negative memory address in an DPMI environment ... - * (from Hanzac) */ area = mem_get(size + sizeof(struct dpmimem_info)); if (area == 0) { @@ -73,13 +75,20 @@ p->signature = MEMSIG; p->size = size; + /* Link */ + if (top != NULL) { + p->next = top->next; + top->next = p; + } + *base = area + sizeof(struct dpmimem_info); return area; } int dpmi_free(DWORD handle) { - struct dpmimem_info *p; + struct dpmimem_info *top = (struct dpmimem_info *)fd32_get_current_pi()->mem_info; + struct dpmimem_info *p, *q; if (handle == 0) { return -1; @@ -89,5 +98,28 @@ return -1; } p->signature = 0; + + /* Remove link */ + if (top != NULL) { + for (q = top; q != NULL; q = q->next) + if (q->next == p) + { + q->next = p->next; + break; + } + + /* if (q == NULL) ...problem */ + } return mem_free(handle, p->size + sizeof(struct dpmimem_info)); } + +void dpmi_clear_mem(struct dpmimem_info *top) +{ + struct dpmimem_info *p, *t; + + for (p = top->next; p != NULL; p = t) + { + t = p->next; + mem_free((DWORD)p, p->size + sizeof(struct dpmimem_info)); + } +} Modified: trunk/fd32/modules/winb/winb.h =================================================================== --- trunk/fd32/modules/winb/winb.h 2006-10-19 11:32:22 UTC (rev 846) +++ trunk/fd32/modules/winb/winb.h 2006-10-24 08:05:31 UTC (rev 847) @@ -30,7 +30,7 @@ void *cds_list; /* Under DOS this is a global array */ char *args; char *filename; - uint32_t memlimit; + void *mem_info; void *jft; uint32_t jft_size; } process_info_t; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-10-19 11:32:35
|
Revision: 846 http://svn.sourceforge.net/freedos-32/?rev=846&view=rev Author: hanzac Date: 2006-10-19 04:32:22 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Bug fix ... Modified Paths: -------------- trunk/fd32/modules/dpmi/src/rmint.c Modified: trunk/fd32/modules/dpmi/src/rmint.c =================================================================== --- trunk/fd32/modules/dpmi/src/rmint.c 2006-10-19 07:13:48 UTC (rev 845) +++ trunk/fd32/modules/dpmi/src/rmint.c 2006-10-19 11:32:22 UTC (rev 846) @@ -87,7 +87,7 @@ return res; case 0x15: - res = dpmi_rmint_to_bios(0x10, r1); + res = dpmi_rmint_to_bios(0x15, r1); return res; case 0x16: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |