-Nearly compiles doscalls

-Added  an mixing header to have ntddk and os2 included without conflicts

svn path=/trunk/; revision=3304
This commit is contained in:
Robert Kopferl 2002-07-26 00:23:13 +00:00
parent 554d0a03f4
commit d35d4191c1
9 changed files with 182 additions and 237 deletions

52
os2/include/ros2.h Normal file
View file

@ -0,0 +1,52 @@
/* $ $
*/
/*
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS OS/2 sub system
* FILE: dll/doscalls.c
* PURPOSE: supportheader for Kernelservices.
* Use this file if your dll or application
* is going to use both, the os2 base services
* as well as the native API of NTDLL.DLL
* PROGRAMMER: Robert K. nonvolatil@yahoo.de
* REVISION HISTORY:
* 1-08-2002 Created
*/
/* How to use:
History got us another time. If you want to write a module
that uses either native-api or os2-services...no problem.
But if you want to use both of them you run into type conflicts.
BOOL is not very surprising. But there are many other types
whose names are equal. This results from the fact that NT
should originally become OS/2 3.0.
So your solution lies in including this file instead of os2.h
and ntddk.h. What this file here does is, it puts the os2-types+
functions into the namespace OS2 while the nt-types+functions are
put into the namespace NT. The still conflicting #defines are handled
like this: If ntddk.h defintes a symbol FOO and os2.h does the same,
this file here undefines the ntddk.h-one and renames it to NT_FOO.
This is only done for conflicting symbols. Of course, this ist a
source for errors. But is there a better solution than renaming
all of the symbols?
*/
namespace NT
{
#include <ddk/ntddk.h>
}
/* rename all the symbols */
#define NT_FILE_CREATE FILE_CREATE
#undef FILE_CREATE
#define NT_CREATE_SUSPENDED CREATE_SUSPENDED
#undef CREATE_SUSPENDED
namespace OS2
{
#include "os2.h"
}
using namespace OS2;

View file

@ -1,4 +1,4 @@
/* $Id: devices.cpp,v 1.1 2002/07/23 13:00:10 robertk Exp $
/* $Id: devices.cpp,v 1.2 2002/07/26 00:23:12 robertk Exp $
*/
/*
*
@ -9,11 +9,12 @@
* PROGRAMMER: Robert K. nonvolatil@yahoo.de
* REVISION HISTORY:
* 13-03-2002 Created
* 25-07-2002 Work to make it compile
*/
#define INCL_DOSDEVICES
#include "../../../include/os2.h"
#include <ddk/ntddk.h>
#define INCL_DOSERRORS
#include "ros2.h"
/*******************************************/
@ -55,5 +56,5 @@ APIRET STDCALL Dos32DevIOCtl(HFILE hDevice, ULONG category, ULONG function,
PVOID pParams,ULONG cbParmLenMax,PULONG pcbParmLen,
PVOID pData,ULONG cbDataLenMax,PULONG pcbDataLen)
{
return 0;
return ERROR_CALL_NOT_IMPLEMENTED;
}

View file

