| 59 | Xilkernel’s dynamic memory functions are used for allocating buffers of custom sizes and widths. The buffers are made from a preset memory table located in the “'''OS and Libraries'''” section of “'''Software Platform Settings'''.” This functionality is useful for creating a buffer repository for memory structures of custom size – such as a packet. The dynamic memory allocation functions provide no resource-locking mechanisms, however. Dynamic memory API may be found in “'''$EDK\doc\oslib_rm.pdf'''.” A basic reference design may be found [http://warp.rice.edu/trac/browser/RefDesigns/WARP_v_1_1/Xilkernel_dynmem_ex_for_WARP_v_1_1_XPS8.zip here]. It is also implemented in the [http://warp.rice.edu/trac/wiki/ACKMAC ACKMAC Research Application]. The following are some of the common or more important functions involved in working with dynamic memory: |
| 60 | * '''bufcreate( )''' – upon a successful call, the function will create a buffer ID given a requested depth (number of blocks) and width (size of blocks). |
| 61 | * '''bufdestroy( )''' – destroys the buffer ID, but not the reserved memory pool |
| 62 | * '''bufmalloc( )''' – allocate memory from a predefined memory pool (from “software platform settings”) to be associated with the buffer ID. |
| 63 | * '''buffree ( )''' – frees the memory that was allocated to a buffer ID |
| 67 | Message Queues are an extremely powerful feature of xilkernel. They are a very easy and safe means of transferring data back and forth between multiple processes. Messaging is safe because the functionality uses semaphores internally. It’s easy because messages can take in custom structs. Only four functions are needed to setup, send and receive messages between threads. There is also support for having multiple messages in the system. Message Queue API may be found in “'''$EDK\doc\oslib_rm.pdf'''.” A message queue demo for WARP may be found [http://warp.rice.edu/trac/browser/RefDesigns/WARP_v_1_1/Xilkernel_msg_queue_ex_for_WARP_v_1_1_XPS8.zip here]. The following are some of the common or more important functions involved in working with message queues: |
| 68 | * '''msgget( )''' – returns an ID number for a message queue given an unused/empty key value. |
| 69 | * '''msgctl( )''' – can be used to either copy the message queue’s data structure into a buffer, or destroy the message queue, given a message queue ID number. |
| 70 | * '''msgsnd( )''' – places a message on the queue |
| 71 | * '''msgrcv ( )''' – takes a message off the queue and places it in a buffer. The user can define the function to return immediately or suspend execution until a message exists if no messages are present at the time of the calling. |
| 72 | |
| 73 | == Setting Up Interrupts in C (Xilkernel OS) == |
| 74 | |
| 75 | Getting interrupts to run in xilkernel is similar to getting them running on the standalone OS, but xilkernel abstracts away function calls to the interrupt controller. First the peripherals must be tied to the interrupt controller in hardware properly. Once this has been accomplished, the following steps are needed to have an interrupts implemented in the software: |
| 76 | |
| 77 | 1. In “Software Platform Settings” under “Interrupt Handlers,” give the desired interrupt a handler name. The interrupt controller does not require a handler unless the user would like a special function call for any interrupt that occurs |
| 78 | 1. In the main code, initialize the interrupting peripheral with it’s API |
| 79 | 1. Initialize the interrupting peripheral’s interrupt with it’s API and start it running if required (such as a timer) |
| 80 | 1. Use the xilkernel function: '''enable_interrupt( )''' – which takes in the interrupt ID of the peripheral, found in “'''xparameters.h'''.” For the enable function call, it is of type “'''int_id_t'''.” |
| 81 | 1. Have a function prepared with the handler name |
| 82 | |
| 83 | A basic timer interrupt demo for xilkernel may be found [http://warp.rice.edu/trac/browser/RefDesigns/WARP_v_1_1/Xilkernel_timer_interrupt_ex_for_WARP_v_1_1_XPS8.zip here]. The xilkernel API documentation for xilkernel interrupts may be found in “'''$EDK\doc\oslib_rm.pdf'''.” |