~samhsmith/AstraOS

908d94e03cbab845a545d8456fbedfabc5eb1371 — Sam H Smith 2 years ago c67de80
moved dave_terminal over to thunder and removed legacy rendering support
3 files changed, 68 insertions(+), 46 deletions(-)

M dave_terminal/dave.c
M square_src/elf.c
M src/tempuser.c
M dave_terminal/dave.c => dave_terminal/dave.c +53 -8
@@ 122,12 122,58 @@ void _start()
    AOS_alloc_pages(pre_send_to_stdin, 1);
    u64 pre_send_to_stdin_len = 0;

    u8 is_running_as_twa = 0;
    u64 twa_session_id;
    u64 twa_window_handle = 0;
    {
        u8* name = "thunder_windowed_application_ipfc_api_v1";
        u64 name_len = strlen(name);
        if(AOS_IPFC_init_session(name, name_len, &twa_session_id))
        {
            is_running_as_twa = 1;
            // create window
            u64 scratch[1024/8];
            if(AOS_IPFC_call(twa_session_id, 0, 0, &scratch))
            {
                twa_window_handle = scratch[0];
                AOS_H_printf("Created a thunder window! handle = %llu\n", twa_window_handle);
            }
            else
            {
                AOS_IPFC_close_session(twa_session_id);
                is_running_as_twa = 0;
                AOS_H_printf("Failed to create thunder window!\n");
            }
        }
        else
        { AOS_H_printf("Failed to init thunder session\n"); }
    }

    spinlock_acquire(&surface_visible_lock);
    while(1)
    {
        spinlock_release(&surface_visible_lock);
        u64 surface_handle = 0;
        AOS_thread_awake_on_surface(&surface_handle, 1);

#define DEBUG_IPFC_TIME 0

        u16 surfaces[512];
        u16 surface_count = 0;

        if(is_running_as_twa)
        {
#if DEBUG_IPFC_TIME
            f64 sec_before_call = AOS_H_time_get_seconds();
#endif
            u64 scratch[1024/8];
            scratch[0] = twa_window_handle;
            surface_count = AOS_IPFC_call(twa_session_id, 2, scratch, surfaces);
#if DEBUG_IPFC_TIME
            f64 sec_after_call = AOS_H_time_get_seconds();
            AOS_H_printf("time to get surfaces via ipfc : %5.5lf ms\n", (sec_after_call - sec_before_call) * 1000.0);
#endif
        }

        AOS_thread_awake_on_surface(&surfaces, surface_count);
        AOS_thread_awake_after_time(100000);  // haha, this sleep causes frame drops
        AOS_thread_sleep();
        spinlock_acquire(&surface_visible_lock);


@@ 156,13 202,13 @@ void _start()
            { surface_visible = 0; }

            if(show_console)
            { AOS_surface_stop_forwarding_to_consumer(surface_handle); }
            { AOS_surface_stop_forwarding_to_consumer(surfaces[0]); }
            else
            {
                if(surface_visible)
                { AOS_surface_forward_to_consumer(surface_handle, consumer_handle); }
                { AOS_surface_forward_to_consumer(surfaces[0], consumer_handle); }
                else
                { AOS_surface_stop_forwarding_to_consumer(surface_handle); }
                { AOS_surface_stop_forwarding_to_consumer(surfaces[0]); }
            }
        }



@@ 370,10 416,9 @@ void _start()
            text_len += taken_count;
        }


        AOS_Framebuffer* fb = 0x696969000;
        u64 fb_page_count = 9001;
        if(AOS_surface_acquire(surface_handle, fb, fb_page_count))
        if(surface_count && AOS_surface_acquire(surfaces[0], fb, fb_page_count))
        {
            u64 column_count = fb->width / 8;
            u64 row_count = (fb->height / 16) + 1;


@@ 529,7 574,7 @@ void _start()
                    }
                }
            }
            AOS_surface_commit(surface_handle);
            AOS_surface_commit(surfaces[0]);
        }
    }
}

M square_src/elf.c => square_src/elf.c +11 -4
@@ 78,27 78,34 @@ void _start()

while(1)
{
#define DEBUG_IPFC_TIME 0

    u16 surfaces[512];
                            surfaces[0] = 0;  // temp
    u16 surface_count = 1; // temp
    u16 surface_count = 0;
    if(is_running_as_ega)
    {
#if DEBUG_IPFC_TIME
        f64 sec_before_call = AOS_H_time_get_seconds();
#endif
        surface_count = AOS_IPFC_call(ega_session_id, 0, 0, surfaces);
#if DEBUG_IPFC_TIME
        f64 sec_after_call = AOS_H_time_get_seconds();
        AOS_H_printf("time to get surfaces via ipfc : %5.5lf ms\n", (sec_after_call - sec_before_call) * 1000.0);
#endif
    }
#if 1
    else if(is_running_as_twa)
    {
#if DEBUG_IPFC_TIME
        f64 sec_before_call = AOS_H_time_get_seconds();
#endif
        u64 scratch[1024/8];
        scratch[0] = twa_window_handle;
        surface_count = AOS_IPFC_call(twa_session_id, 2, scratch, surfaces);
#if DEBUG_IPFC_TIME
        f64 sec_after_call = AOS_H_time_get_seconds();
        AOS_H_printf("time to get surfaces via ipfc : %5.5lf ms\n", (sec_after_call - sec_before_call) * 1000.0);
    }
#endif
    }

    AOS_thread_awake_on_surface(&surfaces, surface_count);
    AOS_thread_sleep();

M src/tempuser.c => src/tempuser.c +4 -34
@@ 785,40 785,10 @@ while(1) {
                        u64 pid = 0;
                        if(AOS_create_process_from_file(partitions[slot_index], &pid))
                        {
                            AOS_H_printf("PROCESS CREATED, PID=%llu\n", pid);
                            u64 con = 0;
                            u64 surface_slot;
                            if(AOS_surface_consumer_create(pid, &con, &surface_slot))
                            {
                                windows[window_count].pid = pid;
                                windows[window_count].consumer = con;
                                windows[window_count].x = 20 + window_count*7;
                                windows[window_count].y = 49*window_count;
                                if(windows[window_count].y > 400) { windows[window_count].y = 400; }
                                windows[window_count].new_x = windows[window_count].x;
                                windows[window_count].new_y = windows[window_count].y;
                                windows[window_count].width = 0;
                                windows[window_count].height = 0;
                                windows[window_count].new_width = 64;
                                windows[window_count].new_height = 64;
                                windows[window_count].fb = 0x54000 + (6900*6900*4*4 * (window_count+1));
                                windows[window_count].fb = (u64)windows[window_count].fb & ~0xfff;
                                windows[window_count].we_have_frame = 0;
                                windows[window_count].window_handle = window_handle_counter++;
                                AOS_process_create_out_stream(pid, 0, &programs[program_count].owned_in_stream);
                                AOS_process_create_in_stream(pid, &programs[program_count].owned_out_stream, 0);
                                AOS_process_start(pid);
                                window_count++;
                                program_count++;

                                if(is_moving_window)
                                {
                                    Window temp = windows[window_count-2];
                                    windows[window_count-2] = windows[window_count-1];
                                    windows[window_count-1] = temp;
                                }
                            }
                            else { AOS_H_printf("Failed to create consumer for PID: %llu\n", pid); }
                            AOS_process_create_out_stream(pid, 0, &programs[program_count].owned_in_stream);
                            AOS_process_create_in_stream(pid, &programs[program_count].owned_out_stream, 0);
                            AOS_process_start(pid);
                            program_count++;
                        }
                        else { AOS_H_printf("failed to create process."); }
                        }