@ -1,4 +1,4 @@
/* $Id: openclose.cpp,v 1.1 2002/07/23 13:00:11 robertk Exp $
/* $Id: openclose.cpp,v 1.2 2002/07/26 00:23:12 robertk Exp $
*/
/*
*
@ -8,13 +8,14 @@
* PURPOSE: Kernelservices for OS/2 apps
* PROGRAMMER: Robert K. nonvolatil@yahoo.de
* REVISION HISTORY:
* 13-03-2002 Created
* 13-03-2002 Created
* 25-07-2002 Work to make it compile
*/
#define INCL_DOSFILEMGR
#include "../../../include/os2.h"
#include <ddk/ntddk.h>
#define INCL_DOSERRORS
#include "ros2.h"
@ -38,7 +39,7 @@ IN PVOID EaBuffer OPTIONAL,
IN ULONG EaLength
);*/
/*
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
@ -114,17 +115,17 @@ IN ULONG EaLength
return INVALID_HANDLE_VALUE;
}
return FileHandle;
return FileHandle;*/
return 0;
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* close a Handle. seems finished */
APIRET STDCALL Dos32Close(HFILE hFile)
{
NTSTATUS nErrCode;
nErrCode = NtClose( (HANDLE)hFile );
NT::NTSTATUS nErrCode;
nErrCode = NT::ZwClose( (NT::HANDLE)hFile );
switch( nErrCode )
{
case STATUS_SUCCESS:
@ -139,14 +140,13 @@ APIRET STDCALL Dos32Close(HFILE hFile)
APIRET STDCALL Dos32Read(HFILE hFile, PVOID pBuffer,
ULONG cbRead, PULONG pcbActual)
{
NTSTATUS nErrCode;
IO_STATUS_BLOCK isbStatus;
NT::NTSTATUS nErrCode;
NT::IO_STATUS_BLOCK isbStatus;
// read data from file
nErrCode = NtReadFile( (HANDLE)hFile, NULL, NULL, NULL,
nErrCode = NT::ZwReadFile( (NT::HANDLE)hFile, NULL, NULL, NULL,
&isbStatus, pBuffer, cbRead,
NULL, NULL );
// contains the # bytes actually read.
@ -164,12 +164,13 @@ APIRET STDCALL Dos32Read(HFILE hFile, PVOID pBuffer,
APIRET STDCALL Dos32Write(HFILE hFile, PVOID pBuffer,
ULONG cbWrite, PULONG pcbActual)
{
NTSTATUS nErrCode;
IO_STATUS_BLOCK StatusBlk;
nErrCode = NtWriteFile( (HANDLE)hFile, NULL, NULL, NULL,
NT::NTSTATUS nErrCode;
NT::IO_STATUS_BLOCK StatusBlk;
nErrCode = NtWriteFile( (NT::HANDLE)hFile, NULL, NULL, NULL,
&StatusBlk, pBuffer, cbWrite, 0, NULL );
*pcbActual = StatusBlk.Information;
// FIXME *pcbActual = StatusBlk.Information;
// do an errorcode translation FIXME: correct
return ERROR_CALL_NOT_IMPLEMENTED;
switch(nErrCode)
{
case STATUS_SUCCESS:

View file

@ -1,31 +1,44 @@
# $Id: makefile,v 1.3 2002/05/30 15:11:46 robertk Exp $
# $Id: makefile,v 1.4 2002/07/26 00:23:12 robertk Exp $
PATH_TO_TOP = ../../../..
PATH_TO_TOP = ../../../reactos
PATH_TO_OS2_TOP = ../..
TARGET_TYPE = dynlink
# TARGET_DEFONLY = yes
TARGET_NAME = doscalls
TARGET_BASE = 0x30000000
TARGET_BASE = 0x60000000
TARGET_CFLAGS = -DDOSCALLS_BASE=$(TARGET_DLLBASE)
TARGET_CPPFLAGS =\
-Wall \
-I$(PATH_TO_OS2_TOP)/include \
-D__DOSCALLSDLL__
# removed CFLAGX
# -fno-builtin \
# -nostdinc \
# -nostdlib \
TARGET_LFLAGS = -nostartfiles
TARGET_SDKLIBS = ntdll.a
TARGET_GCCLIBS = gcc
#TARGET_GCCLIBS = gcc
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CLEAN = file/*.o vio/*.o sync/*.o mem/*.o \
misc/*.o mou/*.o kbd/*.o run/*.o
DOSCALLS_MISC_OBJECTS = misc/doscalls.o file/openclose.o run/process.o devices/devices.o
DOSCALLS_MISC_OBJECTS = misc/doscalls.o misc/error.o
DOSCALLS_OTHER_O = file/openclose.o run/process.o devices/devices.o
#SYNC_OBJECTS =
TARGET_OBJECTS = $(DOSCALLS_MISC_OBJECTS)
TARGET_OBJECTS = $(DOSCALLS_OTHER_O) $(DOSCALLS_MISC_OBJECTS)
include $(PATH_TO_TOP)/rules.mak

View file

@ -1,4 +1,4 @@
/* $Id: doscalls.c,v 1.5 2002/05/30 15:11:46 robertk Exp $
/* $Id: doscalls.cpp,v 1.1 2002/07/26 00:23:13 robertk Exp $
*/
/*
*
@ -12,6 +12,7 @@
*/
// here's only the NTDLL needet
#include <ddk/ntddk.h>

View file

@ -1,83 +0,0 @@
/* $Id: doscalls.h,v 1.4 2002/05/30 15:11:46 robertk Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS OS/2 sub system
* FILE: dll/doscalls.h
* PURPOSE: Kernelservices for OS/2 apps
* PROGRAMMER: Robert K. robertk@mok.lvcm.com
* REVISION HISTORY:
* 13-03-2002 Created
*/
// FIXME: use ib headers
#define EXIT_THREAD 0
#define EXIT_PROCESS 1
#define NO_ERROR 0
#define ERROR_INVALID_HANDLE 5
#define ERROR_FILE_NOT_FOUND 6
// for this
// Give the user nicer names that the internal ones
#define DosSleep Dos32Sleep
#define DosCreateThread Dos32CreateThread
#define DosOpen Dos32Open
#define DosClose Dos32Close
#define DosRead Dos32Read
#define DosWrite Dos32Write
#define DosBeep Dos32Beep
#define DosExit Dos32Exit
APIRET STDCALL Dos32Sleep(ULONG msec);
APIRET STDCALL Dos32CreateThread(PTID ptid,
PFNTHREAD pfn,
ULONG param,
ULONG flag,
ULONG cbStack);
APIRET STDCALL Dos32Open(PSZ pszFileName,
PHFILE pHf,
PULONG pulAction,
ULONG cbFile,
ULONG ulAttribute,
ULONG fsOpenFlags,
ULONG fsOpenMode,
PVOID reserved ); //ULONGPEAOP2 peaop2)
APIRET STDCALL Dos32Close(HFILE hFile);
APIRET STDCALL Dos32Read(HFILE hFile,
PVOID pBuffer,
ULONG cbRead,
PULONG pcbActual);
APIRET STDCALL Dos32Write(HFILE hFile,
PVOID pBuffer,
ULONG cbWrite,
PULONG pcbActual);
APIRET STDCALL Dos32DevIOCtl(HFILE hDevice, ULONG category, ULONG function,
PVOID pParams,ULONG cbParmLenMax,PULONG pcbParmLen,
PVOID pData,ULONG cbDataLenMax,PULONG pcbDataLen);
APIRET STDCALL Dos32Beep(ULONG freq,
ULONG dur);
VOID STDCALL Dos32Exit(ULONG action,
ULONG result);

View file

@ -0,0 +1,73 @@
/* $Id: error.cpp,v 1.1 2002/07/26 00:23:13 robertk Exp $
*/
/*
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS OS/2 sub system
* FILE: dll/process.cpp
* PURPOSE: Kernelservices for OS/2 apps
* PROGRAMMER: Robert K. nonvolatil@yahoo.de
* REVISION HISTORY:
* 13-03-2002 Created
* 25-07-2002 Work to make it compile
*/
#define INCL_DOSPROCESS
#define INCL_DOSERRORS
#include "ros2.h"
// we need the extra definitions of this file
namespace NT {
#include <ddk/ntddbeep.h>
}
APIRET STDCALL DosBeep(ULONG freq, ULONG dur)
{
NT::BEEP_SET_PARAMETERS BeepSetParameters;
NT::HANDLE hBeep;
NT::IO_STATUS_BLOCK ComplStatus;
NT::UNICODE_STRING unistr;
NT::NTSTATUS stat;
NT::OBJECT_ATTRIBUTES oa = {sizeof oa, 0, &unistr, NT::OBJ_CASE_INSENSITIVE, 0, 0};
// init String still bevore use.
NT::RtlInitUnicodeString( &unistr, L"\\\\.\\Beep" );
if( freq<0x25 || freq>0x7FFF )
return ERROR_INVALID_FREQUENCY; //395; //
/* Set beep data */
BeepSetParameters.Frequency = freq;
BeepSetParameters.Duration = dur;
/* open the beep dirver */
stat = NT::ZwOpenFile( &hBeep,
FILE_READ_DATA | FILE_WRITE_DATA,
&oa,
&ComplStatus,
0, // no sharing
FILE_OPEN );
if (!NT_SUCCESS(stat))
{
return ERROR_NOT_READY;
}
/* actually beep */
NT::ZwDeviceIoControlFile(hBeep, 0, // Event
0, // APC-routine
0, // UserAPCContext
&ComplStatus, IOCTL_BEEP_SET,
&BeepSetParameters,
sizeof(NT::BEEP_SET_PARAMETERS),
NULL,
0 );
NT::ZwClose(hBeep);
return NO_ERROR;
}
/* EOF */

View file

@ -1,54 +0,0 @@
/* $Id: os2def.h,v 1.3 2002/04/18 23:49:42 robertk Exp $ */
/* This file conains common OS/2 types that are needed to build this dll */
/* this file should have temporal character until a better idea is born */
#ifndef __OS2DEF__
#define __OS2DEF__
typedef unsigned long __stdcall APIRET;
#define APIENTRY
typedef char *PSZ;
typedef char *NPSZ;
typedef char *NPCH;
#define VOID void
//
/* define these types only when ntdll is not included */
#if( !defined( __INCLUDE_NTDEF_H ))
#define CHAR char
#define SHORT short
#define LONG long
typedef char BYTE;
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
typedef CHAR *PCHAR;
typedef SHORT *PSHORT;
typedef LONG *PLONG;
typedef UCHAR *PUCHAR;
typedef USHORT *PUSHORT;
typedef ULONG *PULONG;
typedef VOID *PVOID;
#endif
//typedef char *PCH;
//typedef const char *PCSZ;
typedef unsigned long LHANDLE;
typedef LHANDLE HMODULE; /* hmod */
typedef LHANDLE PID; /* pid */
typedef LHANDLE TID; /* tid */
typedef LHANDLE HFILE;
typedef HFILE *PHFILE;
typedef HMODULE *PHMODULE;
typedef PID *PPID;
typedef TID *PTID;
typedef VOID APIENTRY FNTHREAD(ULONG);
typedef FNTHREAD *PFNTHREAD;
#endif //__OS2DEF__

View file

@ -1,4 +1,4 @@
/* $Id: process.cpp,v 1.3 2002/05/30 15:11:47 robertk Exp $
/* $Id: process.cpp,v 1.4 2002/07/26 00:23:13 robertk Exp $
*/
/*
*
@ -8,26 +8,27 @@
* PURPOSE: Kernelservices for OS/2 apps
* PROGRAMMER: Robert K. nonvolatil@yahoo.de
* REVISION HISTORY:
* 13-03-2002 Created
* 13-03-2002 Created
* 25-07-2002 Work to make it compile
*/
#define INCL_DOSPROCESS
#include "../../../include/os2.h"
#include <ddk/ntddk.h>
#define INCL_DOSERRORS
#include "ros2.h"
APIRET STDCALL DosSleep(ULONG msec)
{
NTSTATUS stat;
TIME Interv;
NT::NTSTATUS stat;
NT::TIME Interv;
Interv.QuadPart= -(10000 * msec);
stat = NtDelayExecution( TRUE, &Interv );
stat = NT::NtDelayExecution( TRUE, &Interv );
return 0;
}
/* $Id: process.cpp,v 1.3 2002/05/30 15:11:47 robertk Exp $ */
/* $Id: process.cpp,v 1.4 2002/07/26 00:23:13 robertk Exp $ */
/* Terminates the current thread or the current Process.
Decission is made by action
FIXME: move this code to OS2.EXE */
@ -36,79 +37,19 @@ VOID APIENTRY DosExit(ULONG action, ULONG result)
// decide what to do
if( action == EXIT_THREAD)
{
NtTerminateThread( NULL, result );
NT::NtTerminateThread( NULL, result );
}
else // EXIT_PROCESS
{
NtTerminateProcess( NULL, result );
NT::NtTerminateProcess( NULL, result );
}
}
APIRET STDCALL DosBeep(ULONG freq, ULONG dur)
{
if( freq<0x25 || freq>0x7FFF )
return 395; // ERROR_INVALID_FREQUENCY
HANDLE hBeep;
IO_STATUS_BLOCK ComplStatus;
//UNICODE_STRING
OBJECT_ATTRIBUTES oa = {sizeof oa, 0, {8,8,"\\\\.\\Beep"l}, OBJ_CASE_INSENSITIVE};
NTSTATUS stat;
stat = NtOpenFile( &hBeep,
FILE_READ_DATA | FILE_WRITE_DATA,
&oa,
&ComplStatus,
0, // no sharing
FILE_OPEN );
if (!NT_SUCCESS(stat))
{
}
if( ComplStatus->
/* HANDLE hBeep;
BEEP_SET_PARAMETERS BeepSetParameters;
DWORD dwReturned;
hBeep = Dos32Open("\\\\.\\Beep",
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hBeep == INVALID_HANDLE_VALUE)
return FALSE;
*/
// Set beep data
/* BeepSetParameters.Frequency = dwFreq;
BeepSetParameters.Duration = dwDuration;
DeviceIoControl(hBeep,
IOCTL_BEEP_SET,
&BeepSetParameters,
sizeof(BEEP_SET_PARAMETERS),
NULL,
0,
&dwReturned,
NULL);
CloseHandle (hBeep);
return TRUE;
*/
return 0;
}
APIRET STDCALL DosCreateThread(PTID ptid, PFNTHREAD pfn,
ULONG param, ULONG flag, ULONG cbStack)
{
return 0;
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* EOF */