[RPI BSP] zero length array in kernel and refactor of video char output

Gedare Bloom gedare at rtems.org
Tue Jun 23 18:15:27 UTC 2015


On Tue, Jun 23, 2015 at 7:43 AM, QIAO YANG <yangqiao0505 at me.com> wrote:
> Hi,
>
> As suggested by gedare, I think using zero length array to represent the
> mailbox buffer and tag data is a good way, much readable, clearer to
> abstract the structure of mailbox buffer, tag.
> I've done an attemp, here is the scratch:
> https://github.com/yangqiao/rtems/commit/3ed7e9bde493bdc8e644fcefa285d99255201ada
>
> The construction of a buffer is then decomposed by the following procedure:
> 1. Calculate the total length of buffer
> 2. Allocate and inite the buffer
> 3. Pack the request data into buffer
> 4. send the buffer by mailbox, then read the responce
> 5. Unpack the responce data into variables
>
> I've tested it in userspace it works well but in kernel space I cannot
> allocate the memory by malloc. Is there any alternative way to let us use
> zero length array in the kernel driver?
>
It depends. BSP code can use malloc, but care should be taken about
where you use it. An alternative would be to use a free list.

>
> Secondly, since part of functions in outch is considered sharable between
> bsps. If my implementation is acceptable, I'll push the refactor code for
> review. Here is my implementation
> https://github.com/yangqiao/rtems/commit/858a9b091025acc4bfe912f41d70c9a73b99d773
>
You still need to attribute the original source of that file.

> Thanks in advance.



More information about the devel mailing list