46bd9ad0f1
gfx_wait_vsync() и sleep() раньше предполагали, что КАЖДОЕ прерывание на векторе 0xFF — кадровый тик; с CBL/клавиатурой на том же векторе это уже не так. gfx_wait_vsync(): вместо halt — polling бита 5 порта 0xFE (реальная позиция луча, см. MAME kbd_fe_r), доступного пока включён CBL bit7 порта 0x004E. Разделяемое владение портом с CBL через _cbl_port_ref/unref (тот же ref-counting паттерн, что у IM2-таблицы) — cbl_close() возвращает "немой" режим вместо полного выключения, если gfx ещё держит ссылку. Fallback на halt при таймауте. sleep()/delayms(): калиброванный busy-wait по духу delayms.asm вместо подсчёта halt-пробуждений. Калибровка одна на кадр (не на секунду — не переполняет uint16_t и не требует умножения/32-бит арифметики), общий движок libc/time/_sleep_calib.c для обеих функций. Fallback на старое поведение при EBUSY (фрейм-хук занят другим irq_install()). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
49 lines
1.6 KiB
C
49 lines
1.6 KiB
C
/*
|
|
* unistd.h — POSIX-style file descriptor I/O for Sprinter ESTEX.
|
|
*
|
|
* Each call maps to a single ESTEX RST 10h function:
|
|
* read → $13 write → $14
|
|
* close → $12 unlink → $0E
|
|
*
|
|
* On error every call returns -1 (the ESTEX error code is not exposed yet;
|
|
* a future errno mechanism will surface it).
|
|
*/
|
|
|
|
#ifndef UNISTD_H
|
|
#define UNISTD_H
|
|
|
|
#include <stddef.h> /* size_t */
|
|
#include <stdint.h> /* uint16_t */
|
|
|
|
/* lseek whence values (POSIX). */
|
|
#define SEEK_SET 0
|
|
#define SEEK_CUR 1
|
|
#define SEEK_END 2
|
|
|
|
int read (int fd, void *buf, size_t n);
|
|
int write(int fd, const void *buf, size_t n);
|
|
int close(int fd);
|
|
int unlink(const char *path);
|
|
long lseek(int fd, long offset, int whence);
|
|
|
|
/* Block the calling task for `seconds` seconds (calibrated busy-wait). */
|
|
void sleep(unsigned int seconds);
|
|
|
|
/* Block the calling task for `ms` milliseconds (calibrated busy-wait,
|
|
* same engine as sleep() — see libc/time/_sleep_calib.c). */
|
|
void delayms(uint16_t ms);
|
|
|
|
/* 1, если fd — консоль (наши псевдо-fd 0/-1/-2), 0 — файл (любой
|
|
* положительный манипулятор DSS; из командной строки они идут с 1). */
|
|
int isatty(int fd);
|
|
|
|
/* Directory operations (ESTEX $1B-$1E). All return 0 on success and -1
|
|
* with errno set on failure; getcwd returns the buffer on success or NULL.
|
|
* size is ignored — ESTEX always wants a 256-byte buffer. */
|
|
int mkdir (const char *path);
|
|
int rmdir (const char *path);
|
|
int chdir (const char *path);
|
|
char *getcwd(char *buf, size_t size);
|
|
|
|
#endif
|