Memes de cosas tecnicas que hago

un codigo en lima no puede ser tan largo, es un lenguaje simple
el codigo :rofl::

# MKF7.lima

# abstract:
#   because cant conect the debugger with the code this emulates it

# and because that "if dont have the tools of MKF7 make it by youself"

# please execute this before make anything in the uefi , basically its the uefi base

# save the code to the 0 segment (generally the lima base)

org
0
org
1
# for restore uefi and dont lose nothing

sendmw uefi_prototypes()

sendmw uefi_boot()

sendmw uefi_shutdown()

__endprog__


### !
### ! A NEW SECTION WILL BE START SOON
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

######!
######!
######!
######!
######!
######!
######! MKF7 variables convertion
######!
######!
######!
######!
######!
######!

[intersegmental]
message uefi_prototypes()

[globalize]
var
    _returned
       =
    prototype

[globalize]
var
    _action
       =
    prototype

[globalize]
var
    _data1
        =
    prototype

[globalize]
var
    _data2
        =
    prototype

[globalize]
var
    exit from boot services?
       =
    0

[globalize]
var
    uefi recover segment number
       =
    1

[globalize]
var
    _@zip.current_archive
        =
    "Z"

[endmsg]

### !
### ! A NEW SECTION WILL BE START SOON
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

######!
######!
######!
######!
######!
######!
######! prototypes
######!
######!
######!
######!
######!
######!

# prototype for uefi_fs
[prototype]
message uefi_fs() 

    prototype

[endmsg]

# prototype for uefi_arr
[prototype]
message uefi_arr()

    prototype

[endmsg]


# prototype for efishell
[prototype]
message efishell()

    prototype

[endmsg]

# prototype for uefi_boot
[prototype]
message uefi_boot()

    prototype

[endmsg]

# prototype for uefi_shutdown
[prototype]
message uefi_shutdown()

    prototype

[endmsg]

# prototype for uefi_reset
[prototype]
message uefi_reset()

    prototype

[endmsg]

# prototype for uefi_exit_boot_services
[prototype]
message uefi_exit_boot_services()

    prototype

[endmsg]

### !
### ! A NEW SECTION WILL BE START SOON
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

### !
### !
### !
### !

######!
######!
######!
######!
######!
######!
######! built-in MKF7 messages but implemented here
######!
######!
######!
######!
######!
######!

# intersegmental for make it a global message

###! shell commands
[intersegmental]
message shell_command()

.

#jt
#    do_echo

if
(
    @ScratchVar(_action)
    ==
    "ls"
)
{
section
do_ls
    #
    # setuping
    #

    var
        i
        =
        0

    #
    # get the array of the files
    #

    echo "in ls"

    mov
        @eax
        "/glob -gtv -array_startswith"

    mov
        @bx
        "Z>"
    
    %^"!p"

    var
        list
        =
        @ScratchVar(_returned)

    echo list

__endprog__
}

__endprog__

section
do_echo
    #echo "in echo"
    var
        msg
        =
        @ScratchVar(_action)

    var
        msg
        +=
        5

    #echo msg
__endprog__

[endmsg]

###! uefi misc functions
[intersegmental]
message uefi_arr()
    if
    (
        @ScratchVar(_action)
            ==
        "0x0"
    )
    {
        var
            gx
            =
            Console.SizeX

        var
            gx
            -=
            4
        
        var
            gx
            /=
            2

        var
            gy
            =
            Console.SizeY

        var
            gy
            /=
            2

        #gotoxy gx gy

        cecho "MKF8"

        button_echo "the best know firmware solution builded in lima"
    }
[endmsg]

