Ok, here's he code in full:
In Module 2 (where it happens):
=====================
function call:
Code: Select all
parse_request((void *)instream + 1 + 3);
function:
Code: Select all
void parse_request(void *place)
{
uchar *c_place; /*allows chars to be read from the request*/
ushort *u_place; /*allows shorts to be read from the request*/
ushort function; /*for reading the function number into*/
uchar request[1]; /*request is two bytes at the moment*/
/*Extract request from stream*/
c_place = (uchar *)place; /*initialise pointers*/
u_place = (ushort *)place;
function=u_place[0]; /*read the function*/
if(u_place[1]!=1){_print("MM: Object request error",0xCF,4);return;} /*stop if the request length is wrong*/
request[0]=c_place[4];
request[1]=c_place[5];
/*Process it*/
if(request[0]=='a' && request[1]=='p' && function==0x0001)
{
_print("Request recieved",0xCF,4);
}
else
{
if(request[0]!='a')_print("Request recieved, but with error in data (r0)",0xCF,4);
if(request[1]!='p')_print("Request recieved, but with error in data (r1)",0xCF,5);
if(function!=0x0001)_print("Request recieved, but with error in data (f)",0xCF,6);
asm("ljmp 0xFFFFFFF"); /*crash - so as not to continue execution*/
}
}
In Module 1 (the module that starts everything off):
=================================
Function call:
Code: Select all
outstream=(unsigned short *)V_KERNEL_TO_MM_STREAM;
request[0]='a';
request[1]='p';
parameters=0x7777;
write_object_request( (void *)outstream+4,
0x0001,
(unsigned char *)&request,
(uchar *)¶meters,
1,
1);
outstream[0]=4+4+6;
Filling Function:
==========
Code: Select all
void write_object_request( void *place, /*where the request is written to*/
unsigned short function, /*function no. to activate*/
unsigned char *request, /*object requested (in object request format)*/
unsigned char *parameters, /*parameters to be passed*/
unsigned short request_size,/*in bytes*/
unsigned short parameters_size) /**/
{
unsigned char *c_place; /*allows chars to be written to the request*/
unsigned short *u_place; /*allows shorts to be written to the request*/
unsigned long i;
/*Initialise pointers*/
c_place = (unsigned char *)place;
u_place = (unsigned short *)place;
/*Write the function*/
u_place[0]=function;
/*Write the object request:*/
u_place[1]=request_size;
for(i=0; i<=(request_size); i++)
c_place[i+4]=request[i];
}
--------------------------------------------------
Explanation:
- The instream of module 2 and outstream of module 1 are identical memory locations.
- The memory location at which the data being written and read should contain: function number [2 bytes], object name length [2 bytes], object name [1 bytes * length].
- This has been checked and shown correct using the bochs debugger checking both physical and virtual memory locations.
- The two request bytes are read fine by module 2
- The function number is correct when read directly from the stream, as in the following code formulates correctly (shortend):
Code: Select all
if(u_place[0]!=0x0001) _print("error");
- However, the following (shortend) does not formulate correctly:
Code: Select all
function=u_place[0];
if(function!=0x0001) _print("error");
As you can understand, I am completely confuzled as to why this doesn't work!
Thanks,
OScoder
P.S The memory being read off contains the following:
EDIT:
Ugh, this really makes no sense, but the following code does not work either. I'm guessing that in one of the if stements I'm assigning something by accident, but how I cannot guess!:
Code: Select all
void parse_request(void *place)
{
uchar *c_place; /*allows chars to be read from the request*/
ushort *u_place; /*allows shorts to be read from the request*/
uchar request[1]; /*request is two bytes at the moment*/
/*Extract request from stream*/
c_place = (uchar *)place; /*initialise pointers*/
u_place = (ushort *)place;
if(u_place[1]!=1){_print("MM: Object request error",0xCF,4);return;} /*stop if the request length is wrong*/
request[0]=c_place[4];
request[1]=c_place[5];
/*Process it*/
if(request[0]=='a' && request[1]=='p' && u_place[0]==1)
{
_print("Request recieved",0xCF,4);
}
else
{
if(request[0]!='a')_print("Request recieved, but with error in data (r0)",0xCF,4);
if(request[1]!='p')_print("Request recieved, but with error in data (r1)",0xCF,5);
if(u_place[0]!=1)_print("Request recieved, but with error in data (f)",0xCF,6);
asm("ljmp 0xFFFFFFF");
}
}