gma: Add interface functions to update/place/move cursor

Add Update_Cursor() that allows updates to all cursor parameters,
Place_Cursor() and Move_Cursor() to update the position only.

Change-Id: I6e97442847ea42662214390d80aaf634a4b1ab5a
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/23216
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Tested-by: Nico Huber <nico.h@gmx.de>
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 7fa58a4..f962e1c 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -299,6 +299,8 @@
             then
                Display_Controller.Setup_FB
                  (Pipe, New_Config.Mode, New_Config.Framebuffer);
+               Display_Controller.Update_Cursor
+                 (Pipe, New_Config.Framebuffer, New_Config.Cursor);
                Cur_Config := New_Config;
             end if;
          end;
@@ -311,6 +313,44 @@
 
    ----------------------------------------------------------------------------
 
+   procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type)
+   is
+   begin
+      Cur_Configs (Pipe).Cursor := Cursor;
+      Display_Controller.Update_Cursor
+        (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor);
+   end Update_Cursor;
+
+   procedure Place_Cursor
+     (Pipe  : Pipe_Index;
+      X     : Cursor_Pos;
+      Y     : Cursor_Pos)
+   is
+   begin
+      Cur_Configs (Pipe).Cursor.Center_X := X;
+      Cur_Configs (Pipe).Cursor.Center_Y := Y;
+      Display_Controller.Place_Cursor
+        (Pipe, Cur_Configs (Pipe).Framebuffer, Cur_Configs (Pipe).Cursor);
+   end Place_Cursor;
+
+   procedure Move_Cursor
+     (Pipe  : Pipe_Index;
+      X     : Cursor_Pos;
+      Y     : Cursor_Pos)
+   is
+      function Cap_Add (A, B : Cursor_Pos) return Cursor_Pos is
+        (if A + B < 0
+         then Int32'Max (Cursor_Pos'First, A + B)
+         else Int32'Min (Cursor_Pos'Last, A + B));
+   begin
+      Place_Cursor
+        (Pipe  => Pipe,
+         X     => Cap_Add (Cur_Configs (Pipe).Cursor.Center_X, X),
+         Y     => Cap_Add (Cur_Configs (Pipe).Cursor.Center_Y, Y));
+   end Move_Cursor;
+
+   ----------------------------------------------------------------------------
+
    procedure Initialize
      (Write_Delay : in     Word64 := 0;
       Clean_State : in     Boolean := False;