Serial communication between ports using semaphores

Hi,
I am trying develop a project in which I have to write a code for serial communication between the external port RS232 and the internal port of GPS and Modem in a GD32F407 board using freeRTOS. Another task is gong to be used to manage the queues of the messages sent between the three ports by using semaphores.
Can anybody help me regarding how to go for it?

Thank You!!!

My first thought for that sort of problem is start with an interrupt based serial driver that interfaces between ‘task level’ buffers (perhaps queue or stream buffers) and the hardware. I would then have a task for each serial input buffer that processes the messages from it. Each of these tasks would send messages to the appropriate serial output port, with a Mutex to make sure messages stay together.