###! net
[intersegmental]
message uefi_net()

    # the main section of the message
    section
    Main

    # set the condicional var for execute the section recive if you want to recive
    var
        .cnd
        =
        (@ScratchVar(_action)=="0x01")

    # jump if the condition is true
    jt
        .recive

    # set the condicional var for execute the section send if you want to send data to a server
    var
        .cnd
        =
        (@ScratchVar(_action)=="0x02")

    # jump if the condition is true
    jt
        .send

    # if nothing is true finish the function
    __endprog__

    # recive
    # 
    # Summary:
    # 	recive a content from a url
    # 
    # Params:
    # 	@_data1: the url
    #   @returned: the return value
    # 
    # Registers used:
    #   @eax: for the commands
    #   @bx: the data send
    # 
    section
    .recive

        # set the action for make
        mov
            @eax
            "/get-url"

        # set the url to request (in this case the _data1)
        mov
            @bx
            @ScratchVar(_data1)

        #!
        %^"!p"
            # <- esto devuelve automaticamente el _returned

        # check if the interpreter can make the action
        if
        (
            @ScratchVar(@ax)
            ==
            "unsupported"
        )
        {
            # if not , set the return value
            mov
                _returned
                "falied to fetch"
        }

    # end the message
    __endprog__

    # MyFunction
    # 
    # Summary:
    # 	send a data from a server
    # 
    # Params:
    # 	@_data1: the url
    #   @_data2: the data to send
    #   @returned: the return value
    #
    # Registers used:
    #   @eax: for the commands
    #   @bx: the data send
    # 
    section
    .send

        # set the action to make (set the url)
        mov
            @eax
            "/send-set-url"

        # set the data to send to the url
        mov
            @bx
            @ScratchVar(_data1)

        # send the action to the interpreter
        %^"!p"

        # action for send the data
        mov
            @eax
            "/send-url"

        # now the data to send
        mov
            @bx
            @ScratchVar(_data2)

        # action!!!
        %^"!p"

        # if can make it
        if
        (
            @ScratchVar(@ax)
            ==
            "unsupported"
        )
        {
            # ya puedes dejar de enviar datos, ya perdimos ;(

            # set the return value
            mov
                _returned
                "0"
        }

    # the functions has been finished
    __endprog__

[endmsg]

###! diskload actions
[intersegmental]
message load_files()

    echo "loading files..."

    jump
    Main
    # only vfat12 , the subdirs cant be load

    # this loads the files of your real pc in the path where is the uefi executable and coppy it to the
    # Z hard disk

    # Main
    # 
    # Summary:
    # 	the copy main
    # 
    # Params:
    # 	@(your files in the fd dir): for coppy to the virtual disk
    #   @(obiusly your personal files if you want): but is necesary for can put your files in the uefi
    # 
    section
    Main
        # note: all changes maked to the files cant affect to the real file because this loads a
        # coppy and not the real files, and lima only allows read but not write files and directorys
        .
        var
            file_to_load
            =
            0

        #
        # get files count in the dir
        #

        mov
            @eax
            "/dir countf"

        %^"!p"

        var
            max_files
            =
            @ScratchVar(_returned)

        var
            max_files
            -=
            1

        jump
        load

    __endprog__

    # load
    # 
    # Summary:
    # 	loads the files to the disk
    # 
    # Params:
    # 	@max_files: max files number
    #   @file_to_load: the start point of the files array to load
    # 
    section
    load

        #
        # declare vars
        #

        var
            name
            =
            prototype

        var
            content
            =
            prototype

        #
        # get file information
        #

        # file name

        mov
            @eax
            "/file_gName"

        mov
            @bx
            file_to_load

        %^"!p"

        var
            name
            =
            @ScratchVar(_returned)

        # file content
        
        mov
            @eax
            "/file_gContent"

        mov
            @bx
            file_to_load

        %^"!p"

        var
            content
            =
            @ScratchVar(_returned)

        #
        # create file
        #

        mov
            "Z->"(..)name
            content

        echo  "file "(..)name(..)" has been loaded."

        var
            .cnd
            =
            (file_to_load==max_files)

        var
            file_to_load
            +=
            1

        jf
            load
            # next file

    __endprog__
[endmsg]

