Friday, February 20, 2009

How InterruptInitialize wokrs!!! [WinCE]

This API takes basically two parameters:
1. Event name
2. Interrupt id(IRQ) which we choose manually.

It wil verify interrupt id is valid by comparing with SYSINTR_DEVICES, and SYSINTR_MAXIMUM.

Now check for valid event after getting handle for the event.
Next check for manualset and proxylist member.

Now it will convert the IRQ into sysirq and will check for maximum limit.

 If less then it will call OEMInterruptEnable whcih will send the sysintr.

So after that it will again call oalinterruptenable in intr.c.

For wince5.0 only!!!

Thursday, February 19, 2009

How CreateEvent works!!! [WinCE]

The API takes three parameters:
1. Initial status (we determine).
2. Set/reset option like manual or automatic
3. Name of event

First it will validate the parameter like caller needs to be trusted if the named object is system prefixed.
Next check for the name of event in the linked list if it has been already used.

Now call critical section.

Now if the name exists then it will return with error.
Next check for the same object is already opened but name does not exist.

Now if the object does not exist then it will get allocated memory from heap for synchronous object.

Now it will get a pointer of the memory allocated before, and will check the size if available.
If available, then grab the memory and then will call INTERRUPTS_ON() which is nesting interrupts.

Then it will get handle for the object.
Name and security related check will be done.
Also for out of memory.

Now after getting memory, we will clear it by filling 0.
Then copy name and security descriptor. Now will call pfnInit() for the particular object.
Then we will have to set the parameter on manual set/reset.
Note - wince5.0

How InitializeCriticalSection works!!! [WinCE]

This api Initializes a critical section object.
It will take the critical section object and initialize the member of the object with null then will call function CreateCrit which will again take the parameter as the critical section object and in the function it will check for the process trust level and then if it fulfill the trust level then if the object is equal to 1 then will map the critical section object to the base address of process VM base.
Now it verify the valid kernel pointer for the critical section's cric member.
After than it will call EnterCriticalSection on the global critical section object and then will do traversing to find in which location to save the new critical section object using linked list data structure.
When it will find the exact location then it will save there and then will call leave global critical section object (NameCS).
Note - This is for WCE5.0.