add apps
This commit is contained in:
24
user/app1/appl.cc
Normal file
24
user/app1/appl.cc
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// vim: set noet ts=4 sw=4:
|
||||||
|
|
||||||
|
#include "../libsys/stub.h"
|
||||||
|
|
||||||
|
extern "C" void main() {
|
||||||
|
// Thread 1 may be an auxiliary thread
|
||||||
|
|
||||||
|
//sys_test(1,2,3,4,5);
|
||||||
|
|
||||||
|
unsigned id = sys_getpid();
|
||||||
|
char text[] = "testX";
|
||||||
|
text[4] = 0x30+id;
|
||||||
|
|
||||||
|
for (unsigned i = 1;; ++i) {
|
||||||
|
write(1, text, sizeof(text));
|
||||||
|
if(i==id){
|
||||||
|
//write(2, "kill", 4);
|
||||||
|
//write(2, &text[4], 1);
|
||||||
|
//write(2, " ", 1);
|
||||||
|
sys_exit();
|
||||||
|
}
|
||||||
|
sleep(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
user/app1/appl.h
Normal file
32
user/app1/appl.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// vim: set noet ts=4 sw=4:
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief Enthält die Klasse Application
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "../libsys/types.h"
|
||||||
|
#include "../libsys/thread.h"
|
||||||
|
|
||||||
|
//! \brief Test application
|
||||||
|
//!
|
||||||
|
//! \note Any class derived from Thread defines an application for StuBS.
|
||||||
|
//!
|
||||||
|
class Application : public Thread {
|
||||||
|
// Prevent copies and assignments
|
||||||
|
Application(const Application&) = delete;
|
||||||
|
Application& operator=(const Application&) = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Application(Application&&) = delete;
|
||||||
|
|
||||||
|
/*! \brief Constructor
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Application() {}
|
||||||
|
|
||||||
|
/*! \brief Contains the application code.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void action() override;
|
||||||
|
};
|
||||||
BIN
user/app1/build/app
Executable file
BIN
user/app1/build/app
Executable file
Binary file not shown.
BIN
user/app1/build/app.img
Executable file
BIN
user/app1/build/app.img
Executable file
Binary file not shown.
2
user/app1/build/appl.d
Normal file
2
user/app1/build/appl.d
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
build/appl.o: appl.cc ../../libsys/../libsys/stub.h \
|
||||||
|
../../libsys/../libsys/types.h
|
||||||
BIN
user/app1/build/appl.o
Normal file
BIN
user/app1/build/appl.o
Normal file
Binary file not shown.
BIN
user/app2/build/app
Executable file
BIN
user/app2/build/app
Executable file
Binary file not shown.
BIN
user/app2/build/app.img
Executable file
BIN
user/app2/build/app.img
Executable file
Binary file not shown.
2
user/app2/build/kappl.d
Normal file
2
user/app2/build/kappl.d
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
build/kappl.o: kappl.cc ../../libsys/../libsys/stub.h \
|
||||||
|
../../libsys/../libsys/types.h ../../libsys/../libsys/string.h
|
||||||
BIN
user/app2/build/kappl.o
Normal file
BIN
user/app2/build/kappl.o
Normal file
Binary file not shown.
37
user/app2/kappl.cc
Normal file
37
user/app2/kappl.cc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// vim: set noet ts=4 sw=4:
|
||||||
|
|
||||||
|
#include "../libsys/stub.h"
|
||||||
|
#include "../libsys/string.h"
|
||||||
|
|
||||||
|
//#include "../libsys/string.h"
|
||||||
|
|
||||||
|
extern "C" void main() {
|
||||||
|
char cmd_buff[100];
|
||||||
|
uint8_t bufferpos = 0;
|
||||||
|
while(1){
|
||||||
|
char msg[11];
|
||||||
|
int len;
|
||||||
|
len = read(0, msg, 1);
|
||||||
|
if(len){
|
||||||
|
write(0, msg, len);
|
||||||
|
memcpy(&cmd_buff[bufferpos], msg, len);
|
||||||
|
bufferpos+=len;
|
||||||
|
for(uint8_t i=0; i<len; i++)
|
||||||
|
if(msg[i] == '\n'){
|
||||||
|
bufferpos = 0;
|
||||||
|
if(strncmp(cmd_buff, "kill ", 5) == 0){
|
||||||
|
int pid = cmd_buff[5]-0x30;
|
||||||
|
char r[] = "killing X\n";
|
||||||
|
r[8] = pid+0x30;
|
||||||
|
write(0, r, 9);
|
||||||
|
sys_kill(pid);
|
||||||
|
}
|
||||||
|
if(strncmp(cmd_buff, "killall", 7) == 0){
|
||||||
|
for(uint8_t i = 0; i<10; i++){
|
||||||
|
sys_kill(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
user/app2/kappl.h
Normal file
26
user/app2/kappl.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// vim: set noet ts=4 sw=4:
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief Enthält die Klasse KeyboardApplication
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "../../thread/thread.h"
|
||||||
|
#include "../../types.h"
|
||||||
|
|
||||||
|
/*! \brief Keyboard Application
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class KeyboardApplication : public Thread {
|
||||||
|
// Prevent copies and assignments
|
||||||
|
KeyboardApplication(const KeyboardApplication&) = delete;
|
||||||
|
KeyboardApplication& operator=(const KeyboardApplication&) = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
KeyboardApplication() {}
|
||||||
|
|
||||||
|
/*! \brief Contains the application code.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void action() override;
|
||||||
|
};
|
||||||
52
user/sections.ld
Normal file
52
user/sections.ld
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* Einstiegspunkt ist deine 'start' Funktion im C++ Code */
|
||||||
|
ENTRY(start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
/* * 1. Startadresse: 64 MiB (0x4000000)
|
||||||
|
* Hier beginnt der virtuelle Adressraum für dein Programm.
|
||||||
|
*/
|
||||||
|
. = 0x4000000;
|
||||||
|
|
||||||
|
/* --- Code Segment --- */
|
||||||
|
.text : ALIGN(4096) {
|
||||||
|
*(.text)
|
||||||
|
*(.text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Read-Only Data (Strings, Consts) --- */
|
||||||
|
.rodata : ALIGN(4096) {
|
||||||
|
*(.rodata)
|
||||||
|
*(.rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Initialized Data & C++ Arrays --- */
|
||||||
|
.data : ALIGN(4096) {
|
||||||
|
*(.data)
|
||||||
|
*(.data.*)
|
||||||
|
|
||||||
|
/* preinit_array */
|
||||||
|
PROVIDE(__preinit_array_start = .);
|
||||||
|
KEEP(*(.preinit_array))
|
||||||
|
PROVIDE(__preinit_array_end = .);
|
||||||
|
|
||||||
|
/* init_array (Globale Konstruktoren) */
|
||||||
|
PROVIDE(__init_array_start = .);
|
||||||
|
KEEP(*(SORT(.init_array.*)))
|
||||||
|
KEEP(*(.init_array))
|
||||||
|
PROVIDE(__init_array_end = .);
|
||||||
|
|
||||||
|
/* fini_array (Globale Destruktoren) */
|
||||||
|
PROVIDE(__fini_array_start = .);
|
||||||
|
KEEP(*(SORT(.fini_array.*)))
|
||||||
|
KEEP(*(.fini_array))
|
||||||
|
PROVIDE(__fini_array_end = .);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Müll entfernen */
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.comment)
|
||||||
|
*(.eh_frame) /* Außer du willst C++ Exceptions supporten, dann behalten */
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user