###! fs actions
[intersegmental]
message uefi_fs()

    section
    main

    var
        .cnd
        =
        (@ScratchVar(_action)=="0x01")

    jt
        .uefi_current_fs_letter

    var
        .cnd
        =
        (@ScratchVar(_action)=="0x02")

    jt
        .uefi_file_write

    var
        .cnd
        =
        (@ScratchVar(_action)=="0x03")

    jt
        .uefi_file_rename

    var
        .cnd
        =
        (@ScratchVar(_action)=="0x04")

    jt
        .uefi_file_coppy

    var
        .cnd
        =
        (@ScratchVar(_action)=="0x05")

    jt
        .uefi_file_get

    echo "invalid file action"
    __endprog__

    # uefi_current_fs_letter
    # 
    # Summary:
    # 	gets the letter of the fs driver
    # 
    # Params:
    # 	nah
    # 
    section
    .uefi_current_fs_letter
        mov
            _returned
            @ScratchVar(_@zip.current_archive)
    __endprog__

    # uefi_file_write
    # 
    # Summary:
    # 	writes a file
    # 
    # Params:
    # 	@_data1: file name (including path)
    #   @_data2: file content
    # 
    section
    .uefi_file_write
        mov
            @ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data1)
            @ScratchVar(_data2)
    __endprog__

    # uefi_file_rename
    # 
    # Summary:
    # 	renames a file
    # 
    # Params:
    # 	@_data1: file name
    #   @_data2: new name
    # 
    section
    .uefi_file_rename
        mov
            @ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data2)
            @ScratchVar(@ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data1))

        mov
            @ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data1)
            ""
    __endprog__

    # uefi_file_coppy
    # 
    # Summary:
    # 	coppy a file
    # 
    # Params:
    # 	@_data1: file name
    #   @_data2: file dest name
    # 
    section
    .uefi_file_coppy
        mov
            get{@ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data2)}
            @ScratchVar(@ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data1))
    __endprog__

    # uefi_delete_file
    # 
    # Summary:
    # 	deletes a file
    # 
    # Params:
    # 	@_data1 : the file name with path and extension
    # 
    section
    .uefi_delete_file
        mov
            get{@ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data1)}
            ""
    __endprog__

    # uefi_file_get
    # 
    # Summary:
    # 	get a file
    # 
    # Params:
    # 	@_data1: file full name
    # 
    section
    .uefi_file_get
        mov
            _returned
            @ScratchVar(get{@ScratchVar(_@zip.current_archive)(..)">"(..)@ScratchVar(_data1)})
    __endprog__

[endmsg]

###! loads a segment from the uefi
[intersegmental]
message uefi_load()
    
[endmsg]

# shutdowns the system
[intersegmental]
message uefi_shutdown()
    __endprog__
[endmsg]

# reset the system
[intersegmental]
message uefi_reset()
    sendmw uefi_boot()
    sendmw uefi_segment_setup()
[endmsg]

# exit from bootservices
[intersegmental]
message uefi_exit_boot_services()
    mov
        exit from boot services?
        1

    org
    0
    # because the messages execute it as a independence code so , kill the orgiinal uefi segment (0) but
    # dont worry a security coppy its mounted in the segment 1 for this cases
[endmsg]

###! the uefi shell
[intersegmental]
message efishell()

    jump
    loop
    section
    loop
    writel "Shell> "
    var
        command
        =
        ReadLine

    var
        .cnd
        =
        (command=="exit")

    jt
        .exit

    mov
        _action
        command

    sendmw shell_command()

    jump
    loop

    section
    .exit
    __endprog__
[endmsg]

###! the uefi routine
[intersegmental]
message uefi_boot()

    mov
        _action
        "0x0"
    sendmw uefi_arr()

    sleep 1

    sendmw load_files()

    jump
        main
    section
    main
        mov
            exit from boot services?
            0

    jump
    loop

    section
    loop
    
    writel "Boot From: "

    var
        prompt
        =
        ReadLine
    
    if
    (
        prompt
        ==
        "blk-1"
    )
    {
        # the blk -1
        sendmw efishell()
    }

    jump
    loop

[endmsg]

contexto es el codigo de un firmware que estoy haciendo , se llama MKF8

1 me gusta

Se pueden hacer Firmwares en Lima :O?, definitivamente tengo que probarlo

ok tengo curiosidad, que es lima? veo de hace rato que estan hablando de eso y la curiosidad me mata, busque en google y solo sale lima peru.

1 me gusta

Lima por lo que tengo entendido es un lenguaje de programación que esta haciendo @ErickCraftStudios.

btw viva peru

Contiene muchas cosas como variables, mensajes, labels, movs, comandos del intérprete y bueno, también lo que ya dijo mi amigo skale (@l30narw011)

Ah okok hay repo de Github?

Si! GitHub - ErickStudios/Lim22: the opensource version of lima