1 #include "filesys-stub.h"
9 static struct lock lock;
12 filesys_stub_init (void)
14 lock_init (&lock, "filesys-stub");
18 filesys_stub_lock (void)
24 filesys_stub_unlock (void)
30 out_byte (uint8_t byte, void *aux UNUSED)
36 filesys_stub_put_bool (bool b)
38 backdoor_put_bool (b, out_byte, NULL);
42 filesys_stub_put_bytes (const void *buffer, size_t cnt)
44 backdoor_put_bytes (buffer, cnt, out_byte, NULL);
48 filesys_stub_put_file (struct file *file)
50 ASSERT (file != NULL);
51 filesys_stub_put_int32 ((int32_t) file - 1);
55 filesys_stub_put_int32 (int32_t value)
57 backdoor_put_int32 (value, out_byte, NULL);
61 filesys_stub_put_string (const char *string)
63 backdoor_put_string (string, out_byte, NULL);
67 filesys_stub_put_uint32 (uint32_t value)
69 backdoor_put_uint32 (value, out_byte, NULL);
73 in_byte (void *aux UNUSED)
79 filesys_stub_get_bool (void)
81 return backdoor_get_bool (in_byte, NULL);
85 filesys_stub_get_bytes (void *buffer, size_t size)
87 /* We could use backdoor_get_bytes() but this is significantly
89 asm ("rep insl; movl %0, %%ecx; rep insb"
91 : "g" (size % 4), "d" (0x8901), "c" (size / 4), "D" (buffer));
95 filesys_stub_get_file (void)
97 int32_t fd = filesys_stub_get_int32 ();
98 return fd < 0 ? NULL : (struct file *) (fd + 1);
102 filesys_stub_get_int32 (void)
104 return backdoor_get_int32 (in_byte, NULL);
108 filesys_stub_match_string (const char *string)
110 if (backdoor_get_uint32 (in_byte, NULL) != strlen (string))
111 panic ("string match failed");
112 while (*string != '\0')
114 uint8_t c = *string++;
115 if (c != in_byte (NULL))
116 panic ("string match failed");
121 filesys_stub_get_uint32 (void)
123 return backdoor_get_uint32 (in_byte, NULL);