Merge branch 'master' of github.com:klange/osdev
This commit is contained in:
commit
2da22312a5
@ -34,7 +34,7 @@ typedef struct {
|
||||
} shm_mapping_t;
|
||||
|
||||
/* Syscalls */
|
||||
extern void * shm_obtain (char * path, size_t size);
|
||||
extern void * shm_obtain (char * path, size_t * size);
|
||||
extern int shm_release (char * path);
|
||||
|
||||
/* Other exposed functions */
|
||||
|
@ -184,12 +184,17 @@ static void * map_in (shm_chunk_t * chunk, process_t * proc) {
|
||||
return (void *)mapping->vaddrs[0];
|
||||
}
|
||||
|
||||
static size_t chunk_size (shm_chunk_t * chunk) {
|
||||
return (size_t)(chunk->num_frames * 0x1000);
|
||||
}
|
||||
|
||||
|
||||
/* Kernel-Facing Functions and Syscalls */
|
||||
|
||||
|
||||
void * shm_obtain (char * path, size_t size) {
|
||||
void * shm_obtain (char * path, size_t * size) {
|
||||
validate(path);
|
||||
validate(size);
|
||||
spin_lock(&bsl);
|
||||
process_t * proc = (process_t *)current_process;
|
||||
|
||||
@ -204,7 +209,7 @@ void * shm_obtain (char * path, size_t size) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
chunk = create_chunk(node, size);
|
||||
chunk = create_chunk(node, *size);
|
||||
if (chunk == NULL) {
|
||||
LOG(ERROR, "[shm] Could not allocate a shm_chunk_t!\n");
|
||||
return NULL;
|
||||
@ -216,7 +221,7 @@ void * shm_obtain (char * path, size_t size) {
|
||||
chunk->ref_count++;
|
||||
}
|
||||
void * vshm_start = map_in(chunk, proc);
|
||||
|
||||
*size = chunk_size(chunk);
|
||||
|
||||
spin_unlock(&bsl);
|
||||
|
||||
|
@ -301,7 +301,8 @@ void waitabit() {
|
||||
wins_server_global_t volatile * _request_page;
|
||||
|
||||
void init_request_system () {
|
||||
_request_page = (wins_server_global_t *)syscall_shm_obtain(WINS_SERVER_IDENTIFIER, sizeof(wins_server_global_t));
|
||||
size_t size = sizeof(wins_server_global_t);
|
||||
_request_page = (wins_server_global_t *)syscall_shm_obtain(WINS_SERVER_IDENTIFIER, &size);
|
||||
if (!_request_page) {
|
||||
fprintf(stderr, "[wins] Could not get a shm block for its request page! Bailing...");
|
||||
exit(-1);
|
||||
@ -474,8 +475,12 @@ char * loadMemFont(char * ident, char * name, size_t * size) {
|
||||
fseek(f, 0, SEEK_END);
|
||||
s = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
printf("loading %s, size %d\n", name, s);
|
||||
char * font = (char *)syscall_shm_obtain(ident, s); //malloc(s);
|
||||
size_t shm_size = s;
|
||||
char * font = (char *)syscall_shm_obtain(ident, &shm_size); //malloc(s);
|
||||
assert((shm_size >= s) && "shm_obtain returned too little memory to load a font into!");
|
||||
|
||||
fread(font, s, 1, f);
|
||||
|
||||
printf("First few bytes are %x%x%x%x\n", font[0], font[1], font[2], font[3]);
|
||||
|
@ -35,7 +35,7 @@ DEFN_SYSCALL0(getgraphicswidth, 18);
|
||||
DEFN_SYSCALL0(getgraphicsheight, 19);
|
||||
DEFN_SYSCALL0(getgraphicsdepth, 20);
|
||||
*/
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
|
||||
|
||||
@ -74,10 +74,11 @@ int main (int argc, char ** argv) {
|
||||
char * julia_window_key = "julia2.windowbuffer";
|
||||
char * game_window_key = "game2.windowbuffer";
|
||||
|
||||
char * julia_window = (char *)syscall_shm_obtain(julia_window_key, SIZE);
|
||||
char * game_window = (char *)syscall_shm_obtain(game_window_key, SIZE);
|
||||
memset(julia_window, 0, SIZE);
|
||||
memset(game_window, 0, SIZE);
|
||||
size_t size = SIZE;
|
||||
char * julia_window = (char *)syscall_shm_obtain(julia_window_key, &size);
|
||||
char * game_window = (char *)syscall_shm_obtain(game_window_key, &size);
|
||||
memset(julia_window, 0, size);
|
||||
memset(game_window, 0, size);
|
||||
|
||||
/* Fork off two children */
|
||||
if (!fork()) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
DEFN_SYSCALL1(kbd_mode, 12, int);
|
||||
DEFN_SYSCALL0(kbd_get, 13);
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
|
||||
typedef struct sprite {
|
||||
@ -337,8 +337,8 @@ int main(int argc, char ** argv) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
int buf_size = (graphics_width * graphics_depth * graphics_depth);
|
||||
gfx_mem = (void *)syscall_shm_obtain(argv[4], buf_size);
|
||||
size_t buf_size = (graphics_width * graphics_depth * graphics_depth);
|
||||
gfx_mem = (void *)syscall_shm_obtain(argv[4], &buf_size);
|
||||
if (!gfx_mem) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
DEFN_SYSCALL1(kbd_mode, 12, int);
|
||||
DEFN_SYSCALL0(kbd_get, 13);
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
|
||||
uint16_t graphics_width = 0;
|
||||
@ -116,8 +116,8 @@ int main(int argc, char ** argv) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
int buf_size = (GFX_W * GFX_H * GFX_B);
|
||||
gfx_mem = (void *)syscall_shm_obtain(argv[4], buf_size);
|
||||
size_t buf_size = (GFX_W * GFX_H * GFX_B);
|
||||
gfx_mem = (void *)syscall_shm_obtain(argv[4], &buf_size);
|
||||
if (!gfx_mem) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "window.h"
|
||||
|
||||
#if 1
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
DEFN_SYSCALL2(send_signal, 37, int, int)
|
||||
DEFN_SYSCALL2(sys_signal, 38, int, int)
|
||||
@ -66,8 +66,8 @@ window_t * init_window (process_windows_t * pw, wid_t wid, int32_t x, int32_t y,
|
||||
char key[1024];
|
||||
SHMKEY(key, 1024, window);
|
||||
|
||||
/* And now the fucked up stuff happens */
|
||||
window->buffer = (uint8_t *)syscall_shm_obtain(key, (width * height * WIN_B));
|
||||
size_t size = (width * height * WIN_B);
|
||||
window->buffer = (uint8_t *)syscall_shm_obtain(key, &size);
|
||||
|
||||
if (!window->buffer) {
|
||||
fprintf(stderr, "[%d] [window] Could not create a buffer for a new window for pid %d!", getpid(), pw->pid);
|
||||
@ -102,8 +102,8 @@ window_t * init_window_client (process_windows_t * pw, wid_t wid, int32_t x, int
|
||||
char key[1024];
|
||||
SHMKEY_(key, 1024, window);
|
||||
|
||||
/* And now the fucked up stuff happens */
|
||||
window->buffer = (uint8_t *)syscall_shm_obtain(key, (width * height * WIN_B));
|
||||
size_t size = (width * height * WIN_B);
|
||||
window->buffer = (uint8_t *)syscall_shm_obtain(key, &size);
|
||||
|
||||
if (!window->buffer) {
|
||||
fprintf(stderr, "[%d] [window] Could not create a buffer for a new window for pid %d!", getpid(), pw->pid);
|
||||
@ -152,8 +152,9 @@ void resize_window_buffer (window_t * window, int16_t left, int16_t top, uint16_
|
||||
/* Create the new one */
|
||||
window->bufid++;
|
||||
SHMKEY(key, 256, window);
|
||||
window->buffer = (uint8_t *)syscall_shm_obtain(key, (width * height * WIN_B));
|
||||
memset(window->buffer, 0, (width * height * WIN_B));
|
||||
size_t size = (width * height * WIN_B);
|
||||
window->buffer = (uint8_t *)syscall_shm_obtain(key, &size);
|
||||
memset(window->buffer, 0, size);
|
||||
}
|
||||
|
||||
window->x = left;
|
||||
@ -431,7 +432,8 @@ int wins_connect() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
wins_globals = (volatile wins_server_global_t *)syscall_shm_obtain(WINS_SERVER_IDENTIFIER, sizeof(wins_server_global_t));
|
||||
size_t size = sizeof(wins_server_global_t);
|
||||
wins_globals = (volatile wins_server_global_t *)syscall_shm_obtain(WINS_SERVER_IDENTIFIER, &size);
|
||||
if (!wins_globals) {
|
||||
fprintf(stderr, "[%d] [window] Unable to connect with wins through shared memory.\n", getpid());
|
||||
return EACCES;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "graphics.h"
|
||||
|
||||
|
||||
DECL_SYSCALL2(shm_obtain, char *, int);
|
||||
DECL_SYSCALL2(shm_obtain, char *, size_t *);
|
||||
DECL_SYSCALL1(shm_release, char *);
|
||||
DECL_SYSCALL2(send_signal, int, int);
|
||||
DECL_SYSCALL2(sys_signal, int, int);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
|
||||
#define SHMSZ 27
|
||||
@ -26,8 +26,9 @@ int main(int argc, char ** argv) {
|
||||
/*
|
||||
* Attach the segment to our data space.
|
||||
*/
|
||||
size_t size = SHMSZ;
|
||||
malloc(9 * 0x1000); // Make our heap a bit different from the server
|
||||
if ((shm = (char *)syscall_shm_obtain(key, SHMSZ)) == (char *) NULL) {
|
||||
if ((shm = (char *)syscall_shm_obtain(key, &size)) == (char *) NULL) {
|
||||
printf("Client: syscall_shm_mount returned NULL!\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
|
||||
#define SHMSZ 27
|
||||
@ -26,7 +26,8 @@ int main(int argc, char ** argv) {
|
||||
/*
|
||||
* Attach to the shared memory chunk
|
||||
*/
|
||||
if ((shm = (char *)syscall_shm_obtain(key, SHMSZ)) == (char *) NULL) {
|
||||
size_t size = SHMSZ;
|
||||
if ((shm = (char *)syscall_shm_obtain(key, &size)) == (char *) NULL) {
|
||||
return 1;
|
||||
}
|
||||
printf("Server: mounted to 0x%x\n", shm);
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
|
||||
|
||||
@ -23,7 +23,8 @@ int main (int argc, char ** argv) {
|
||||
|
||||
printf("(This should fork and the child process (but not the parent) should segfault)\n");
|
||||
|
||||
volatile char * shm = (char *)syscall_shm_obtain(argv[1], 27);
|
||||
size_t size = 27;
|
||||
volatile char * shm = (char *)syscall_shm_obtain(argv[1], &size);
|
||||
if (shm == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
DEFN_SYSCALL1(shm_release, 36, char *)
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ int main (int argc, char ** argv) {
|
||||
|
||||
printf("(this should not crash; but the kernel should free the shm block)\n");
|
||||
|
||||
volatile char * shm = (char *)syscall_shm_obtain(argv[1], 0x1000);
|
||||
size_t size = 0x1000;
|
||||
volatile char * shm = (char *)syscall_shm_obtain(argv[1], &size);
|
||||
if (shm == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -5,13 +5,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, int)
|
||||
DEFN_SYSCALL2(shm_obtain, 35, char *, size_t *)
|
||||
|
||||
#define KEY "shm_test3.mem"
|
||||
#define MAGIC 111
|
||||
|
||||
int client_proc(uint32_t size) {
|
||||
volatile unsigned char * mem = (volatile unsigned char *)syscall_shm_obtain(KEY, size);
|
||||
volatile unsigned char * mem = (volatile unsigned char *)syscall_shm_obtain(KEY, &size);
|
||||
|
||||
while (mem[0] != MAGIC) {}
|
||||
mem[0] = (uint8_t)(MAGIC + 1);
|
||||
@ -28,7 +28,7 @@ int client_proc(uint32_t size) {
|
||||
}
|
||||
|
||||
int server_proc(uint32_t size) {
|
||||
volatile unsigned char * mem = (volatile unsigned char *)syscall_shm_obtain(KEY, size);
|
||||
volatile unsigned char * mem = (volatile unsigned char *)syscall_shm_obtain(KEY, &size);
|
||||
|
||||
for (uint32_t i = 1; i < size; i++) {
|
||||
mem[i] = (unsigned char)i;
|
||||
|
Loading…
Reference in New Issue
Block a user