Getting Started

This is documentation for creating software for the Atom operating system. here the main functions and how to use them and data structures are described

Contribute

Clone a ready-made template in C/C++ from github or write your own. Then clone the AtomSDK repository into your project.

Syscalls

void print(const char* text);
printing char array to console buffer
void print_char(char* text, uint8_t color);
printing char to console buffer
void print_hex(const char* text);
printing data in hex mode to console buffer
void print_dec(uint32_t text);
printing data in dec mode to console buffer
void print_newline();
printing newline to console buffer
void remove_char();
removing last char from console buffer
void clear_screen();
clearing console buffer
void getch(char* input);
gives keyboard input
arg1: char* input - will contain keyboard input or NULL
void set_color(unsigned char fore_col, unsigned char back_col);
works only in textmode
int get_color();
works only in textmode
void find_root(inode_t* root);
gives root filesystem node (/)
arg1: inode_t* root - will contain root node or NULL
void find_dir(char* name, inode_t node, inode_t* dir);
gives a file system node by its name
arg1: char* name - name of the path to find
arg2: inode_t node - node in which the search is carried out
arg3: inode_t* dir - will contain node or NULL
void vfs_get_abs_dir(inode_t node, char* out);
gives absolute dir path as char array
arg1: inode_t node - your node
arg2: char* out - will contain path to node
void create_file(const char* name, inode_t node, inode_t* file);
creating file into filesystem node
arg1: const char* name - name of new file
arg2: inode_t node - parent node
arg3: inode_t* file - will contain new file node
void write(inode_t file, void* buffer, uint64_t size);
writing buffer to file
arg1: inode_t file - target file node
arg2: void* buffer - data buffer
arg3: uint64_t size - size of buffer
void read(inode_t file, void* out_buffer, uint64_t size);
puts file data into a buffer
arg1: inode_t file - file you read
arg2: void* out_buffer - will contain data from file
arg3: uint64_t size - size you read
void free(uint32_t address);
free allocated memory
arg1: uint32_t address - put here what you alloc for
void vfs_close(inode_t node);
works only in textmode =3
void thread_exit(uint32_t ret_code);
ending your program (YOU SHOULD ALWAYS USE IT)
arg1: uint32_t ret_code - return code of your program
void kernel_info();
printing kernel info to console
void fs_tree();
printing filesystem tree to console
void thread_show_info();
printing thread info to console
void thread_create_console();
creating new console for your application (one app = one console)
void create_window(vec2* size, vec2* pos, char* name, window_t** window);
createing display object with window type
arg1: vec2* size - size of your window
arg2: vec2* pos - position of your window
arg3: char* name - name of your window
arg4: window_t** window - will contain you window or NULL
void create_button(vec2* size, vec2* pos, char* name, dobject_t* parent, button_t** button);
createing display object with text type
arg1: vec2* size - size of your button
arg2: vec2* pos - position of your button
arg3: char* name - name of your button
arg4: dobject_t* parent - button parent
arg5: button_t** button - will contain you button or NULL
void bind_button(button_t** button, uint32_t func, void** param_pointer);
binds function to button press
arg1: button_t** button - pointer to button data
arg2: uint32_t* func - function you want to bind
arg3: void** param_pointer - used as func params on callback
preview:
func(param_pointer)
void create_text(vec2* pos, color_t* fg_color, char* _text, dobject_t* parent, text_t** text);
createing display object with text type
arg1: vec2* size - size of your text
arg2: vec2* pos - position of your text
arg3: char* name - name of your text
arg4: dobject_t* parent - text parent
arg5: text_t** button - will contain you text or NULL
void play(const char* path);
playing audio file
arg1: const char* path - path to file

Structs

vec2 - used to store position

Code:
typedef struct position {
  int x;
  int y;
} vec2;

dobject_t

Code:
typedef struct _dobject {
  uint8_t* name;
  uint32_t type;
  bool visible;
  vec2 size;
  vec2 pos;
  color_t bg_color;
  color_t fg_color;
  struct _dobject* parent;
  struct _dobject* child;
  struct _dobject* next;

  // virtual functions
  void (*onMouseEvent)(struct _dobject* object, vec2 mouse_hit, uint8_t flags, int x, int y);

  void* internalData_onButtonCallback;
} dobject_t;

window_t

Code:
typedef struct _window {
  dobject_t dobject;

  char* name;
  bool active;
} window_t;

text_t

Code:
typedef struct _text {
  dobject_t dobject;
} text_t;

button_t

Code:
typedef struct _button {
  dobject_t dobject;

  bool active;

  void (*onButtonDown)();
} button_t;