Remove MBR

This commit is contained in:
Alex Kotov 2022-12-25 13:41:29 +04:00
parent 6c84bc942b
commit b461b8919f
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
12 changed files with 0 additions and 180 deletions

View File

@ -73,9 +73,6 @@ endif
# Default packages #
####################
if WITH_MBR
libkernaux_la_SOURCES += src/mbr.c
endif
if WITH_PFA
libkernaux_la_SOURCES += src/pfa.c
endif

View File

@ -45,8 +45,6 @@ zero). Work-in-progress APIs can change at any time.
* Stack trace *(planned)*
* Algorithms
* [Page Frame Allocator](/include/kernaux/pfa.h) (*work in progress*)
* Data formats
* [MBR](/include/kernaux/mbr.h) (*work in progress*)
* libc replacement (*work in progress*)
* [ctype.h](/libc/include/ctype.h)
* [errno.h](/libc/include/errno.h)

View File

@ -66,7 +66,6 @@ AC_ARG_WITH( [arch-i386], AS_HELP_STRING([--without-arch-i386], [wit
AC_ARG_WITH( [arch-riscv64], AS_HELP_STRING([--without-arch-riscv64], [without architecture riscv64]))
AC_ARG_WITH( [arch-x86-64], AS_HELP_STRING([--without-arch-x86-64], [without architecture x86-64]))
AC_ARG_WITH( [asm], AS_HELP_STRING([--without-asm], [without kernel assembler helpers]))
AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without MBR utils]))
AC_ARG_WITH( [pfa], AS_HELP_STRING([--without-pfa], [without Page Frame Allocator]))
dnl Packages (disabled by default)
@ -99,7 +98,6 @@ if test -z "$with_arch_i386"; then with_arch_i386=no; fi
if test -z "$with_arch_riscv64"; then with_arch_riscv64=no; fi
if test -z "$with_arch_x86_64"; then with_arch_x86_64=no; fi
if test -z "$with_asm"; then with_asm=no; fi
if test -z "$with_mbr"; then with_mbr=no; fi
if test -z "$with_pfa"; then with_pfa=no; fi
])
AS_IF([test "$with_all" = no], do_without_all)
@ -133,7 +131,6 @@ AS_IF([test "$with_arch_i386" = no ], [with_arch_i386=no], [wit
AS_IF([test "$with_arch_riscv64" = no ], [with_arch_riscv64=no], [with_arch_riscv64=yes])
AS_IF([test "$with_arch_x86_64" = no ], [with_arch_x86_64=no], [with_arch_x86_64=yes])
AS_IF([test "$with_asm" = no ], [with_asm=no], [with_asm=yes])
AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes])
AS_IF([test "$with_pfa" = no ], [with_pfa=no], [with_pfa=yes])
dnl Packages (disabled by default)
@ -181,7 +178,6 @@ AM_CONDITIONAL([WITH_ARCH_I386], [test "$with_arch_i386" = yes])
AM_CONDITIONAL([WITH_ARCH_RISCV64], [test "$with_arch_riscv64" = yes])
AM_CONDITIONAL([WITH_ARCH_X86_64], [test "$with_arch_x86_64" = yes])
AM_CONDITIONAL([WITH_ASM], [test "$with_asm" = yes])
AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes])
AM_CONDITIONAL([WITH_PFA], [test "$with_pfa" = yes])
dnl Packages (disabled by default)
@ -221,7 +217,6 @@ AS_IF([test "$with_arch_i386" = yes], [AC_DEFINE([WITH_ARCH_I386],
AS_IF([test "$with_arch_riscv64" = yes], [AC_DEFINE([WITH_ARCH_RISCV64], [1], [with architecture riscv64])])
AS_IF([test "$with_arch_x86_64" = yes], [AC_DEFINE([WITH_ARCH_X86_64], [1], [with architecture x86_64])])
AS_IF([test "$with_asm" = yes], [AC_DEFINE([WITH_ASM], [1], [with kernel assembler helpers])])
AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with MBR utils])])
AS_IF([test "$with_pfa" = yes], [AC_DEFINE([WITH_PFA], [1], [with Page Frame Allocator])])
dnl Packages (disabled by default)
@ -244,7 +239,6 @@ dnl Packages (enabled by default)
AS_IF([test "$with_arch_i386" = no], [AC_SUBST([comment_line_arch_i386], [//])])
AS_IF([test "$with_arch_riscv64" = no], [AC_SUBST([comment_line_arch_riscv64], [//])])
AS_IF([test "$with_arch_x86_64" = no], [AC_SUBST([comment_line_arch_x86_64], [//])])
AS_IF([test "$with_mbr" = no], [AC_SUBST([comment_line_mbr], [//])])
AS_IF([test "$with_pfa" = no], [AC_SUBST([comment_line_pfa], [//])])

View File

@ -12,7 +12,6 @@ nobase_include_HEADERS = \
kernaux/macro.h \
kernaux/macro/packing_end.run \
kernaux/macro/packing_start.run \
kernaux/mbr.h \
kernaux/pfa.h \
kernaux/runtime.h \
kernaux/version.h

View File

@ -7,7 +7,6 @@
#include <kernaux/arch/riscv64.h>
#include <kernaux/arch/x86_64.h>
#include <kernaux/macro.h>
#include <kernaux/mbr.h>
#include <kernaux/pfa.h>
#include <kernaux/runtime.h>
#include <kernaux/version.h>

View File

@ -1,68 +0,0 @@
#ifndef KERNAUX_INCLUDED_MBR
#define KERNAUX_INCLUDED_MBR
#ifdef __cplusplus
extern "C" {
#endif
#include <kernaux/macro.h>
#include <stdbool.h>
#include <stdint.h>
#define KERNAUX_MBR_SIZE 512
#define KERNAUX_MBR_MAGIC 0xaa55
#define KERNAUX_MBR_ENTRIES 4
#define KERNAUX_MBR_BOOTSTRAP_SIZE \
(KERNAUX_MBR_SIZE - sizeof(struct KernAux_Mbr_Info))
#include <kernaux/macro/packing_start.run>
struct KernAux_Mbr_Entry {
uint8_t drive_attributes;
unsigned first_sector_chs_addr : 24;
uint8_t partition_type;
unsigned last_sector_chs_addr : 24;
uint32_t first_sector_lba_addr;
uint32_t sectors_count;
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Mbr_Entry, 16);
struct KernAux_Mbr_Info {
uint32_t disk_id;
uint16_t reserved;
struct KernAux_Mbr_Entry entries[KERNAUX_MBR_ENTRIES];
uint16_t magic;
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(
KernAux_Mbr_Info,
8 + KERNAUX_MBR_ENTRIES * sizeof(struct KernAux_Mbr_Entry)
);
struct KernAux_Mbr {
uint8_t bootstrap[KERNAUX_MBR_BOOTSTRAP_SIZE];
struct KernAux_Mbr_Info info;
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(
KernAux_Mbr,
KERNAUX_MBR_BOOTSTRAP_SIZE + sizeof(struct KernAux_Mbr_Info)
);
#include <kernaux/macro/packing_end.run>
bool KernAux_Mbr_is_valid(const struct KernAux_Mbr *mbr);
bool KernAux_Mbr_Info_is_valid(const struct KernAux_Mbr_Info *mbr_info);
bool KernAux_Mbr_Entry_is_valid(const struct KernAux_Mbr_Entry *mbr_entry);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,7 +1,6 @@
#ifndef KERNAUX_INCLUDED_VERSION
#define KERNAUX_INCLUDED_VERSION
@comment_line_mbr@#define KERNAUX_VERSION_WITH_MBR
@comment_line_pfa@#define KERNAUX_VERSION_WITH_PFA
#endif

View File

@ -11,7 +11,6 @@ include/kernaux/asm/x86_64.h
include/kernaux/macro.h
include/kernaux/macro/packing_end.run
include/kernaux/macro/packing_start.run
include/kernaux/mbr.h
include/kernaux/pfa.h
include/kernaux/runtime.h
include/kernaux/version.h

View File

@ -1,41 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "assert.h"
#include <kernaux/mbr.h>
#include <stdbool.h>
#include <stddef.h>
bool KernAux_Mbr_is_valid(const struct KernAux_Mbr *const mbr)
{
KERNAUX_NOTNULL(mbr);
return KernAux_Mbr_Info_is_valid(&mbr->info);
}
bool KernAux_Mbr_Info_is_valid(const struct KernAux_Mbr_Info *const mbr_info)
{
KERNAUX_NOTNULL(mbr_info);
if (mbr_info->magic != KERNAUX_MBR_MAGIC) return false;
for (size_t index = 0; index < KERNAUX_MBR_ENTRIES; ++index) {
if (!KernAux_Mbr_Entry_is_valid(&mbr_info->entries[index])) {
return false;
}
}
return true;
}
bool KernAux_Mbr_Entry_is_valid(const struct KernAux_Mbr_Entry *const mbr_entry)
{
KERNAUX_NOTNULL(mbr_entry);
// TODO: implement this
(void)mbr_entry;
return true;
}

1
tests/.gitignore vendored
View File

@ -1,4 +1,3 @@
/test_arch_i386
/test_mbr
/test_pfa
/test_pfa_assert

View File

@ -16,18 +16,6 @@ test_arch_i386_SOURCES = \
test_arch_i386.c
endif
############
# test_mbr #
############
if WITH_MBR
TESTS += test_mbr
test_mbr_LDADD = $(top_builddir)/libkernaux.la
test_mbr_SOURCES = \
main.c \
test_mbr.c
endif
############
# test_pfa #
############

View File

@ -1,43 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kernaux/mbr.h>
#include <assert.h>
#include <string.h>
static void create_valid_mbr(struct KernAux_Mbr *mbr);
void test_main()
{
struct KernAux_Mbr mbr;
create_valid_mbr(&mbr);
assert(KernAux_Mbr_is_valid(&mbr));
assert(KernAux_Mbr_Info_is_valid(&mbr.info));
for (size_t index = 0; index < KERNAUX_MBR_ENTRIES; ++index) {
assert(KernAux_Mbr_Entry_is_valid(&mbr.info.entries[index]));
}
create_valid_mbr(&mbr);
mbr.info.magic = 123;
assert(!KernAux_Mbr_is_valid(&mbr));
assert(!KernAux_Mbr_Info_is_valid(&mbr.info));
for (size_t index = 0; index < KERNAUX_MBR_ENTRIES; ++index) {
assert(KernAux_Mbr_Entry_is_valid(&mbr.info.entries[index]));
}
// TODO: test partition table
}
void create_valid_mbr(struct KernAux_Mbr *const mbr)
{
memset(mbr, 0, sizeof(*mbr));
mbr->info.magic = KERNAUX_MBR_MAGIC;
mbr->info.disk_id = 0xCAFEBABE;
// TODO: fill partition table
}